This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Support COPY, INFO, OVERLAY output sections attributes.
ClosedPublic

Authored by grimar on Feb 8 2018, 7:04 AM.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

grimar created this revision.Feb 8 2018, 7:04 AM

For what it is worth COPY and OVERLAY are used quite a bit in embedded systems. The Arm GCC Embedded toolchain linker scripts in the sample directory use COPY to reserve an area for the heap and stack https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads

.heap (COPY):
	{
		__end__ = .;
		PROVIDE(end = .);
		*(.heap*)
		__HeapLimit = .;
	} > RAM

	/* .stack_dummy section doesn't contains any symbols. It is only
	 * used for linker to calculate size of stack sections, and assign
	 * values to stack symbols later */
	.stack_dummy (COPY):
	{
		*(.stack*)
	} > RAM

I'd be very happy to see COPY implemented.

ruiu added a comment.Feb 8 2018, 4:25 PM

Why do you want them? Do you actually want to build "TianoCore UEFI" firmware with lld?

ELF/ScriptParser.cpp
621

can be -> is

622

or "(OVERLAY)"

("A, B, C" isn't grammatically correct.)

ruiu added a comment.Feb 8 2018, 4:30 PM

I mean, for any language, if you google for some extremely minor feature of that language, I'm pretty sure that you can always find one. So the fact that you can find a use case on the internet isn't very convincing that we should support it.

I mean, for any language, if you google for some extremely minor feature of that language, I'm pretty sure that you can always find one. So the fact that you can find a use case on the internet isn't very convincing that we should support it.

While these minor features are not used at all in a system sophisticated enough to run ELF files directly, I'd argue that at least COPY will be used heavily in embedded systems as placement of the heap and stack via symbols derived from linker script sections is a common idiom. Overlays are not so common these days but they still exist. It is true that we haven't got a large contingent of embedded developers using the Arm port, there are a few, but I'm hoping we don't scare them away.

grimar added a comment.Feb 9 2018, 6:59 AM

I mean, for any language, if you google for some extremely minor feature of that language, I'm pretty sure that you can always find one. So the fact that you can find a use case on the internet isn't very convincing that we should support it.

I inspected binutils bugtracker and found following issue:
https://sourceware.org/bugzilla/show_bug.cgi?id=20062

In short it was about that person was unable to use gold as a drop in replacement for bfd to link
UEFI. I was interested if LLD can do this. Previous experience showed that linking specific things,
like kernels can reveal unobvious issues. And I expect LLD should be able to link UEFI or other programs
or at least would be nice to know why not and document it in bugtracker.

We were thinking about implementing features like "INSERT AFTER/INSERT BEFORE" which are probably even
more specific, and "INFO" is too simple for implementation to ignore it when alternative is to report
"undefined symbol INFO" error what we do now which is just bogus and not user friendly.
(and somebeody can try to define INFO symbol it will be treated as address expression and we will link
it without errors.)

grimar planned changes to this revision.Feb 9 2018, 7:09 AM
grimar updated this revision to Diff 133628.Feb 9 2018, 8:56 AM
grimar marked 2 inline comments as done.
grimar retitled this revision from [ELF] - Support DSECT, COPY, INFO, OVERLAY output sections attributes. to [ELF] - Support COPY, INFO, OVERLAY output sections attributes..
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
ruiu accepted this revision.Feb 15 2018, 9:11 PM

LGTM

ELF/ScriptParser.cpp
626

beginning

This revision is now accepted and ready to land.Feb 15 2018, 9:11 PM
This revision was automatically updated to reflect the committed changes.