summaryrefslogtreecommitdiff
path: root/test/MC/ELF
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-03-29 06:26:49 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-03-29 06:26:49 +0000
commit224dbf4aec6488e6ac55f2155a238e57086ef473 (patch)
tree095ac391fabe67b3e979b3bbd6cc60ec32109d80 /test/MC/ELF
parent44b2b9dc1a6192fda90990ec9eec922e3f8d2049 (diff)
downloadllvm-224dbf4aec6488e6ac55f2155a238e57086ef473.tar.gz
llvm-224dbf4aec6488e6ac55f2155a238e57086ef473.tar.bz2
llvm-224dbf4aec6488e6ac55f2155a238e57086ef473.tar.xz
Completely rewrite ELFObjectWriter::RecordRelocation.
I started trying to fix a small issue, but this code has seen a small fix too many. The old code was fairly convoluted. Some of the issues it had: * It failed to check if a symbol difference was in the some section when converting a relocation to pcrel. * It failed to check if the relocation was already pcrel. * The pcrel value computation was wrong in some cases (relocation-pc.s) * It was missing quiet a few cases where it should not convert symbol relocations to section relocations, leaving the backends to patch it up. * It would not propagate the fact that it had changed a relocation to pcrel, requiring a quiet nasty work around in ARM. * It was missing comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205076 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/MC/ELF')
-rw-r--r--test/MC/ELF/bad-expr2.s12
-rw-r--r--test/MC/ELF/bad-expr3.s10
-rw-r--r--test/MC/ELF/merge.s9
-rw-r--r--test/MC/ELF/relocation-386.s4
-rw-r--r--test/MC/ELF/relocation-pc.s4
5 files changed, 30 insertions, 9 deletions
diff --git a/test/MC/ELF/bad-expr2.s b/test/MC/ELF/bad-expr2.s
new file mode 100644
index 0000000000..3da916b7fa
--- /dev/null
+++ b/test/MC/ELF/bad-expr2.s
@@ -0,0 +1,12 @@
+// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o /dev/null \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: No relocation available to represent this relative expression
+// CHECK: call foo - bar
+
+
+ call foo - bar
+ .section .foo
+foo:
+ .section .bar
+bar:
diff --git a/test/MC/ELF/bad-expr3.s b/test/MC/ELF/bad-expr3.s
new file mode 100644
index 0000000000..990167cda5
--- /dev/null
+++ b/test/MC/ELF/bad-expr3.s
@@ -0,0 +1,10 @@
+// RUN: not llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o /dev/null \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK: Cannot represent a difference across sections
+
+ .long foo - bar
+ .section .zed
+foo:
+ .section .bah
+bar:
diff --git a/test/MC/ELF/merge.s b/test/MC/ELF/merge.s
index 0e92583192..d6e0b7c4b7 100644
--- a/test/MC/ELF/merge.s
+++ b/test/MC/ELF/merge.s
@@ -1,10 +1,7 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -r | FileCheck %s
-// Test that PIC relocations with local symbols in a mergeable section are done
-// with a reference to the symbol. Not sure if this is a linker limitation,
-// but this matches the behavior of gas.
-
-// Non-PIC relocations with 0 offset don't use the symbol.
+// Test that relocations with local symbols in a mergeable section are done
+// with a reference to the symbol if the offset is non zero.
movsd .Lfoo(%rip), %xmm1
@@ -13,6 +10,7 @@
jmp foo@PLT
movq foo@GOTPCREL, %rax
movq zed, %rax
+ movsd .Lfoo+4(%rip), %xmm1
.section .sec1,"aM",@progbits,16
.Lfoo:
@@ -30,5 +28,6 @@ foo:
// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_PLT32 foo 0x{{[^ ]+}}
// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_GOTPCREL foo 0x{{[^ ]+}}
// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_32S zed 0x{{[^ ]+}}
+// CHECK-NEXT: 0x{{[^ ]+}} R_X86_64_PC32 .sec1 0x{{[^ ]+}}
// CHECK-NEXT: }
// CHECK-NEXT: ]
diff --git a/test/MC/ELF/relocation-386.s b/test/MC/ELF/relocation-386.s
index e8c31fc85c..1409465b73 100644
--- a/test/MC/ELF/relocation-386.s
+++ b/test/MC/ELF/relocation-386.s
@@ -5,7 +5,7 @@
// CHECK: Relocations [
// CHECK-NEXT: Section (2) .rel.text {
-// CHECK-NEXT: 0x2 R_386_GOTOFF .Lfoo 0x0
+// CHECK-NEXT: 0x2 R_386_GOTOFF .rodata.str1.16 0x0
// CHECK-NEXT: 0x{{[^ ]+}} R_386_PLT32 bar2 0x0
// CHECK-NEXT: 0x{{[^ ]+}} R_386_GOTPC _GLOBAL_OFFSET_TABLE_ 0x0
// Relocation 3 (bar3@GOTOFF) is done with symbol 7 (bss)
@@ -67,7 +67,7 @@
// Symbol 4 is zed
// CHECK: Symbol {
-// CHECK: Name: zed (53)
+// CHECK: Name: zed
// CHECK-NEXT: Value: 0x0
// CHECK-NEXT: Size: 0
// CHECK-NEXT: Binding: Local
diff --git a/test/MC/ELF/relocation-pc.s b/test/MC/ELF/relocation-pc.s
index fc7420c398..0ce32010cf 100644
--- a/test/MC/ELF/relocation-pc.s
+++ b/test/MC/ELF/relocation-pc.s
@@ -26,7 +26,7 @@
// CHECK-NEXT: AddressAlignment: 8
// CHECK-NEXT: EntrySize: 24
// CHECK-NEXT: Relocations [
-// CHECK-NEXT: 0x1 R_X86_64_PC8 - 0x0
-// CHECK-NEXT: 0x3 R_X86_64_PC32 - 0x0
+// CHECK-NEXT: 0x1 R_X86_64_PC8 - 0xFFFFFFFFFFFFFFFF
+// CHECK-NEXT: 0x3 R_X86_64_PC32 - 0xFFFFFFFFFFFFFEFC
// CHECK-NEXT: ]
// CHECK-NEXT: }