[PATCH] D54867: [yaml2obj] Make sh_info field editable in raw content section
Xing via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 24 03:05:29 PST 2018
Higuoxing updated this revision to Diff 175153.
Higuoxing added a comment.
format codes
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D54867/new/
https://reviews.llvm.org/D54867
Files:
test/tools/yaml2obj/raw-content-section-info.yaml
tools/yaml2obj/yaml2elf.cpp
Index: tools/yaml2obj/yaml2elf.cpp
===================================================================
--- tools/yaml2obj/yaml2elf.cpp
+++ tools/yaml2obj/yaml2elf.cpp
@@ -253,9 +253,18 @@
SHeader.sh_link = Index;
}
- if (auto S = dyn_cast<ELFYAML::RawContentSection>(Sec.get()))
+ if (auto S = dyn_cast<ELFYAML::RawContentSection>(Sec.get())) {
+ if (!Sec->Info.empty()) {
+ unsigned Index;
+ if (SN2I.lookup(Sec->Info, Index) && !to_integer(Sec->Info, Index)) {
+ WithColor::error() << "Unknown section referenced: '" << Sec->Info
+ << "' at YAML section '" << Sec->Name << "'.\n";
+ return false;
+ }
+ SHeader.sh_info = Index;
+ }
writeSectionContent(SHeader, *S, CBA);
- else if (auto S = dyn_cast<ELFYAML::RelocationSection>(Sec.get())) {
+ } else if (auto S = dyn_cast<ELFYAML::RelocationSection>(Sec.get())) {
if (S->Link.empty())
// For relocation section set link to .symtab by default.
SHeader.sh_link = getDotSymTabSecNo();
Index: test/tools/yaml2obj/raw-content-section-info.yaml
===================================================================
--- /dev/null
+++ test/tools/yaml2obj/raw-content-section-info.yaml
@@ -0,0 +1,26 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s
+
+# CHECK: Name: .raw.content (1)
+# CHECK-NEXT: Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT: Flags [ (0x2)
+# CHECK-NEXT: SHF_ALLOC (0x2)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address: 0x0
+# CHECK-NEXT: Offset: 0x180
+# CHECK-NEXT: Size: 2
+# CHECK-NEXT: Link: 0
+# CHECK-NEXT: Info: 4660
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_EXEC
+ Machine: EM_X86_64
+Sections:
+ - Name: .raw.content
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC ]
+ Info: 0x1234
+ Content: 1234
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54867.175153.patch
Type: text/x-patch
Size: 1999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181124/c37f88af/attachment.bin>
More information about the llvm-commits
mailing list