[lld] r324467 - [ELF][MIPS] Ignore incorrect version definition index for _gp_disp symbol
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 02:02:49 PST 2018
Author: atanasyan
Date: Wed Feb 7 02:02:49 2018
New Revision: 324467
URL: http://llvm.org/viewvc/llvm-project?rev=324467&view=rev
Log:
[ELF][MIPS] Ignore incorrect version definition index for _gp_disp symbol
MIPS BFD linker puts _gp_disp symbol into DSO files and assigns zero
version definition index to it. This value means 'unversioned local
symbol' while _gp_disp is a section global symbol. We have to handle
this bug in the LLD because BFD linker is used for building MIPS
toolchain libraries.
Differential revision: https://reviews.llvm.org/D42486
Added:
lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.s
lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.so (with props)
lld/trunk/test/ELF/mips-gp-disp-ver.s
Modified:
lld/trunk/ELF/InputFiles.cpp
Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=324467&r1=324466&r2=324467&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Feb 7 02:02:49 2018
@@ -862,6 +862,14 @@ template <class ELFT> void SharedFile<EL
continue;
}
+ if (Config->EMachine == EM_MIPS) {
+ // FIXME: MIPS BFD linker puts _gp_disp symbol into DSO files
+ // and incorrectly assigns VER_NDX_LOCAL to this section global
+ // symbol. Here is a workaround for this bug.
+ if (Versym && VersymIndex == VER_NDX_LOCAL && Name == "_gp_disp")
+ continue;
+ }
+
const Elf_Verdef *Ver = nullptr;
if (VersymIndex != VER_NDX_GLOBAL) {
if (VersymIndex >= Verdefs.size() || VersymIndex == VER_NDX_LOCAL) {
Added: lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.s?rev=324467&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.s (added)
+++ lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.s Wed Feb 7 02:02:49 2018
@@ -0,0 +1,14 @@
+# Source file for mips-gp-dips-corrupt-ver.so
+#
+# % cat gpdisp.ver
+# LLD_1.0.0 { global: foo; };
+#
+# % as mips-gp-dips-corrupt-ver.s -o mips-gp-dips-corrupt-ver.o
+# % ld -shared -o mips-gp-dips-corrupt-ver.so \
+# --version-script gpdisp.ver mips-gp-dips-corrupt-ver.o
+
+ .global foo
+ .text
+foo:
+ lui $t0, %hi(_gp_disp)
+ addi $t0, $t0, %lo(_gp_disp)
Added: lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.so
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.so?rev=324467&view=auto
==============================================================================
Binary files lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.so (added) and lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.so Wed Feb 7 02:02:49 2018 differ
Propchange: lld/trunk/test/ELF/Inputs/mips-gp-dips-corrupt-ver.so
------------------------------------------------------------------------------
svn:executable = *
Added: lld/trunk/test/ELF/mips-gp-disp-ver.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gp-disp-ver.s?rev=324467&view=auto
==============================================================================
--- lld/trunk/test/ELF/mips-gp-disp-ver.s (added)
+++ lld/trunk/test/ELF/mips-gp-disp-ver.s Wed Feb 7 02:02:49 2018
@@ -0,0 +1,13 @@
+# MIPS BFD linker puts _gp_disp symbol into DSO files and assigns zero
+# version definition index to it. This value means 'unversioned local symbol'
+# while _gp_disp is a section global symbol. We have to handle this bug
+# in the LLD because BFD linker is used for building MIPS toolchain
+# libraries. This test checks such handling.
+
+# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o %S/Inputs/mips-gp-dips-corrupt-ver.so
+
+ .global __start
+ .text
+__start:
+ lw $t0, %got(foo)($gp)
More information about the llvm-commits
mailing list