[llvm] r363368 - [yaml2obj] - Allow setting the custom Address for .strtab
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 04:13:32 PDT 2019
Author: grimar
Date: Fri Jun 14 04:13:32 2019
New Revision: 363368
URL: http://llvm.org/viewvc/llvm-project?rev=363368&view=rev
Log:
[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
Added:
llvm/trunk/test/tools/yaml2obj/implicit-sections-addr.yaml
Removed:
llvm/trunk/test/tools/yaml2obj/dynsym-dynstr-addr.yaml
Modified:
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Removed: llvm/trunk/test/tools/yaml2obj/dynsym-dynstr-addr.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/dynsym-dynstr-addr.yaml?rev=363367&view=auto
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/dynsym-dynstr-addr.yaml (original)
+++ llvm/trunk/test/tools/yaml2obj/dynsym-dynstr-addr.yaml (removed)
@@ -1,40 +0,0 @@
-# RUN: yaml2obj %s -o %t
-# RUN: llvm-readobj --sections %t | FileCheck %s
-
-## Check yaml2obj does not ignore the address of the
-## explicitly listed .dynstr and .dynsym sections.
-
-# CHECK: Name: .dynstr
-# CHECK-NEXT: Type: SHT_STRTAB
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x1000
-
-# CHECK: Name: .dynsym
-# CHECK-NEXT: Type: SHT_DYNSYM
-# CHECK-NEXT: Flags [
-# CHECK-NEXT: SHF_ALLOC
-# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x2000
-
-!ELF
-FileHeader:
- Class: ELFCLASS64
- Data: ELFDATA2LSB
- Type: ET_DYN
- Machine: EM_X86_64
-Sections:
- - Name: .dynstr
- Type: SHT_STRTAB
- Flags: [ SHF_ALLOC ]
- Address: 0x1000
- EntSize: 0x1
- - Name: .dynsym
- Type: SHT_DYNSYM
- Flags: [ SHF_ALLOC ]
- Address: 0x2000
- EntSize: 0x18
-DynamicSymbols:
- - Name: foo
- Binding: STB_GLOBAL
Added: llvm/trunk/test/tools/yaml2obj/implicit-sections-addr.yaml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/yaml2obj/implicit-sections-addr.yaml?rev=363368&view=auto
==============================================================================
--- llvm/trunk/test/tools/yaml2obj/implicit-sections-addr.yaml (added)
+++ llvm/trunk/test/tools/yaml2obj/implicit-sections-addr.yaml Fri Jun 14 04:13:32 2019
@@ -0,0 +1,57 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj --sections %t | FileCheck %s
+
+## Check yaml2obj does not ignore the address of the
+## explicitly listed .dynstr, .dynsym, .strtab
+## and .symtab sections.
+
+# CHECK: Name: .dynstr
+# CHECK-NEXT: Type: SHT_STRTAB
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x1000
+
+# CHECK: Name: .dynsym
+# CHECK-NEXT: Type: SHT_DYNSYM
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x2000
+
+# CHECK: Name: .strtab
+# CHECK-NEXT: Type: SHT_STRTAB
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x3000
+
+# CHECK: Name: .symtab
+# CHECK-NEXT: Type: SHT_SYMTAB
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x4000
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+ Machine: EM_X86_64
+Sections:
+ - Name: .dynstr
+ Type: SHT_STRTAB
+ Flags: [ SHF_ALLOC ]
+ Address: 0x1000
+ - Name: .dynsym
+ Type: SHT_DYNSYM
+ Flags: [ SHF_ALLOC ]
+ Address: 0x2000
+ - Name: .strtab
+ Type: SHT_STRTAB
+ Address: 0x3000
+ - Name: .symtab
+ Type: SHT_SYMTAB
+ Address: 0x4000
+DynamicSymbols:
+ - Name: foo
+ Binding: STB_GLOBAL
Modified: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/yaml2obj/yaml2elf.cpp?rev=363368&r1=363367&r2=363368&view=diff
==============================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp (original)
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp Fri Jun 14 04:13:32 2019
@@ -489,10 +489,9 @@ void ELFState<ELFT>::initStrtabSectionHe
else if (Name == ".dynstr")
SHeader.sh_flags = ELF::SHF_ALLOC;
- // If .dynstr section is explicitly described in the YAML
+ // If the section is explicitly described in the YAML
// then we want to use its section address.
- // TODO: Allow this for any explicitly described section.
- if (YAMLSec && Name == ".dynstr")
+ if (YAMLSec)
SHeader.sh_addr = YAMLSec->Address;
}
More information about the llvm-commits
mailing list