summaryrefslogtreecommitdiffstats
path: root/lld/wasm/Writer.cpp
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2018-02-27 23:58:03 +0000
committerSam Clegg <sbc@chromium.org>2018-02-27 23:58:03 +0000
commit99eb42c0c5ebe7ffe65c1bd7efeeaf9f3edf8340 (patch)
tree5b9396988ac8867fe9716a55f05d910e26230dcb /lld/wasm/Writer.cpp
parent86b4a09a99b689f9717bd17cabd850857a53388d (diff)
downloadbcm5719-llvm-99eb42c0c5ebe7ffe65c1bd7efeeaf9f3edf8340.tar.gz
bcm5719-llvm-99eb42c0c5ebe7ffe65c1bd7efeeaf9f3edf8340.zip
[WebAssembly] Remove DataSize from linking metadata
This means we don't need to write the linking metadata section at all for executable (non-relocatable) output. Differential Revision: https://reviews.llvm.org/D42869 llvm-svn: 326268
Diffstat (limited to 'lld/wasm/Writer.cpp')
-rw-r--r--lld/wasm/Writer.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 2d9a9d95fa2..90252b71fe0 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -117,7 +117,6 @@ private:
void writeSections();
uint64_t FileSize = 0;
- uint32_t DataSize = 0;
uint32_t NumMemoryPages = 0;
std::vector<const WasmSignature *> Types;
@@ -386,11 +385,6 @@ void Writer::createLinkingSection() {
createSyntheticSection(WASM_SEC_CUSTOM, "linking");
raw_ostream &OS = Section->getStream();
- SubSection DataSizeSubSection(WASM_DATA_SIZE);
- writeUleb128(DataSizeSubSection.getStream(), DataSize, "data size");
- DataSizeSubSection.finalizeContents();
- DataSizeSubSection.writeToStream(OS);
-
if (!Config->Relocatable)
return;
@@ -550,10 +544,8 @@ void Writer::writeSections() {
// - heap start / unallocated
void Writer::layoutMemory() {
uint32_t MemoryPtr = 0;
- if (!Config->Relocatable) {
- MemoryPtr = Config->GlobalBase;
- debugPrint("mem: global base = %d\n", Config->GlobalBase);
- }
+ MemoryPtr = Config->GlobalBase;
+ debugPrint("mem: global base = %d\n", Config->GlobalBase);
createOutputSegments();
@@ -574,10 +566,7 @@ void Writer::layoutMemory() {
if (WasmSym::DataEnd)
WasmSym::DataEnd->setVirtualAddress(MemoryPtr);
- DataSize = MemoryPtr;
- if (!Config->Relocatable)
- DataSize -= Config->GlobalBase;
- debugPrint("mem: static data = %d\n", DataSize);
+ debugPrint("mem: static data = %d\n", MemoryPtr - Config->GlobalBase);
// Stack comes after static data and bss
if (!Config->Relocatable) {
@@ -624,9 +613,10 @@ void Writer::createSections() {
createDataSection();
// Custom sections
- if (Config->Relocatable)
+ if (Config->Relocatable) {
createRelocSections();
- createLinkingSection();
+ createLinkingSection();
+ }
if (!Config->StripDebug && !Config->StripAll)
createNameSection();
@@ -919,6 +909,9 @@ void Writer::calculateInitFunctions() {
}
void Writer::run() {
+ if (Config->Relocatable)
+ Config->GlobalBase = 0;
+
log("-- calculateImports");
calculateImports();
log("-- assignIndexes");
OpenPOWER on IntegriCloud