This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Linkerscript: add test for checking interaction with archive files.
ClosedPublic

Authored by grimar on Aug 28 2017, 3:59 AM.

Details

Summary

Imagine we have archive file with symbols foo and bar.
And script that do foo = 1.
In that case correct behavior is not to fetch symbols from archive but
create absolute symbol.
If we have script zed = foo then symbol foo will be fetched from archive.
Currently we have Opt.ReferencedSymbols list of symbols referenced
by script and create them undefined early. That allows archives fetching logic
to work. That is what LLD already do and it seems everything is fine here.

But during writing D37059 I had to add left side of assignments to
Opt.ReferencedSymbols list because wanted to stop optimizing out
these symbols when LTO is involved (LTO also uses this list).
And today I realized that testcase from this patch would have fail if we
would have it before.

So I suggest to add this testcase to be able to catch such situations
during writing other patches.

Diff Detail

Event Timeline

grimar created this revision.Aug 28 2017, 3:59 AM
grimar edited the summary of this revision. (Show Details)Aug 28 2017, 3:59 AM
ruiu added inline comments.Aug 28 2017, 8:45 AM
test/ELF/linkerscript/assignment-archive.s
3

I believe you can just feed an empty file by doing llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t.o < /dev/null so that you can merge this file with the one under Innputs directory.

grimar updated this revision to Diff 113052.Aug 29 2017, 3:31 AM
  • Addressed review comment.
ruiu accepted this revision.Aug 29 2017, 7:53 AM

LGTM

This revision is now accepted and ready to land.Aug 29 2017, 7:53 AM
This revision was automatically updated to reflect the committed changes.