BTW - this is definately not PIC code.
Here is a slightly better disassembly:
006f8420 <find_display>:
6f8420: 55 push %ebp
6f8421: 89 e5 mov %esp,%ebp
6f8423: 83 ec 14 sub $0x14,%esp
6f8426: 53 push %ebx
6f8427: 8b 5d 08 mov 0x8(%ebp),%ebx
6f842a: 83 3d 60 b8 88 00 00 cmpl $0x0,0x88b860
6f8431: 75 15 jne 6f8448 <find_display+0x28
6f8433: e8 fc ff ff ff call 6f8434 <find_display+0x14
6f8438: a3 60 b8 88 00 mov %eax,0x88b860
6f843d: 85 c0 test %eax,%eax
6f843f: 75 07 jne 6f8448 <find_display+0x28
6f8441: 31 c0 xor %eax,%eax
6f8443: eb 37 jmp 6f847c <find_display+0x5c
6f8445: 8d 76 00 lea 0x0(%esi),%esi
6f8448: 83 c4 f8 add $0xfffffff8,%esp
6f844b: 53 push %ebx
6f844c: ff 35 60 b8 88 00 pushl 0x88b860
6f8452: e8 fc ff ff ff call 6f8453 <find_display+0x33
6f8457: 83 c4 10 add $0x10,%esp
6f845a: 85 c0 test %eax,%eax
6f845c: 75 1e jne 6f847c <find_display+0x5c
6f845e: 83 c4 f8 add $0xfffffff8,%esp
6f8461: 6a 00 push $0x0
6f8463: 6a 00 push $0x0
6f8465: 68 80 b8 88 00 push $0x88b880
6f846a: ff 35 64 b8 88 00 pushl 0x88b864
6f8470: 53 push %ebx
6f8471: ff 35 60 b8 88 00 pushl 0x88b860
6f8477: e8 fc ff ff ff call 6f8478 <find_display+0x58
6f847c: 8b 5d e8 mov 0xffffffe8(%ebp),%ebx
6f847f: c9 leave
6f8480: c3 ret
6f8481: 8d 76 00 lea 0x0(%esi),%esi
“Jens H Jorgensen” <> jhj@remove-nospam-videk.com> > wrote in message
news:a7sk2n$7sp$> 1@inn.qnx.com> …
Here is what the disassembly gave:
006f8430 <find_display+0x10>:
6f8430: 00 75 15 add %dh,0x15(%ebp)
6f8433: e8 fc ff ff ff call 6f8434 <find_display+0x14
6f8438: a3 60 b8 88 00 mov %eax,0x88b860
6f843d: 85 c0 test %eax,%eax
6f843f: 75 07 jne 6f8448 <find_display+0x28
Now is find_display() in the offending library or is it calling the
offending library?
Jens
“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:a7r0em$kjk$> 1@nntp.qnx.com> …
The easiest way to find out where the problem is is to disassemble
your lib and look at the function that contains the address 0x6f8434
(the first R_386_PC32 relocation)
Jens H Jorgensen <> jhj@remove-nospam-videk.com> > wrote:
Here is what I get:
objdump -h libqt-mt.so.3.0.2 | grep .rel.text
3 .rel.text 00000138 00122220 00122220 00122220 2**2
so there is some position dependent code! Then on to the readelf
command:
readelf -r libqt-mt.so.3.0.2 | more
Relocation section ‘.rel.text’ at offset 0x122220 contains 39 entries:
Offset Info Type Symbol’s Value Symbol’s Name
006f842c 00008 R_386_RELATIVE
006f8434 3aab02 R_386_PC32 00000000 XextCreateExtension
006f8439 00008 R_386_RELATIVE
006f844e 00008 R_386_RELATIVE
006f8453 319a02 R_386_PC32 00000000 XextFindDisplay
006f8466 00008 R_386_RELATIVE
006f846c 00008 R_386_RELATIVE
006f8473 00008 R_386_RELATIVE
006f8478 149402 R_386_PC32 00000000 XextAddDisplay
006f8492 00008 R_386_RELATIVE
006f8497 46b302 R_386_PC32 00000000 XextRemoveDisplay
006f8504 00008 R_386_RELATIVE
006f850a 4b9f02 R_386_PC32 00000000 XMissingExtension
006f8528 3ec002 R_386_PC32 00000000 _XFlush
006f8563 338302 R_386_PC32 00000000 _XReply
006f85b8 130d02 R_386_PC32 00000000 malloc
006f85ec 00008 R_386_RELATIVE
006f85f2 4b9f02 R_386_PC32 00000000 XMissingExtension
006f8610 3ec002 R_386_PC32 00000000 _XFlush
006f8649 338302 R_386_PC32 00000000 _XReply
006f86b8 00008 R_386_RELATIVE
006f86be 4b9f02 R_386_PC32 00000000 XMissingExtension
006f86dc 3ec002 R_386_PC32 00000000 _XFlush
006f8715 338302 R_386_PC32 00000000 _XReply
006f8784 00008 R_386_RELATIVE
006f878a 4b9f02 R_386_PC32 00000000 XMissingExtension
006f87a8 3ec002 R_386_PC32 00000000 _XFlush
006f87e7 338302 R_386_PC32 00000000 _XReply
006f884b 19c902 R_386_PC32 006f84a0
XPanoramiXQueryExtension
006f8867 337602 R_386_PC32 006f84dc
XPanoramiXQueryVersion
006f88a3 3ec002 R_386_PC32 00000000 _XFlush
006f88d6 338302 R_386_PC32 00000000 _XReply
006f893c 00008 R_386_RELATIVE
006f8945 4b9f02 R_386_PC32 00000000 XMissingExtension
006f8963 3ec002 R_386_PC32 00000000 _XFlush
006f899c 338302 R_386_PC32 00000000 _XReply
006f89d9 130d02 R_386_PC32 00000000 malloc
006f89ff 45ec02 R_386_PC32 00000000 _XRead
006f8a4b 3e9802 R_386_PC32 00000000 _XEatData
Then following your example:
addr2line -e libqt-mt.so.3.0.2 0x122220
??:0
Does that mean one of my X libraries are not linked correctly?
Does anyone know of the top of their head which X library it is?
Thanks
–
Jens
“Colin Burgess” <> cburgess@qnx.com> > wrote in message
news:a7olga$qj0$> 1@nntp.qnx.com> …
First, let’s confirm whether it is a pic problem - do an objdump -h
on
your
solib, if there is a rel.text section then you are linking
in some non-pic files somewhere, and I would check your link (maybe
produce
a mapfile)
You can also narrow it down by looking at the text relocations
(readelf -r),
since they will point to the non-pic functions.
Eg.
shared.c:
extern int func2(void);
int func(void)
{
return func2() * 2;
}
qcc -c -g shared.c
qcc -shared -o shared.so shared.o -g
readelf -r shared.so
Relocation section ‘.rel.text’ at offset 0x438 contains 1 entries:
Offset Info Type Symbol’s Value Symbol’s Name
000004b3 01e02 R_386_PC32 00000000 func2
Relocation section ‘.rel.data’ at offset 0x440 contains 2 entries:
Offset Info Type
Symbol’s Value Symbol’s Name 0000152c 00008
R_386_RELATIVE
00001528
00008 R_386_RELATIVE
Relocation section ‘.rel.text’ at offset 0x438 contains 1 entries:
Offset Info Type Symbol’s Value Symbol’s Name
000004b3 01e02 R_386_PC32 00000000 func2
Relocation section ‘.rel.data’ at offset 0x440 contains 2 entries:
Offset Info Type Symbol’s Value Symbol’s Name
0000152c 00008 R_386_RELATIVE
00001528 00008 R_386_RELATIVE
0x4b3 is the text relocation address, so we can objdump the shared
object
objdump -D shared.so
[…]
000004ac :
4ac: 55 push %ebp
4ad: 89 e5 mov %esp,%ebp
4af: 83 ec 08 sub $0x8,%esp
4b2: e8 fc ff ff ff call 4b3 <func+0x7
4b7: 89 c0 mov %eax,%eax
4b9: 8d 14 00 lea (%eax,%eax,1),%edx
4bc: 89 d0 mov %edx,%eax
4be: eb 00 jmp 4c0 <func+0x14
4c0: c9 leave
4c1: c3 ret
4c2: 90 nop
4c3: 90 nop
[…]
and we can see that the bad address is in the function func()
addr2line -e shared.so 0x4b3
shared.c:5
and the relocation refers to line 5 of shared.c
cburgess@qnx.com