[PATCH] D90446: [yaml2obj] - Add support of Offset for .strtab/.shstrtab/.dynstr sections.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 2 01:04:01 PST 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ffafa870c50: [yaml2obj] - Add support of Offset for .strtab/.shstrtab/.dynstr sections. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D90446?vs=301830&id=302222#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D90446/new/
https://reviews.llvm.org/D90446
Files:
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/test/tools/yaml2obj/ELF/strtab-implicit-sections.yaml
Index: llvm/test/tools/yaml2obj/ELF/strtab-implicit-sections.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/strtab-implicit-sections.yaml
+++ llvm/test/tools/yaml2obj/ELF/strtab-implicit-sections.yaml
@@ -23,25 +23,29 @@
- Name: .strtab
Type: SHT_STRTAB
Flags: [[STRTABFLAGS=<none>]]
+ Offset: [[STRTABOFFSET=<none>]]
- Name: .shstrtab
Type: SHT_STRTAB
Flags: [[SHSTRTABFLAGS=<none>]]
+ Offset: [[SHSTRTABOFFSET=<none>]]
- Name: .dynstr
Type: SHT_STRTAB
Flags: [[DYNSTRFLAGS=<none>]]
+ Offset: [[DYNSTROFFSET=<none>]]
-## Check we can set arbitrary flags for .strtab/.dynstr.
+## Check we can set arbitrary flags and offsets for
+## implicit string table sections.
# RUN: yaml2obj --docnum=1 \
-# RUN: -DSTRTABFLAGS="[ SHF_ALLOC, SHF_STRINGS ]" \
-# RUN: -DSHSTRTABFLAGS="[ SHF_ALLOC, SHF_WRITE ]" \
-# RUN: -DDYNSTRFLAGS="[ SHF_STRINGS ]" %s -o %t2
+# RUN: -DSTRTABFLAGS="[ SHF_ALLOC, SHF_STRINGS ]" -DSTRTABOFFSET=0x100 \
+# RUN: -DSHSTRTABFLAGS="[ SHF_ALLOC, SHF_WRITE ]" -DSHSTRTABOFFSET=0x200 \
+# RUN: -DDYNSTRFLAGS="[ SHF_STRINGS ]" -DDYNSTROFFSET=0x300 %s -o %t2
# RUN: llvm-readelf %t2 --sections | FileCheck %s --check-prefix=CASE2
-# CASE2: [Nr] Name Type {{.*}} Flg Lk
-# CASE2: [ 1] .strtab STRTAB {{.*}} AS 0
-# CASE2-NEXT: [ 2] .shstrtab STRTAB {{.*}} WA 0
-# CASE2-NEXT: [ 3] .dynstr STRTAB {{.*}} S 0
+# CASE2: [Nr] Name Type Address Off {{.*}} Flg Lk
+# CASE2: [ 1] .strtab STRTAB 0000000000000000 000100 {{.*}} AS 0
+# CASE2-NEXT: [ 2] .shstrtab STRTAB 0000000000000001 000200 {{.*}} WA 0
+# CASE2-NEXT: [ 3] .dynstr STRTAB 0000000000000000 000300 {{.*}} S 0
## Check no flags are set by default for implicit string table sections
## when they are not described in the YAML.
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -930,7 +930,8 @@
ELFYAML::RawContentSection *RawSec =
dyn_cast_or_null<ELFYAML::RawContentSection>(YAMLSec);
- SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign, /*Offset=*/None);
+ SHeader.sh_offset = alignToOffset(CBA, SHeader.sh_addralign,
+ YAMLSec ? YAMLSec->Offset : None);
if (RawSec && (RawSec->Content || RawSec->Size)) {
SHeader.sh_size = writeContent(CBA, RawSec->Content, RawSec->Size);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90446.302222.patch
Type: text/x-patch
Size: 2561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201102/fbb8da6c/attachment.bin>
More information about the llvm-commits
mailing list