llvm.org GIT mirror llvm / f7dff4c
[yaml2elf/obj2yaml] - Allow normal parsing/dumping of the .rela.dyn section .rela.dyn is a section that has sh_info normally set to zero. And Info is an optional field in the description of the relocation section in YAML. But currently, yaml2obj would fail to produce the object when Info is not explicitly listed. The patch fixes the issue. Differential revision: https://reviews.llvm.org/D60820 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358656 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar 6 months ago
2 changed file(s) with 47 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 # RUN: yaml2obj %s -o %t
1 # RUN: llvm-readobj --sections %t | FileCheck %s
2 # RUN: obj2yaml %t | FileCheck %s --check-prefix=YAML
3
4 ## .rela.dyn is a dynamic relocation section that normally has
5 ## no value in sh_info field. Check we are able to use
6 ## yaml2obj/obj2yaml without needing to explicitly set it.
7
8 # CHECK: Name: .rela.dyn
9 # CHECK-NEXT: Type: SHT_RELA
10 # CHECK-NEXT: Flags [
11 # CHECK-NEXT: SHF_ALLOC
12 # CHECK-NEXT: ]
13 # CHECK-NEXT: Address:
14 # CHECK-NEXT: Offset:
15 # CHECK-NEXT: Size:
16 # CHECK-NEXT: Link:
17 # CHECK-NEXT: Info: 0
18 # CHECK-NEXT: AddressAlignment:
19 # CHECK-NEXT: EntrySize:
20
21 # YAML: - Name: .rela.dyn
22 # YAML-NEXT: Type: SHT_RELA
23 # YAML-NEXT: Flags: [ SHF_ALLOC ]
24 # YAML-NEXT: Link: .dynsym
25 # YAML-NEXT: EntSize: 0x0000000000000018
26
27 --- !ELF
28 FileHeader:
29 Class: ELFCLASS64
30 Data: ELFDATA2LSB
31 Type: ET_DYN
32 Machine: EM_X86_64
33 Entry: 0x0000000000001000
34 Sections:
35 - Name: .rela.dyn
36 Type: SHT_RELA
37 Flags: [ SHF_ALLOC ]
38 Link: .dynsym
39 EntSize: 0x0000000000000018
40 # Add at least one symbol to trigger the .dynsym emission.
41 DynamicSymbols:
42 - Name: bar
43 Binding: STB_GLOBAL
277277 // For relocation section set link to .symtab by default.
278278 SHeader.sh_link = getDotSymTabSecNo();
279279
280 unsigned Index;
281 if (!convertSectionIndex(SN2I, S->Name, S->RelocatableSec, Index))
280 unsigned Index = 0;
281 if (!S->RelocatableSec.empty() &&
282 !convertSectionIndex(SN2I, S->Name, S->RelocatableSec, Index))
282283 return false;
283284 SHeader.sh_info = Index;
284285 if (!writeSectionContent(SHeader, *S, CBA))