diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-04-12 02:24:43 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-04-12 02:24:43 +0000 |
commit | 9b3f99e50f5aff081352f362c1923e2dd3ed3aaf (patch) | |
tree | ee1fda4fd48d9698b646599b85c10986e6ab5a90 | |
parent | 58e3269aa509ca6d48abb697a408e0233a25b525 (diff) | |
download | bcm5719-llvm-9b3f99e50f5aff081352f362c1923e2dd3ed3aaf.tar.gz bcm5719-llvm-9b3f99e50f5aff081352f362c1923e2dd3ed3aaf.zip |
Devide _gp in the same spot as other mips symbols. NFC.
The test changes are just because of the symbol order.
llvm-svn: 266037
-rw-r--r-- | lld/ELF/Driver.cpp | 8 | ||||
-rw-r--r-- | lld/ELF/Writer.cpp | 6 | ||||
-rw-r--r-- | lld/test/ELF/duplicate-internal.s | 2 | ||||
-rw-r--r-- | lld/test/ELF/mips-dynamic.s | 2 | ||||
-rw-r--r-- | lld/test/ELF/mips-got-relocs.s | 5 | ||||
-rw-r--r-- | lld/test/ELF/mips-hilo-gp-disp.s | 4 |
6 files changed, 13 insertions, 14 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 1d15f142c8e..b5dcc871772 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -415,14 +415,6 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) { 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) diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 483c069bb9d..31cf3198e72 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -928,6 +928,12 @@ OutputSectionFactory<ELFT>::createKey(InputSectionBase<ELFT> *C, // 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"); diff --git a/lld/test/ELF/duplicate-internal.s b/lld/test/ELF/duplicate-internal.s index 2395a6cae0d..d1ccf532212 100644 --- a/lld/test/ELF/duplicate-internal.s +++ b/lld/test/ELF/duplicate-internal.s @@ -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 diff --git a/lld/test/ELF/mips-dynamic.s b/lld/test/ELF/mips-dynamic.s index cc5f233163c..bcb8e10244c 100644 --- a/lld/test/ELF/mips-dynamic.s +++ b/lld/test/ELF/mips-dynamic.s @@ -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 diff --git a/lld/test/ELF/mips-got-relocs.s b/lld/test/ELF/mips-got-relocs.s index 27180fbf82e..408a0853632 100644 --- a/lld/test/ELF/mips-got-relocs.s +++ b/lld/test/ELF/mips-got-relocs.s @@ -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 diff --git a/lld/test/ELF/mips-hilo-gp-disp.s b/lld/test/ELF/mips-hilo-gp-disp.s index ba05a5d1b3e..41d09b2b33a 100644 --- a/lld/test/ELF/mips-hilo-gp-disp.s +++ b/lld/test/ELF/mips-hilo-gp-disp.s @@ -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 |