This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Do not remove empty sections that use symbols in expressions.
ClosedPublic

Authored by grimar on Feb 28 2018, 2:35 AM.

Details

Summary

This is PR36515.

Currenly if we have script like .debug_info 0 : { *(.debug_info) },
we would not remove this section and keep it in output.
That does not work, because it is common case for
debug sections to have zero address expression.
Patch changes behavior so that we remove only sections
that do not use symbols in its expressions.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

grimar created this revision.Feb 28 2018, 2:35 AM
jhenderson added inline comments.Feb 28 2018, 2:57 AM
test/ELF/linkerscript/empty-sections-expressions.s
13–15

I think I'd personally prefer the test define foo and then checks to make sure that the section is emitted in this case, as that demonstrates the end effect better. We could change the underlying mechanism to detect errors and still remove the section, but then this test doesn't actually test the claimed behaviour.

grimar updated this revision to Diff 136265.Feb 28 2018, 3:21 AM
  • Updated testcase in according to review comments.
jhenderson accepted this revision.Feb 28 2018, 3:33 AM

LGTM, with nit.

@ruiu / @espindola should probably still review it, as I'm aware that there's a little bit of concern about adding extra class members sometimes.

ELF/OutputSections.cpp
89 ↗(On Diff #136265)

defined in output -> defined in the output

This revision is now accepted and ready to land.Feb 28 2018, 3:33 AM
This revision was automatically updated to reflect the committed changes.