[lld] r313333 - Don't make _gp absolute.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 14 18:49:01 PDT 2017
Author: rafael
Date: Thu Sep 14 18:49:01 2017
New Revision: 313333
URL: http://llvm.org/viewvc/llvm-project?rev=313333&view=rev
Log:
Don't make _gp absolute.
_gp points to a position in the file, so it is not really absolute. It
is also simpler to not force it to be absolute, so if there is no
strong ABI requirement we should not do it.
Modified:
lld/trunk/ELF/Writer.cpp
lld/trunk/test/ELF/basic-mips.s
lld/trunk/test/ELF/mips-64-gprel-so.s
lld/trunk/test/ELF/mips-64-rels.s
lld/trunk/test/ELF/mips-got-relocs.s
lld/trunk/test/ELF/mips-gp-disp.s
lld/trunk/test/ELF/mips-gp-local.s
lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s
lld/trunk/test/ELF/mips-gprel32-relocs.s
lld/trunk/test/ELF/mips-hilo-gp-disp.s
lld/trunk/test/ELF/mips-micro-relocs.s
lld/trunk/test/ELF/mips-n32-rels.s
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Thu Sep 14 18:49:01 2017
@@ -63,7 +63,6 @@ private:
void assignFileOffsetsBinary();
void setPhdrs();
void fixSectionAlignments();
- void makeMipsGpAbs();
void openFile();
void writeTrapInstr();
void writeHeader();
@@ -216,8 +215,6 @@ template <class ELFT> void Writer<ELFT>:
if (Config->Relocatable) {
for (OutputSection *Sec : OutputSections)
Sec->Addr = 0;
- } else {
- makeMipsGpAbs();
}
// It does not make sense try to open the file if we have error already.
@@ -1774,14 +1771,6 @@ static uint16_t getELFType() {
return ET_EXEC;
}
-// For some reason we have to make the mips gp symbol absolute.
-template <class ELFT> void Writer<ELFT>::makeMipsGpAbs() {
- if (ElfSym::MipsGp && ElfSym::MipsGp->Section) {
- ElfSym::MipsGp->Value += cast<OutputSection>(ElfSym::MipsGp->Section)->Addr;
- ElfSym::MipsGp->Section = nullptr;
- }
-}
-
template <class ELFT> void Writer<ELFT>::writeHeader() {
uint8_t *Buf = Buffer->getBufferStart();
memcpy(Buf, "\177ELF", 4);
Modified: lld/trunk/test/ELF/basic-mips.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/basic-mips.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/basic-mips.s (original)
+++ lld/trunk/test/ELF/basic-mips.s Thu Sep 14 18:49:01 2017
@@ -228,7 +228,7 @@ __start:
# CHECK-NEXT: Other [ (0x2)
# CHECK-NEXT: STV_HIDDEN (0x2)
# CHECK-NEXT: ]
-# CHECK-NEXT: Section: Absolute
+# CHECK-NEXT: Section: .got
# CHECK-NEXT: }
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name: __start
Modified: lld/trunk/test/ELF/mips-64-gprel-so.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-64-gprel-so.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-64-gprel-so.s (original)
+++ lld/trunk/test/ELF/mips-64-gprel-so.s Thu Sep 14 18:49:01 2017
@@ -12,7 +12,7 @@
# CHECK-NEXT: 10004: 03 99 e0 2d daddu $gp, $gp, $25
# CHECK-NEXT: 10008: 67 9c 7f f0 daddiu $gp, $gp, 32752
-# CHECK: 0000000000027ff0 *ABS* 00000000 .hidden _gp
+# CHECK: 0000000000027ff0 .got 00000000 .hidden _gp
# CHECK: 0000000000010000 .text 00000000 foo
.text
Modified: lld/trunk/test/ELF/mips-64-rels.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-64-rels.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-64-rels.s (original)
+++ lld/trunk/test/ELF/mips-64-rels.s Thu Sep 14 18:49:01 2017
@@ -24,7 +24,7 @@
# ^-- 0x20004 - 0x37ff0 = 0xfffffffffffe8014
# CHECK: 0000000000020004 .text 00000000 loc
-# CHECK: 0000000000037ff0 *ABS* 00000000 .hidden _gp
+# CHECK: 0000000000037ff0 .got 00000000 .hidden _gp
# CHECK: 0000000000020000 .text 00000000 __start
# REL: Relocations [
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=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-got-relocs.s (original)
+++ lld/trunk/test/ELF/mips-got-relocs.s Thu Sep 14 18:49:01 2017
@@ -47,7 +47,7 @@ v1:
# EXE_SYM: Sections:
# EXE_SYM: .got 0000000c 0000000000030010 DATA
# EXE_SYM: SYMBOL TABLE:
-# EXE_SYM: 00038000 *ABS* 00000000 .hidden _gp
+# EXE_SYM: 00038000 .got 00000000 .hidden _gp
# ^-- .got + GP offset (0x7ff0)
# EXE_SYM: 00030000 g .data 00000004 v1
@@ -71,7 +71,7 @@ v1:
# DSO_SYM: Sections:
# DSO_SYM: .got 0000000c 0000000000020010 DATA
# DSO_SYM: SYMBOL TABLE:
-# DSO_SYM: 00028000 *ABS* 00000000 .hidden _gp
+# DSO_SYM: 00028000 .got 00000000 .hidden _gp
# ^-- .got + GP offset (0x7ff0)
# DSO_SYM: 00020000 g .data 00000004 v1
Modified: lld/trunk/test/ELF/mips-gp-disp.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gp-disp.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gp-disp.s (original)
+++ lld/trunk/test/ELF/mips-gp-disp.s Thu Sep 14 18:49:01 2017
@@ -24,7 +24,7 @@
# DIS-NEXT: 10000: 3c 08 00 01 lui $8, 1
# DIS-NEXT: 10004: 21 08 7f f0 addi $8, $8, 32752
# ^-- 0x37ff0 & 0xffff
-# DIS: 00027ff0 *ABS* 00000000 .hidden _gp
+# DIS: 00027ff0 .got 00000000 .hidden _gp
# REL: Relocations [
# REL-NEXT: ]
Modified: lld/trunk/test/ELF/mips-gp-local.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gp-local.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gp-local.s (original)
+++ lld/trunk/test/ELF/mips-gp-local.s Thu Sep 14 18:49:01 2017
@@ -11,7 +11,7 @@
# CHECK-NEXT: 20000: 3c 08 00 03 lui $8, 3
# CHECK-NEXT: 20004: 21 08 7f f0 addi $8, $8, 32752
-# CHECK: 00037ff0 *ABS* 00000000 .hidden _gp
+# CHECK: 00037ff0 .got 00000000 .hidden _gp
.text
.globl __start
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=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s (original)
+++ lld/trunk/test/ELF/mips-gprel32-relocs-gp0.s Thu Sep 14 18:49:01 2017
@@ -29,7 +29,7 @@
# DUMP: SYMBOL TABLE:
# DUMP: 00010008 .text 00000000 bar
# DUMP: 00010004 .text 00000000 foo
-# DUMP: 00027ff0 *ABS* 00000000 .hidden _gp
+# DUMP: 00027ff0 .got 00000000 .hidden _gp
# ERR: error: {{.*}}mips-gp0-non-zero.o: unsupported non-zero ri_gp_value
Modified: lld/trunk/test/ELF/mips-gprel32-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-gprel32-relocs.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-gprel32-relocs.s (original)
+++ lld/trunk/test/ELF/mips-gprel32-relocs.s Thu Sep 14 18:49:01 2017
@@ -28,4 +28,4 @@ v1:
# CHECK: SYMBOL TABLE:
# CHECK: 00010008 .text 00000000 bar
# CHECK: 00010004 .text 00000000 foo
-# CHECK: 00027ff0 *ABS* 00000000 .hidden _gp
+# CHECK: 00027ff0 .got 00000000 .hidden _gp
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=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-hilo-gp-disp.s (original)
+++ lld/trunk/test/ELF/mips-hilo-gp-disp.s Thu Sep 14 18:49:01 2017
@@ -34,7 +34,7 @@ bar:
# EXE: SYMBOL TABLE:
# EXE: 0002000c .text 00000000 bar
-# EXE: 00038000 *ABS* 00000000 .hidden _gp
+# EXE: 00038000 .got 00000000 .hidden _gp
# EXE: 00020000 .text 00000000 __start
# SO: Disassembly of section .text:
@@ -51,5 +51,5 @@ bar:
# SO: SYMBOL TABLE:
# SO: 0001000c .text 00000000 bar
-# SO: 00028000 *ABS* 00000000 .hidden _gp
+# SO: 00028000 .got 00000000 .hidden _gp
# SO: 00010000 .text 00000000 __start
Modified: lld/trunk/test/ELF/mips-micro-relocs.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-micro-relocs.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-micro-relocs.s (original)
+++ lld/trunk/test/ELF/mips-micro-relocs.s Thu Sep 14 18:49:01 2017
@@ -54,7 +54,7 @@
# FIXME-EL-NEXT: 20028: 00 00 00 00 nop
# FIXME-EL-NEXT: 2002c: 00 94 e8 ff b -44
-# SYM: 00037ff0 *ABS* 00000000 .hidden _gp
+# SYM: 00037ff0 .got 00000000 .hidden _gp
# SYM: 00020000 g F .text 00000000 foo
# SYM: 00020010 .text 00000000 __start
Modified: lld/trunk/test/ELF/mips-n32-rels.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/mips-n32-rels.s?rev=313333&r1=313332&r2=313333&view=diff
==============================================================================
--- lld/trunk/test/ELF/mips-n32-rels.s (original)
+++ lld/trunk/test/ELF/mips-n32-rels.s Thu Sep 14 18:49:01 2017
@@ -42,7 +42,7 @@
# ^-- loc
# CHECK: 00020004 .text 00000000 loc
-# CHECK: 00037ff0 *ABS* 00000000 .hidden _gp
+# CHECK: 00037ff0 .got 00000000 .hidden _gp
# CHECK: 00020000 g F .text 00000000 __start
# ELF: Format: ELF32-mips
More information about the llvm-commits
mailing list