[lld] r283194 - [ELF][MIPS] Do not accept non-zero GP0 value for relocatable object only
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 4 01:24:25 PDT 2016
Author: atanasyan
Date: Tue Oct 4 03:24:25 2016
New Revision: 283194
URL: http://llvm.org/viewvc/llvm-project?rev=283194&view=rev
Log:
[ELF][MIPS] Do not accept non-zero GP0 value for relocatable object only
Follow-up to r282716. Reject input files with non-zero GP0 value only in
case of relocatable object generation. In other case we can handle
arbitrary GP0 value so it does not have a sense to make the restriction
so wide.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=283194&r1=283193&r2=283194&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Oct 4 03:24:25 2016
@@ -665,7 +665,7 @@ MipsReginfoInputSection<ELFT>::MipsRegin
return;
}
Reginfo = reinterpret_cast<const Elf_Mips_RegInfo<ELFT> *>(Data.data());
- if (Reginfo->ri_gp_value)
+ if (Config->Relocatable && Reginfo->ri_gp_value)
error(getName(this) + ": unsupported non-zero ri_gp_value");
}
@@ -690,7 +690,7 @@ MipsOptionsInputSection<ELFT>::MipsOptio
auto *O = reinterpret_cast<const Elf_Mips_Options<ELFT> *>(D.data());
if (O->kind == ODK_REGINFO) {
Reginfo = &O->getRegInfo();
- if (Reginfo->ri_gp_value)
+ if (Config->Relocatable && Reginfo->ri_gp_value)
error(getName(this) + ": unsupported non-zero ri_gp_value");
break;
}
Modified: lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s?rev=283194&r1=283193&r2=283194&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s (original)
+++ lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s Tue Oct 4 03:24:25 2016
@@ -1,27 +1,30 @@
# Check that relocatable object produced by LLD has zero gp0 value.
-# Also check an error message if input object file has non-zero gp0 value.
+# Also check an error message if input object file has non-zero gp0 value
+# and the linker generates a relocatable object.
# mips-gp0-non-zero.o is a relocatable object produced from the asm code
# below and linked by GNU bfd linker.
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
-# RUN: ld.lld -r -o %t-r.o %t.o
-# RUN: ld.lld -shared -o %t.so %t-r.o
-# RUN: llvm-readobj -mips-reginfo %t-r.o %t.so | FileCheck %s
+# RUN: ld.lld -r -o %t-rel.o %t.o
+# RUN: llvm-readobj -mips-reginfo %t-rel.o | FileCheck --check-prefix=REL %s
+
+# RUN: ld.lld -shared -o %t.so %S/Inputs/mips-gp0-non-zero.o
+# RUN: llvm-readobj -mips-reginfo %t.so | FileCheck --check-prefix=DSO %s
# RUN: llvm-objdump -s -t %t.so | FileCheck --check-prefix=DUMP %s
-# RUN: not ld.lld -shared -o %t.so %S/Inputs/mips-gp0-non-zero.o 2>&1 \
+
+# RUN: not ld.lld -r -o %t-rel.o %S/Inputs/mips-gp0-non-zero.o 2>&1 \
# RUN: | FileCheck --check-prefix=ERR %s
# REQUIRES: mips
-# CHECK: {{.*}}mips-gprel32-relocs-gp0.s.tmp-r.o
-# CHECK: GP: 0x0
-# CHECK: {{.*}}mips-gprel32-relocs-gp0.s.tmp.so
-# CHECK: GP: 0x27FF0
+# REL: GP: 0x0
+
+# DSO: GP: 0x27FF0
# DUMP: Contents of section .rodata:
-# DUMP: 0114 fffe8014 fffe8018
-# ^ 0x10004 + 0 - 0x27ff0
-# ^ 0x10008 + 0 - 0x27ff0
+# DUMP: 0114 ffff0004 ffff0008
+# ^ 0x10004 + 0x7ff0 - 0x27ff0
+# ^ 0x10008 + 0x7ff0 - 0x27ff0
# DUMP: SYMBOL TABLE:
# DUMP: 00010008 .text 00000000 bar
More information about the llvm-commits
mailing list