Fourth chunk split out of D41955.
There is no corresponding LLVM patch to go along with this.
Headline: Fix some bugs in the existing handling of exports when LLD generates "relocatable" output
Changes:
- LLD's relocatable output was writing out an export for all globals (including file-local syms), but not for functions. Oops. To be consistent with non-relocatable output, all symbols (file-local and public) should be exported. Any symbol targetted by further relocations needs to be exported. The lack of local function exports was just an omission, I think.
- Second bug: Local symbol names can collide, causing an illegal Wasm file to be generated! Oops again. This only previously affected producing relocatable output from two files, where each had a global with the same name. We need to "budge" the symbol names for locals that are exported on relocatable output.
- Third bug: LLD's relocatable output wasn't writing out any symbol flags! Thus the local globals weren't being marked as local, and the hidden flag was also stripped...
- Added tests to exercise colliding local names with/without relocatable flag
Are there llvm terms you can use here rather than local and public? I think llvm this internal and external linkage, right?