File: many-sections.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (69 lines) | stat: -rw-r--r-- 2,397 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
## Here we simulate an object with more than ~65k sections and check how we dump it.
## When an ELF object has SHN_LORESERVE (0xff00) or more sections, its e_shnum field
## should be zero and sh_size of the section header at index 0 is used
## to store the value. If the section name string table section index is
## greater than or equal to SHN_LORESERVE, then e_shstrndx field
## should have the value of SHN_XINDEX and sh_link of the section header
## at index 0 is used to store the value.

# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --file-headers -S %t1 | FileCheck %s --check-prefix=GNU1
# GNU1: Number of section headers:         0 (3)
# GNU1: Section header string table index: 65535 (2)
# GNU1: There are 3 section headers, starting at offset 0x58

# RUN: llvm-readobj --file-headers %t1 | FileCheck %s --check-prefix=LLVM1
# LLVM1: SectionHeaderCount: 0 (3)
# LLVM1: StringTableSectionIndex: 65535 (2)

--- !ELF
FileHeader:
  Class:     ELFCLASS64
  Data:      ELFDATA2LSB
  Type:      ET_REL
  Machine:   EM_X86_64
  EShNum:    0
  EShStrNdx: 0xffff ## SHN_XINDEX
Sections:
  - Type: SHT_NULL
    Link: .shstrtab
    Size: 0x3

## Another case is when e_shoff field set to zero, but not e_shstrndx.
## We want to show that this corrupt case is handled correctly.

# RUN: yaml2obj --docnum=2 %s -o %t2

# RUN: llvm-readelf --file-headers --sections %t2 2>&1 | \
# RUN:   FileCheck %s -DFILE=%t2 --check-prefix=GNU2
# GNU2: Number of section headers:         0
# GNU2: Section header string table index: 65535 (corrupt: out of range)

# GNU2:       There are 0 section headers, starting at offset 0x0:
# GNU2-EMPTY:
# GNU2-NEXT:  Section Headers:
# GNU2-NEXT:   [Nr] Name Type Address Off Size ES Flg Lk Inf Al
# GNU2-NEXT:  warning: '[[FILE]]': e_shstrndx == SHN_XINDEX, but the section header table is empty
# GNU2-NEXT:  Key to Flags:

# RUN: llvm-readobj --file-headers --sections %t2 | \
# RUN:   FileCheck %s --check-prefix=LLVM2 --implicit-check-not="warning:"
# LLVM2:       SectionHeaderCount: 0
# LLVM2:       StringTableSectionIndex: 65535 (corrupt: out of range)
# LLVM2-NEXT: }
# LLVM2-NEXT: Sections [
# LLVM2-NEXT: ]

--- !ELF
FileHeader:
  Class:     ELFCLASS64
  Data:      ELFDATA2LSB
  Type:      ET_REL
  Machine:   EM_X86_64
  EShOff:    0
  EShNum:    0
  EShStrNdx: 0xffff ## SHN_XINDEX
Sections:
  - Type: SHT_NULL
    Link: .shstrtab
    Size: 0x3