This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Introduce getInputSections() helper.
ClosedPublic

Authored by grimar on Feb 21 2018, 7:25 AM.

Details

Summary

We sometimes need to iterate over input sections for a given
output section. It is not very convinent because we have to iterate
over section descriptions.
Patch introduces getInputSections helper, it simplifies things.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Feb 21 2018, 7:25 AM
ruiu accepted this revision.Feb 21 2018, 10:49 AM

LGTM

ELF/SyntheticSections.cpp
2582–2584 ↗(On Diff #135249)

Please write it with a regular for-loop instead of a higher-order function.

This revision is now accepted and ready to land.Feb 21 2018, 10:49 AM
This revision was automatically updated to reflect the committed changes.

LGTM

Thanks ! btw, it turns out getInputSections could be just a member of OutputSection. Should we do that ?

jhenderson added inline comments.
lld/trunk/ELF/Writer.cpp
1395

This isn't a direct equivalent of what was there before, as it only takes account of InputSectionDescription commands, and not other commands, such as BYTE() or symbol assignments. This has an effect on the layout, though I haven't conclusively determined what (it affects the "Rank" somehow). See PR36475.

grimar added inline comments.Feb 22 2018, 8:36 AM
lld/trunk/ELF/Writer.cpp
1395

You right.
What we do is set output section flags to flags of synthetic input section. Then we remove this empty section here and mark output
section as dead.
adjustSectionsBeforeSorting might resurrect it and reassign flags to different ones.
If script would not contain empty synthetic section in output section description, I think flags would be the same as now.
So, this is definitely not a direct equivalent, but I am not sure if it is an issue ?

grimar added inline comments.Feb 22 2018, 8:48 AM
lld/trunk/ELF/Writer.cpp
1395

Moreover it seems for me that previous behavior probably was not quite right as we used flags from dead synthetic sections I believe.
Is there any reasons why new behavior is less acceptable ?