File: elf-reloc-zero-name-or-value.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 (95 lines) | stat: -rw-r--r-- 2,894 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
# Show that the value field is omitted if a symbol has no name or value, but is
# printed if one is present. Test for both static and dynamic relocation
# printing.

# RUN: yaml2obj %s -o %t
# RUN: llvm-readelf --relocations --dyn-relocations %t | FileCheck %s

# CHECK:      Relocation section '.rela.text' at offset {{.*}} contains 2 entries:
# CHECK-NEXT:     Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
# CHECK-NEXT: 0000000000000000  0000000000000000 R_X86_64_NONE                           1
# CHECK-NEXT: 0000000000000000  0000000100000000 R_X86_64_NONE          0000000000000000 sym + 1

# CHECK:      Relocation section '.rela.dyn' at offset {{.*}} contains 2 entries:
# CHECK-NEXT:     Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
# CHECK-NEXT: 0000000000000000  0000000000000000 R_X86_64_NONE                           1
# CHECK-NEXT: 0000000000000000  0000000100000000 R_X86_64_NONE          0000000000000000 sym + 1

# CHECK:      'RELA' relocation section at offset {{.*}} contains 48 bytes:
# CHECK-NEXT:     Offset             Info             Type               Symbol's Value  Symbol's Name + Addend
# CHECK-NEXT: 0000000000000000  0000000000000000 R_X86_64_NONE                           1
# CHECK-NEXT: 0000000000000000  0000000100000000 R_X86_64_NONE          0000000000000000 sym + 1

# TODO: Add test for symbol with no name but with a value once yaml2obj allows
# referencing symbols with no name from relocations.

--- !ELF
FileHeader:
  Class:   ELFCLASS64
  Data:    ELFDATA2LSB
  Type:    ET_EXEC
  Machine: EM_X86_64
Sections:
  - Name: .text
    Type: SHT_PROGBITS
    Size: 0x10
  - Name: .rela.text
    Type: SHT_RELA
    Link: .symtab
    Info: .text
    Relocations:
      - Offset: 0
        Type: R_X86_64_NONE
        Addend: 1
      - Offset: 0
        Type: R_X86_64_NONE
        Addend: 1
        Symbol: sym
  - Name: .dynamic
    Type: SHT_DYNAMIC
    Flags: [SHF_ALLOC]
    Address: 0x1000
    AddressAlign: 0x1000
    Entries:
      - Tag: DT_RELA
        Value: 0x1100
      - Tag: DT_RELASZ
        Value: 48
      - Tag: DT_RELAENT
        Value: 24
      - Tag: DT_NULL
        Value: 0
  - Name: .rela.dyn
    Type: SHT_RELA
    Flags: [SHF_ALLOC]
    Info: .text
    Address: 0x1100
    AddressAlign: 0x100
    Relocations:
      - Offset: 0
        Type: R_X86_64_NONE
        Addend: 1
      - Offset: 0
        Type: R_X86_64_NONE
        Addend: 1
        Symbol: sym
Symbols:
  - Name:    sym
    Value:   0
    Section: .text
    Binding: STB_GLOBAL
DynamicSymbols:
  - Name:    sym
    Value:   0
    Section: .text
    Binding: STB_GLOBAL
ProgramHeaders:
  - Type: PT_LOAD
    VAddr: 0x1000
    Sections:
      - Section: .rela.dyn
      - Section: .dynamic
  - Type: PT_DYNAMIC
    VAddr: 0x1000
    Sections:
      - Section: .dynamic