[PATCH] D50235: [yaml2obj] - Add a support for changing EntSize.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 7 01:12:17 PDT 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.
Closed by commit rL339113: [yaml2obj] - Add a support for changing EntSize. (authored by grimar, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D50235?vs=159162&id=159462#toc
Repository:
rL LLVM
https://reviews.llvm.org/D50235
Files:
llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
llvm/trunk/test/tools/yaml2obj/elf-ent-size.yaml
llvm/trunk/tools/yaml2obj/yaml2elf.cpp
Index: llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
===================================================================
--- llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
+++ llvm/trunk/lib/ObjectYAML/ELFYAML.cpp
@@ -816,6 +816,7 @@
IO.mapOptional("Address", Section.Address, Hex64(0));
IO.mapOptional("Link", Section.Link, StringRef());
IO.mapOptional("AddressAlign", Section.AddressAlign, Hex64(0));
+ IO.mapOptional("EntSize", Section.EntSize);
IO.mapOptional("Info", Section.Info, StringRef());
}
Index: llvm/trunk/tools/yaml2obj/yaml2elf.cpp
===================================================================
--- llvm/trunk/tools/yaml2obj/yaml2elf.cpp
+++ llvm/trunk/tools/yaml2obj/yaml2elf.cpp
@@ -461,7 +461,9 @@
Section.Content.writeAsBinary(OS);
for (auto i = Section.Content.binary_size(); i < Section.Size; ++i)
OS.write(0);
- if (Section.Type == llvm::ELF::SHT_RELR)
+ if (Section.EntSize)
+ SHeader.sh_entsize = *Section.EntSize;
+ else if (Section.Type == llvm::ELF::SHT_RELR)
SHeader.sh_entsize = sizeof(Elf_Relr);
else if (Section.Type == llvm::ELF::SHT_DYNAMIC)
SHeader.sh_entsize = sizeof(Elf_Dyn);
Index: llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
===================================================================
--- llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
+++ llvm/trunk/include/llvm/ObjectYAML/ELFYAML.h
@@ -123,6 +123,7 @@
StringRef Link;
StringRef Info;
llvm::yaml::Hex64 AddressAlign;
+ Optional<llvm::yaml::Hex64> EntSize;
Section(SectionKind Kind) : Kind(Kind) {}
virtual ~Section();
Index: llvm/trunk/test/tools/yaml2obj/elf-ent-size.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/elf-ent-size.yaml
+++ llvm/trunk/test/tools/yaml2obj/elf-ent-size.yaml
@@ -0,0 +1,50 @@
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj -sections %t | FileCheck %s
+
+!ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ OSABI: ELFOSABI_FREEBSD
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Type: SHT_PROGBITS
+ Name: .strings
+ Flags: [ SHF_ALLOC, SHF_MERGE, SHF_STRINGS ]
+ AddressAlign: 0x04
+ Content: "FFFFFFFFFFFFFFFF"
+ EntSize: 0x1
+ - Name: .mydynamic
+ Type: SHT_DYNAMIC
+ EntSize: 0x0
+
+
+## Check we were able to set entry size for .strings and .mydynamic
+# CHECK: Name: .strings
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_MERGE
+# CHECK-NEXT: SHF_STRINGS
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info:
+# CHECK-NEXT: AddressAlignment:
+# CHECK-NEXT: EntrySize: 1
+# CHECK-NEXT: }
+# CHECK: Name: .mydynamic
+# CHECK-NEXT: Type: SHT_DYNAMIC
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size:
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info:
+# CHECK-NEXT: AddressAlignment:
+# CHECK-NEXT: EntrySize: 0
+# CHECK-NEXT: }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50235.159462.patch
Type: text/x-patch
Size: 3183 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180807/0ab25c2a/attachment.bin>
More information about the llvm-commits
mailing list