[PATCH] D104098: [yaml2obj] Fix bug when referencing items in SectionHeaderTable
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 16 02:02:48 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfef3bfb1b23a: [yaml2obj] Fix bug when referencing items in SectionHeaderTable (authored by jhenderson).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104098/new/
https://reviews.llvm.org/D104098
Files:
llvm/lib/ObjectYAML/ELFEmitter.cpp
llvm/test/tools/yaml2obj/ELF/section-headers.yaml
Index: llvm/test/tools/yaml2obj/ELF/section-headers.yaml
===================================================================
--- llvm/test/tools/yaml2obj/ELF/section-headers.yaml
+++ llvm/test/tools/yaml2obj/ELF/section-headers.yaml
@@ -418,3 +418,39 @@
Sections:
- Name: .strtab
- Name: .shstrtab
+
+## Show that we can reference both the first and last section in the section
+## header table, via sh_link.
+
+# RUN: yaml2obj %s --docnum=14 -o %t14
+# RUN: llvm-readelf --sections %t14 | FileCheck %s --check-prefix=LINK
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+Sections:
+ - Name: .strtab
+ Type: SHT_STRTAB
+ - Type: SectionHeaderTable
+ Sections:
+ - Name: .strtab
+ - Name: .ref.first
+ - Name: .ref.last
+ - Name: .shstrtab
+ - Name: .ref.first
+ Type: SHT_PROGBITS
+ Link: .strtab
+ - Name: .ref.last
+ Type: SHT_PROGBITS
+ Link: .shstrtab
+ - Name: .shstrtab
+ Type: SHT_STRTAB
+
+# LINK: There are 5 section headers
+# LINK: [Nr] Name Type Address Off Size ES Flg Lk
+# LINK: [ 1] .strtab
+# LINK-NEXT: [ 2] .ref.first PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] [[#%x,]] 1
+# LINK-NEXT: [ 3] .ref.last PROGBITS [[#%x,]] [[#%x,]] [[#%x,]] [[#%x,]] 4
+# LINK-NEXT: [ 4] .shstrtab
Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -563,7 +563,7 @@
!SectionHeaders.Sections);
size_t FirstExcluded =
SectionHeaders.Sections ? SectionHeaders.Sections->size() : 0;
- if (Index >= FirstExcluded) {
+ if (Index > FirstExcluded) {
if (LocSym.empty())
reportError("unable to link '" + LocSec + "' to excluded section '" + S +
"'");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104098.352376.patch
Type: text/x-patch
Size: 1890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210616/50d9e451/attachment-0001.bin>
More information about the llvm-commits
mailing list