News for hackers. Stuff that matters.
Re:Hand-Coded Assembly Beats Intrinsics in Speed and Simplicity by nteon on Tuesday August 11, 2015 @04:08PM (#10043991)
If you're using shared libraries in your program, you already have this extra indirection - at compilation/link time the compiler/linker doesn't know where in memory the shared library will be when the program is run, so every call into a library goes through the procedure linkage table (PLT), which works by looking up the 'real' function pointer in the global offset table (GOT).

So yea, populating this at runtime depending on the CPU features supported by your CPU is possible, and the linux dynamic linker does this: http://man7.org/linux/man-pages/man8/ld.so.8.html (check out the section on hardware capabilities).

Re:Hand-Coded Assembly Beats Intrinsics in Speed and Simplicity by nteon on Tuesday August 11, 2015 @04:18PM (#10044062)
for an example, checkout this: http://pasky.or.cz/dev/glibc/ifunc.c

Two implementations are compiled (one is optimized using instructions only available on certain processors), and the decision of which one to use is made at program startup.

Re:Hand-Coded Assembly Beats Intrinsics in Speed and Simplicity by pjc50 on Tuesday August 11, 2015 @05:21PM (#10044478)
We should bring this point out next time there's a wave of comments saying that static linking is the one true way.
Re:Hand-Coded Assembly Beats Intrinsics in Speed and Simplicity by qu4z-2 on Tuesday August 11, 2015 @05:25PM (#10044514)
If you need to redirect all your function calls through a giant array, you can technically do that with static linking too. Just sayin'...