summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-07-12 00:24:54 +0000
committerSam Clegg <sbc@chromium.org>2017-07-12 00:24:54 +0000
commit9c07f94a1f6d33a05f208b713c717cf9a221cb00 (patch)
tree40481a6b372e9b00b47659633ca123796235bb75 /llvm/lib/Object
parent878fdee0cf4e0357773b5198f6de1b48996dd090 (diff)
downloadbcm5719-llvm-9c07f94a1f6d33a05f208b713c717cf9a221cb00.tar.gz
bcm5719-llvm-9c07f94a1f6d33a05f208b713c717cf9a221cb00.zip
[WebAssembly] Expose the offset of each data segment
Summary: This allows tools like lld that process relocations to apply data relocation correctly. This information is required because relocation are stored as section offset. Subscribers: jfb, dschuff, jgravelle-google, aheejin Differential Revision: https://reviews.llvm.org/D35234 llvm-svn: 307741
Diffstat (limited to 'llvm/lib/Object')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 3c675aa71b9..7f80bf0b83a 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -675,15 +675,17 @@ Error WasmObjectFile::parseElemSection(const uint8_t *Ptr, const uint8_t *End) {
}
Error WasmObjectFile::parseDataSection(const uint8_t *Ptr, const uint8_t *End) {
+ const uint8_t *Start = Ptr;
uint32_t Count = readVaruint32(Ptr);
DataSegments.reserve(Count);
while (Count--) {
- wasm::WasmDataSegment Segment;
- Segment.Index = readVaruint32(Ptr);
- if (Error Err = readInitExpr(Segment.Offset, Ptr))
+ WasmSegment Segment;
+ Segment.Data.MemoryIndex = readVaruint32(Ptr);
+ if (Error Err = readInitExpr(Segment.Data.Offset, Ptr))
return Err;
uint32_t Size = readVaruint32(Ptr);
- Segment.Content = ArrayRef<uint8_t>(Ptr, Size);
+ Segment.Data.Content = ArrayRef<uint8_t>(Ptr, Size);
+ Segment.SectionOffset = Ptr - Start;
Ptr += Size;
DataSegments.push_back(Segment);
}
OpenPOWER on IntegriCloud