aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2023-09-11 18:37:24 +0000
committerDimitry Andric <dim@FreeBSD.org>2023-12-08 17:35:11 +0000
commit8a4dda33d67586ca2624f2a38417baa03a533a7f (patch)
treeea87f69d4341b5a653c3747ebbdbedd7b41da233 /contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp
parent06c3fb2749bda94cb5201f81ffdb8fa6c3161b2e (diff)
parent8092e001bcd76c0b9fec2311f3a515aa60d2ed07 (diff)
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp b/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp
index a72242bc4ac2..11b9b579a8d7 100644
--- a/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp
+++ b/contrib/llvm-project/llvm/lib/Object/WasmObjectFile.cpp
@@ -268,7 +268,11 @@ static Error readSection(WasmSection &Section, WasmObjectFile::ReadContext &Ctx,
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
+ // it. This allows objcopy/strip to reproduce the binary identically.
+ const uint8_t *PreSizePtr = Ctx.Ptr;
uint32_t Size = readVaruint32(Ctx);
+ Section.HeaderSecSizeEncodingLen = Ctx.Ptr - PreSizePtr;
if (Size == 0)
return make_error<StringError>("zero length section",
object_error::parse_failed);