[llvm-commits] [llvm] r118798 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/weakref-plt.s
Rafael Espindola
rafael.espindola at gmail.com
Thu Nov 11 09:24:43 PST 2010
Author: rafael
Date: Thu Nov 11 11:24:43 2010
New Revision: 118798
URL: http://llvm.org/viewvc/llvm-project?rev=118798&view=rev
Log:
Make AliasedSymbol able to handle MCTargetExpr. They can get here if
a weakref is used with a VariantKind.
Added:
llvm/trunk/test/MC/ELF/weakref-plt.s
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=118798&r1=118797&r2=118798&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Nov 11 11:24:43 2010
@@ -470,10 +470,23 @@
const MCSymbol *S = &Symbol;
while (S->isVariable()) {
const MCExpr *Value = S->getVariableValue();
- if (Value->getKind() != MCExpr::SymbolRef)
+ MCExpr::ExprKind Kind = Value->getKind();
+ switch (Kind) {
+ case MCExpr::SymbolRef: {
+ const MCSymbolRefExpr *Ref = static_cast<const MCSymbolRefExpr*>(Value);
+ S = &Ref->getSymbol();
+ break;
+ }
+ case MCExpr::Target: {
+ const MCTargetExpr *TExp = static_cast<const MCTargetExpr*>(Value);
+ MCValue Res;
+ TExp->EvaluateAsRelocatableImpl(Res, NULL);
+ S = &Res.getSymA()->getSymbol();
+ break;
+ }
+ default:
return *S;
- const MCSymbolRefExpr *Ref = static_cast<const MCSymbolRefExpr*>(Value);
- S = &Ref->getSymbol();
+ }
}
return *S;
}
Added: llvm/trunk/test/MC/ELF/weakref-plt.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/weakref-plt.s?rev=118798&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/weakref-plt.s (added)
+++ llvm/trunk/test/MC/ELF/weakref-plt.s Thu Nov 11 11:24:43 2010
@@ -0,0 +1,8 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
+
+ .weakref bar,foo
+ call bar at PLT
+
+// CHECK: # Symbol 0x00000005
+// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
+// CHECK-NEXT: ('st_bind', 0x00000002)
More information about the llvm-commits
mailing list