[PATCH] D40614: Add .init_array support to Wasm LLD

Dan Gohman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 29 13:16:37 PST 2017


sunfish added a comment.

I'm not too bothered by the special-casing here.

That said, I have an idea for a different approach and I'm curious what you and others think. Instead of traditional .init_array sections, what if we taught the linker to link multiple start sections, by synthesizing a new start function that calls all the start functions from the input? So if you link a.o and b.o, and each have a start function, the output would contain a start function containing two calls, one to a.o's start function and one to b.o's. Start functions never have arguments or return values, so the synthesized start function would just look like "0x10 <first callee> 0x10 <second callee> ..." (0x10 is the call opcode).

This would require changes to how eg. musl and other things work. However, it would fit well within the spirit of using the wasm format for .o files in a natural way.

(There's also .fini_array, but we can talk about that if the overall idea is worth pursuing.)


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D40614





More information about the llvm-commits mailing list