[llvm-commits] [llvm] r115454 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/pic-diff.s
Rafael Espindola
rafael.espindola at gmail.com
Sat Oct 2 17:46:57 PDT 2010
Author: rafael
Date: Sat Oct 2 19:46:57 2010
New Revision: 115454
URL: http://llvm.org/viewvc/llvm-project?rev=115454&view=rev
Log:
Implement a very basic PIC case.
Added:
llvm/trunk/test/MC/ELF/pic-diff.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=115454&r1=115453&r2=115454&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Sat Oct 2 19:46:57 2010
@@ -535,6 +535,13 @@
MCSymbolData &SD = Asm.getSymbolData(*Symbol);
MCFragment *F = SD.getFragment();
+ if (const MCSymbolRefExpr *RefB = Target.getSymB()) {
+ const MCSymbol &SymbolB = RefB->getSymbol();
+ MCSymbolData &SDB = Asm.getSymbolData(SymbolB);
+ IsPCRel = true;
+ Value += Fixup.getOffset() - Layout.getSymbolAddress(&SDB);
+ }
+
// Check that this case has already been fully resolved before we get
// here.
if (Symbol->isDefined() && !SD.isExternal() &&
Added: llvm/trunk/test/MC/ELF/pic-diff.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/pic-diff.s?rev=115454&view=auto
==============================================================================
--- llvm/trunk/test/MC/ELF/pic-diff.s (added)
+++ llvm/trunk/test/MC/ELF/pic-diff.s Sat Oct 2 19:46:57 2010
@@ -0,0 +1,25 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
+
+// CHECK: # Symbol 5
+// CHECK-NEXT: (('st_name', 5) # 'baz'
+// CHECK-NEXT: ('st_bind', 1)
+// CHECK-NEXT: ('st_type', 0)
+// CHECK-NEXT: ('st_other', 0)
+// CHECK-NEXT: ('st_shndx', 0)
+// CHECK-NEXT: ('st_value', 0)
+// CHECK-NEXT: ('st_size', 0)
+// CHECK-NEXT: ),
+
+// CHECK: ('_relocations', [
+// CHECK-NEXT: # Relocation 0
+// CHECK-NEXT: (('r_offset', 12)
+// CHECK-NEXT: ('r_sym', 5)
+// CHECK-NEXT: ('r_type', 2)
+// CHECK-NEXT: ('r_addend', 8)
+// CHECK-NEXT: ),
+// CHECK-NEXT: ])
+
+.zero 4
+foo:
+.zero 8
+.long baz - foo
More information about the llvm-commits
mailing list