[llvm-commits] [llvm] r116741 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/MC/ELF/relocation-386.s
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 18 13:25:33 PDT 2010
Author: rafael
Date: Mon Oct 18 15:25:33 2010
New Revision: 116741
URL: http://llvm.org/viewvc/llvm-project?rev=116741&view=rev
Log:
Relocate with .bss instead of using the symbol. Matches gas behavior.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ELF/relocation-386.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=116741&r1=116740&r2=116741&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Oct 18 15:25:33 2010
@@ -560,6 +560,9 @@
const MCSectionELF &Sec2 =
static_cast<const MCSectionELF&>(F.getParent()->getSection());
+ if (Section.getKind().isBSS())
+ return false;
+
if (&Sec2 != &Section &&
(Kind == MCSymbolRefExpr::VK_PLT ||
Kind == MCSymbolRefExpr::VK_GOTPCREL ||
Modified: llvm/trunk/test/MC/ELF/relocation-386.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation-386.s?rev=116741&r1=116740&r2=116741&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/relocation-386.s (original)
+++ llvm/trunk/test/MC/ELF/relocation-386.s Mon Oct 18 15:25:33 2010
@@ -3,10 +3,23 @@
// Test that we produce the correct relocation types and that the relocation
// to .Lfoo uses the symbol and not the section.
+// Section 3 is bss
+// CHECK: # Section 3
+// CHECK-NEXT: (('sh_name', 13) # '.bss'
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 5) # '.Lfoo'
+// Symbol 6 is section 3
+// CHECK: # Symbol 6
+// CHECK-NEXT: (('st_name', 0) # ''
+// CHECK-NEXT: ('st_value', 0)
+// CHECK-NEXT: ('st_size', 0)
+// CHECK-NEXT: ('st_bind', 0)
+// CHECK-NEXT: ('st_type', 3)
+// CHECK-NEXT: ('st_other', 0)
+// CHECK-NEXT: ('st_shndx', 3)
+
// CHECK: # Relocation 0
// CHECK-NEXT: (('r_offset', 2)
// CHECK-NEXT: ('r_sym', 1)
@@ -23,6 +36,13 @@
// CHECK-NEXT: ('r_type', 10)
// CHECK-NEXT: ),
+// Relocation 3 (bar3 at GOTOFF) is done symbol 6 (bss)
+// CHECK-NEXT: # Relocation 3
+// CHECK-NEXT: (('r_offset',
+// CHECK-NEXT: ('r_sym', 6
+// CHECK-NEXT: ('r_type',
+// CHECK-NEXT: ),
+
.text
bar:
leal .Lfoo at GOTOFF(%ebx), %eax
@@ -31,6 +51,11 @@
bar2:
calll bar2 at PLT
addl $_GLOBAL_OFFSET_TABLE_, %ebx
+ movb bar3 at GOTOFF(%ebx), %al
+
+ .type bar3, at object
+ .local bar3
+ .comm bar3,1,1
.section .rodata.str1.16,"aMS", at progbits,1
.Lfoo:
More information about the llvm-commits
mailing list