[lld] 3493f1a - [lld-macho] Simplify base address calculation for init offsets (NFC)
Daniel Bertalan via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 17 01:24:07 PDT 2022
Author: Daniel Bertalan
Date: 2022-09-17T10:23:05+02:00
New Revision: 3493f1a1079127c54f3d1715306af7a8ee018e94
URL: https://github.com/llvm/llvm-project/commit/3493f1a1079127c54f3d1715306af7a8ee018e94
DIFF: https://github.com/llvm/llvm-project/commit/3493f1a1079127c54f3d1715306af7a8ee018e94.diff
LOG: [lld-macho] Simplify base address calculation for init offsets (NFC)
Added:
Modified:
lld/MachO/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 78f379ea8625f..a9900b016621d 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -1832,19 +1832,12 @@ uint64_t InitOffsetsSection::getSize() const {
}
void InitOffsetsSection::writeTo(uint8_t *buf) const {
- uint64_t textVA = 0;
- for (const OutputSegment *oseg : outputSegments)
- if (oseg->name == segment_names::text) {
- textVA = oseg->addr;
- break;
- }
-
// FIXME: Add function specified by -init when that argument is implemented.
for (ConcatInputSection *isec : sections) {
for (const Reloc &rel : isec->relocs) {
const Symbol *referent = rel.referent.dyn_cast<Symbol *>();
assert(referent && "section relocation should have been rejected");
- uint64_t offset = referent->getVA() - textVA;
+ uint64_t offset = referent->getVA() - in.header->addr;
// FIXME: Can we handle this gracefully?
if (offset > UINT32_MAX)
fatal(isec->getLocation(rel.offset) + ": offset to initializer " +
More information about the llvm-commits
mailing list