summaryrefslogtreecommitdiffstats
path: root/lib/Object
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-06-27 20:27:59 +0000
committerSam Clegg <sbc@chromium.org>2017-06-27 20:27:59 +0000
commit49ab5d599222f7dd82c73e09d5a420c7c640ac59 (patch)
tree8270e094f214eaa7fb722e8dd61a85b1b6bba433 /lib/Object
parentf4a2d1d749c9a9cc2c358028ae3aefe6f338339c (diff)
[WebAssembly] Add data size and alignement to linking section
The overal size of the data section (including BSS) is otherwise not included in the wasm binary. Differential Revision: https://reviews.llvm.org/D34657 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Object')
-rw-r--r--lib/Object/WasmObjectFile.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Object/WasmObjectFile.cpp b/lib/Object/WasmObjectFile.cpp
index d15860674aeb..e87dd48cb01f 100644
--- a/lib/Object/WasmObjectFile.cpp
+++ b/lib/Object/WasmObjectFile.cpp
@@ -193,6 +193,9 @@ static Error readSection(WasmSection &Section, const uint8_t *&Ptr,
WasmObjectFile::WasmObjectFile(MemoryBufferRef Buffer, Error &Err)
: ObjectFile(Binary::ID_Wasm, Buffer) {
+ LinkingData.DataAlignment = 0;
+ LinkingData.DataSize = 0;
+
ErrorAsOutParameter ErrAsOutParam(&Err);
Header.Magic = getData().substr(0, 4);
if (Header.Magic != StringRef("\0asm", 4)) {
@@ -305,7 +308,7 @@ Error WasmObjectFile::parseLinkingSection(const uint8_t *Ptr,
auto iter = SymbolMap.find(Symbol);
if (iter == SymbolMap.end()) {
return make_error<GenericBinaryError>(
- "Invalid symbol name in linking section",
+ "Invalid symbol name in linking section: " + Symbol,
object_error::parse_failed);
}
uint32_t SymIndex = iter->second;
@@ -318,6 +321,12 @@ Error WasmObjectFile::parseLinkingSection(const uint8_t *Ptr,
}
break;
}
+ case wasm::WASM_DATA_SIZE:
+ LinkingData.DataSize = readVaruint32(Ptr);
+ break;
+ case wasm::WASM_DATA_ALIGNMENT:
+ LinkingData.DataAlignment = readVaruint32(Ptr);
+ break;
case wasm::WASM_STACK_POINTER:
default:
Ptr += Size;