This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Linkerscript: report orphans if --verbose used.
AbandonedPublic

Authored by grimar on Sep 19 2016, 6:02 AM.

Details

Reviewers
ruiu
rafael
Summary

Reviewing ld command line I found interesting option that seems to be usefull to have:
(https://sourceware.org/binutils/docs/ld/Options.html#Options)
--orphan-handling

But we decided not to support it for now,
therefore latest diff just reports orphans if --verbose used.

Diff Detail

Event Timeline

grimar updated this revision to Diff 71818.Sep 19 2016, 6:02 AM
grimar retitled this revision from to [ELF] - Linkerscript: implemented --orphan-handling command line option..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777, emaste.

Nice, thanks for this discovery! I hadn't seen it before because FreeBSD's base system ld is too old and doesn't have the option :(

ELF/Options.td
142–144

Should also support --orphan-handling MODE I believe.

Nice, thanks for this discovery! I hadn't seen it before because FreeBSD's base system ld is too old and doesn't have the option :(

btw gold does not support it, at least one that I have.

davide added a subscriber: davide.Sep 19 2016, 7:37 AM

I think "error" is good and definitely would've helped catching bugs while we were bringing the FreeBSD kernel up&running with lld.
"discard" seems like a dangerous semantic, at least to me, so I'd like to not implement it, at least for now. Do you have a real use case when it's ok to drop input sections if there's no room to place them in the output?

I think "error" is good and definitely would've helped catching bugs while we were bringing the FreeBSD kernel up&running with lld.
"discard" seems like a dangerous semantic, at least to me, so I'd like to not implement it, at least for now. Do you have a real use case when it's ok to drop input sections if there's no room to place them in the output?

I think "error" is good and definitely would've helped catching bugs while we were bringing the FreeBSD kernel up&running with lld.
"discard" seems like a dangerous semantic, at least to me, so I'd like to not implement it, at least for now. Do you have a real use case when it's ok to drop input sections if there's no room to place them in the output?

I think it is not about case when "no room", but about all orphans if any. We can remove discard mode, I do not know if it is useful or not, just implemented all what ld has.

I think "error" is good and definitely would've helped catching bugs while we were bringing the FreeBSD kernel up&running with lld.
"discard" seems like a dangerous semantic, at least to me, so I'd like to not implement it, at least for now. Do you have a real use case when it's ok to drop input sections if there's no room to place them in the output?

I think it is not about case when "no room", but about all orphans if any. We can remove discard mode, I do not know if it is useful or not, just implemented all what ld has.

Even worse. I think that discarding input sections tout court is very dangerous and I'm not exactly happy supporting it.

ruiu edited edge metadata.Sep 19 2016, 4:49 PM

Obligatory question: do we want it? I've never seen a project that uses this option.

In D24725#546997, @ruiu wrote:

Obligatory question: do we want it? I've never seen a project that uses this option.

That is probably the only way for users to clean up their scripts and include orphans explicitly ?
They might want it at least because we may have different heuristic for placing orphans
(currently without possible D23352 we even do not have it at all, and just placing them to the end).

grimar updated this revision to Diff 71944.Sep 20 2016, 8:43 AM
grimar edited edge metadata.
  • Removed support for "discard"
  • Added "--orphan-handling MODE" form support.
grimar updated this revision to Diff 72062.Sep 21 2016, 8:57 AM
grimar retitled this revision from [ELF] - Linkerscript: implemented --orphan-handling command line option. to [ELF] - Linkerscript: report orphans if --verbose used..
grimar updated this object.
  • As was duscussed in llvm maillist, just report orphans if --verbose used.
rafael edited edge metadata.Sep 23 2016, 1:52 PM

Does bfd consider linker created sections to be orphans? For example, will it warn if the script doesn't mention .dynsym?

Does bfd consider linker created sections to be orphans? For example, will it warn if the script doesn't mention .dynsym?

Yes, it is. Patch needs update to handle this case then.

grimar updated this revision to Diff 72495.Sep 26 2016, 8:39 AM
grimar edited edge metadata.
  • Updated patch to let it report linker generated orphan sections just like ld do.

This now always talks about output sections.

We should also note if an input section is not placed in any output. For example, given

SECTIONS
{

foo : { *(bar) }

}

and a .o with sections foo and and bar we should warn about the *input* section foo being an orphan. The idea is to warn anytime the linker has to guess where to put the input or output section.

grimar abandoned this revision.Aug 3 2017, 4:36 AM

Too much outdated.