[PATCH] D67054: [yaml2obj] Make e_phoff and e_phentsize 0 if there are no program headers
Alex Brachet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 5 19:28:13 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL371162: [yaml2obj] Make e_phoff and e_phentsize 0 if there are no program headers (authored by abrachet, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D67054?vs=219022&id=219023#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67054/new/
https://reviews.llvm.org/D67054
Files:
llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
llvm/trunk/test/tools/yaml2obj/elf-no-phdrs.yaml
Index: llvm/trunk/test/tools/yaml2obj/elf-no-phdrs.yaml
===================================================================
--- llvm/trunk/test/tools/yaml2obj/elf-no-phdrs.yaml
+++ llvm/trunk/test/tools/yaml2obj/elf-no-phdrs.yaml
@@ -0,0 +1,15 @@
+## Check that e_phoff and e_phentsize are set to 0 when there are no
+## program headers.
+
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-readobj --file-headers %t | FileCheck %s
+
+# CHECK: ProgramHeaderOffset: 0x0{{$}}
+# CHECK: ProgramHeaderEntrySize: 0{{$}}
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
Index: llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/trunk/lib/ObjectYAML/ELFEmitter.cpp
@@ -224,10 +224,10 @@
Header.e_machine = Doc.Header.Machine;
Header.e_version = EV_CURRENT;
Header.e_entry = Doc.Header.Entry;
- Header.e_phoff = sizeof(Header);
+ Header.e_phoff = Doc.ProgramHeaders.size() ? sizeof(Header) : 0;
Header.e_flags = Doc.Header.Flags;
Header.e_ehsize = sizeof(Elf_Ehdr);
- Header.e_phentsize = sizeof(Elf_Phdr);
+ Header.e_phentsize = Doc.ProgramHeaders.size() ? sizeof(Elf_Phdr) : 0;
Header.e_phnum = Doc.ProgramHeaders.size();
Header.e_shentsize =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67054.219023.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190906/100e6e11/attachment.bin>
More information about the llvm-commits
mailing list