This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Fix for "Bug 34238 - LTO is optimizing away symbols referenced from linker scripts"
ClosedPublic

Authored by grimar on Aug 22 2017, 5:53 AM.

Details

Summary

Code suggested by Rui Ueyama in PR34238 comments.

Previously LTO optimized away symbols referenced from linker script
because did not see that them are used from regular objects.

Patch adds such symbols as undefined earlier, before running LTO,
what sets IsUsedInRegularObj for them and fixes the issue.

Diff Detail

Event Timeline

grimar created this revision.Aug 22 2017, 5:53 AM
grimar edited the summary of this revision. (Show Details)Aug 22 2017, 5:56 AM
ruiu added inline comments.Aug 22 2017, 9:46 AM
ELF/Driver.cpp
1017–1018

You don't need to mention that because that is also applicable to all code that adds undefined symbols. If you add this comment, you need to add the same comment to line 1026, for example. Essentially, all undefined symbols must be added line 1025 as the comment for that line explains.

grimar updated this revision to Diff 112194.Aug 22 2017, 10:16 AM
  • Restored original comment.
ELF/Driver.cpp
1017–1018

Ok.

ruiu accepted this revision.Aug 22 2017, 10:18 AM

LGTM

This revision is now accepted and ready to land.Aug 22 2017, 10:18 AM
This revision was automatically updated to reflect the committed changes.