Only amd64 and i386 are handled at the moment, and only amd64 tested.
This is what mandated by the contract I have signed with FF.
The code is taken literally from the Intel App Note 485 CPU Identification. Code uses XOR, so any state of the EFLAGS.ID bit is fine for it. I do not believe that we need to care about anything else. The same code is present in x86/__vdso_tc.c and in i386/gen/getcontextx.c.
buildworld fails for me with:
===> libexec/rtld-elf (all) /usr/bin/ld: error: duplicate symbol: bzero >>> defined at rtld.c:5599 (/usr/home/mjg/repos/freebsd/libexec/rtld-elf/rtld.c:5599) >>> rtld.o:(bzero) >>> defined at ifunc.c:17 (/usr/home/mjg/repos/freebsd/lib/libc/amd64/ifunc.c:17) >>> ifunc.nossppico:(bzero_resolver) in archive /usr/obj/usr/home/mjg/repos/freebsd/amd64.amd64/lib/libc/libc_nossp_pic.a /usr/bin/ld: error: duplicate symbol: memset >>> defined at rtld.c:5589 (/usr/home/mjg/repos/freebsd/libexec/rtld-elf/rtld.c:5589) >>> rtld.o:(memset) >>> defined at ifunc.c:8 (/usr/home/mjg/repos/freebsd/lib/libc/amd64/ifunc.c:8) >>> ifunc.nossppico:(memset_resolver) in archive /usr/obj/usr/home/mjg/repos/freebsd/amd64.amd64/lib/libc/libc_nossp_pic.a cc: error: linker command failed with exit code 1 (use -v to see invocation) *** [ld-elf.so.1.full] Error code 1
Note the build host runs without any of the patches.
Here is the change I was testing with, it creates all expected symbols (memmove, memcpy, bcopy, bzero, memset):
Right, this is due to your change defining resolvers for all functions in one .o file. You need to
- add remaining overrides to rtld.c
- split ifunc,c into per-function ifunc.
And, until ld.lld and strip bugs are not fixed, static binaries will be broken. Workaround is to not strip them on install.
Why would debugger require that ? What matter is the address of the function which is written into the call instruction, not the return value from the ifunc resolver.
If really wanted, debugger can reconstruct the args.
As discussed elsewhere there are a few toolchain issues with static binaries with ifuncs - one fix is in https://github.com/emaste/freebsd/commit/36131f9c4c9aa343ea2679c18b3d1d621bb837f1
Just seems strange to me to combine crtbrand and my upcoming feature flags into one, and ignore_init and ifuncs into another. But either way I agree this can be a change after this patch.