[llvm-branch-commits] [lld] d39adea - [ELF] Improve R_PPC64_ADDR* relocation tests
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jan 19 11:48:51 PST 2021
Author: Fangrui Song
Date: 2021-01-19T11:42:51-08:00
New Revision: d39adeaf440bc0db508b7d2a4eb9ace7f40178fc
URL: https://github.com/llvm/llvm-project/commit/d39adeaf440bc0db508b7d2a4eb9ace7f40178fc
DIFF: https://github.com/llvm/llvm-project/commit/d39adeaf440bc0db508b7d2a4eb9ace7f40178fc.diff
LOG: [ELF] Improve R_PPC64_ADDR* relocation tests
Added:
lld/test/ELF/ppc64-reloc-addr-err.s
Modified:
lld/test/ELF/ppc64-reloc-addr.s
lld/test/ELF/ppc64-relocs.s
Removed:
################################################################################
diff --git a/lld/test/ELF/ppc64-reloc-addr-err.s b/lld/test/ELF/ppc64-reloc-addr-err.s
new file mode 100644
index 000000000000..ef423a1c2e2b
--- /dev/null
+++ b/lld/test/ELF/ppc64-reloc-addr-err.s
@@ -0,0 +1,25 @@
+# REQUIRES: ppc
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %S/Inputs/abs255.s -o %t255.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %S/Inputs/abs256.s -o %t256.o
+# RUN: llvm-mc -filetype=obj -triple=powerpc64le %S/Inputs/abs257.s -o %t257.o
+
+# RUN: ld.lld %t.o %t256.o -o %t
+# RUN: llvm-readelf -x .data %t | FileCheck %s
+# CHECK: 0x{{[0-9a-f]+}} ffff0080 ffffffff 00000080
+
+# RUN: not ld.lld %t.o %t255.o -o /dev/null 2>&1 | FileCheck --check-prefix=OVERFLOW1 %s
+# OVERFLOW1: relocation R_PPC64_ADDR16 out of range: -32769 is not in [-32768, 65535]; references foo
+# OVERFLOW1: relocation R_PPC64_ADDR32 out of range: -2147483649 is not in [-2147483648, 4294967295]; references foo
+
+# RUN: not ld.lld %t.o %t257.o -o /dev/null 2>&1 | FileCheck --check-prefix=OVERFLOW2 %s
+# OVERFLOW2: relocation R_PPC64_ADDR16 out of range: 65536 is not in [-32768, 65535]; references foo
+# OVERFLOW2: relocation R_PPC64_ADDR32 out of range: 4294967296 is not in [-2147483648, 4294967295]; references foo
+
+.globl _start
+_start:
+.data
+.word foo + 0xfeff
+.word foo - 0x8100
+.long foo + 0xfffffeff
+.long foo - 0x80000100
diff --git a/lld/test/ELF/ppc64-reloc-addr.s b/lld/test/ELF/ppc64-reloc-addr.s
index ef423a1c2e2b..7eb13c2ef5bc 100644
--- a/lld/test/ELF/ppc64-reloc-addr.s
+++ b/lld/test/ELF/ppc64-reloc-addr.s
@@ -1,25 +1,46 @@
# REQUIRES: ppc
-# RUN: llvm-mc -filetype=obj -triple=powerpc64le %s -o %t.o
-# RUN: llvm-mc -filetype=obj -triple=powerpc64le %S/Inputs/abs255.s -o %t255.o
-# RUN: llvm-mc -filetype=obj -triple=powerpc64le %S/Inputs/abs256.s -o %t256.o
-# RUN: llvm-mc -filetype=obj -triple=powerpc64le %S/Inputs/abs257.s -o %t257.o
-
-# RUN: ld.lld %t.o %t256.o -o %t
-# RUN: llvm-readelf -x .data %t | FileCheck %s
-# CHECK: 0x{{[0-9a-f]+}} ffff0080 ffffffff 00000080
-
-# RUN: not ld.lld %t.o %t255.o -o /dev/null 2>&1 | FileCheck --check-prefix=OVERFLOW1 %s
-# OVERFLOW1: relocation R_PPC64_ADDR16 out of range: -32769 is not in [-32768, 65535]; references foo
-# OVERFLOW1: relocation R_PPC64_ADDR32 out of range: -2147483649 is not in [-2147483648, 4294967295]; references foo
-
-# RUN: not ld.lld %t.o %t257.o -o /dev/null 2>&1 | FileCheck --check-prefix=OVERFLOW2 %s
-# OVERFLOW2: relocation R_PPC64_ADDR16 out of range: 65536 is not in [-32768, 65535]; references foo
-# OVERFLOW2: relocation R_PPC64_ADDR32 out of range: 4294967296 is not in [-2147483648, 4294967295]; references foo
-
-.globl _start
-_start:
-.data
-.word foo + 0xfeff
-.word foo - 0x8100
-.long foo + 0xfffffeff
-.long foo - 0x80000100
+# RUN: llvm-mc -filetype=obj -triple=ppc64le %s -o %t.o
+# RUN: ld.lld %t.o --defsym=a=0x0123456789abcdef --defsym=b=0x76543210 -o %t
+# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s
+# RUN: llvm-objdump -s --no-show-raw-insn %t | FileCheck --check-prefixes=HEX,HEXLE %s
+
+# HEX-LABEL: section .R_PPC64_ADDR32:
+# HEXLE-NEXT: 10325476
+# HEXBE-NEXT: 76543210
+.section .R_PPC64_ADDR32,"a", at progbits
+ .long b
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_LO>:
+# CHECK-NEXT: addi 4, 4, 12816
+.section .R_PPC64_ADDR16_LO,"ax", at progbits
+ addi 4, 4, b at l
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_HI>:
+# CHECK-NEXT: lis 4, 30292
+.section .R_PPC64_ADDR16_HI,"ax", at progbits
+ lis 4, b at h
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_HA>:
+# CHECK-NEXT: lis 4, 30292
+.section .R_PPC64_ADDR16_HA,"ax", at progbits
+ lis 4, b at ha
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_HIGHER>:
+# CHECK-NEXT: li 3, 17767
+.section .R_PPC64_ADDR16_HIGHER,"ax", at progbits
+ li 3, a at higher
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_HIGHERA>:
+# CHECK-NEXT: li 3, 17767
+.section .R_PPC64_ADDR16_HIGHERA,"ax", at progbits
+ li 3, a at highera
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_HIGHEST>:
+# CHECK-NEXT: li 3, 291
+.section .R_PPC64_ADDR16_HIGHEST,"ax", at progbits
+ li 3, a at highest
+
+# CHECK-LABEL: <.R_PPC64_ADDR16_HIGHESTA>:
+# CHECK-NEXT: li 3, 291
+.section .R_PPC64_ADDR16_HIGHESTA,"ax", at progbits
+ li 3, a at highesta
diff --git a/lld/test/ELF/ppc64-relocs.s b/lld/test/ELF/ppc64-relocs.s
index e3363b60488f..0b0be487521e 100644
--- a/lld/test/ELF/ppc64-relocs.s
+++ b/lld/test/ELF/ppc64-relocs.s
@@ -40,54 +40,6 @@ _start:
# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_HI:
# CHECK: addis 1, 2, -1
-.section .R_PPC64_TOC16_HA,"ax", at progbits
- addis 1, 2, .L1 at toc@ha
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_TOC16_HA:
-# CHECK: addis 1, 2, 0
-
-.section .R_PPC64_ADDR16_LO,"ax", at progbits
- li 1, .Lfoo at l
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_LO:
-# CHECK: li 1, 464
-
-.section .R_PPC64_ADDR16_HI,"ax", at progbits
- li 1, .Lfoo at h
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HI:
-# CHECK: li 1, 4097
-
-.section .R_PPC64_ADDR16_HA,"ax", at progbits
- li 1, .Lfoo at ha
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HA:
-# CHECK: li 1, 4097
-
-.section .R_PPC64_ADDR16_HIGHER,"ax", at progbits
- li 1, .Lfoo at higher
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHER:
-# CHECK: li 1, 0
-
-.section .R_PPC64_ADDR16_HIGHERA,"ax", at progbits
- li 1, .Lfoo at highera
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHERA:
-# CHECK: li 1, 0
-
-.section .R_PPC64_ADDR16_HIGHEST,"ax", at progbits
- li 1, .Lfoo at highest
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHEST:
-# CHECK: li 1, 0
-
-.section .R_PPC64_ADDR16_HIGHESTA,"ax", at progbits
- li 1, .Lfoo at highesta
-
-# CHECK-LABEL: Disassembly of section .R_PPC64_ADDR16_HIGHESTA:
-# CHECK: li 1, 0
-
.section .R_PPC64_TOC,"a", at progbits
.quad .TOC. at tocbase
@@ -95,7 +47,7 @@ _start:
## tocbase = .got+0x8000 = 0x10028208
# DATALE-LABEL: section '.R_PPC64_TOC':
-# DATALE: 08820210 00000000
+# DATALE-NEXT: e8810210 00000000
# DATABE-LABEL: section '.R_PPC64_TOC':
-# DATABE: 00000000 10028208
+# DATABE-NEXT: 00000000 100281e8
More information about the llvm-branch-commits
mailing list