xref: /llvm-project/llvm/test/tools/yaml2obj/ELF/dynamic-relocations.yaml (revision 1b704e889f09b5dfc0549786542bc6d2cd54e85b)
1## Show that yaml2obj uses the correct set of symbols for relocation sections
2## referencing the dynamic symbol table.
3
4# RUN: yaml2obj %s -o %t
5# RUN: llvm-readelf -r %t | FileCheck %s
6
7# RUN: yaml2obj -DTYPE=SHT_CREL %s -o %t.crel
8# RUN: llvm-readelf -r %t.crel | FileCheck %s
9
10# CHECK:      Relocation section '.rela.dyn' at offset {{.*}} contains 2 entries:
11# CHECK-NEXT:     Offset             Info             Type      Symbol's Value  Symbol's Name
12# CHECK-NEXT: 0000000000000000  0000000100000000 R_X86_64_NONE 0000000012345678 dynamic
13# CHECK-NEXT: 0000000000000008  0000000200000000 R_X86_64_NONE 0000000087654321 both
14# CHECK-EMPTY:
15# CHECK-NEXT: Relocation section '.rela.data' at offset {{.*}} contains 2 entries:
16# CHECK-NEXT:     Offset             Info             Type      Symbol's Value  Symbol's Name
17# CHECK-NEXT: 0000000000000010  0000000200000000 R_X86_64_NONE 0000000011223344 static
18# CHECK-NEXT: 0000000000000018  0000000100000000 R_X86_64_NONE 0000000088776655 both
19
20!ELF
21FileHeader:
22  Class:   ELFCLASS64
23  Data:    ELFDATA2LSB
24  Type:    ET_DYN
25  Machine: EM_X86_64
26Sections:
27  - Name: .data
28    Type: SHT_PROGBITS
29  - Name: .rela.dyn
30    Type: [[TYPE=SHT_REL]]
31    Link: .dynsym
32    Info: .data
33    Relocations:
34      - Type: R_X86_64_NONE
35        Symbol: dynamic
36      - Offset: 8
37        Type: R_X86_64_NONE
38        Symbol: both
39  - Name: .rela.data
40    Type: SHT_REL
41    Link: .symtab
42    Info: .data
43    Relocations:
44      - Offset: 16
45        Type: R_X86_64_NONE
46        Symbol: static
47      - Offset: 24
48        Type: R_X86_64_NONE
49        Symbol: both
50Symbols:
51    - Name: both
52      Section: .data
53      Value: 0x88776655
54      Binding: STB_GLOBAL
55    - Name: static
56      Section: .data
57      Value: 0x11223344
58      Binding: STB_GLOBAL
59DynamicSymbols:
60    - Name: dynamic
61      Section: .data
62      Value: 0x12345678
63      Binding: STB_GLOBAL
64    - Name: both
65      Section: .data
66      Value: 0x87654321
67      Binding: STB_GLOBAL
68