[lld] r266037 - Devide _gp in the same spot as other mips symbols. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 11 19:24:43 PDT 2016
Author: rafael
Date: Mon Apr 11 21:24:43 2016
New Revision: 266037
URL: http://llvm.org/viewvc/llvm-project?rev=266037&view=rev
Log:
Devide _gp in the same spot as other mips symbols. NFC.
The test changes are just because of the symbol order.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/duplicate-internal.s
lld/trunk/test/ELF/mips-dynamic.s
lld/trunk/test/ELF/mips-got-relocs.s
lld/trunk/test/ELF/mips-hilo-gp-disp.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=266037&r1=266036&r2=266037&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Apr 11 21:24:43 2016
@@ -415,14 +415,6 @@ template <class ELFT> void LinkerDriver:
Config->EntrySym = Symtab.addUndefined(S);
}
- if (Config->EMachine == EM_MIPS) {
- // Define _gp for MIPS. st_value of _gp symbol will be updated by Writer
- // so that it points to an absolute address which is relative to GOT.
- // See "Global Data Symbols" in Chapter 6 in the following document:
- // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
- ElfSym<ELFT>::MipsGp = Symtab.addAbsolute("_gp", STV_DEFAULT);
- }
-
for (std::unique_ptr<InputFile> &F : Files)
Symtab.addFile(std::move(F));
if (HasError)
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=266037&r1=266036&r2=266037&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Apr 11 21:24:43 2016
@@ -928,6 +928,12 @@ OutputSectionFactory<ELFT>::createKey(In
// the linking result. This function defines such symbols.
template <class ELFT> void Writer<ELFT>::addReservedSymbols() {
if (Config->EMachine == EM_MIPS) {
+ // Define _gp for MIPS. st_value of _gp symbol will be updated by Writer
+ // so that it points to an absolute address which is relative to GOT.
+ // See "Global Data Symbols" in Chapter 6 in the following document:
+ // ftp://www.linux-mips.org/pub/linux/mips/doc/ABI/mipsabi.pdf
+ ElfSym<ELFT>::MipsGp = Symtab.addAbsolute("_gp", STV_DEFAULT);
+
// On MIPS O32 ABI, _gp_disp is a magic symbol designates offset between
// start of function and 'gp' pointer into GOT.
ElfSym<ELFT>::MipsGpDisp = Symtab.addIgnored("_gp_disp");
Modified: lld/trunk/test/ELF/duplicate-internal.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/duplicate-internal.s?rev=266037&r1=266036&r2=266037&view=diff
==============================================================================
--- lld/trunk/test/ELF/duplicate-internal.s (original)
+++ lld/trunk/test/ELF/duplicate-internal.s Mon Apr 11 21:24:43 2016
@@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
# RUN: not ld.lld -shared %t.o -o %t.so 2>&1 | FileCheck %s
-# CHECK: duplicate symbol: _gp in (internal) and {{.*}}
+# CHECK: duplicate symbol: _gp in {{.*}} and (internal)
# REQUIRES: mips
Modified: lld/trunk/test/ELF/mips-dynamic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-dynamic.s?rev=266037&r1=266036&r2=266037&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-dynamic.s (original)
+++ lld/trunk/test/ELF/mips-dynamic.s Mon Apr 11 21:24:43 2016
@@ -71,9 +71,9 @@
# DSO: ]
# DSO: DynamicSymbols [
# DSO: Name: @
-# DSO: Name: _gp@
# DSO: Name: __start@
# DSO: Name: _foo@
+# DSO: Name: _gp@
# DSO: ]
# DSO: DynamicSection [
# DSO-NEXT: Tag Type Name/Value
Modified: lld/trunk/test/ELF/mips-got-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-got-relocs.s?rev=266037&r1=266036&r2=266037&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-got-relocs.s (original)
+++ lld/trunk/test/ELF/mips-got-relocs.s Mon Apr 11 21:24:43 2016
@@ -47,9 +47,10 @@ v1:
# EXE_SYM: Sections:
# EXE_SYM: .got 0000000c 0000000000030000 DATA
# EXE_SYM: SYMBOL TABLE:
+# EXE_SYM: 00040000 g .data 00000004 v1
# EXE_SYM: 00037ff0 *ABS* 00000000 _gp
# ^-- .got + GP offset (0x7ff0)
-# EXE_SYM: 00040000 g .data 00000004 v1
+
# EXE_GOT_BE: Contents of section .got:
# EXE_GOT_BE: 30000 00000000 80000000 00040000
@@ -70,9 +71,9 @@ v1:
# DSO_SYM: Sections:
# DSO_SYM: .got 0000000c 0000000000020000 DATA
# DSO_SYM: SYMBOL TABLE:
+# DSO_SYM: 00030000 g .data 00000004 v1
# DSO_SYM: 00027ff0 *ABS* 00000000 _gp
# ^-- .got + GP offset (0x7ff0)
-# DSO_SYM: 00030000 g .data 00000004 v1
# DSO_GOT_BE: Contents of section .got:
# DSO_GOT_BE: 20000 00000000 80000000 00030000
Modified: lld/trunk/test/ELF/mips-hilo-gp-disp.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-hilo-gp-disp.s?rev=266037&r1=266036&r2=266037&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-hilo-gp-disp.s (original)
+++ lld/trunk/test/ELF/mips-hilo-gp-disp.s Mon Apr 11 21:24:43 2016
@@ -26,8 +26,8 @@ __start:
# EXE: SYMBOL TABLE:
# EXE: 00020000 .text 00000000 __start
-# EXE: 00037ff0 *ABS* 00000000 _gp
# EXE: 00020010 .text 00000000 _foo
+# EXE: 00037ff0 *ABS* 00000000 _gp
# SO: Disassembly of section .text:
# SO-NEXT: __start:
@@ -37,6 +37,6 @@ __start:
# ^-- %lo(0x27ff0-0x10004+4)
# SO: SYMBOL TABLE:
-# SO: 00027ff0 *ABS* 00000000 _gp
# SO: 00010000 .text 00000000 __start
# SO: 00010010 .text 00000000 _foo
+# SO: 00027ff0 *ABS* 00000000 _gp
More information about the llvm-commits
mailing list