diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-04-17 21:15:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-04-17 21:15:17 +0000 |
commit | 35d6189f0fc2bbb103846ffaac4b3e0043607885 (patch) | |
tree | 24b20082223c32a65f69a5181b5e7f7efdf61b9b /llvm/lib/MC/ELFObjectWriter.cpp | |
parent | 84b801f6b46520611d4428e6facd7c09489ae516 (diff) | |
download | bcm5719-llvm-35d6189f0fc2bbb103846ffaac4b3e0043607885.tar.gz bcm5719-llvm-35d6189f0fc2bbb103846ffaac4b3e0043607885.zip |
Compute A-B when A or B is weak.
Similar to r235222, but for the weak symbol case.
In an "ideal" assembler/object format an expression would always refer to the
final value and A-B would only be computed from a section in the same
comdat as A and B with A and B strong.
Unfortunately that is not the case with debug info on ELF, so we need an
heuristic. Since we need an heuristic, we may as well use the same one as
gas:
* call weak_sym : produces a relocation, even if in the same section.
* A - weak_sym and weak_sym -A: don't produce a relocation if we can
compute it.
This fixes pr23272 and changes the fix of pr22815 to match what gas does.
llvm-svn: 235227
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/MC/ELFObjectWriter.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 32ec969c369..1646fe59ce4 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -275,7 +275,6 @@ class ELFObjectWriter : public MCObjectWriter { bool IsSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm, const MCSymbolData &DataA, - const MCSymbolData *DataB, const MCFragment &FB, bool InSet, bool IsPCRel) const override; @@ -1669,13 +1668,15 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm, } bool ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( - const MCAssembler &Asm, const MCSymbolData &DataA, - const MCSymbolData *DataB, const MCFragment &FB, bool InSet, - bool IsPCRel) const { - if (!InSet && (::isWeak(DataA) || (DataB && ::isWeak(*DataB)))) - return false; - return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl( - Asm, DataA, DataB, FB, InSet, IsPCRel); + const MCAssembler &Asm, const MCSymbolData &DataA, const MCFragment &FB, + bool InSet, bool IsPCRel) const { + if (IsPCRel) { + assert(!InSet); + if (::isWeak(DataA)) + return false; + } + return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, DataA, FB, + InSet, IsPCRel); } bool ELFObjectWriter::isWeak(const MCSymbolData &SD) const { |