I'm working on upgrading OpenSSL in OpenSolaris to the latest version
which includes a number of hand-coded asm files which give large perf
gains on amd64.
When I compile and link the OpenSSL library I'm getting a couple of
errors like this:
Text relocation remains referenced
against symbol offset in file
OPENSSL_cpuid_setup 0x1 libcrypto.a(x86_64cpuid.o)
The link stage includes the following options "-z text -B direct". After
playing around with Sun Studio with -KPIC and looking at assembler
output from the test programs I traced the issue down to the function
calls the asm is doing (like OPENSSL_cpuid_setup above).
If I append @PLT to the function call the errors disappear. For e.g.
call OPENSSL_cpuid_setup
becomes
call OPENSSL_cpuid_setup at PLT
This makes intuitive sense as the function calls will now reference the
Procedure Lookup Table so things like lazy loading should work.
Is this ok (the adding of @PLT)? Do I need to save regs before using
@PLT? Anything else I should be aware of?
Thanks,
-Mark