[lld] r239614 - [Mips] Define _gpxxx symbols in both static/dynamic linking modes
Simon Atanasyan
simon at atanasyan.com
Fri Jun 12 09:13:02 PDT 2015
Author: atanasyan
Date: Fri Jun 12 11:13:00 2015
New Revision: 239614
URL: http://llvm.org/viewvc/llvm-project?rev=239614&view=rev
Log:
[Mips] Define _gpxxx symbols in both static/dynamic linking modes
Added:
lld/trunk/test/elf/Mips/static-01.test
Modified:
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp?rev=239614&r1=239613&r2=239614&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsELFWriters.cpp Fri Jun 12 11:13:00 2015
@@ -49,9 +49,6 @@ void MipsELFWriter<ELFT>::setELFHeader(E
template <class ELFT>
void MipsELFWriter<ELFT>::finalizeMipsRuntimeAtomValues() {
- if (!_ctx.isDynamic())
- return;
-
auto gotSection = _targetLayout.findOutputSection(".got");
auto got = gotSection ? gotSection->virtualAddr() : 0;
auto gp = gotSection ? got + _targetLayout.getGPOffset() : 0;
@@ -64,12 +61,11 @@ void MipsELFWriter<ELFT>::finalizeMipsRu
template <class ELFT>
std::unique_ptr<RuntimeFile<ELFT>> MipsELFWriter<ELFT>::createRuntimeFile() {
auto file = llvm::make_unique<RuntimeFile<ELFT>>(_ctx, "Mips runtime file");
- if (_ctx.isDynamic()) {
- file->addAbsoluteAtom("_gp");
- file->addAbsoluteAtom("_gp_disp");
- file->addAbsoluteAtom("__gnu_local_gp");
+ file->addAbsoluteAtom("_gp");
+ file->addAbsoluteAtom("_gp_disp");
+ file->addAbsoluteAtom("__gnu_local_gp");
+ if (_ctx.isDynamic())
file->addAtom(*new (file->allocator()) MipsDynamicAtom(*file));
- }
return file;
}
Added: lld/trunk/test/elf/Mips/static-01.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/Mips/static-01.test?rev=239614&view=auto
==============================================================================
--- lld/trunk/test/elf/Mips/static-01.test (added)
+++ lld/trunk/test/elf/Mips/static-01.test Fri Jun 12 11:13:00 2015
@@ -0,0 +1,119 @@
+# Check handling relocations against _gp/__gnu_local_gp symbols
+# in case of "-static" linking.
+
+# RUN: yaml2obj -format=elf -docnum 1 %s > %t1.o
+# RUN: yaml2obj -format=elf -docnum 2 %s > %t2.o
+# RUN: lld -flavor gnu -target mipsel -e T0 -static -o %t.exe %t1.o %t2.o
+# RUN: llvm-nm %t.exe | FileCheck %s
+
+# CHECK: 00401000 ? _GLOBAL_OFFSET_TABLE_
+# CHECK: 00408ff0 A __gnu_local_gp
+# CHECK: 00408ff0 A _gp
+# CHECK: 00408ff0 A _gp_disp
+
+# o1.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
+
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 16
+ Size: 28
+
+ - Name: .rel.text
+ Type: SHT_REL
+ Link: .symtab
+ AddressAlign: 4
+ Info: .text
+ Relocations:
+ - Offset: 0
+ Symbol: .data
+ Type: R_MIPS_HI16
+ - Offset: 4
+ Symbol: .data
+ Type: R_MIPS_LO16
+ - Offset: 8
+ Symbol: T1
+ Type: R_MIPS_26
+ - Offset: 12
+ Symbol: _gp
+ Type: R_MIPS_HI16
+ - Offset: 16
+ Symbol: _gp
+ Type: R_MIPS_LO16
+ - Offset: 20
+ Symbol: __gnu_local_gp
+ Type: R_MIPS_HI16
+ - Offset: 24
+ Symbol: __gnu_local_gp
+ Type: R_MIPS_LO16
+
+ - Name: .data
+ Type: SHT_PROGBITS
+ Flags: [ SHF_WRITE, SHF_ALLOC ]
+ AddressAlign: 16
+ Size: 4
+
+ - Name: .pdr
+ Type: SHT_PROGBITS
+ AddressAlign: 4
+ Size: 4
+
+ - Name: .rel.pdr
+ Type: SHT_REL
+ Link: .symtab
+ AddressAlign: 4
+ Info: .pdr
+ Relocations:
+ - Offset: 0
+ Symbol: T0
+ Type: R_MIPS_32
+
+Symbols:
+ Local:
+ - Type: STT_SECTION
+ Section: .text
+ - Type: STT_SECTION
+ Section: .data
+ - Type: STT_SECTION
+ Section: .pdr
+
+ Global:
+ - Name: T0
+ Type: STT_FUNC
+ Section: .text
+ Size: 28
+ - Name: T1
+ - Name: _gp
+ - Name: __gnu_local_gp
+
+# o2.o
+---
+FileHeader:
+ Class: ELFCLASS32
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_MIPS
+ Flags: [EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
+
+Sections:
+ - Name: .text
+ Type: SHT_PROGBITS
+ Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
+ AddressAlign: 16
+ Size: 4
+
+Symbols:
+ Global:
+ - Name: T1
+ Type: STT_FUNC
+ Section: .text
+ Size: 20
+...
More information about the llvm-commits
mailing list