aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2023-12-21 14:16:37 -0800
committerGitHub <noreply@github.com>2023-12-21 14:16:37 -0800
commit35a5df2de6bd56c95edcd10d6acab040b251238e (patch)
tree4629488e03d9420f7a407fced81afff2ce8c7c75 /llvm/lib/Object
parent011024536963c7822c81f33434969e8eff08e180 (diff)
downloadllvm-35a5df2de6bd56c95edcd10d6acab040b251238e.zip
llvm-35a5df2de6bd56c95edcd10d6acab040b251238e.tar.gz
llvm-35a5df2de6bd56c95edcd10d6acab040b251238e.tar.bz2
[WebAssembly][Object] Record section start offsets at start of payload (#76188)
LLVM ObjectFile currently records the start offsets of sections as the start of the section header, whereas most other tools (WABT, emscripten, wasm-tools) record it as the start of the section content, after the header. This affects binutils tools such as objdump and nm, but not compilation/assembly (since that is driven by symbols and assembler labels which already have their values inside the section payload rather in the header. This patch updates LLVM to match the other tools.
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 05bd730..dfe86a4 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -265,7 +265,6 @@ static wasm::WasmTableType readTableType(WasmObjectFile::ReadContext &Ctx) {
static Error readSection(WasmSection &Section, WasmObjectFile::ReadContext &Ctx,
WasmSectionOrderChecker &Checker) {
- Section.Offset = Ctx.Ptr - Ctx.Start;
Section.Type = readUint8(Ctx);
LLVM_DEBUG(dbgs() << "readSection type=" << Section.Type << "\n");
// When reading the section's size, store the size of the LEB used to encode
@@ -273,6 +272,7 @@ static Error readSection(WasmSection &Section, WasmObjectFile::ReadContext &Ctx,
const uint8_t *PreSizePtr = Ctx.Ptr;
uint32_t Size = readVaruint32(Ctx);
Section.HeaderSecSizeEncodingLen = Ctx.Ptr - PreSizePtr;
+ Section.Offset = Ctx.Ptr - Ctx.Start;
if (Size == 0)
return make_error<StringError>("zero length section",
object_error::parse_failed);