I’m having a senior moment. I have a program, one of the things it does is call gettimeofday(), I compiled with –fPIC then I put into a shared library which I built using gcc –shared. When a program that is linked against this shared library runs and invokes the program in question it craps out calling gettimeofday() branching somewhere unexpected (i.e. Not within libc.so which is what I would have expected).
I’ve verified that the code generated is correct:
lgr %r1,%r11
aghi %r1,168
lgr %r2,%r1
lghi %r3,0
brasl %r14,gettimeofday@PLT
lg %r1,168(%r11)
Used readelf on the objet to see what it thinks about that symbol:
00000000012a 062900000013 R_390_PC32DBL 0000000000000000 gettimeofday + 2
000000003736 062900000013 R_390_PC32DBL 0000000000000000 gettimeofday + 2
1577: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND gettimeofday
Used it again on the shared library:
00000000c572 005c00000013 R_390_PC32DBL 0000000000000000 gettimeofday + 2
00000000fb7e 005c00000013 R_390_PC32DBL 0000000000000000 gettimeofday + 2
92: 0000000000000000 0 FUNC GLOBAL DEFAULT UND gettimeofday(a)GLIBC_2.2 (2)
442: 0000000000000000 0 FUNC GLOBAL DEFAULT UND gettimeofday@@GLIBC_2.2
With -fPIC it should be R_390_PLT32DBL in the .o and there has to be a R_390_JMP_SLOT relocation in the .so. The R_390_PC32DBL is not sufficient to reach the symbol. (Got that tidbit from IBM but should’ve realized that myself.)
All I can think of is that I created the shared library incorrectly:
gcc –g –fPIC –o lineUtil.o lineUtil.c
:
gcc –shared –o libxxx.so lineUtil.o ...
So it appears something in binutils is in error. The version installed on my Fedora 15 system is 2.21.51.0.6-6.fc15.
Neale