[PATCH] D78363: [yaml2obj] - Change how p_offset is calculated when creating segments. NFCI.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 22 03:12:59 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG87d33d9e09c6: [yaml2obj] - Change how p_offset is calculated when creating segments. NFCI. (authored by grimar).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78363

Files:
  llvm/lib/ObjectYAML/ELFEmitter.cpp


Index: llvm/lib/ObjectYAML/ELFEmitter.cpp
===================================================================
--- llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -759,18 +759,12 @@
       reportError("sections in the program header with index " +
                   Twine(PhdrIdx) + " are not sorted by their file offset");
 
-    if (YamlPhdr.Offset) {
+    if (YamlPhdr.Offset)
       PHeader.p_offset = *YamlPhdr.Offset;
-    } else {
-      if (YamlPhdr.Sections.size())
-        PHeader.p_offset = UINT32_MAX;
-      else
-        PHeader.p_offset = 0;
-
-      // Find the minimum offset for the program header.
-      for (const Fragment &F : Fragments)
-        PHeader.p_offset = std::min((uint64_t)PHeader.p_offset, F.Offset);
-    }
+    else if (!Fragments.empty())
+      PHeader.p_offset = Fragments.front().Offset;
+    else
+      PHeader.p_offset = 0;
 
     // Find the maximum offset of the end of a section in order to set p_filesz
     // and p_memsz. When setting p_filesz, trailing SHT_NOBITS sections are not


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78363.259220.patch
Type: text/x-patch
Size: 1062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200422/f6d8ee0a/attachment.bin>


More information about the llvm-commits mailing list