Page MenuHomePhabricator

[ELF] Set `referenced` bit of Undefined created by BitcodeFile
ClosedPublic

Authored by MaskRay on Aug 29 2019, 11:42 PM.

Details

Summary

D64136 and D65584, while fixing STB_WEAK issues and improving our
compatibility with ld.bfd, can cause another STB_WEAK problem related to
LTO:

If %tundef.o has an undefined reference on f,
and %tweakundef.o has a weak undefined reference on f,
%tdef.o has a definition of f

ld.lld %tundef.o %tweakundef.o --start-lib %tdef.o --end-lib
  1. %tundef.o doesn't set referenced bit.
  2. %weakundef.o changes the binding from STB_GLOBAL to STB_WEAK
  3. %tdef.o is not fetched because the binding is weak.

Step (1) is incorrect. This patch sets the referenced bit of Undefined
created by bitcode files.

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Aug 29 2019, 11:42 PM
ruiu accepted this revision.Aug 30 2019, 12:05 AM

LGTM

This revision is now accepted and ready to land.Aug 30 2019, 12:05 AM
MaskRay updated this revision to Diff 218031.Aug 30 2019, 12:08 AM
MaskRay edited the summary of this revision. (Show Details)

Seems we don't have enough tests.

Add two other cases that the lazy object should be fetched

This revision was automatically updated to reflect the committed changes.