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.
I'd be tempted to only include IMPORT and CUSTOM sections, and to use CHECK-NEXT.
We only care about the name of function 0 too.
e.g.
Same for the MC test