This is the mail archive of the libc-alpha@sourceware.org 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]

Should undefined symbols in sysv hash table be ignored in do_lookup_x?


Hi,

GNU hash table only has defined symbols:

[hjl@gnu-6 tmp]$ cat h.c
void foo () __attribute__ ((weak));

void
bar ()
{
  foo ();
}
[hjl@gnu-6 tmp]$ gcc -fPIC h.c -c
[hjl@gnu-6 tmp]$ ld -shared --hash-style=both h.o
[hjl@gnu-6 tmp]$ readelf -D -s a.out

Symbol table for image:
  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name
    5   0: 0000000000000290    16 FUNC    GLOBAL DEFAULT   7 bar
    3   0: 0000000000200420     0 NOTYPE  GLOBAL DEFAULT  10 _edata
    2   0: 0000000000000000     0 NOTYPE  WEAK   DEFAULT UND foo
    4   1: 0000000000200420     0 NOTYPE  GLOBAL DEFAULT  10 _end
    6   2: 0000000000200420     0 NOTYPE  GLOBAL DEFAULT  10 __bss_start

Symbol table of `.gnu.hash' for image:
  Num Buc:    Value          Size   Type   Bind Vis      Ndx Name
    3   0: 0000000000200420     0 NOTYPE  GLOBAL DEFAULT  10 _edata
    4   0: 0000000000200420     0 NOTYPE  GLOBAL DEFAULT  10 _end
    5   0: 0000000000000290    16 FUNC    GLOBAL DEFAULT   7 bar
    6   1: 0000000000200420     0 NOTYPE  GLOBAL DEFAULT  10 __bss_start
[hjl@gnu-6 tmp]$

do_lookup_x has

      const ElfW(Addr) *bitmask = map->l_gnu_bitmask;
      if (__builtin_expect (bitmask != NULL, 1))
        {
           Handle GNU hash table
        }
      else
        {
          if (*old_hash == 0xffffffff)
            *old_hash = _dl_elf_hash (undef_name);

          /* Use the old SysV-style hash table.  Search the appropriate
             hash bucket in this object's symbol table for a definition
             for the same symbol name.  */
          for (symidx = map->l_buckets[*old_hash % map->l_nbuckets];
               symidx != STN_UNDEF;
               symidx = map->l_chain[symidx])
            {
              sym = check_match (&symtab[symidx]);
              if (sym != NULL)
                goto found_it;
            }
        }

It may return undefined symbol entry for sysv hash table.  Should we
ignore undefined symbol entry in sysv hash stable so that we get the
same symbol entry for both GNU and sysv hash tables?


-- 
H.J.


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