aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-02-05 19:38:00 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-02-05 19:38:00 +0000
commita863509cdddf90a3ec3b23a5b2da6d65b68c4800 (patch)
tree3b7aece88aa1d94d3de2b633050e43f3fa030f05
parent63b9abd1dbe002d940a818f51dd9d6e585e41c84 (diff)
downloadsrc-vendor/lld/lld-release_40-r294123.tar.gz
src-vendor/lld/lld-release_40-r294123.zip
Vendor import of lld release_40 branch r294123:vendor/lld/lld-release_40-r294123
-rw-r--r--ELF/Config.h1
-rw-r--r--ELF/Driver.cpp2
-rw-r--r--ELF/Options.td13
-rw-r--r--ELF/Symbols.cpp2
-rw-r--r--ELF/SyntheticSections.cpp15
-rw-r--r--ELF/Writer.cpp14
-rw-r--r--test/ELF/basic-mips.s36
-rw-r--r--test/ELF/eh-frame-hdr-abs-fde.s6
-rw-r--r--test/ELF/mips-64-disp.s17
-rw-r--r--test/ELF/mips-64-got.s17
-rw-r--r--test/ELF/mips-64-rels.s2
-rw-r--r--test/ELF/mips-got-and-copy.s20
-rw-r--r--test/ELF/mips-got-extsym.s4
-rw-r--r--test/ELF/mips-got-hilo.s8
-rw-r--r--test/ELF/mips-got-redundant.s8
-rw-r--r--test/ELF/mips-got-relocs.s16
-rw-r--r--test/ELF/mips-got-weak.s24
-rw-r--r--test/ELF/mips-got16.s22
-rw-r--r--test/ELF/mips-gp-ext.s8
-rw-r--r--test/ELF/mips-gp-lowest.s6
-rw-r--r--test/ELF/mips-gprel32-relocs-gp0.s2
-rw-r--r--test/ELF/mips-gprel32-relocs.s2
-rw-r--r--test/ELF/mips-hilo-gp-disp.s30
-rw-r--r--test/ELF/mips-n32-rels.s2
-rw-r--r--test/ELF/mips-options.s4
-rw-r--r--test/ELF/mips-tls-64.s60
-rw-r--r--test/ELF/mips-tls-hilo.s4
-rw-r--r--test/ELF/mips-tls-static.s4
-rw-r--r--test/ELF/mips-tls.s68
-rw-r--r--test/ELF/mips-xgot-order.s4
-rw-r--r--test/ELF/relocatable-common.s36
31 files changed, 254 insertions, 203 deletions
diff --git a/ELF/Config.h b/ELF/Config.h
index b828cdb25047..b7706205a5b6 100644
--- a/ELF/Config.h
+++ b/ELF/Config.h
@@ -98,6 +98,7 @@ struct Configuration {
bool Bsymbolic;
bool BsymbolicFunctions;
bool ColorDiagnostics = false;
+ bool DefineCommon;
bool Demangle = true;
bool DisableVerify;
bool EhFrameHdr;
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
index b4544d78f725..50b701175d3e 100644
--- a/ELF/Driver.cpp
+++ b/ELF/Driver.cpp
@@ -496,6 +496,8 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) {
Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
Config->Relocatable = Args.hasArg(OPT_relocatable);
+ Config->DefineCommon = getArg(Args, OPT_define_common, OPT_no_define_common,
+ !Config->Relocatable);
Config->Discard = getDiscardOption(Args);
Config->SaveTemps = Args.hasArg(OPT_save_temps);
Config->SingleRoRx = Args.hasArg(OPT_no_rosegment);
diff --git a/ELF/Options.td b/ELF/Options.td
index d436f056d013..77ed4c7e466f 100644
--- a/ELF/Options.td
+++ b/ELF/Options.td
@@ -45,6 +45,9 @@ def color_diagnostics: F<"color-diagnostics">,
def color_diagnostics_eq: J<"color-diagnostics=">,
HelpText<"Use colors in diagnostics">;
+def define_common: F<"define-common">,
+ HelpText<"Assign space to common symbols">;
+
def disable_new_dtags: F<"disable-new-dtags">,
HelpText<"Disable new dynamic tags">;
@@ -130,6 +133,9 @@ def no_as_needed: F<"no-as-needed">,
def no_color_diagnostics: F<"no-color-diagnostics">,
HelpText<"Do not use colors in diagnostics">;
+def no_define_common: F<"no-define-common">,
+ HelpText<"Do not assign space to common symbols">;
+
def no_demangle: F<"no-demangle">,
HelpText<"Do not demangle symbol names">;
@@ -255,6 +261,9 @@ def alias_Bstatic_dn: F<"dn">, Alias<Bstatic>;
def alias_Bstatic_non_shared: F<"non_shared">, Alias<Bstatic>;
def alias_Bstatic_static: F<"static">, Alias<Bstatic>;
def alias_L__library_path: J<"library-path=">, Alias<L>;
+def alias_define_common_d: Flag<["-"], "d">, Alias<define_common>;
+def alias_define_common_dc: F<"dc">, Alias<define_common>;
+def alias_define_common_dp: F<"dp">, Alias<define_common>;
def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>;
def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>;
@@ -320,7 +329,6 @@ def plugin_opt_eq: J<"plugin-opt=">;
// Options listed below are silently ignored for now for compatibility.
def allow_shlib_undefined: F<"allow-shlib-undefined">;
def cref: Flag<["--"], "cref">;
-def define_common: F<"define-common">;
def demangle: F<"demangle">;
def detect_odr_violations: F<"detect-odr-violations">;
def g: Flag<["-"], "g">;
@@ -347,9 +355,6 @@ def G: JoinedOrSeparate<["-"], "G">;
def Qy : F<"Qy">;
// Aliases for ignored options
-def alias_define_common_d: Flag<["-"], "d">, Alias<define_common>;
-def alias_define_common_dc: F<"dc">, Alias<define_common>;
-def alias_define_common_dp: F<"dp">, Alias<define_common>;
def alias_Map_eq: J<"Map=">, Alias<Map>;
def alias_version_script_version_script: J<"version-script=">,
Alias<version_script>;
diff --git a/ELF/Symbols.cpp b/ELF/Symbols.cpp
index 0fe42be250cf..43af44ec4b84 100644
--- a/ELF/Symbols.cpp
+++ b/ELF/Symbols.cpp
@@ -73,6 +73,8 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body,
return VA;
}
case SymbolBody::DefinedCommonKind:
+ if (!Config->DefineCommon)
+ return 0;
return In<ELFT>::Common->OutSec->Addr + In<ELFT>::Common->OutSecOff +
cast<DefinedCommon>(Body).Offset;
case SymbolBody::SharedKind: {
diff --git a/ELF/SyntheticSections.cpp b/ELF/SyntheticSections.cpp
index 204b5993a62a..b673a4ece1d2 100644
--- a/ELF/SyntheticSections.cpp
+++ b/ELF/SyntheticSections.cpp
@@ -59,6 +59,9 @@ template <class ELFT> InputSection<ELFT> *elf::createCommonSection() {
ArrayRef<uint8_t>(), "COMMON");
Ret->Live = true;
+ if (!Config->DefineCommon)
+ return Ret;
+
// Sort the common symbols by alignment as an heuristic to pack them better.
std::vector<DefinedCommon *> Syms = getCommonSymbols<ELFT>();
std::stable_sort(Syms.begin(), Syms.end(),
@@ -434,7 +437,7 @@ template <class ELFT> void GotSection<ELFT>::writeTo(uint8_t *Buf) {
template <class ELFT>
MipsGotSection<ELFT>::MipsGotSection()
: SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL,
- SHT_PROGBITS, Target->GotEntrySize, ".got") {}
+ SHT_PROGBITS, 16, ".got") {}
template <class ELFT>
void MipsGotSection<ELFT>::addEntry(SymbolBody &Sym, uintX_t Addend,
@@ -1168,10 +1171,14 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *Buf) {
ESym->setVisibility(Body->symbol()->Visibility);
ESym->st_value = Body->getVA<ELFT>();
- if (const OutputSectionBase *OutSec = getOutputSection(Body))
+ if (const OutputSectionBase *OutSec = getOutputSection(Body)) {
ESym->st_shndx = OutSec->SectionIndex;
- else if (isa<DefinedRegular<ELFT>>(Body))
+ } else if (isa<DefinedRegular<ELFT>>(Body)) {
ESym->st_shndx = SHN_ABS;
+ } else if (isa<DefinedCommon>(Body)) {
+ ESym->st_shndx = SHN_COMMON;
+ ESym->st_value = cast<DefinedCommon>(Body)->Alignment;
+ }
if (Config->EMachine == EM_MIPS) {
// On MIPS we need to mark symbol which has a PLT entry and requires
@@ -1203,6 +1210,8 @@ SymbolTableSection<ELFT>::getOutputSection(SymbolBody *Sym) {
break;
}
case SymbolBody::DefinedCommonKind:
+ if (!Config->DefineCommon)
+ return nullptr;
return In<ELFT>::Common->OutSec;
case SymbolBody::SharedKind: {
auto &SS = cast<SharedSymbol<ELFT>>(*Sym);
diff --git a/ELF/Writer.cpp b/ELF/Writer.cpp
index f00fb6d11ea5..b004a4f0d7f7 100644
--- a/ELF/Writer.cpp
+++ b/ELF/Writer.cpp
@@ -476,6 +476,16 @@ static int getPPC64SectionRank(StringRef SectionName) {
.Default(1);
}
+// All sections with SHF_MIPS_GPREL flag should be grouped together
+// because data in these sections is addressable with a gp relative address.
+static int getMipsSectionRank(const OutputSectionBase *S) {
+ if ((S->Flags & SHF_MIPS_GPREL) == 0)
+ return 0;
+ if (S->getName() == ".got")
+ return 1;
+ return 2;
+}
+
template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {
if (!Config->ZRelro)
return false;
@@ -494,8 +504,6 @@ template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {
return true;
if (In<ELFT>::Got && Sec == In<ELFT>::Got->OutSec)
return true;
- if (In<ELFT>::MipsGot && Sec == In<ELFT>::MipsGot->OutSec)
- return true;
if (Sec == Out<ELFT>::BssRelRo)
return true;
StringRef S = Sec->getName();
@@ -595,6 +603,8 @@ static bool compareSectionsNonScript(const OutputSectionBase *A,
if (Config->EMachine == EM_PPC64)
return getPPC64SectionRank(A->getName()) <
getPPC64SectionRank(B->getName());
+ if (Config->EMachine == EM_MIPS)
+ return getMipsSectionRank(A) < getMipsSectionRank(B);
return false;
}
diff --git a/test/ELF/basic-mips.s b/test/ELF/basic-mips.s
index 57181caf4eaf..b143697ce0f8 100644
--- a/test/ELF/basic-mips.s
+++ b/test/ELF/basic-mips.s
@@ -35,7 +35,7 @@ __start:
# CHECK-NEXT: ]
# CHECK-NEXT: HeaderSize: 52
# CHECK-NEXT: ProgramHeaderEntrySize: 32
-# CHECK-NEXT: ProgramHeaderCount: 6
+# CHECK-NEXT: ProgramHeaderCount: 5
# CHECK-NEXT: SectionHeaderEntrySize: 40
# CHECK-NEXT: SectionHeaderCount: 11
# CHECK-NEXT: StringTableSectionIndex: 9
@@ -62,8 +62,8 @@ __start:
# CHECK-NEXT: Flags [ (0x2)
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x100F8
-# CHECK-NEXT: Offset: 0xF8
+# CHECK-NEXT: Address: 0x100D8
+# CHECK-NEXT: Offset: 0xD8
# CHECK-NEXT: Size: 24
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@@ -77,8 +77,8 @@ __start:
# CHECK-NEXT: Flags [ (0x2)
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x10110
-# CHECK-NEXT: Offset: 0x110
+# CHECK-NEXT: Address: 0x100F0
+# CHECK-NEXT: Offset: 0xF0
# CHECK-NEXT: Size: 24
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
@@ -131,7 +131,7 @@ __start:
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
-# CHECK-NEXT: AddressAlignment: 4
+# CHECK-NEXT: AddressAlignment: 16
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK-NEXT: Section {
@@ -142,7 +142,7 @@ __start:
# CHECK-NEXT: SHF_ALLOC (0x2)
# CHECK-NEXT: SHF_WRITE (0x1)
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0x40000
+# CHECK-NEXT: Address: 0x30010
# CHECK-NEXT: Offset: 0x20008
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Link: 0
@@ -246,8 +246,8 @@ __start:
# CHECK-NEXT: Offset: 0x34
# CHECK-NEXT: VirtualAddress: 0x10034
# CHECK-NEXT: PhysicalAddress: 0x10034
-# CHECK-NEXT: FileSize: 192
-# CHECK-NEXT: MemSize: 192
+# CHECK-NEXT: FileSize: 160
+# CHECK-NEXT: MemSize: 160
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -258,8 +258,8 @@ __start:
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x10000
# CHECK-NEXT: PhysicalAddress: 0x10000
-# CHECK-NEXT: FileSize: 296
-# CHECK-NEXT: MemSize: 296
+# CHECK-NEXT: FileSize: 264
+# CHECK-NEXT: MemSize: 264
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
@@ -284,7 +284,7 @@ __start:
# CHECK-NEXT: VirtualAddress: 0x30000
# CHECK-NEXT: PhysicalAddress: 0x30000
# CHECK-NEXT: FileSize: 8
-# CHECK-NEXT: MemSize: 65536
+# CHECK-NEXT: MemSize: 16
# CHECK-NEXT: Flags [
# CHECK-NEXT: PF_R
# CHECK-NEXT: PF_W
@@ -292,18 +292,6 @@ __start:
# CHECK-NEXT: Alignment: 65536
# CHECK-NEXT: }
# CHECK-NEXT: ProgramHeader {
-# CHECK-NEXT: Type: PT_GNU_RELRO (0x6474E552)
-# CHECK-NEXT: Offset: 0x20000
-# CHECK-NEXT: VirtualAddress: 0x30000
-# CHECK-NEXT: PhysicalAddress: 0x30000
-# CHECK-NEXT: FileSize: 8
-# CHECK-NEXT: MemSize: 65536
-# CHECK-NEXT: Flags [ (0x4)
-# CHECK-NEXT: PF_R (0x4)
-# CHECK-NEXT: ]
-# CHECK-NEXT: Alignment: 1
-# CHECK-NEXT: }
-# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_GNU_STACK
# CHECK-NEXT: Offset: 0x0
# CHECK-NEXT: VirtualAddress: 0x0
diff --git a/test/ELF/eh-frame-hdr-abs-fde.s b/test/ELF/eh-frame-hdr-abs-fde.s
index dd0836a0ab72..c3dc862ceb49 100644
--- a/test/ELF/eh-frame-hdr-abs-fde.s
+++ b/test/ELF/eh-frame-hdr-abs-fde.s
@@ -9,10 +9,10 @@
# REQUIRES: mips
# CHECK: Contents of section .eh_frame_hdr:
-# CHECK-NEXT: 10148 011b033b 00000010 00000001 0000feb8
-# ^-- 0x20000 - 0x10148
+# CHECK-NEXT: 10128 011b033b 00000010 00000001 0000fed8
+# ^-- 0x20000 - 0x10138
# .text - .eh_frame_hdr
-# CHECK-NEXT: 10158 0000002c
+# CHECK-NEXT: 10138 0000002c
# CHECK: Contents of section .text:
# CHECK-NEXT: 20000 00000000
diff --git a/test/ELF/mips-64-disp.s b/test/ELF/mips-64-disp.s
index 04dd743d0b56..29b62dcd050a 100644
--- a/test/ELF/mips-64-disp.s
+++ b/test/ELF/mips-64-disp.s
@@ -18,23 +18,22 @@
# CHECK-NEXT: 20010: 24 42 80 38 addiu $2, $2, -32712
# CHECK: 0000000000020014 .text 00000000 foo
-# CHECK: 0000000000047ff0 *ABS* 00000000 .hidden _gp
# CHECK: 0000000000020000 .text 00000000 __start
# CHECK: 0000000000000000 g F *UND* 00000000 foo1a
# GOT: Relocations [
# GOT-NEXT: ]
# GOT-NEXT: Primary GOT {
-# GOT-NEXT: Canonical gp value: 0x47FF0
+# GOT-NEXT: Canonical gp value:
# GOT-NEXT: Reserved entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40000
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32752
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Purpose: Lazy resolver
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40008
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32744
# GOT-NEXT: Initial: 0x8000000000000000
# GOT-NEXT: Purpose: Module pointer (GNU extension)
@@ -42,29 +41,29 @@
# GOT-NEXT: ]
# GOT-NEXT: Local entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40010
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32736
# GOT-NEXT: Initial: 0x20014
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40018
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32728
# GOT-NEXT: Initial: 0x20004
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40020
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32720
# GOT-NEXT: Initial: 0x20008
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40028
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32712
# GOT-NEXT: Initial: 0x2000C
# GOT-NEXT: }
# GOT-NEXT: ]
# GOT-NEXT: Global entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40030
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32704
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
diff --git a/test/ELF/mips-64-got.s b/test/ELF/mips-64-got.s
index 9bb45c57aa9f..f2b4d5b07ab5 100644
--- a/test/ELF/mips-64-got.s
+++ b/test/ELF/mips-64-got.s
@@ -19,23 +19,22 @@
# CHECK-NEXT: 20010: 24 42 80 38 addiu $2, $2, -32712
# CHECK: 0000000000020018 .text 00000000 foo
-# CHECK: 0000000000047ff0 *ABS* 00000000 .hidden _gp
# CHECK: 0000000000020000 .text 00000000 __start
# CHECK: 0000000000020014 .text 00000000 bar
# GOT: Relocations [
# GOT-NEXT: ]
# GOT-NEXT: Primary GOT {
-# GOT-NEXT: Canonical gp value: 0x47FF0
+# GOT-NEXT: Canonical gp value:
# GOT-NEXT: Reserved entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40000
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32752
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Purpose: Lazy resolver
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40008
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32744
# GOT-NEXT: Initial: 0x8000000000000000
# GOT-NEXT: Purpose: Module pointer (GNU extension)
@@ -43,29 +42,29 @@
# GOT-NEXT: ]
# GOT-NEXT: Local entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40010
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32736
# GOT-NEXT: Initial: 0x20000
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40018
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32728
# GOT-NEXT: Initial: 0x30000
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40020
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32720
# GOT-NEXT: Initial: 0x20014
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40028
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32712
# GOT-NEXT: Initial: 0x20018
# GOT-NEXT: }
# GOT-NEXT: ]
# GOT-NEXT: Global entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x40030
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32704
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
diff --git a/test/ELF/mips-64-rels.s b/test/ELF/mips-64-rels.s
index b9a3ee738485..93d893aacbde 100644
--- a/test/ELF/mips-64-rels.s
+++ b/test/ELF/mips-64-rels.s
@@ -20,7 +20,7 @@
# ^-- %lo(0x17ff0)
# CHECK: Contents of section .rodata:
-# CHECK-NEXT: 10190 ffffffff fffe8014
+# CHECK-NEXT: 10158 ffffffff fffe8014
# ^-- 0x20004 - 0x37ff0 = 0xfffffffffffe8014
# CHECK: 0000000000020004 .text 00000000 loc
diff --git a/test/ELF/mips-got-and-copy.s b/test/ELF/mips-got-and-copy.s
index 70bb8d388d86..4e3ca5f2804a 100644
--- a/test/ELF/mips-got-and-copy.s
+++ b/test/ELF/mips-got-and-copy.s
@@ -14,29 +14,29 @@
# CHECK: Relocations [
# CHECK-NEXT: Section (7) .rel.dyn {
-# CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data0
-# CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data1
+# CHECK-NEXT: 0x[[DATA0:[0-9A-F]+]] R_MIPS_COPY data0
+# CHECK-NEXT: 0x[[DATA1:[0-9A-F]+]] R_MIPS_COPY data1
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: Primary GOT {
-# CHECK-NEXT: Canonical gp value: 0x47FF0
+# CHECK-NEXT: Canonical gp value:
# CHECK-NEXT: Reserved entries [
# CHECK: ]
# CHECK-NEXT: Local entries [
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x40008
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32744
-# CHECK-NEXT: Initial: 0x50000
+# CHECK-NEXT: Initial: 0x[[DATA0]]
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: Global entries [
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x4000C
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32740
-# CHECK-NEXT: Initial: 0x50004
-# CHECK-NEXT: Value: 0x50004
-# CHECK-NEXT: Type: Object (0x1)
-# CHECK-NEXT: Section: .bss (0xD)
+# CHECK-NEXT: Initial: 0x[[DATA1]]
+# CHECK-NEXT: Value: 0x[[DATA1]]
+# CHECK-NEXT: Type: Object
+# CHECK-NEXT: Section: .bss
# CHECK-NEXT: Name: data1@
# CHECK-NEXT: }
# CHECK-NEXT: ]
diff --git a/test/ELF/mips-got-extsym.s b/test/ELF/mips-got-extsym.s
index f9d809c10097..3af4ba07b234 100644
--- a/test/ELF/mips-got-extsym.s
+++ b/test/ELF/mips-got-extsym.s
@@ -30,7 +30,7 @@
# CHECK: Local entries [
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x40008
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32744
# CHECK-NEXT: Initial: 0x20008
# ^-- bar
@@ -38,7 +38,7 @@
# CHECK-NEXT: ]
# CHECK-NEXT: Global entries [
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x4000C
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32740
# CHECK-NEXT: Initial: 0x0
# CHECK-NEXT: Value: 0x0
diff --git a/test/ELF/mips-got-hilo.s b/test/ELF/mips-got-hilo.s
index 26a198115168..fa7e752d9f91 100644
--- a/test/ELF/mips-got-hilo.s
+++ b/test/ELF/mips-got-hilo.s
@@ -20,22 +20,22 @@
# GOT-NEXT: ]
# GOT: Primary GOT {
-# GOT-NEXT: Canonical gp value: 0x37FF0
+# GOT-NEXT: Canonical gp value:
# GOT: Local entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x30008
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32744
# GOT-NEXT: Initial: 0x20000
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x3000C
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32740
# GOT-NEXT: Initial: 0x20004
# GOT-NEXT: }
# GOT-NEXT: ]
# GOT-NEXT: Global entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x30010
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32736
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
diff --git a/test/ELF/mips-got-redundant.s b/test/ELF/mips-got-redundant.s
index e734aa5b4524..b4c6a2b31a0e 100644
--- a/test/ELF/mips-got-redundant.s
+++ b/test/ELF/mips-got-redundant.s
@@ -8,25 +8,25 @@
# CHECK: Local entries [
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x40008
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32744
# CHECK-NEXT: Initial: 0x20000
# ^-- loc1
# CHECK-NEXT: }
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x4000C
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32740
# CHECK-NEXT: Initial: 0x30000
# ^-- loc2, loc3, loc4
# CHECK-NEXT: }
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x40010
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32736
# CHECK-NEXT: Initial: 0x40000
# ^-- redundant
# CHECK-NEXT: }
# CHECK-NEXT: Entry {
-# CHECK-NEXT: Address: 0x40014
+# CHECK-NEXT: Address:
# CHECK-NEXT: Access: -32732
# CHECK-NEXT: Initial: 0x30008
# ^-- glb1
diff --git a/test/ELF/mips-got-relocs.s b/test/ELF/mips-got-relocs.s
index bb4efd039fdc..4471bc210e2d 100644
--- a/test/ELF/mips-got-relocs.s
+++ b/test/ELF/mips-got-relocs.s
@@ -45,21 +45,21 @@ v1:
.word 0
# EXE_SYM: Sections:
-# EXE_SYM: .got 0000000c 0000000000040000 DATA
+# EXE_SYM: .got 0000000c 0000000000030010 DATA
# EXE_SYM: SYMBOL TABLE:
-# EXE_SYM: 00047ff0 *ABS* 00000000 .hidden _gp
+# EXE_SYM: 00038000 *ABS* 00000000 .hidden _gp
# ^-- .got + GP offset (0x7ff0)
# EXE_SYM: 00030000 g .data 00000004 v1
# EXE_GOT_BE: Contents of section .got:
-# EXE_GOT_BE: 40000 00000000 80000000 00030000
+# EXE_GOT_BE: 30010 00000000 80000000 00030000
# ^ ^ ^-- v1 (0x30000)
# | +-- Module pointer (0x80000000)
# +-- Lazy resolver (0x0)
# EXE_GOT_EL: Contents of section .got:
-# EXE_GOT_EL: 40000 00000000 00000080 00000300
+# EXE_GOT_EL: 30010 00000000 00000080 00000300
# ^ ^ ^-- v1 (0x30000)
# | +-- Module pointer (0x80000000)
# +-- Lazy resolver (0x0)
@@ -69,20 +69,20 @@ v1:
# EXE_DIS_EL: 20000: 18 80 02 3c lui $2, 32792
# DSO_SYM: Sections:
-# DSO_SYM: .got 0000000c 0000000000030000 DATA
+# DSO_SYM: .got 0000000c 0000000000020010 DATA
# DSO_SYM: SYMBOL TABLE:
-# DSO_SYM: 00037ff0 *ABS* 00000000 .hidden _gp
+# DSO_SYM: 00028000 *ABS* 00000000 .hidden _gp
# ^-- .got + GP offset (0x7ff0)
# DSO_SYM: 00020000 g .data 00000004 v1
# DSO_GOT_BE: Contents of section .got:
-# DSO_GOT_BE: 30000 00000000 80000000 00020000
+# DSO_GOT_BE: 20010 00000000 80000000 00020000
# ^ ^ ^-- v1 (0x20000)
# | +-- Module pointer (0x80000000)
# +-- Lazy resolver (0x0)
# DSO_GOT_EL: Contents of section .got:
-# DSO_GOT_EL: 30000 00000000 00000080 00000200
+# DSO_GOT_EL: 20010 00000000 00000080 00000200
# ^ ^ ^-- v1 (0x20000)
# | +-- Module pointer (0x80000000)
# +-- Lazy resolver (0x0)
diff --git a/test/ELF/mips-got-weak.s b/test/ELF/mips-got-weak.s
index f1faf7c3d2d7..e860bb482a2c 100644
--- a/test/ELF/mips-got-weak.s
+++ b/test/ELF/mips-got-weak.s
@@ -47,16 +47,16 @@
# NOSYM-NEXT: 0x70000013 MIPS_GOTSYM 0x1
# NOSYM: Primary GOT {
-# NOSYM-NEXT: Canonical gp value: 0x37FF0
+# NOSYM-NEXT: Canonical gp value:
# NOSYM-NEXT: Reserved entries [
# NOSYM-NEXT: Entry {
-# NOSYM-NEXT: Address: 0x30000
+# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32752
# NOSYM-NEXT: Initial: 0x0
# NOSYM-NEXT: Purpose: Lazy resolver
# NOSYM-NEXT: }
# NOSYM-NEXT: Entry {
-# NOSYM-NEXT: Address: 0x30004
+# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32748
# NOSYM-NEXT: Initial: 0x80000000
# NOSYM-NEXT: Purpose: Module pointer (GNU extension)
@@ -66,7 +66,7 @@
# NOSYM-NEXT: ]
# NOSYM-NEXT: Global entries [
# NOSYM-NEXT: Entry {
-# NOSYM-NEXT: Address: 0x30008
+# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32744
# NOSYM-NEXT: Initial: 0x20000
# NOSYM-NEXT: Value: 0x20000
@@ -75,7 +75,7 @@
# NOSYM-NEXT: Name: foo
# NOSYM-NEXT: }
# NOSYM-NEXT: Entry {
-# NOSYM-NEXT: Address: 0x3000C
+# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32740
# NOSYM-NEXT: Initial: 0x0
# NOSYM-NEXT: Value: 0x0
@@ -84,7 +84,7 @@
# NOSYM-NEXT: Name: bar
# NOSYM-NEXT: }
# NOSYM-NEXT: Entry {
-# NOSYM-NEXT: Address: 0x30010
+# NOSYM-NEXT: Address:
# NOSYM-NEXT: Access: -32736
# NOSYM-NEXT: Initial: 0x20004
# NOSYM-NEXT: Value: 0x20004
@@ -115,16 +115,16 @@
# SYM-NEXT: 0x70000013 MIPS_GOTSYM 0x3
# SYM: Primary GOT {
-# SYM-NEXT: Canonical gp value: 0x37FF0
+# SYM-NEXT: Canonical gp value:
# SYM-NEXT: Reserved entries [
# SYM-NEXT: Entry {
-# SYM-NEXT: Address: 0x30000
+# SYM-NEXT: Address:
# SYM-NEXT: Access: -32752
# SYM-NEXT: Initial: 0x0
# SYM-NEXT: Purpose: Lazy resolver
# SYM-NEXT: }
# SYM-NEXT: Entry {
-# SYM-NEXT: Address: 0x30004
+# SYM-NEXT: Address:
# SYM-NEXT: Access: -32748
# SYM-NEXT: Initial: 0x80000000
# SYM-NEXT: Purpose: Module pointer (GNU extension)
@@ -132,19 +132,19 @@
# SYM-NEXT: ]
# SYM-NEXT: Local entries [
# SYM-NEXT: Entry {
-# SYM-NEXT: Address: 0x30008
+# SYM-NEXT: Address:
# SYM-NEXT: Access: -32744
# SYM-NEXT: Initial: 0x20000
# SYM-NEXT: }
# SYM-NEXT: Entry {
-# SYM-NEXT: Address: 0x3000C
+# SYM-NEXT: Address:
# SYM-NEXT: Access: -32740
# SYM-NEXT: Initial: 0x20004
# SYM-NEXT: }
# SYM-NEXT: ]
# SYM-NEXT: Global entries [
# SYM-NEXT: Entry {
-# SYM-NEXT: Address: 0x30010
+# SYM-NEXT: Address:
# SYM-NEXT: Access: -32736
# SYM-NEXT: Initial: 0x0
# SYM-NEXT: Value: 0x0
diff --git a/test/ELF/mips-got16.s b/test/ELF/mips-got16.s
index b7e04ad93b3f..6ad7b2b0d46e 100644
--- a/test/ELF/mips-got16.s
+++ b/test/ELF/mips-got16.s
@@ -29,16 +29,16 @@
# GOT-NEXT: ]
# GOT: Primary GOT {
-# GOT-NEXT: Canonical gp value: 0x57FF0
+# GOT-NEXT: Canonical gp value:
# GOT-NEXT: Reserved entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50000
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32752
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Purpose: Lazy resolver
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50004
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32748
# GOT-NEXT: Initial: 0x80000000
# GOT-NEXT: Purpose: Module pointer (GNU extension)
@@ -46,44 +46,44 @@
# GOT-NEXT: ]
# GOT-NEXT: Local entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50008
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32744
# GOT-NEXT: Initial: 0x10000
# ^-- (0x1002c + 0x8000) & ~0xffff
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x5000C
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32740
# GOT-NEXT: Initial: 0x20000
# ^-- redundant unused entry
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50010
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32736
# GOT-NEXT: Initial: 0x20000
# ^-- redundant unused entry
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50014
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32732
# GOT-NEXT: Initial: 0x30000
# ^-- (0x29000 + 0x8000) & ~0xffff
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50018
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32728
# GOT-NEXT: Initial: 0x40000
# ^-- (0x29000 + 0x10004 + 0x8000) & ~0xffff
# ^-- (0x29000 + 0x18004 + 0x8000) & ~0xffff
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x5001C
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32724
# GOT-NEXT: Initial: 0x50000
# ^-- redundant unused entry
# GOT-NEXT: }
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50020
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32720
# GOT-NEXT: Initial: 0x41008
# ^-- 'bar' address
@@ -91,7 +91,7 @@
# GOT-NEXT: ]
# GOT-NEXT: Global entries [
# GOT-NEXT: Entry {
-# GOT-NEXT: Address: 0x50024
+# GOT-NEXT: Address:
# GOT-NEXT: Access: -32716
# GOT-NEXT: Initial: 0x0
# GOT-NEXT: Value: 0x0
diff --git a/test/ELF/mips-gp-ext.s b/test/ELF/mips-gp-ext.s
index 21879986d514..ff459380764c 100644
--- a/test/ELF/mips-gp-ext.s
+++ b/test/ELF/mips-gp-ext.s
@@ -20,10 +20,10 @@
# REQUIRES: mips
# REL: Contents of section .text:
-# REL-NEXT: 0000 3c080000 2108010c 8f82fff0
+# REL-NEXT: 0000 3c080000 2108010c 8f82fffc
# ^-- %hi(_gp_disp)
# ^-- %lo(_gp_disp)
-# ^-- 8 - (0x10c - 0xf4)
+# ^-- 8 - (0x10c - 0x100)
# G - (GP - .got)
# REL: Contents of section .reginfo:
@@ -40,10 +40,10 @@
# REL: 0000010c *ABS* 00000000 .hidden _gp
# ABS: Contents of section .text:
-# ABS-NEXT: 0000 3c080000 21080200 8f82fefc
+# ABS-NEXT: 0000 3c080000 21080200 8f82ff08
# ^-- %hi(_gp_disp)
# ^-- %lo(_gp_disp)
-# ^-- 8 - (0x200 - 0xf4)
+# ^-- 8 - (0x200 - 0x100)
# G - (GP - .got)
# ABS: Contents of section .reginfo:
diff --git a/test/ELF/mips-gp-lowest.s b/test/ELF/mips-gp-lowest.s
index 86c44b0e94e6..32a3e85ee9ec 100644
--- a/test/ELF/mips-gp-lowest.s
+++ b/test/ELF/mips-gp-lowest.s
@@ -26,7 +26,7 @@ foo:
# CHECK-NEXT: SHF_MIPS_GPREL
# CHECK-NEXT: SHF_WRITE
# CHECK-NEXT: ]
-# CHECK-NEXT: Address: 0xDD
+# CHECK-NEXT: Address: 0xE0
# CHECK: }
# CHECK: Section {
# CHECK: Name: .got
@@ -40,5 +40,5 @@ foo:
# CHECK: }
# CHECK: Name: _gp (5)
-# CHECK-NEXT: Value: 0x80CD
-# ^-- 0xDD + 0x7ff0
+# CHECK-NEXT: Value: 0x80D0
+# ^-- 0xE0 + 0x7ff0
diff --git a/test/ELF/mips-gprel32-relocs-gp0.s b/test/ELF/mips-gprel32-relocs-gp0.s
index e71f8856afee..4f1962bd683b 100644
--- a/test/ELF/mips-gprel32-relocs-gp0.s
+++ b/test/ELF/mips-gprel32-relocs-gp0.s
@@ -22,7 +22,7 @@
# DSO: GP: 0x27FF0
# DUMP: Contents of section .rodata:
-# DUMP: 0114 ffff0004 ffff0008
+# DUMP: 00f4 ffff0004 ffff0008
# ^ 0x10004 + 0x7ff0 - 0x27ff0
# ^ 0x10008 + 0x7ff0 - 0x27ff0
diff --git a/test/ELF/mips-gprel32-relocs.s b/test/ELF/mips-gprel32-relocs.s
index 993596deedb7..1c877b12b297 100644
--- a/test/ELF/mips-gprel32-relocs.s
+++ b/test/ELF/mips-gprel32-relocs.s
@@ -21,7 +21,7 @@ v1:
.gpword bar
# CHECK: Contents of section .rodata:
-# CHECK: 0114 fffe8014 fffe8018
+# CHECK: 00f4 fffe8014 fffe8018
# ^ 0x10004 - 0x27ff0
# ^ 0x10008 - 0x27ff0
diff --git a/test/ELF/mips-hilo-gp-disp.s b/test/ELF/mips-hilo-gp-disp.s
index 0edc29210914..62e03c7b6760 100644
--- a/test/ELF/mips-hilo-gp-disp.s
+++ b/test/ELF/mips-hilo-gp-disp.s
@@ -24,32 +24,32 @@ bar:
# EXE-NEXT: __start:
# EXE-NEXT: 20000: 3c 08 00 02 lui $8, 2
# ^-- %hi(0x47ff0-0x20000)
-# EXE-NEXT: 20004: 21 08 7f f0 addi $8, $8, 32752
-# ^-- %lo(0x47ff0-0x20004+4)
+# EXE-NEXT: 20004: 21 08 80 00 addi $8, $8, -32768
+# ^-- %lo(0x38000-0x20004+4)
# EXE: bar:
-# EXE-NEXT: 2000c: 3c 08 00 02 lui $8, 2
-# ^-- %hi(0x47ff0-0x2000c)
-# EXE-NEXT: 20010: 21 08 7f e4 addi $8, $8, 32740
-# ^-- %lo(0x47ff0-0x20010+4)
+# EXE-NEXT: 2000c: 3c 08 00 01 lui $8, 1
+# ^-- %hi(0x38000-0x2000c)
+# EXE-NEXT: 20010: 21 08 7f f4 addi $8, $8, 32756
+# ^-- %lo(0x38000-0x20010+4)
# EXE: SYMBOL TABLE:
# EXE: 0002000c .text 00000000 bar
-# EXE: 00047ff0 *ABS* 00000000 .hidden _gp
+# EXE: 00038000 *ABS* 00000000 .hidden _gp
# EXE: 00020000 .text 00000000 __start
# SO: Disassembly of section .text:
# SO-NEXT: __start:
# SO-NEXT: 10000: 3c 08 00 02 lui $8, 2
-# ^-- %hi(0x37ff0-0x10000)
-# SO-NEXT: 10004: 21 08 7f f0 addi $8, $8, 32752
-# ^-- %lo(0x37ff0-0x10004+4)
+# ^-- %hi(0x28000-0x10000)
+# SO-NEXT: 10004: 21 08 80 00 addi $8, $8, -32768
+# ^-- %lo(0x28000-0x10004+4)
# SO: bar:
-# SO-NEXT: 1000c: 3c 08 00 02 lui $8, 2
-# ^-- %hi(0x37ff0-0x1000c)
-# SO-NEXT: 10010: 21 08 7f e4 addi $8, $8, 32740
-# ^-- %lo(0x37ff0-0x10010+4)
+# SO-NEXT: 1000c: 3c 08 00 01 lui $8, 1
+# ^-- %hi(0x28000-0x1000c)
+# SO-NEXT: 10010: 21 08 7f f4 addi $8, $8, 32756
+# ^-- %lo(0x28000-0x10010+4)
# SO: SYMBOL TABLE:
# SO: 0001000c .text 00000000 bar
-# SO: 00037ff0 *ABS* 00000000 .hidden _gp
+# SO: 00028000 *ABS* 00000000 .hidden _gp
# SO: 00010000 .text 00000000 __start
diff --git a/test/ELF/mips-n32-rels.s b/test/ELF/mips-n32-rels.s
index 4cf72887785e..7706e2591a33 100644
--- a/test/ELF/mips-n32-rels.s
+++ b/test/ELF/mips-n32-rels.s
@@ -38,7 +38,7 @@
# ^-- %lo(0x17ff0)
# CHECK: Contents of section .rodata:
-# CHECK-NEXT: 100f4 00020004
+# CHECK-NEXT: 100d4 00020004
# ^-- loc
# CHECK: 00020004 .text 00000000 loc
diff --git a/test/ELF/mips-options.s b/test/ELF/mips-options.s
index 34bf48898116..edafd09c8da4 100644
--- a/test/ELF/mips-options.s
+++ b/test/ELF/mips-options.s
@@ -17,11 +17,11 @@ __start:
lui $gp, %hi(%neg(%gp_rel(g1)))
# CHECK: Name: _gp
-# CHECK-NEXT: Value: 0x100008258
+# CHECK-NEXT: Value: 0x[[GP:[0-9A-F]+]]
# CHECK: MIPS Options {
# CHECK-NEXT: ODK_REGINFO {
-# CHECK-NEXT: GP: 0x100008258
+# CHECK-NEXT: GP: 0x[[GP]]
# CHECK-NEXT: General Mask: 0x10000001
# CHECK-NEXT: Co-Proc Mask0: 0x0
# CHECK-NEXT: Co-Proc Mask1: 0x0
diff --git a/test/ELF/mips-tls-64.s b/test/ELF/mips-tls-64.s
index 39459cf2efac..259dd1f56b02 100644
--- a/test/ELF/mips-tls-64.s
+++ b/test/ELF/mips-tls-64.s
@@ -23,11 +23,11 @@
# DIS-NEXT: 20010: 24 62 80 58 addiu $2, $3, -32680
# DIS: Contents of section .got:
-# DIS-NEXT: 40008 00000000 00000000 80000000 00000000
-# DIS-NEXT: 40018 00000000 00000000 00000000 00000000
-# DIS-NEXT: 40028 00000000 00000000 00000000 00000001
-# DIS-NEXT: 40038 00000000 00000000 00000000 00000001
-# DIS-NEXT: 40048 ffffffff ffff8004 ffffffff ffff9004
+# DIS-NEXT: 30010 00000000 00000000 80000000 00000000
+# DIS-NEXT: 30020 00000000 00000000 00000000 00000000
+# DIS-NEXT: 30030 00000000 00000000 00000000 00000001
+# DIS-NEXT: 30040 00000000 00000000 00000000 00000001
+# DIS-NEXT: 30050 ffffffff ffff8004 ffffffff ffff9004
# DIS: 0000000000040000 l .tdata 00000000 .tdata
# DIS: 0000000000040000 l .tdata 00000000 loc
@@ -36,13 +36,13 @@
# CHECK: Relocations [
# CHECK-NEXT: Section (7) .rela.dyn {
-# CHECK-NEXT: 0x40018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
-# CHECK-NEXT: 0x40020 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
-# CHECK-NEXT: 0x40028 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
+# CHECK-NEXT: 0x30020 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
+# CHECK-NEXT: 0x30028 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
+# CHECK-NEXT: 0x30030 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: Primary GOT {
-# CHECK-NEXT: Canonical gp value: 0x47FF8
+# CHECK-NEXT: Canonical gp value: 0x38000
# CHECK-NEXT: Reserved entries [
# CHECK: ]
# CHECK-NEXT: Local entries [
@@ -60,25 +60,25 @@
# ^-- -32680 R_MIPS_TLS_GOTTPREL VA - 0x7000 bar
# DIS-SO: Contents of section .got:
-# DIS-SO-NEXT: 20008 00000000 00000000 80000000 00000000
-# DIS-SO-NEXT: 20018 00000000 00000000 00000000 00000000
-# DIS-SO-NEXT: 20028 00000000 00000000 00000000 00000000
-# DIS-SO-NEXT: 20038 00000000 00000000 00000000 00000000
-# DIS-SO-NEXT: 20048 00000000 00000000 00000000 00000000
+# DIS-SO-NEXT: 20000 00000000 00000000 80000000 00000000
+# DIS-SO-NEXT: 20010 00000000 00000000 00000000 00000000
+# DIS-SO-NEXT: 20020 00000000 00000000 00000000 00000000
+# DIS-SO-NEXT: 20030 00000000 00000000 00000000 00000000
+# DIS-SO-NEXT: 20040 00000000 00000000 00000000 00000000
# SO: Relocations [
# SO-NEXT: Section (7) .rela.dyn {
-# SO-NEXT: 0x20030 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE - 0x0
-# SO-NEXT: 0x20040 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
-# SO-NEXT: 0x20048 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
-# SO-NEXT: 0x20050 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
-# SO-NEXT: 0x20018 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
-# SO-NEXT: 0x20020 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
-# SO-NEXT: 0x20028 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
+# SO-NEXT: 0x20028 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE - 0x0
+# SO-NEXT: 0x20038 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
+# SO-NEXT: 0x20040 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
+# SO-NEXT: 0x20048 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE bar 0x0
+# SO-NEXT: 0x20010 R_MIPS_TLS_DTPMOD64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
+# SO-NEXT: 0x20018 R_MIPS_TLS_DTPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
+# SO-NEXT: 0x20020 R_MIPS_TLS_TPREL64/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# SO-NEXT: }
# SO-NEXT: ]
# SO-NEXT: Primary GOT {
-# SO-NEXT: Canonical gp value: 0x27FF8
+# SO-NEXT: Canonical gp value: 0x27FF0
# SO-NEXT: Reserved entries [
# SO: ]
# SO-NEXT: Local entries [
@@ -86,14 +86,14 @@
# SO-NEXT: Global entries [
# SO-NEXT: ]
# SO-NEXT: Number of TLS and multi-GOT entries: 8
-# ^-- 0x20018 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 foo
-# ^-- 0x20020 R_MIPS_TLS_DTPREL64 foo
-# ^-- 0x20028 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 foo
-# ^-- 0x20030 R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD64 loc
-# ^-- 0x20038 0 loc
-# ^-- 0x20040 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 bar
-# ^-- 0x20048 R_MIPS_TLS_DTPREL64 bar
-# ^-- 0x20050 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 bar
+# ^-- -32736 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 foo
+# ^-- -32728 R_MIPS_TLS_DTPREL64 foo
+# ^-- -32720 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 foo
+# ^-- -32712 R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD64 loc
+# ^-- -32704 0 loc
+# ^-- -32696 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD64 bar
+# ^-- -32688 R_MIPS_TLS_DTPREL64 bar
+# ^-- -32680 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL64 bar
.text
.global __start
diff --git a/test/ELF/mips-tls-hilo.s b/test/ELF/mips-tls-hilo.s
index 7628cb3a6ec6..fb026a40bbb1 100644
--- a/test/ELF/mips-tls-hilo.s
+++ b/test/ELF/mips-tls-hilo.s
@@ -21,8 +21,8 @@
# DIS-NEXT: 2000c: 24 62 90 00 addiu $2, $3, -28672
# %lo(loc0 - .tdata - 0x7000) --^
-# DIS: 00030000 l .tdata 00000000 .tdata
-# DIS: 00030000 l .tdata 00000000 loc0
+# DIS: 00040000 l .tdata 00000000 .tdata
+# DIS: 00040000 l .tdata 00000000 loc0
# CHECK: Relocations [
# CHECK-NEXT: ]
diff --git a/test/ELF/mips-tls-static.s b/test/ELF/mips-tls-static.s
index c8571a2658e2..84b56cb42240 100644
--- a/test/ELF/mips-tls-static.s
+++ b/test/ELF/mips-tls-static.s
@@ -10,8 +10,8 @@
# CHECK: Contents of section .data:
# CHECK-NEXT: 30000 0002000c ffff8004 ffff9004
# CHECK: Contents of section .got:
-# CHECK-NEXT: 40008 00000000 80000000 00000001 ffff8000
-# CHECK-NEXT: 40018 00000001 00000000 ffff9000
+# CHECK-NEXT: 30010 00000000 80000000 00000001 ffff8000
+# CHECK-NEXT: 30020 00000001 00000000 ffff9000
#
# CHECK: SYMBOL TABLE:
# CHECK: 0002000c .text 00000000 __tls_get_addr
diff --git a/test/ELF/mips-tls.s b/test/ELF/mips-tls.s
index 7bca4773c995..fd8bab8fa3a2 100644
--- a/test/ELF/mips-tls.s
+++ b/test/ELF/mips-tls.s
@@ -23,9 +23,9 @@
# DIS-NEXT: 20010: 24 62 80 34 addiu $2, $3, -32716
# DIS: Contents of section .got:
-# DIS-NEXT: 40008 00000000 80000000 00000000 00000000
-# DIS-NEXT: 40018 00000000 00000001 00000000 00000001
-# DIS-NEXT: 40028 ffff8004 ffff9004
+# DIS-NEXT: 30010 00000000 80000000 00000000 00000000
+# DIS-NEXT: 30020 00000000 00000001 00000000 00000001
+# DIS-NEXT: 30030 ffff8004 ffff9004
# DIS: 00040000 l .tdata 00000000 .tdata
# DIS: 00040000 l .tdata 00000000 loc
@@ -34,13 +34,13 @@
# CHECK: Relocations [
# CHECK-NEXT: Section (7) .rel.dyn {
-# CHECK-NEXT: 0x40010 R_MIPS_TLS_DTPMOD32 foo 0x0
-# CHECK-NEXT: 0x40014 R_MIPS_TLS_DTPREL32 foo 0x0
-# CHECK-NEXT: 0x40018 R_MIPS_TLS_TPREL32 foo 0x0
+# CHECK-NEXT: 0x30018 R_MIPS_TLS_DTPMOD32 foo 0x0
+# CHECK-NEXT: 0x3001C R_MIPS_TLS_DTPREL32 foo 0x0
+# CHECK-NEXT: 0x30020 R_MIPS_TLS_TPREL32 foo 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]
# CHECK-NEXT: Primary GOT {
-# CHECK-NEXT: Canonical gp value: 0x47FF8
+# CHECK-NEXT: Canonical gp value: 0x38000
# CHECK-NEXT: Reserved entries [
# CHECK: ]
# CHECK-NEXT: Local entries [
@@ -48,33 +48,33 @@
# CHECK-NEXT: Global entries [
# CHECK-NEXT: ]
# CHECK-NEXT: Number of TLS and multi-GOT entries: 8
-# ^-- 0x30010 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
-# ^-- 0x30014 R_MIPS_TLS_DTPREL32 foo
-# ^-- 0x30018 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
-# ^-- 0x3001C R_MIPS_TLS_LDM 1 loc
-# ^-- 0x30020 0 loc
-# ^-- 0x30024 R_MIPS_TLS_GD 1 bar
-# ^-- 0x30028 VA - 0x8000 bar
-# ^-- 0x3002C R_MIPS_TLS_GOTTPREL VA - 0x7000 bar
+# ^-- -32744 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
+# ^-- -32740 R_MIPS_TLS_DTPREL32 foo
+# ^-- -32736 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
+# ^-- -32732 R_MIPS_TLS_LDM 1 loc
+# ^-- -32728 0 loc
+# ^-- -32724 R_MIPS_TLS_GD 1 bar
+# ^-- -32720 VA - 0x8000 bar
+# ^-- -32716 R_MIPS_TLS_GOTTPREL VA - 0x7000 bar
# DIS-SO: Contents of section .got:
-# DIS-SO-NEXT: 20008 00000000 80000000 00000000 00000000
-# DIS-SO-NEXT: 20018 00000000 00000000 00000000 00000000
-# DIS-SO-NEXT: 20028 00000000 00000000
+# DIS-SO-NEXT: 20000 00000000 80000000 00000000 00000000
+# DIS-SO-NEXT: 20010 00000000 00000000 00000000 00000000
+# DIS-SO-NEXT: 20020 00000000 00000000
# SO: Relocations [
# SO-NEXT: Section (7) .rel.dyn {
-# SO-NEXT: 0x2001C R_MIPS_TLS_DTPMOD32 - 0x0
-# SO-NEXT: 0x20024 R_MIPS_TLS_DTPMOD32 bar 0x0
-# SO-NEXT: 0x20028 R_MIPS_TLS_DTPREL32 bar 0x0
-# SO-NEXT: 0x2002C R_MIPS_TLS_TPREL32 bar 0x0
-# SO-NEXT: 0x20010 R_MIPS_TLS_DTPMOD32 foo 0x0
-# SO-NEXT: 0x20014 R_MIPS_TLS_DTPREL32 foo 0x0
-# SO-NEXT: 0x20018 R_MIPS_TLS_TPREL32 foo 0x0
+# SO-NEXT: 0x20014 R_MIPS_TLS_DTPMOD32 - 0x0
+# SO-NEXT: 0x2001C R_MIPS_TLS_DTPMOD32 bar 0x0
+# SO-NEXT: 0x20020 R_MIPS_TLS_DTPREL32 bar 0x0
+# SO-NEXT: 0x20024 R_MIPS_TLS_TPREL32 bar 0x0
+# SO-NEXT: 0x20008 R_MIPS_TLS_DTPMOD32 foo 0x0
+# SO-NEXT: 0x2000C R_MIPS_TLS_DTPREL32 foo 0x0
+# SO-NEXT: 0x20010 R_MIPS_TLS_TPREL32 foo 0x0
# SO-NEXT: }
# SO-NEXT: ]
# SO-NEXT: Primary GOT {
-# SO-NEXT: Canonical gp value: 0x27FF8
+# SO-NEXT: Canonical gp value: 0x27FF0
# SO-NEXT: Reserved entries [
# SO: ]
# SO-NEXT: Local entries [
@@ -82,14 +82,14 @@
# SO-NEXT: Global entries [
# SO-NEXT: ]
# SO-NEXT: Number of TLS and multi-GOT entries: 8
-# ^-- 0x20010 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
-# ^-- 0x20014 R_MIPS_TLS_DTPREL32 foo
-# ^-- 0x20018 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
-# ^-- 0x2001C R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD32 loc
-# ^-- 0x20020 0 loc
-# ^-- 0x20024 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 bar
-# ^-- 0x20028 R_MIPS_TLS_DTPREL32 bar
-# ^-- 0x2002C R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 bar
+# ^-- -32744 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 foo
+# ^-- -32740 R_MIPS_TLS_DTPREL32 foo
+# ^-- -32736 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 foo
+# ^-- -32732 R_MIPS_TLS_LDM R_MIPS_TLS_DTPMOD32 loc
+# ^-- -32728 0 loc
+# ^-- -32724 R_MIPS_TLS_GD R_MIPS_TLS_DTPMOD32 bar
+# ^-- -32720 R_MIPS_TLS_DTPREL32 bar
+# ^-- -32716 R_MIPS_TLS_GOTTPREL R_MIPS_TLS_TPREL32 bar
.text
.global __start
diff --git a/test/ELF/mips-xgot-order.s b/test/ELF/mips-xgot-order.s
index b235c0c6b09c..911731c713cd 100644
--- a/test/ELF/mips-xgot-order.s
+++ b/test/ELF/mips-xgot-order.s
@@ -20,10 +20,10 @@
# CHECK-NEXT: 20018: 20 42 00 00 addi $2, $2, 0
# CHECK: Contents of section .got:
-# CHECK-NEXT: 40000 00000000 80000000 00030000 00040000
+# CHECK-NEXT: 30010 00000000 80000000 00030000 00040000
# ^ %hi(loc)
# ^ redundant entry
-# CHECK-NEXT: 40010 00020010 00020000 00030000
+# CHECK-NEXT: 30020 00020010 00020000 00030000
# ^ %got(bar)
# ^ %got_hi/lo(start)
# ^ %got_hi/lo(loc)
diff --git a/test/ELF/relocatable-common.s b/test/ELF/relocatable-common.s
new file mode 100644
index 000000000000..b1b6edba2a36
--- /dev/null
+++ b/test/ELF/relocatable-common.s
@@ -0,0 +1,36 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
+# RUN: ld.lld -r %t1.o -o %t
+# RUN: llvm-readobj -symbols -r %t | FileCheck %s
+# RUN: ld.lld -r --no-define-common %t1.o -o %t
+# RUN: llvm-readobj -symbols -r %t | FileCheck %s
+# RUN: ld.lld -r --define-common %t1.o -o %t
+# RUN: llvm-readobj -symbols -r %t | FileCheck -check-prefix=DEFCOMM %s
+# RUN: ld.lld -r -d %t1.o -o %t
+# RUN: llvm-readobj -symbols -r %t | FileCheck -check-prefix=DEFCOMM %s
+# RUN: ld.lld -r -dc %t1.o -o %t
+# RUN: llvm-readobj -symbols -r %t | FileCheck -check-prefix=DEFCOMM %s
+# RUN: ld.lld -r -dp %t1.o -o %t
+# RUN: llvm-readobj -symbols -r %t | FileCheck -check-prefix=DEFCOMM %s
+
+# CHECK: Symbol {
+# CHECK: Name: common (1)
+# CHECK-NEXT: Value: 0x4
+# CHECK-NEXT: Size: 4
+# CHECK-NEXT: Binding: Global (0x1)
+# CHECK-NEXT: Type: Object (0x1)
+# CHECK-NEXT: Other: 0
+# CHECK-NEXT: Section: Common (0xFFF2)
+# CHECK-NEXT: }
+
+# DEFCOMM: Symbol {
+# DEFCOMM: Name: common (1)
+# DEFCOMM-NEXT: Value: 0x0
+# DEFCOMM-NEXT: Size: 4
+# DEFCOMM-NEXT: Binding: Global (0x1)
+# DEFCOMM-NEXT: Type: Object (0x1)
+# DEFCOMM-NEXT: Other: 0
+# DEFCOMM-NEXT: Section: COMMON (0x2)
+# DEFCOMM-NEXT: }
+
+.comm common,4,4