diff options
author | Derek Schuff <dschuff@chromium.org> | 2016-05-05 08:01:57 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2016-05-05 08:01:57 -0700 |
commit | 2811727a118e92e6b7ef293458f9bab1cf5dacdc (patch) | |
tree | ad18967b67f3596b28f3013ad6f05cc269d126c6 /src/s2wasm.h | |
parent | 1397997bc91663f19c387c69c7e47930efe57539 (diff) | |
download | binaryen-2811727a118e92e6b7ef293458f9bab1cf5dacdc.tar.gz binaryen-2811727a118e92e6b7ef293458f9bab1cf5dacdc.tar.bz2 binaryen-2811727a118e92e6b7ef293458f9bab1cf5dacdc.zip |
[Linker] Handle archive files
Add a class to parse archive files.
Support linking archive files, with archive semantics (i.e. an archive
member is linked in if it satisfies an undefined reference).
Archive files must be gnu-format archives containing .s files.
Add tests for linking semantics.
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r-- | src/s2wasm.h | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h index 941779ae5..9c0ac81e2 100644 --- a/src/s2wasm.h +++ b/src/s2wasm.h @@ -43,6 +43,7 @@ class S2WasmBuilder { Module* wasm; MixedArena* allocator; LinkerObject* linkerObj; + std::unique_ptr<LinkerObject::SymbolInfo> symbolInfo; public: S2WasmBuilder(const char* input, bool debug) @@ -54,9 +55,10 @@ class S2WasmBuilder { linkerObj(nullptr) {} - void build(LinkerObject *obj, LinkerObject::SymbolInfo* info) { - if (!obj->isEmpty()) Fatal() << "Cannot construct an S2WasmBuilder in an non-empty LinkerObject"; - if (!info) info = getSymbolInfo(); + void build(LinkerObject *obj) { + // If getSymbolInfo has not already been called, populate the symbol + // info now. + if (!symbolInfo) symbolInfo.reset(getSymbolInfo()); linkerObj = obj; wasm = &obj->wasm; allocator = &wasm->allocator; @@ -65,10 +67,14 @@ class S2WasmBuilder { process(); } + // getSymbolInfo scans the .s file to determine what symbols it defines + // and references. LinkerObject::SymbolInfo* getSymbolInfo() { - auto* info = new LinkerObject::SymbolInfo(); - scan(info); - return info; + if (!symbolInfo) { + symbolInfo = make_unique<LinkerObject::SymbolInfo>(); + scan(symbolInfo.get()); + } + return symbolInfo.get(); } private: |