This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/19415] New: dladdr returns wrong names on hppa

            Bug ID: 19415
           Summary: dladdr returns wrong names on hppa
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: danglin at gcc dot
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---
              Host: hppa-unknown-linux-gnu
            Target: hppa-unknown-linux-gnu
             Build: hppa-unknown-linux-gnu

Created attachment 8868
Test program.

Attached is a small test program that demonstrates.  The code attempts
to find address info the function foo.

The files foo.c and bar.c should be compiled as shared libraries.  The file
main.c should be compiled and linked against libfoo, libbar and libdl.

The code executes as follows:

dave@mx3210:~/debian/nss$ ./main

The following glibc is used to find the function descriptor associated
with the function pointer &foo:

_dl_lookup_address (const void *address)
  ElfW(Addr) addr = (ElfW(Addr)) address;
  struct fdesc_table *t;
  unsigned long int i;

  for (t = local.root; t != NULL; t = t->next)
      i = (struct fdesc *) addr - &t->fdesc[0];
      if (i < t->first_unused && addr == (ElfW(Addr)) &t->fdesc[i])
          addr = t->fdesc[i].ip;

  return addr;

The first time it is called we have

Breakpoint 1, main () at main.c:17
17        result = dladdr ((void *)&foo, &info);
(gdb) disass _dl_lookup_address
Dump of assembler code for function _dl_lookup_address:
   0xfd4822c8 <+0>:     addil L%800,r19,r1
   0xfd4822cc <+4>:     ldw 44(r1),ret0
   0xfd4822d0 <+8>:     ldw 0(ret0),r21
   0xfd4822d4 <+12>:    cmpib,= 0,r21,0xfd482310 <_dl_lookup_address+72>
   0xfd4822d8 <+16>:    copy r26,ret0
   0xfd4822dc <+20>:    ldo c(r21),r20
   0xfd4822e0 <+24>:    ldw 8(r21),r31
   0xfd4822e4 <+28>:    sub r26,r20,r20
   0xfd4822e8 <+32>:    extrw,s r20,28,29,r20
   0xfd4822ec <+36>:    cmpb,<<= r31,r20,0xfd482304 <_dl_lookup_address+60>
   0xfd4822f0 <+40>:    ldo 1(r20),r22
   0xfd4822f4 <+44>:    shladd,l r22,3,r21,r22
   0xfd4822f8 <+48>:    ldo 4(r22),r20
   0xfd4822fc <+52>:    cmpclr,<> r20,r26,r0
   0xfd482300 <+56>:    b,l,n 0xfd482314 <_dl_lookup_address+76>,r0
   0xfd482304 <+60>:    ldw 0(r21),r21
   0xfd482308 <+64>:    cmpib,<> 0,r21,0xfd4822e0 <_dl_lookup_address+24>
   0xfd48230c <+68>:    ldo c(r21),r20
   0xfd482310 <+72>:    bv,n r0(rp)
   0xfd482314 <+76>:    bv r0(rp)
   0xfd482318 <+80>:    ldw 4(r22),ret0
End of assembler dump.
(gdb) break *0xfd4822d4
Breakpoint 2 at 0xfd4822d4: file ../sysdeps/hppa/dl-fptr.c, line 332.
(gdb) c

Breakpoint 2, 0xfd4822d4 in _dl_lookup_address (address=0x11164)
    at ../sysdeps/hppa/dl-fptr.c:332
332     ../sysdeps/hppa/dl-fptr.c: No such file or directory.
(gdb) p/x local
$1 = {root = 0xfd48b2c0, free_list = 0x0, npages = 0x2, boot_table = {
    next = 0x0, len = 0x400, first_unused = 0x5, 
    fdesc = 0xfd48b2cc <local+24>}, boot_fdescs = {{ip = 0xfd480a88, 
      gp = 0xfd48d410}, {ip = 0xfc9b9cc0, gp = 0xfcaa6c30}, {ip = 0xfc99b2dc, 
      gp = 0xfcaa6c30}, {ip = 0xfc9b91b4, gp = 0xfcaa6c30}, {ip = 0xfc96c590, 
      gp = 0xfcaa6c30}, {ip = 0x0, gp = 0x0} <repeats 1019 times>}}
(gdb) p *t
$2 = {next = 0x0, len = 1024, first_unused = 5, fdesc = 0xfd48b2cc <local+24>}
(gdb) x/2x 0x11164
0x11164:        0x00011198      0x00000054
(gdb) bt
#0  0xfd4822d4 in _dl_lookup_address (address=0x11164)
    at ../sysdeps/hppa/dl-fptr.c:332
#1  0xfca6c0fc in __GI__dl_addr (address=<optimized out>, info=0xfd70330c, 
    mapp=mapp@entry=0x0, symbolp=symbolp@entry=0x0) at dl-addr.c:127
#2  0xfcb56b74 in __dladdr (address=<optimized out>, info=<optimized out>)
    at dladdr.c:38
#3  0x00010804 in main () at main.c:17

The function descriptor being used is not in the table so it is not found.
So, we end up with an address in main.

Think this lookup is only relevant to ia64?

You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]