[PATCH] D144009: [obj2yaml] Save offset for segments and size for PHDR
Denis Revunov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 14 08:30:02 PST 2023
treapster updated this revision to Diff 497341.
treapster added a comment.
Herald added a subscriber: emaste.
Only save offset for the first segment for now to fix tests. But changing tests and saving all offsets is probably better?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D144009/new/
https://reviews.llvm.org/D144009
Files:
llvm/test/tools/obj2yaml/ELF/program-headers.yaml
llvm/tools/obj2yaml/elf2yaml.cpp
Index: llvm/tools/obj2yaml/elf2yaml.cpp
===================================================================
--- llvm/tools/obj2yaml/elf2yaml.cpp
+++ 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,13 @@
PH.Flags = Phdr.p_flags;
PH.VAddr = Phdr.p_vaddr;
PH.PAddr = Phdr.p_paddr;
+ if (Phdr.p_offset == 0 && Phdr.p_filesz)
+ 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.
Index: llvm/test/tools/obj2yaml/ELF/program-headers.yaml
===================================================================
--- llvm/test/tools/obj2yaml/ELF/program-headers.yaml
+++ llvm/test/tools/obj2yaml/ELF/program-headers.yaml
@@ -42,6 +42,7 @@
# YAML-NEXT: FirstSec: .hash
# YAML-NEXT: LastSec: .dynstr
# YAML-NEXT: Align: 0x1000
+# YAML-NEXT: Offset: 0x0
# YAML-NEXT: - Type: PT_LOAD
# YAML-NEXT: Flags: [ PF_X, PF_R ]
# YAML-NEXT: FirstSec: .foo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144009.497341.patch
Type: text/x-patch
Size: 1404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230214/fa173c96/attachment.bin>
More information about the llvm-commits
mailing list