diff options
-rw-r--r-- | lld/wasm/Driver.cpp | 7 | ||||
-rw-r--r-- | lld/wasm/InputChunks.cpp | 7 | ||||
-rw-r--r-- | lld/wasm/InputFiles.cpp | 30 | ||||
-rw-r--r-- | lld/wasm/OutputSections.h | 2 | ||||
-rw-r--r-- | lld/wasm/Writer.cpp | 6 |
5 files changed, 27 insertions, 25 deletions
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index cf6184036ec..f477ba3b235 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -186,8 +186,7 @@ static void readImportFile(StringRef Filename) { // Returns slices of MB by parsing MB as an archive file. // Each slice consists of a member file in the archive. -std::vector<MemoryBufferRef> static getArchiveMembers( - MemoryBufferRef MB) { +std::vector<MemoryBufferRef> static getArchiveMembers(MemoryBufferRef MB) { std::unique_ptr<Archive> File = CHECK(Archive::create(MB), MB.getBufferIdentifier() + ": failed to parse archive"); @@ -205,8 +204,8 @@ std::vector<MemoryBufferRef> static getArchiveMembers( V.push_back(MBRef); } if (Err) - fatal(MB.getBufferIdentifier() + ": Archive::children failed: " + - toString(std::move(Err))); + fatal(MB.getBufferIdentifier() + + ": Archive::children failed: " + toString(std::move(Err))); // Take ownership of memory buffers created for members of thin archives. for (std::unique_ptr<MemoryBuffer> &MB : File->takeThinBuffers()) diff --git a/lld/wasm/InputChunks.cpp b/lld/wasm/InputChunks.cpp index 1dc7a6f16c6..ed658366b5d 100644 --- a/lld/wasm/InputChunks.cpp +++ b/lld/wasm/InputChunks.cpp @@ -25,7 +25,9 @@ using namespace lld::wasm; static StringRef ReloctTypeToString(uint8_t RelocType) { switch (RelocType) { -#define WASM_RELOC(NAME, REL) case REL: return #NAME; +#define WASM_RELOC(NAME, REL) \ + case REL: \ + return #NAME; #include "llvm/BinaryFormat/WasmRelocs.def" #undef WASM_RELOC } @@ -257,7 +259,8 @@ void InputFunction::writeTo(uint8_t *Buf) const { return InputChunk::writeTo(Buf); Buf += OutputOffset; - uint8_t *Orig = Buf; (void)Orig; + uint8_t *Orig = Buf; + (void)Orig; const uint8_t *SecStart = File->CodeSection->Content.data(); const uint8_t *FuncStart = SecStart + getInputSectionOffset(); diff --git a/lld/wasm/InputFiles.cpp b/lld/wasm/InputFiles.cpp index 2a693b80234..7ecbafd732c 100644 --- a/lld/wasm/InputFiles.cpp +++ b/lld/wasm/InputFiles.cpp @@ -94,16 +94,17 @@ uint32_t ObjFile::calcExpectedValue(const WasmRelocation &Reloc) const { switch (Reloc.Type) { case R_WEBASSEMBLY_TABLE_INDEX_I32: case R_WEBASSEMBLY_TABLE_INDEX_SLEB: { - const WasmSymbol& Sym = WasmObj->syms()[Reloc.Index]; + const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index]; return TableEntries[Sym.Info.ElementIndex]; } case R_WEBASSEMBLY_MEMORY_ADDR_SLEB: case R_WEBASSEMBLY_MEMORY_ADDR_I32: case R_WEBASSEMBLY_MEMORY_ADDR_LEB: { - const WasmSymbol& Sym = WasmObj->syms()[Reloc.Index]; + const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index]; if (Sym.isUndefined()) return 0; - const WasmSegment& Segment = WasmObj->dataSegments()[Sym.Info.DataRef.Segment]; + const WasmSegment &Segment = + WasmObj->dataSegments()[Sym.Info.DataRef.Segment]; return Segment.Data.Offset.Value.Int32 + Sym.Info.DataRef.Offset + Reloc.Addend; } @@ -119,7 +120,7 @@ uint32_t ObjFile::calcExpectedValue(const WasmRelocation &Reloc) const { return Reloc.Index; case R_WEBASSEMBLY_FUNCTION_INDEX_LEB: case R_WEBASSEMBLY_GLOBAL_INDEX_LEB: { - const WasmSymbol& Sym = WasmObj->syms()[Reloc.Index]; + const WasmSymbol &Sym = WasmObj->syms()[Reloc.Index]; return Sym.Info.ElementIndex; } default: @@ -166,14 +167,12 @@ static void setRelocs(const std::vector<T *> &Chunks, return; ArrayRef<WasmRelocation> Relocs = Section->Relocations; + assert(std::is_sorted(Relocs.begin(), Relocs.end(), + [](const WasmRelocation &R1, const WasmRelocation &R2) { + return R1.Offset < R2.Offset; + })); assert(std::is_sorted( - Relocs.begin(), Relocs.end(), - [](const WasmRelocation &R1, const WasmRelocation &R2) { - return R1.Offset < R2.Offset; - })); - assert(std::is_sorted( - Chunks.begin(), Chunks.end(), - [](InputChunk *C1, InputChunk *C2) { + Chunks.begin(), Chunks.end(), [](InputChunk *C1, InputChunk *C2) { return C1->getInputSectionOffset() < C2->getInputSectionOffset(); })); @@ -185,9 +184,9 @@ static void setRelocs(const std::vector<T *> &Chunks, for (InputChunk *C : Chunks) { auto RelocsStart = std::lower_bound(RelocsNext, RelocsEnd, C->getInputSectionOffset(), RelocLess); - RelocsNext = std::lower_bound(RelocsStart, RelocsEnd, - C->getInputSectionOffset() + C->getInputSize(), - RelocLess); + RelocsNext = std::lower_bound( + RelocsStart, RelocsEnd, C->getInputSectionOffset() + C->getInputSize(), + RelocLess); C->setRelocations(ArrayRef<WasmRelocation>(RelocsStart, RelocsNext)); } } @@ -259,7 +258,8 @@ void ObjFile::parse() { Functions.reserve(Funcs.size()); for (size_t I = 0, E = Funcs.size(); I != E; ++I) - Functions.emplace_back(make<InputFunction>(Types[FuncTypes[I]], &Funcs[I], this)); + Functions.emplace_back( + make<InputFunction>(Types[FuncTypes[I]], &Funcs[I], this)); setRelocs(Functions, CodeSection); // Populate `Globals`. diff --git a/lld/wasm/OutputSections.h b/lld/wasm/OutputSections.h index 189d6507c4b..46916f334c1 100644 --- a/lld/wasm/OutputSections.h +++ b/lld/wasm/OutputSections.h @@ -113,7 +113,7 @@ protected: size_t BodySize = 0; }; -// Represents a custom section in the output file. Wasm custom sections are +// Represents a custom section in the output file. Wasm custom sections are // used for storing user-defined metadata. Unlike the core sections types // they are identified by their string name. // The linker combines custom sections that have the same name by simply diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp index 23a7b5da7ef..64affd8c0d7 100644 --- a/lld/wasm/Writer.cpp +++ b/lld/wasm/Writer.cpp @@ -586,9 +586,9 @@ void Writer::writeSections() { // - heap start / unallocated // // The --stack-first option means that stack is placed before any static data. -// This can be useful since it means that stack overflow traps immediately rather -// than overwriting global data, but also increases code size since all static -// data loads and stores requires larger offsets. +// This can be useful since it means that stack overflow traps immediately +// rather than overwriting global data, but also increases code size since all +// static data loads and stores requires larger offsets. void Writer::layoutMemory() { createOutputSegments(); |