[llvm] 87d33d9 - [yaml2obj] - Change how p_offset is calculated when creating segments. NFCI.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 22 02:43:55 PDT 2020
Author: Georgii Rymar
Date: 2020-04-22T12:37:44+03:00
New Revision: 87d33d9e09c6b727e108c6cd86b36743740e08cc
URL: https://github.com/llvm/llvm-project/commit/87d33d9e09c6b727e108c6cd86b36743740e08cc
DIFF: https://github.com/llvm/llvm-project/commit/87d33d9e09c6b727e108c6cd86b36743740e08cc.diff
LOG: [yaml2obj] - Change how p_offset is calculated when creating segments. NFCI.
This depends on D78361 and simplifies the computation of the `p_offset`.
Differential revision: https://reviews.llvm.org/D78363
Added:
Modified:
llvm/lib/ObjectYAML/ELFEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/ObjectYAML/ELFEmitter.cpp b/llvm/lib/ObjectYAML/ELFEmitter.cpp
index 3a673cf67e87..450856daa874 100644
--- a/llvm/lib/ObjectYAML/ELFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/ELFEmitter.cpp
@@ -759,18 +759,12 @@ void ELFState<ELFT>::setProgramHeaderLayout(std::vector<Elf_Phdr> &PHeaders,
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
More information about the llvm-commits
mailing list