summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2018-03-11 01:35:02 +0000
committerSam Clegg <sbc@chromium.org>2018-03-11 01:35:02 +0000
commitc1be8230ef81c3dacaa1b0f8b4990666d63a0792 (patch)
treed71d3d83d6736cd8a312a65ff70bd6a55c17936f
parent6d18d6e4d3d7cede100774a314d07c36b02ae4a4 (diff)
downloadbcm5719-llvm-c1be8230ef81c3dacaa1b0f8b4990666d63a0792.tar.gz
bcm5719-llvm-c1be8230ef81c3dacaa1b0f8b4990666d63a0792.zip
[WebAssembly] Improve logging and comments around relocations. NFC.
Differential Revision: https://reviews.llvm.org/D44350 llvm-svn: 327232
-rw-r--r--lld/wasm/InputChunks.cpp17
-rw-r--r--lld/wasm/InputFiles.cpp7
2 files changed, 16 insertions, 8 deletions
diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp
index f5df6eb0eb1..585d1163147 100644
--- a/lld/wasm/InputChunks.cpp
+++ b/lld/wasm/InputChunks.cpp
@@ -23,6 +23,15 @@ using namespace llvm::support::endian;
using namespace lld;
using namespace lld::wasm;
+StringRef ReloctTypeToString(uint8_t RelocType) {
+ switch (RelocType) {
+#define WASM_RELOC(NAME, REL) case REL: return #NAME;
+#include "llvm/BinaryFormat/WasmRelocs.def"
+#undef WASM_RELOC
+ }
+ llvm_unreachable("unknown reloc type");
+}
+
std::string lld::toString(const InputChunk *C) {
return (toString(C->File) + ":(" + C->getName() + ")").str();
}
@@ -46,14 +55,14 @@ void InputChunk::writeTo(uint8_t *Buf) const {
if (Relocations.empty())
return;
- DEBUG(dbgs() << "applyRelocations: count=" << Relocations.size() << "\n");
+ DEBUG(dbgs() << "applying relocations: count=" << Relocations.size() << "\n");
int32_t Off = OutputOffset - getInputSectionOffset();
for (const WasmRelocation &Rel : Relocations) {
uint8_t *Loc = Buf + Rel.Offset + Off;
- uint64_t Value = File->calcNewValue(Rel);
-
- DEBUG(dbgs() << "write reloc: type=" << Rel.Type << " index=" << Rel.Index
+ uint32_t Value = File->calcNewValue(Rel);
+ DEBUG(dbgs() << "apply reloc: type=" << ReloctTypeToString(Rel.Type)
+ << " addend=" << Rel.Addend << " index=" << Rel.Index
<< " value=" << Value << " offset=" << Rel.Offset << "\n");
switch (Rel.Type) {
diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp
index 12ee9ec6f8c..5b69070b3de 100644
--- a/lld/wasm/InputFiles.cpp
+++ b/lld/wasm/InputFiles.cpp
@@ -49,10 +49,9 @@ void ObjFile::dumpInfo() const {
"\n Global Imports : " + Twine(WasmObj->getNumImportedGlobals()));
}
-// Relocations contain an index into the function, global or table index
-// space of the input file. This function takes a relocation and returns the
-// relocated index (i.e. translates from the input index space to the output
-// index space).
+// Relocations contain either symbol or type indices. This function takes a
+// relocation and returns relocated index (i.e. translates from the input
+// sybmol/type space to the output symbol/type space).
uint32_t ObjFile::calcNewIndex(const WasmRelocation &Reloc) const {
if (Reloc.Type == R_WEBASSEMBLY_TYPE_INDEX_LEB) {
assert(TypeIsUsed[Reloc.Index]);
OpenPOWER on IntegriCloud