Second chunk split out of D41954.
Must be committed simultaneously with LLD change, D42081.
Changes:
- Change the binary format for table relocations. Formerly, if you wanted to reloc against function "2", you'd put "2" in the table, then put the table index in the relocation. Now, you just put "2" in the relocation. For Clang output (or relocatable LLD output) the actual table is completely ignored - the relocation specifies which function.
- Test expectations are updated accordingly. The new relocation values should match the old values from the ELEM section.
- I haven't changed anything about the ELEM section itself. It's now unused, and has the same value it always has. This can freely changed in a future commit, since it now does nothing. (The next commit will change it, so that "relocatable" and non-relocatable Wasm objects have identical ELEM section. There's no need at all for the current artificial differences, so for the dummy values the Clang outputs there, we may as well write out the same values that LLD would.)
Reason for change
- Due to pesky aliases, there can be more Symbols in a wasm file than Functions. I want in a future revision to get rid of the duplicate imports used to work around this problem.
- But if the imports are removed, then it will no longer be legal to put the symbol index in the ELEM table! This is because Wasm ELEM sections contain a vector of funcid, ie the indexes in the ELEM section have to be valid Wasm functions. So we won't be able to put the generalised symbol indexes in there.
- Hence, this change puts the symbol index directly in the relocation itself. This is a necessary change for getting rid of the duplicate imports in the Wasm object files.