This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Add test for interaction of --gc-sections and undefined references
ClosedPublic

Authored by jhenderson on Jan 19 2018, 6:56 AM.

Details

Summary

It is possible for a link to fail with an undefined reference, unless --gc-sections is specified, removing the reference in the process. This doesn't look to be tested anywhere explicitly, so I thought it useful to add a test for it to ensure the behaviour is maintained.

Diff Detail

Repository
rL LLVM

Event Timeline

jhenderson created this revision.Jan 19 2018, 6:56 AM
ruiu accepted this revision.Jan 19 2018, 2:27 PM

LGTM

test/ELF/gc-sections-no-undef-error.s
7–8 ↗(On Diff #130613)

You can write this in one line.

not ld.lld %t.o -o %t 2>&1 | FileCheck %s
This revision is now accepted and ready to land.Jan 19 2018, 2:27 PM
jhenderson added inline comments.Jan 22 2018, 2:51 AM
test/ELF/gc-sections-no-undef-error.s
7–8 ↗(On Diff #130613)

Thanks Rui. I thought I'd read somewhere on the mailing lists advising against doing that for some reason, but I can't find it now, so I may be misremembering it.

This revision was automatically updated to reflect the committed changes.
ruiu added a comment.Jan 22 2018, 4:08 PM

I thought I'd read somewhere on the mailing lists advising against doing that for some reason, but I can't find it now, so I may be misremembering it.

Not sure if it is actually discouraged, but at least in lld it's conventional.