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

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 27 12:44:57 PST 2018

sbc100 added a comment.

In https://reviews.llvm.org/D42176#1021076, @ruiu wrote:

> This may be a silly question, but what is the distinction of Chunk and Section? Chunk seems like a section in a section, so I wonder why wasm object files is designed that way. In ELF and COFF, everything is a section, and section is a atomic unit of linking.

In a wasm binary all code is in a single section (`WASM_SEC_CODE`) and all data is defined in single section (`WASM_SEC_DATA`).   Within the code section there are N functions and within the data section there are N data *segments*.  Things are not as homogeneous as in ELF were everything is just bytes and virtual addresses.    We use the term "chunk" there as an abstraction that linker can use to handle both functions bodies and data segements, even though in the file format these are no really the same thing.

We could have gone a different route for the intermediate object and allowed multiple code sections, but then none of the existing wasm tools would load the file (i.e. they would no longer we valid wasm files) and I'm not sure this would have made the linker any simpler, since we would still not be able to match ELF in its ability to blindly concatenate everything.

  rLLD LLVM Linker


More information about the llvm-commits mailing list