[PATCH] D42176: [WebAssembly] Optimise relocation iteration to remove n^2 loop. NFC.

Nicholas Wilson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 08:01:59 PST 2018

ncw added a comment.

We can't change WebAssembly - it's too late for that. What seems to be the disagreement here is that the Wasm spec has chosen the word "section" to describe a different concept to what "section" means in ELF. We're stuck with that!

Rui's suggesting changing the Wasm object format, so that each function gets its own Wasm "section". But that's not going to make the format any better, the thing that's called a "section" in Wasm isn't designed for holding individual functions. Just because it's called a "section" in the Wasm spec, has got nothing to do with whether it means the same thing to the linker that an ELF "section" does.

I think we just have to accept that the ELF and Wasm specs have chosen to use terminology differently. That's not even a defect in those specs, the Wasm meaning of "section" is perfectly in line with how it's used in other file formats to represent a portion of the data in the file.

To resolve this, I think it's just a question of how terminology and naming should be used in LLD. We have total freedom to change the LLD class names, so if Rui really wants LLD to operate on "sections" then it can, just with some renaming! But, we can't change the Wasm format itself without a good reason, since there are downstream projects already using these files.

Non-exhaustive options:

1. Status quo. Accept the difference, and use "chunk" where the ELF linker uses "section", and use "section" in the Wasm code with the same meaning it has in the Wasm spec.
2. Rename the Wasm code to avoid the contentious "section" terminology entirely. Come up with a different name for Wasm "sections" so no-one is tempted into thinking it's supposed to be the unit of linking like it is in ELF.
3. Rename the Wasm code to use the terminology "section" to match the ELF linker (ie rename InputChunk -> InputSection), with a comment explaining that InputSection doesn't represent the thing that's called a "section" in the Wasm spec.



I agree that everything in the linker should be "sections" - and that's already how it works, it's just that that abstraction is called a "chunk" currently in the Wasm code, because "section" is taken to mean something else in Wasm. Surely it already //is// what you want it to be, apart from the fact it's called "chunk". The fact that Wasm has something called a "section" doesn't mean that's what Wasm object files should be using for storing each function. We can do whatever we want with the terminology in the code to fix the situation, but the file format itself isn't the problem.

  rLLD LLVM Linker


More information about the llvm-commits mailing list