[PATCH] D19190: [ELF] - Implemented PROVIDE linker script command.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Thu May 5 07:57:17 PDT 2016


grimar added a comment.

In http://reviews.llvm.org/D19190#408584, @ruiu wrote:

> I spent half a day on poking around LinkerScript and Writer to figure out how to implement SECTIONS sub-commands nicely, and my conclusion is that the current code needs redesigning.
>
> The current design is structurally hard to handle SECTIONS command because both Writer and LinkerScript have partial view of the sections being constructed. Writer creates output sections in Writer::createSections, and LinkerScript is barely involved with that process. However, if linker scripts are in use, then the constructed output sections are passed to LinkerScript to create symbols, layout sections while evaulating linker script expressions. It is hard to do it right because some information are lost between Writer and LinkerScript. It's not just hard to understand, but it also sets a limitation on what we can do with SECTIONS subcommands. For example, this patch can't handle expressions that appear in middle of an output section description. Adding a support for that would be at least tricky.
>
> The right way I think is to make LinkerScript create output sections, instead of using Writer's createSections, if there is a SECTIONS command, so that LinkerScript controls everything about layout. In the new function, we should order sections *and* assign addresses at the same time. As long as sections sizes are fixed by then (this needs some refactoring as well), it should be doable. It is probably the cleanest and simplest way to handle SECTIONS command, as it is going to be a single pass and won't require any intermediate representation as we interpret SECTIONS sub-commands directly.
>
> I'm going to explore this more.


My vision is here: http://reviews.llvm.org/D19976


http://reviews.llvm.org/D19190





More information about the llvm-commits mailing list