mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
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
This commit is contained in:
12
test/MC/ELF/bad-expr2.s
Normal file
12
test/MC/ELF/bad-expr2.s
Normal file
@@ -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:
|
10
test/MC/ELF/bad-expr3.s
Normal file
10
test/MC/ELF/bad-expr3.s
Normal file
@@ -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:
|
@@ -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: ]
|
||||
|
@@ -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
|
||||
|
@@ -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: }
|
||||
|
Reference in New Issue
Block a user