File: elf-symbol-shndx.test

package info (click to toggle)
llvm-toolchain-9 1%3A9.0.1-16
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 882,436 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 (108 lines) | stat: -rw-r--r-- 3,189 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
105
106
107
108
# Show that llvm-readobj prints symbol shndxes correctly, for valid indexes,
# invalid indexes (i.e. section indexes that don't correspond to a real
# section), reserved values and processor/os-specific index values, for both GNU
# and LLVM styles.

# Use --dyn-symbols because yaml2obj does not currently support large section indexes
# and also does not allow hand-crafting of static symbol tables.
# RUN: yaml2obj --docnum=1 %s > %t1
# RUN: llvm-readobj --symbols --dyn-symbols %t1 | FileCheck %s --check-prefix=LLVM
# RUN: llvm-readelf --symbols --dyn-symbols %t1 | FileCheck %s --check-prefix=GNU1

# llvm-readobj doesn't accept shndx values that are not valid section indexes
# for LLVM style, so only test GNU output in this case.
# RUN: yaml2obj --docnum=2 %s > %t2
# RUN: llvm-readelf --symbols %t2 | FileCheck %s --check-prefix=GNU2

# LLVM: Name:    undef
# LLVM: Section: Undefined (0x0)
# LLVM: Name:    normal
# LLVM: Section: .text (0x1)
# LLVM: Name:    common
# LLVM: Section: Common (0xFFF2)
# LLVM: Name:    absolute
# LLVM: Section: Absolute (0xFFF1)
# LLVM: Name:    proc
# LLVM: Section: Processor Specific (0xFF01)
# LLVM: Name:    os
# LLVM: Section: Operating System Specific (0xFF21)
# LLVM: Name:    reserved
# LLVM: Section: Reserved (0xFFFE)

# GNU1:      Symbol table '.dynsym' contains 2 entries:
# GNU1-NEXT:   Num: {{.*}} Ndx Name
# GNU1-NEXT:     0: {{.*}} UND
# GNU1-NEXT:     1: {{.*}}   1 xindex
# GNU1:      Symbol table '.symtab' contains 8 entries:
# GNU1-NEXT:   Num: {{.*}} Ndx Name
# GNU1-NEXT:     0: {{.*}} UND
# GNU1-NEXT:     1: {{.*}} UND undef
# GNU1-NEXT:     2: {{.*}}   1 normal
# GNU1-NEXT:     3: {{.*}} COM common
# GNU1-NEXT:     4: {{.*}} ABS absolute
# GNU1-NEXT:     5: {{.*}} PRC[0xff01] proc
# GNU1-NEXT:     6: {{.*}} OS[0xff21] os
# GNU1-NEXT:     7: {{.*}} RSV[0xfffe] reserved

# GNU2:      Symbol table '.symtab' contains 2 entries:
# GNU2-NEXT:   Num: {{.*}} Ndx Name
# GNU2-NEXT:     0: {{.*}} UND
# GNU2-NEXT:     1: {{.*}}  66 bad

--- !ELF
FileHeader:
  Class:   ELFCLASS32
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_386
Sections:
  - Name: .text
    Type: SHT_PROGBITS
  - Name: .dynstr
    Type: SHT_STRTAB
    #\0xindex\0
    Content: "0078696e64657800"
  - Name: .dynsym
    Type: SHT_DYNSYM
    Link: .dynstr
    EntSize: 16
    # Null symbol
    # Symbol with st_name = 1, st_shndx = SHN_XINDEX
    Content: "000000000000000000000000000000000100000000000000000000000000ffff"
  - Name: .symtab_shndx
    Type: SHT_SYMTAB_SHNDX
    Link: .dynsym
    EntSize: 4
    Content: "0000000001000000"
Symbols:
  - Name:    undef
    Binding: STB_GLOBAL
  - Name:    normal
    Section: .text
    Binding: STB_GLOBAL
  - Name:    common
    Index:   SHN_COMMON
    Binding: STB_GLOBAL
  - Name:    absolute
    Index:   SHN_ABS
    Binding: STB_GLOBAL
  - Name:    proc
    Index:   0xff01
    Binding: STB_GLOBAL
  - Name:    os
    Index:   0xff21
    Binding: STB_GLOBAL
  - Name:    reserved
    Index:   0xfffe
    Binding: STB_GLOBAL

--- !ELF
FileHeader:
  Class:   ELFCLASS32
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_386
Symbols:
  - Name:    bad
    Index:   0x42
    Binding: STB_GLOBAL