File: gnu-hash-symbols.test

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,388 kB
  • sloc: cpp: 4,167,636; ansic: 714,256; asm: 457,610; python: 155,927; objc: 65,094; sh: 42,856; lisp: 26,908; perl: 7,786; pascal: 7,722; makefile: 6,881; ml: 5,581; awk: 3,648; cs: 2,027; xml: 888; javascript: 381; ruby: 156
file content (104 lines) | stat: -rw-r--r-- 4,396 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# RUN: llvm-readelf --hash-symbols %p/Inputs/dynamic-table-exe.x86 \
# RUN:   | FileCheck %s --check-prefix HASH

# HASH:     Symbol table of .hash for image:
# HASH-NEXT:   Num Buc:    Value  Size   Type   Bind Vis      Ndx Name
# HASH-NEXT:     9   0: 00000000     0 FUNC    GLOBAL DEFAULT UND __gxx_personality_v0@CXXABI_1.3
# HASH-NEXT:    13   0: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS _edata{{$}}
# HASH-NEXT:     7   0: 00000000     0 FUNC    GLOBAL DEFAULT UND _ZNSt14basic_ifstreamIcSt11char_traitsIcEEC1EPKcSt13_Ios_Openmode@GLIBCXX_3.4
# HASH-NEXT:     2   0: 00000000     0 NOTYPE  WEAK   DEFAULT UND _Jv_RegisterClasses{{$}}
# HASH-NEXT:     1   0: 00000000     0 NOTYPE  WEAK   DEFAULT UND __gmon_start__{{$}}
# HASH-NEXT:    16   1: 00000850    81 FUNC    GLOBAL DEFAULT  14 main{{$}}
# HASH-NEXT:    10   1: 00000000     0 FUNC    GLOBAL DEFAULT UND _Unwind_Resume@GCC_3.0
# HASH-NEXT:     8   1: 00000000     0 FUNC    GLOBAL DEFAULT UND puts@GLIBC_2.0
# HASH-NEXT:    12   1: 00001b68     0 NOTYPE  GLOBAL DEFAULT ABS _end{{$}}
# HASH-NEXT:     6   1: 00000000     0 FUNC    GLOBAL DEFAULT UND _ZNSt14basic_ifstreamIcSt11char_traitsIcEED1Ev@GLIBCXX_3.4
# HASH-NEXT:     5   1: 00000000     0 NOTYPE  WEAK   DEFAULT UND _ITM_registerTMCloneTable{{$}}
# HASH-NEXT:     4   1: 00000000     0 NOTYPE  WEAK   DEFAULT UND _ITM_deregisterTMCloneTable{{$}}
# HASH-NEXT:     3   1: 00000000     0 FUNC    GLOBAL DEFAULT UND __libc_start_main@GLIBC_2.0
# HASH-NEXT:    11   2: 00000000     0 FUNC    WEAK   DEFAULT UND __cxa_finalize@GLIBC_2.1.3
# HASH-NEXT:    15   2: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS __bss_start{{$}}
# HASH-NEXT:    14   2: 0000093c     4 OBJECT  GLOBAL DEFAULT  16 _IO_stdin_used{{$}}
# HASH:     Symbol table of .gnu.hash for image:
# HASH-NEXT:   Num Buc:    Value  Size   Type   Bind Vis      Ndx Name
# HASH-NEXT:    12   0: 00001b68     0 NOTYPE  GLOBAL DEFAULT ABS _end{{$}}
# HASH-NEXT:    13   0: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS _edata{{$}}
# HASH-NEXT:    14   1: 0000093c     4 OBJECT  GLOBAL DEFAULT  16 _IO_stdin_used{{$}}
# HASH-NEXT:    15   1: 00001b64     0 NOTYPE  GLOBAL DEFAULT ABS __bss_start{{$}}
# HASH-NEXT:    16   1: 00000850    81 FUNC    GLOBAL DEFAULT  14 main{{$}}

## Show that if there are no hash sections, we do not print anything.
# RUN: yaml2obj %s -o %t.o
# RUN: llvm-readelf --hash-symbols %t.o \
# RUN:   | FileCheck %s --check-prefix NO-HASH --allow-empty

# NO-HASH-NOT: {{.}}

## Sanity check that we can still find the dynamic symbols (i.e. the above test
## doesn't pass due to a mistake in the dynamic section).
# RUN: llvm-readelf --dyn-symbols %t.o | FileCheck %s --check-prefix DYNSYMS

# DYNSYMS: Symbol table '.dynsym' contains 2 entries:

!ELF
FileHeader:
  Class:           ELFCLASS64
  Data:            ELFDATA2LSB
  Type:            ET_DYN
  Machine:         EM_X86_64
Sections:
  - Name:         .dynstr
    Type:         SHT_STRTAB
    Flags:        [ SHF_ALLOC ]
    AddressAlign: 0x100
    EntSize:      0x1
  - Name:         .dynsym
    Type:         SHT_DYNSYM
    Flags:        [ SHF_ALLOC ]
    Link:         .dynstr
    Address:      0x100
    AddressAlign: 0x100
    EntSize:      0x18
  - Name:            .dynamic
    Type:            SHT_DYNAMIC
    Flags:           [ SHF_ALLOC ]
    Address:         0x0000000000001000
    Link:            .dynstr
    AddressAlign:    0x0000000000001000
    EntSize:         0x0000000000000010
    Entries:
      - Tag:             DT_STRTAB
        Value:           0x0000000000000000
      - Tag:             DT_STRSZ
        Value:           0x0000000000000009
      - Tag:             DT_SYMTAB
        Value:           0x0000000000000100
      - Tag:             DT_SYMENT
        Value:           0x0000000000000018
      - Tag:             DT_NULL
        Value:           0x0000000000000000
  - Name:  .text.foo
    Type:  SHT_PROGBITS
    Flags: [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
    Size:  0x40
    Address: 0x2000
    AddressAlign: 0x2000
DynamicSymbols:
  - Name:    _Z3fooi
    Binding: STB_GLOBAL
ProgramHeaders:
  - Type:  PT_LOAD
    Flags: [ PF_R, PF_X ]
    VAddr: 0x0
    PAddr: 0x0
    Sections:
      - Section: .dynsym
      - Section: .dynstr
      - Section: .dynamic
      - Section: .text.foo
  - Type:  PT_DYNAMIC
    Flags: [ PF_R ]
    VAddr: 0x1000
    PAddr: 0x1000
    Sections:
      - Section: .dynamic