Interpretation of .gnu.hash

Peng Yu pengyu.ut@gmail.com
Sun May 2 05:12:34 GMT 2021


Hi,

Hex dump of section '.gnu.hash':
  0x00000308 02000000 06000000 01000000 06000000 ................
  0x00000318 00008100 00000000 06000000 00000000 ................
  0x00000328 d165ce6d                            .e.m

For the above .gnu.hash hexdump. I can see the values of the following
four variables are below (from the row of 0x00000308).

nbuckets: 2
symndx: 6
maskwords: 1
shift2: 6

https://sourceware.org/legacy-ml/binutils/2006-10/msg00377.html

I see dynsymcount = 6. So dynsymcount - symndx = 0. Therefore, part 4
does not exist?

"The fourth part of the .gnu.hash section contains dynsymcount - symndx
32-bit words."

Symbol table '.dynsym' contains 7 entries:
   Num:    Value          Size Type    Bind   Vis      Ndx Name
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND
     1: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND
_ITM_deregisterTMCloneTable
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND puts@GLIBC_2.2.5 (2)
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND
__libc_start_main@GLIBC_2.2.5 (2)
     4: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     5: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND
_ITM_registerTMCloneTable
     6: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND
__cxa_finalize@GLIBC_2.2.5 (2)

But I have trouble fully understand parts 2 and 3. There are a total
of 20 bytes for parts 2 and 3 (covering the row of 0x00000318 to
0x00000328).

"The second part of the .gnu.hash section is the bloom filter,
consisting of maskwords 32-bit words for ELFCLASS32 and maskwords
64-bit words for ELFCLASS64."

"The third part of the .gnu.hash section contains nbuckets 32-bit words."

My understanding is part 2 = 1 * 8 = 8 bytes, part 3 = 2 * 4 = 8
bytes. But they don't add up to 20 bytes.

Could anybody help me understand the interpretation of .gnu.hash better?

-- 
Regards,
Peng


More information about the Binutils mailing list