[llvm-branch-commits] [llvm] 425d15a - [ELF][PowerPC] Support R_PPC_COPY and R_PPC64_COPY
Fangrui Song via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jan 24 09:11:30 PST 2020
Author: Fangrui Song
Date: 2020-01-24T09:06:52-08:00
New Revision: 425d15aeb13e2f60867654dd1abab515447a71ec
URL: https://github.com/llvm/llvm-project/commit/425d15aeb13e2f60867654dd1abab515447a71ec
DIFF: https://github.com/llvm/llvm-project/commit/425d15aeb13e2f60867654dd1abab515447a71ec.diff
LOG: [ELF][PowerPC] Support R_PPC_COPY and R_PPC64_COPY
Reviewed By: Bdragon28, jhenderson, grimar, sfertile
Differential Revision: https://reviews.llvm.org/D73255
(cherry picked from commit f1dab29908d25a4044abff6ffc120c48b20f034d)
Added:
lld/test/ELF/ppc-reloc-copy.s
Modified:
lld/ELF/Arch/PPC.cpp
lld/ELF/Arch/PPC64.cpp
llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC64.def
llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-ppc64.test
Removed:
################################################################################
diff --git a/lld/ELF/Arch/PPC.cpp b/lld/ELF/Arch/PPC.cpp
index 3c0b0c290b58..1d4e80184dcd 100644
--- a/lld/ELF/Arch/PPC.cpp
+++ b/lld/ELF/Arch/PPC.cpp
@@ -136,6 +136,7 @@ void writePPC32GlinkSection(uint8_t *buf, size_t numEntries) {
}
PPC::PPC() {
+ copyRel = R_PPC_COPY;
gotRel = R_PPC_GLOB_DAT;
noneRel = R_PPC_NONE;
pltRel = R_PPC_JMP_SLOT;
diff --git a/lld/ELF/Arch/PPC64.cpp b/lld/ELF/Arch/PPC64.cpp
index da77a4ddaddf..e48a184c9db2 100644
--- a/lld/ELF/Arch/PPC64.cpp
+++ b/lld/ELF/Arch/PPC64.cpp
@@ -293,6 +293,7 @@ static uint32_t readFromHalf16(const uint8_t *loc) {
}
PPC64::PPC64() {
+ copyRel = R_PPC64_COPY;
gotRel = R_PPC64_GLOB_DAT;
noneRel = R_PPC64_NONE;
pltRel = R_PPC64_JMP_SLOT;
diff --git a/lld/test/ELF/ppc-reloc-copy.s b/lld/test/ELF/ppc-reloc-copy.s
new file mode 100644
index 000000000000..1f169e40d375
--- /dev/null
+++ b/lld/test/ELF/ppc-reloc-copy.s
@@ -0,0 +1,29 @@
+# REQUIRES: ppc
+# RUN: llvm-mc -filetype=obj -triple=powerpc %p/Inputs/relocation-copy.s -o %t1.32.o
+# RUN: ld.lld -shared %t1.32.o -soname=so -o %t1.32.so
+# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.32.o
+# RUN: ld.lld %t.32.o %t1.32.so -o %t.32
+# RUN: llvm-readobj -r %t.32 | FileCheck --check-prefix=REL32 %s
+# RUN: llvm-nm -S %t.32 | FileCheck --check-prefix=NM32 %s
+
+# RUN: llvm-mc -filetype=obj -triple=powerpc64 %p/Inputs/relocation-copy.s -o %t1.64.o
+# RUN: ld.lld -shared %t1.64.o -soname=so -o %t1.64.so
+# RUN: llvm-mc -filetype=obj -triple=powerpc64 %s -o %t.64.o
+# RUN: ld.lld %t.64.o %t1.64.so -o %t.64
+# RUN: llvm-readobj -r %t.64 | FileCheck --check-prefix=REL64 %s
+# RUN: llvm-nm -S %t.64 | FileCheck --check-prefix=NM64 %s
+
+# REL32: .rela.dyn {
+# REL32-NEXT: 0x10030210 R_PPC_COPY x 0x0
+# REL32-NEXT: }
+
+# NM32: 10030210 00000004 B x
+
+# REL64: .rela.dyn {
+# REL64-NEXT: 0x10030350 R_PPC64_COPY x 0x0
+# REL64-NEXT: }
+
+# NM64: 0000000010030350 0000000000000004 B x
+
+lis 3, x at ha
+lwz 3, x at l(3)
diff --git a/llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC64.def b/llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC64.def
index 8c5b482f0511..719d0c9c36ac 100644
--- a/llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC64.def
+++ b/llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC64.def
@@ -26,6 +26,7 @@
#undef R_PPC64_GOT16_LO
#undef R_PPC64_GOT16_HI
#undef R_PPC64_GOT16_HA
+#undef R_PPC64_COPY
#undef R_PPC64_GLOB_DAT
#undef R_PPC64_JMP_SLOT
#undef R_PPC64_RELATIVE
@@ -119,6 +120,7 @@ ELF_RELOC(R_PPC64_GOT16, 14)
ELF_RELOC(R_PPC64_GOT16_LO, 15)
ELF_RELOC(R_PPC64_GOT16_HI, 16)
ELF_RELOC(R_PPC64_GOT16_HA, 17)
+ELF_RELOC(R_PPC64_COPY, 19)
ELF_RELOC(R_PPC64_GLOB_DAT, 20)
ELF_RELOC(R_PPC64_JMP_SLOT, 21)
ELF_RELOC(R_PPC64_RELATIVE, 22)
diff --git a/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-ppc64.test b/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-ppc64.test
index 7e081b7e4e22..3a00dafb7367 100644
--- a/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-ppc64.test
+++ b/llvm/test/tools/llvm-readobj/ELF/reloc-types-elf-ppc64.test
@@ -22,6 +22,7 @@
# CHECK: Type: R_PPC64_GOT16_LO (15)
# CHECK: Type: R_PPC64_GOT16_HI (16)
# CHECK: Type: R_PPC64_GOT16_HA (17)
+# CHECK: Type: R_PPC64_COPY (19)
# CHECK: Type: R_PPC64_GLOB_DAT (20)
# CHECK: Type: R_PPC64_JMP_SLOT (21)
# CHECK: Type: R_PPC64_RELATIVE (22)
@@ -143,6 +144,8 @@ Sections:
Type: R_PPC64_GOT16_HI
- Offset: 0x0000000000000000
Type: R_PPC64_GOT16_HA
+ - Offset: 0x0000000000000000
+ Type: R_PPC64_COPY
- Offset: 0x0000000000000000
Type: R_PPC64_GLOB_DAT
- Offset: 0x0000000000000000
More information about the llvm-branch-commits
mailing list