[PATCH] D90224: [yaml2obj] - Support the "Offset" key for the .dynsym section.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 28 04:31:01 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rGedfb2f8b235f: [yaml2obj] - Support the "Offset" key for the .dynsym section. (authored by grimar).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90224/new/
https://reviews.llvm.org/D90224
Files:
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/test/tools/yaml2obj/ELF/dynsym-section.yaml
llvm/test/tools/yaml2obj/ELF/explicit-dynsym-no-dynstr.yaml
Index: llvm/test/tools/yaml2obj/ELF/explicit-dynsym-no-dynstr.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/explicit-dynsym-no-dynstr.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-## Check we do not crash/assert when .dynsym is specified
-## explicitly, but .dynstr is not present.
-
-# RUN: yaml2obj %s -o %t
-# RUN: llvm-readelf --section-headers %t | FileCheck %s
-
-## Check that .dynsym has Link field set to 0.
-
-# CHECK: Section Headers:
-# CHECK-NEXT: [Nr] Name Type Address Off Size ES Flg Lk
-# CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0
-# CHECK-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000018 18 A 0
-
---- !ELF
-FileHeader:
- Class: ELFCLASS64
- Data: ELFDATA2LSB
- Type: ET_DYN
-Sections:
- - Name: .dynsym
- Type: SHT_DYNSYM
Index: llvm/test/tools/yaml2obj/ELF/dynsym-section.yaml
===================================================================
--- /dev/null
+++ llvm/test/tools/yaml2obj/ELF/dynsym-section.yaml
@@ -0,0 +1,33 @@
+## Check how we produce SHT_DYNSYM sections.
+
+## Check we do not crash/assert when .dynsym is specified
+## explicitly, but .dynstr is not present.
+## Check we set the sh_link field to 0 for the .dynsym section in this case.
+
+# RUN: yaml2obj %s -o %t1
+# RUN: llvm-readelf --section-headers %t1 | FileCheck %s
+
+# CHECK: Section Headers:
+# CHECK-NEXT: [Nr] Name Type Address Off Size ES Flg Lk
+# CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0
+# CHECK-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000040 000018 18 A 0
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_DYN
+Sections:
+ - Name: .dynsym
+ Type: SHT_DYNSYM
+ Offset: [[OFFSET=<none>]]
+
+## Check we can use the "Offset" key to to set an arbitrary offset for the SHT_DYNSYM section.
+
+# RUN: yaml2obj %s -DOFFSET=0x100 -o %t2
+# RUN: llvm-readelf --section-headers %t2 | FileCheck %s --check-prefix=OFFSET
+
+# OFFSET: Section Headers:
+# OFFSET-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
+# OFFSET-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
+# OFFSET-NEXT: [ 1] .dynsym DYNSYM 0000000000000000 000100 000018 18 A 0 1 0
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -903,7 +903,8 @@
assignSectionAddress(SHeader, YAMLSec);
- SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign, /*Offset=*/None);
+ SHeader.sh_offset =
+ alignToOffset(CBA, SHeader.sh_addralign, RawSec ? RawSec->Offset : None);
if (RawSec && (RawSec->Content || RawSec->Size)) {
assert(Symbols.empty());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90224.301236.patch
Type: text/x-patch
Size: 2867 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201028/43669bba/attachment.bin>
More information about the llvm-commits
mailing list