diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-20 02:12:01 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-03-20 02:12:01 +0000 |
commit | 7fadc0ea7df49f4fef7da3797ea382d9486cc259 (patch) | |
tree | a240de0de7267b634fd4b36e1e7673f661941f53 /llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp | |
parent | 05c152b5d134a878ae8781d6fc3b8619f387c9de (diff) | |
download | llvm-7fadc0ea7df49f4fef7da3797ea382d9486cc259.zip llvm-7fadc0ea7df49f4fef7da3797ea382d9486cc259.tar.gz llvm-7fadc0ea7df49f4fef7da3797ea382d9486cc259.tar.bz2 |
Look through variables when computing relocations.
Given
bar = foo + 4
.long bar
MC would eat the 4. GNU as includes it in the relocation. The rule seems to be
that a variable that defines a symbol is used in the relocation and one that
does not define a symbol is evaluated and the result included in the relocation.
Fixing this unfortunately required some other changes:
* Since the variable is now evaluated, it would prevent the ELF writer from
noticing the weakref marker the elf streamer uses. This patch then replaces
that with a VariantKind in MCSymbolRefExpr.
* Using VariantKind then requires us to look past other VariantKind to see
.weakref bar,foo
call bar@PLT
doing this also fixes
zed = foo +2
call zed@PLT
so that is a good thing.
* Looking past VariantKind means that the relocation selection has to use
the fixup instead of the target.
This is a reboot of the previous fixes for MC. I will watch the sanitizer
buildbot and wait for a build before adding back the previous fixes.
llvm-svn: 204294
Diffstat (limited to 'llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp')
-rw-r--r-- | llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp index 25efd67..d829394e 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp @@ -71,17 +71,16 @@ const MCSymbol *ARMELFObjectWriter::ExplicitRelSym(const MCAssembler &Asm, bool InNormalSection = true; unsigned RelocType = 0; RelocType = GetRelocTypeInner(Target, Fixup, IsPCRel); + assert(!Target.getSymB() || + Target.getSymB()->getKind() == MCSymbolRefExpr::VK_None); DEBUG( - const MCSymbolRefExpr::VariantKind Kind = Target.getSymA()->getKind(); - MCSymbolRefExpr::VariantKind Kind2; - Kind2 = Target.getSymB() ? Target.getSymB()->getKind() : - MCSymbolRefExpr::VK_None; + MCSymbolRefExpr::VariantKind Kind = Fixup.getAccessVariant(); dbgs() << "considering symbol " << Section.getSectionName() << "/" << Symbol.getName() << "/" << " Rel:" << (unsigned)RelocType - << " Kind: " << (int)Kind << "/" << (int)Kind2 + << " Kind: " << (int)Kind << " Tmp:" << Symbol.isAbsolute() << "/" << Symbol.isDefined() << "/" << Symbol.isVariable() << "/" << Symbol.isTemporary() @@ -152,8 +151,7 @@ unsigned ARMELFObjectWriter::GetRelocType(const MCValue &Target, unsigned ARMELFObjectWriter::GetRelocTypeInner(const MCValue &Target, const MCFixup &Fixup, bool IsPCRel) const { - MCSymbolRefExpr::VariantKind Modifier = Target.isAbsolute() ? - MCSymbolRefExpr::VK_None : Target.getSymA()->getKind(); + MCSymbolRefExpr::VariantKind Modifier = Fixup.getAccessVariant(); unsigned Type = 0; if (IsPCRel) { |