[PATCH] D57632: [WebAssembly] Fix imported function symbol names that differ from their import names in the .o format
Dan Gohman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 1 17:12:33 PST 2019
sunfish created this revision.
sunfish added a reviewer: sbc100.
Herald added subscribers: rupprecht, dexonsmith, steven_wu, jgravelle-google, mehdi_amini.
Herald added a project: LLVM.
It appears that in the current .o file format, symbol names for undefined function symbols are not included, which means that we can't have symbols where the symbol name differs from the import name.
The following patch fixes it. (It includes both llvm and lld changes, as they're closely related, but I'll split them when committing.) With this patch, the following testcase:
__attribute__((import_module("bar"), import_name("qux"))) void foo(void);
void _start(void) {
foo();
}
compiles with `clang -nostdlib test.c --target=wasm32-unknown-unknown -Wl,--allow-undefined-file=undefined.txt
where undefined.txt contains:
foo
into a wasm that contains this import:
(import "bar" "qux" (func $foo (type 0)))
Since this requires a change to the binary form, this patch also bumps the metadata version number.
Repository:
rL LLVM
https://reviews.llvm.org/D57632
Files:
include/llvm/BinaryFormat/Wasm.h
lib/MC/WasmObjectWriter.cpp
lib/Object/WasmObjectFile.cpp
test/MC/WebAssembly/assembler-binary.ll
test/MC/WebAssembly/comdat.ll
test/MC/WebAssembly/event-section.ll
test/MC/WebAssembly/function-sections.ll
test/MC/WebAssembly/global-ctor-dtor.ll
test/MC/WebAssembly/unnamed-data.ll
test/MC/WebAssembly/weak-alias.ll
test/Object/Inputs/trivial-object-test.wasm
test/Object/wasm-bad-metadata-version.yaml
test/ObjectYAML/wasm/code_section.yaml
test/ObjectYAML/wasm/data_section.yaml
test/ObjectYAML/wasm/event_section.yaml
test/ObjectYAML/wasm/invalid_global_weak.yaml
test/ObjectYAML/wasm/linking_section.yaml
test/ObjectYAML/wasm/weak_symbols.yaml
test/tools/llvm-nm/wasm/exports.yaml
test/tools/llvm-nm/wasm/imports.yaml
test/tools/llvm-nm/wasm/weak-symbols.yaml
test/tools/llvm-objdump/Inputs/trivial.obj.wasm
test/tools/llvm-readobj/Inputs/trivial.obj.wasm
tools/lld/wasm/InputFiles.cpp
tools/lld/wasm/LTO.cpp
tools/lld/wasm/SymbolTable.cpp
tools/lld/wasm/SymbolTable.h
tools/lld/wasm/Symbols.h
tools/lld/wasm/Writer.cpp
tools/yaml2obj/yaml2wasm.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57632.184873.patch
Type: text/x-patch
Size: 17096 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190202/f260dc71/attachment.bin>
More information about the llvm-commits
mailing list