[PATCH] D67054: [yaml2obj] Make e_phoff 0 if there are no program headers

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 2 02:16:30 PDT 2019


jhenderson added inline comments.


================
Comment at: llvm/lib/ObjectYAML/ELFEmitter.cpp:231
   Header.e_ehsize = sizeof(Elf_Ehdr);
   Header.e_phentsize = sizeof(Elf_Phdr);
   Header.e_phnum = Doc.ProgramHeaders.size();
----------------
grimar wrote:
> Perhaps we might want to set this to 0 too when there are no headers.
+1 to this (it's not required by the gABI, but it seems to be common practice). We might as well do it at the same time.


================
Comment at: llvm/test/tools/yaml2obj/elf-header-ephoff.yaml:1
+## Check that e_phoff is set to 0 when there are no program headers
+
----------------
Nit: missing trailing full stop.

If you go with changing the size field too, I'd test that and e_phnum in the same test, and rename this to "elf-header-no-phdrs.yaml" or even "elf-no-phdrs.yaml".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67054/new/

https://reviews.llvm.org/D67054





More information about the llvm-commits mailing list