diff --git a/llvm/tools/obj2yaml/elf2yaml.cpp b/llvm/tools/obj2yaml/elf2yaml.cpp --- a/llvm/tools/obj2yaml/elf2yaml.cpp +++ b/llvm/tools/obj2yaml/elf2yaml.cpp @@ -10,6 +10,7 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Twine.h" +#include "llvm/BinaryFormat/ELF.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/Object/ELFObjectFile.h" #include "llvm/ObjectYAML/DWARFYAML.h" @@ -484,6 +485,12 @@ PH.Flags = Phdr.p_flags; PH.VAddr = Phdr.p_vaddr; PH.PAddr = Phdr.p_paddr; + PH.Offset = Phdr.p_offset; + + if (Phdr.p_type == ELF::PT_PHDR) { + PH.MemSize = Phdr.p_memsz; + PH.FileSize = Phdr.p_filesz; + } // yaml2obj sets the alignment of a segment to 1 by default. // We do not print the default alignment to reduce noise in the output.