diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2010-10-21 18:00:20 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2010-10-21 18:00:20 +0000 |
commit | 8c8bc05a383890ab29b288625c746bf24240e9a1 (patch) | |
tree | c8acd442ac99960bfca63cd4f577199dd53b0816 | |
parent | 0b9325c97d031ab0e9a240d69a2be11ec1559e37 (diff) |
Do not recurse into symbol refs that have a variant kind. This prevents us
from losing the variant when producing a relocation on an alias.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117037 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/MCExpr.cpp | 2 | ||||
-rw-r--r-- | test/MC/ELF/alias-reloc.s | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 3524b8035c..abc3b51c79 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -306,7 +306,7 @@ bool MCExpr::EvaluateAsRelocatableImpl(MCValue &Res, const MCSymbol &Sym = SRE->getSymbol(); // Evaluate recursively if this is a variable. - if (Sym.isVariable()) + if (Sym.isVariable() && SRE->getKind() == MCSymbolRefExpr::VK_None) return Sym.getVariableValue()->EvaluateAsRelocatableImpl(Res, Layout, true); diff --git a/test/MC/ELF/alias-reloc.s b/test/MC/ELF/alias-reloc.s new file mode 100644 index 0000000000..e31afa1030 --- /dev/null +++ b/test/MC/ELF/alias-reloc.s @@ -0,0 +1,16 @@ +// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s + +// Test that this produces a R_X86_64_PLT32. We produce a relocation with foo +// and gas with bar, but both should be OK as long as the type is correct. + .globl foo +foo: +bar = foo + call bar@PLT + +// CHECK: # Relocation 0 +// CHECK-NEXT: (('r_offset', +// CHECK-NEXT: ('r_sym', +// CHECK-NEXT: ('r_type', 0x00000004) +// CHECK-NEXT: ('r_addend', +// CHECK-NEXT: ), +// CHECK-NEXT: ]) |