llvm.org GIT mirror llvm / abc1500
[yaml2obj] - Allow setting the custom Address for .strtab Despite the fact that .strtab is non-allocatable, there is no reason to disallow setting the custom address for it. The patch also adds a test case showing we can set any address we want for other implicit sections. Differential revision: https://reviews.llvm.org/D63137 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363368 91177308-0d34-0410-b5e6-96231b3b80d8 George Rimar 3 months ago
3 changed file(s) with 59 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
+0
-40
test/tools/yaml2obj/dynsym-dynstr-addr.yaml less more
None # RUN: yaml2obj %s -o %t
1 # RUN: llvm-readobj --sections %t | FileCheck %s
2
3 ## Check yaml2obj does not ignore the address of the
4 ## explicitly listed .dynstr and .dynsym sections.
5
6 # CHECK: Name: .dynstr
7 # CHECK-NEXT: Type: SHT_STRTAB
8 # CHECK-NEXT: Flags [
9 # CHECK-NEXT: SHF_ALLOC
10 # CHECK-NEXT: ]
11 # CHECK-NEXT: Address: 0x1000
12
13 # CHECK: Name: .dynsym
14 # CHECK-NEXT: Type: SHT_DYNSYM
15 # CHECK-NEXT: Flags [
16 # CHECK-NEXT: SHF_ALLOC
17 # CHECK-NEXT: ]
18 # CHECK-NEXT: Address: 0x2000
19
20 !ELF
21 FileHeader:
22 Class: ELFCLASS64
23 Data: ELFDATA2LSB
24 Type: ET_DYN
25 Machine: EM_X86_64
26 Sections:
27 - Name: .dynstr
28 Type: SHT_STRTAB
29 Flags: [ SHF_ALLOC ]
30 Address: 0x1000
31 EntSize: 0x1
32 - Name: .dynsym
33 Type: SHT_DYNSYM
34 Flags: [ SHF_ALLOC ]
35 Address: 0x2000
36 EntSize: 0x18
37 DynamicSymbols:
38 - Name: foo
39 Binding: STB_GLOBAL
0 # RUN: yaml2obj %s -o %t
1 # RUN: llvm-readobj --sections %t | FileCheck %s
2
3 ## Check yaml2obj does not ignore the address of the
4 ## explicitly listed .dynstr, .dynsym, .strtab
5 ## and .symtab sections.
6
7 # CHECK: Name: .dynstr
8 # CHECK-NEXT: Type: SHT_STRTAB
9 # CHECK-NEXT: Flags [
10 # CHECK-NEXT: SHF_ALLOC
11 # CHECK-NEXT: ]
12 # CHECK-NEXT: Address: 0x1000
13
14 # CHECK: Name: .dynsym
15 # CHECK-NEXT: Type: SHT_DYNSYM
16 # CHECK-NEXT: Flags [
17 # CHECK-NEXT: SHF_ALLOC
18 # CHECK-NEXT: ]
19 # CHECK-NEXT: Address: 0x2000
20
21 # CHECK: Name: .strtab
22 # CHECK-NEXT: Type: SHT_STRTAB
23 # CHECK-NEXT: Flags [
24 # CHECK-NEXT: ]
25 # CHECK-NEXT: Address: 0x3000
26
27 # CHECK: Name: .symtab
28 # CHECK-NEXT: Type: SHT_SYMTAB
29 # CHECK-NEXT: Flags [
30 # CHECK-NEXT: ]
31 # CHECK-NEXT: Address: 0x4000
32
33 !ELF
34 FileHeader:
35 Class: ELFCLASS64
36 Data: ELFDATA2LSB
37 Type: ET_DYN
38 Machine: EM_X86_64
39 Sections:
40 - Name: .dynstr
41 Type: SHT_STRTAB
42 Flags: [ SHF_ALLOC ]
43 Address: 0x1000
44 - Name: .dynsym
45 Type: SHT_DYNSYM
46 Flags: [ SHF_ALLOC ]
47 Address: 0x2000
48 - Name: .strtab
49 Type: SHT_STRTAB
50 Address: 0x3000
51 - Name: .symtab
52 Type: SHT_SYMTAB
53 Address: 0x4000
54 DynamicSymbols:
55 - Name: foo
56 Binding: STB_GLOBAL
488488 else if (Name == ".dynstr")
489489 SHeader.sh_flags = ELF::SHF_ALLOC;
490490
491 // If .dynstr section is explicitly described in the YAML
491 // If the section is explicitly described in the YAML
492492 // then we want to use its section address.
493 // TODO: Allow this for any explicitly described section.
494 if (YAMLSec && Name == ".dynstr")
493 if (YAMLSec)
495494 SHeader.sh_addr = YAMLSec->Address;
496495 }
497496