[PATCH] D41313: [WebAssembly] Move code for copying of data segment relocation. NFC.
Sam Clegg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 16 11:51:11 PST 2017
sbc100 updated this revision to Diff 127253.
sbc100 added a comment.
- fix function name
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D41313
Files:
wasm/InputFiles.cpp
wasm/Writer.cpp
Index: wasm/Writer.cpp
===================================================================
--- wasm/Writer.cpp
+++ wasm/Writer.cpp
@@ -646,12 +646,6 @@
}
S->addInputSegment(Segment);
DEBUG(dbgs() << "added data: " << Name << ": " << S->Size << "\n");
- for (const WasmRelocation &R : File->DataSection->Relocations) {
- if (R.Offset >= Segment->getInputSectionOffset() &&
- R.Offset < Segment->getInputSectionOffset() + Segment->getSize()) {
- Segment->Relocations.push_back(R);
- }
- }
}
}
}
Index: wasm/InputFiles.cpp
===================================================================
--- wasm/InputFiles.cpp
+++ wasm/InputFiles.cpp
@@ -139,6 +139,14 @@
return nullptr;
}
+static void copyRelocationsRange(std::vector<WasmRelocation> &To,
+ ArrayRef<WasmRelocation> From, size_t Start,
+ size_t End) {
+ for (const WasmRelocation &R : From)
+ if (R.Offset >= Start && R.Offset < End)
+ To.push_back(R);
+}
+
void ObjFile::initializeSymbols() {
Symbols.reserve(WasmObj->getNumberOfSymbols());
@@ -156,8 +164,13 @@
FunctionSymbols.resize(FunctionImports + WasmObj->functions().size());
GlobalSymbols.resize(GlobalImports + WasmObj->globals().size());
- for (const WasmSegment &Seg : WasmObj->dataSegments())
- Segments.emplace_back(make<InputSegment>(&Seg, this));
+ for (const WasmSegment &S : WasmObj->dataSegments()) {
+ InputSegment *Seg = make<InputSegment>(&S, this);
+ copyRelocationsRange(Seg->Relocations, DataSection->Relocations,
+ Seg->getInputSectionOffset(),
+ Seg->getInputSectionOffset() + Seg->getSize());
+ Segments.emplace_back(Seg);
+ }
// Populate `FunctionSymbols` and `GlobalSymbols` based on the WasmSymbols
// in the object
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41313.127253.patch
Type: text/x-patch
Size: 1888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171216/84e06d8c/attachment.bin>
More information about the llvm-commits
mailing list