>
>OK, attached is the test application. The executable under Debug/
>directory is built on solaris 8 x86. When run under Solaris 8, it
>output "Works", under Nevada b63, it output "Failed", and fprintf ()
>fails as well.
>I am pretty sure that it is the readlink() function causing trouble.
No, it's your GNU cross linker which is causing the issue.
Your binary fails.
Your .o file linked natively succeeds (this pretty much rules out ABI
differences in my book because we are running the exact same code.
Some quick examination suggests that the copy relocations do not
work correctly since a particular build of Solaris. I can't tell
right now what causes this: a regression in the Solaris linker *or*
a latent bug in the way "gld" creates executables.
Some background:
ELF binaries sometimes reference global symbols in shared libraries; this
is dealt with using "copy relocations" if the binaries are not compiled
as PIC code (the default in Solaris is non-PIC, so that is what you have).
As the binary needs to be read-only text the addresses of the objects need to
be fixed at link time; but how can that be if the object lives in the
shared library?
This is done with something called "copy relocations"; a second copy
of the object is created in the binary; all uses in the binary refer to
that particular object.
Copy relocations work as follows:
- an object of the proper size is added to the binary
- at program start, the runtime linker will copy whateever is
in the binary to that particular location in the binary
- all references to the object in the library are redirected to
the binary.
in other words, the library and the binary *both* use the copy in the
*binary*.
In the case of your simple test program these are "errno" and "__iob"
(stderr).
You can test the binding using "env LD_BINDINGS=-1" which provides the
output on stderr.
Grepping this for "errno" we see:
Local compile (works):
25661: binding file=localcompile to file=/lib/libc.so.1: symbol `errno'
25661: binding file=/lib/libc.so.1 to file=localcompile: symbol `errno'
Local link (works):
25663: binding file=locallink to file=/lib/libc.so.1: symbol `errno'
25663: binding file=/lib/libc.so.1 to file=locallink: symbol `errno'
In both cases, the first binding stands for the copy relocation, I believe,
the second one is the use of the appropriate errno by libc.so.1.
Your cross compile & link:
25667: binding file=Debug/solaris_test2 to file=/lib/libc.so.1: symbol `errno'
25667: binding file=/lib/libc.so.1 to file=/lib/libc.so.1: symbol `errno'
here we see that errno is incorrectly bound to libc.so.1 on the second
line.
This is somewhat where my linker knowledge ends, but I don't see anything
out of the ordinary with elfdump, except that there are a few issues in
the binary:
Debug/solaris_test2: .dynsym: index[11]: version 2 is out of range: version
definitions available: 0-0
Debug/solaris_test2: .dynsym: index[12]: version 2 is out of range: version
definitions available: 0-0
Debug/solaris_test2: .dynsym: index[14]: version 3 is out of range: version
definitions available: 0-0
Debug/solaris_test2: .dynsym: index[17]: version 2 is out of range: version
definitions available: 0-0
Debug/solaris_test2: .dynsym: index[24]: version 3 is out of range: version
definitions available: 0-0
Debug/solaris_test2: .note: bad sh_offset alignment
But I'm not sure what effect these errors have.
I'll forward this to our linker folks.
Casper
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code