[llvm-commits] [llvm] r117037 - in /llvm/trunk: lib/MC/MCExpr.cpp test/MC/ELF/alias-reloc.s
Rafael Espindola
rafael.espindola at gmail.com
Thu Oct 21 11:00:20 PDT 2010
Author: rafael
Date: Thu Oct 21 13:00:20 2010
New Revision: 117037
URL: http://llvm.org/viewvc/llvm-project?rev=117037&view=rev
Log:
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.
Added:
llvm/trunk/test/MC/ELF/alias-reloc.s
Modified:
llvm/trunk/lib/MC/MCExpr.cpp
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=117037&r1=117036&r2=117037&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Thu Oct 21 13:00:20 2010
@@ -306,7 +306,7 @@
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);
Added: llvm/trunk/test/MC/ELF/alias-reloc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/alias-reloc.s?rev=117037&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/alias-reloc.s (added)
+++ llvm/trunk/test/MC/ELF/alias-reloc.s Thu Oct 21 13:00:20 2010
@@ -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 at 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: ])
More information about the llvm-commits
mailing list