File: elf-header-sh-fields.yaml

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 (61 lines) | stat: -rw-r--r-- 1,787 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
## In this test case we check that we can override the default values for
## e_shentsize, e_shoff, e_shnum and e_shstrndx fields in the YAML.

## First we check the default values.

# RUN: yaml2obj --docnum=1 %s -o %t1
# RUN: llvm-readelf --file-headers %t1 | FileCheck %s --check-prefix=DEFAULT

# DEFAULT:   Start of section headers:          64 (bytes into file)
# DEFAULT:   Size of section headers:           64 (bytes)
# DEFAULT:   Number of section headers:         4
# DEFAULT:   Section header string table index: 3

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_X86_64

## Override 3 fields: e_shoff, e_shnum and e_shstrndx. Check the output.

# RUN: yaml2obj --docnum=2 %s -o %t2
# RUN: llvm-readelf --file-headers %t2 | FileCheck %s --check-prefix=CUSTOM

# CUSTOM: Start of section headers:          2 (bytes into file)
# CUSTOM: Size of section headers:           64 (bytes)
# CUSTOM: Number of section headers:         3
# CUSTOM: Section header string table index: 4

--- !ELF
FileHeader:
  Class:     ELFCLASS64
  Data:      ELFDATA2LSB
  Type:      ET_REL
  Machine:   EM_X86_64
  SHEntSize: 64
  SHOffset:  2
  SHNum:     3
  SHStrNdx:  4

## Finally, we use the same YAML as above, but set e_shentsize to 1.
## Check the result using raw output from 'od' because llvm-readelf
## is unable to dump such headers.

# RUN: yaml2obj --docnum=3 %s -o %t3
# RUN: od -t x1 -v -j 0x3a -N 1 %t3 | FileCheck %s --check-prefix=NEWSIZE
# RUN: od -t x1 -v -j 0x3a -N 1 %t2 | FileCheck %s --check-prefix=OLDSIZE
# NEWSIZE: 0000072 01
# OLDSIZE: 0000072 40

--- !ELF
FileHeader:
  Class:     ELFCLASS64
  Data:      ELFDATA2LSB
  Type:      ET_REL
  Machine:   EM_X86_64
  SHEntSize: 1
  SHOffset:  2
  SHNum:     3
  SHStrNdx:  4