From owner-svn-src-vendor@freebsd.org Wed May 3 20:26:49 2017 Return-Path: Delivered-To: svn-src-vendor@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 719D7D5C7AA; Wed, 3 May 2017 20:26:49 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D9501D9F; Wed, 3 May 2017 20:26:49 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v43KQmZE049084; Wed, 3 May 2017 20:26:48 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v43KQlHC049072; Wed, 3 May 2017 20:26:47 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201705032026.v43KQlHC049072@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Wed, 3 May 2017 20:26:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r317767 - in vendor/lld/dist: COFF ELF test/ELF test/ELF/Inputs X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 20:26:49 -0000 Author: dim Date: Wed May 3 20:26:46 2017 New Revision: 317767 URL: https://svnweb.freebsd.org/changeset/base/317767 Log: Vendor import of lld trunk r302069: https://llvm.org/svn/llvm-project/lld/trunk@302069 Added: vendor/lld/dist/test/ELF/Inputs/weak-and-strong-undef.s (contents, props changed) vendor/lld/dist/test/ELF/gdb-index-ranges.s (contents, props changed) vendor/lld/dist/test/ELF/sectionstart-noallochdr.s (contents, props changed) vendor/lld/dist/test/ELF/weak-and-strong-undef.s (contents, props changed) Modified: vendor/lld/dist/COFF/PDB.cpp vendor/lld/dist/ELF/Driver.h vendor/lld/dist/ELF/InputFiles.cpp vendor/lld/dist/ELF/LTO.cpp vendor/lld/dist/ELF/LinkerScript.cpp vendor/lld/dist/ELF/SymbolTable.cpp vendor/lld/dist/ELF/Target.cpp vendor/lld/dist/ELF/Writer.cpp Modified: vendor/lld/dist/COFF/PDB.cpp ============================================================================== --- vendor/lld/dist/COFF/PDB.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/COFF/PDB.cpp Wed May 3 20:26:46 2017 (r317767) @@ -28,8 +28,8 @@ #include "llvm/DebugInfo/PDB/Native/InfoStreamBuilder.h" #include "llvm/DebugInfo/PDB/Native/PDBFile.h" #include "llvm/DebugInfo/PDB/Native/PDBFileBuilder.h" +#include "llvm/DebugInfo/PDB/Native/PDBStringTableBuilder.h" #include "llvm/DebugInfo/PDB/Native/PDBTypeServerHandler.h" -#include "llvm/DebugInfo/PDB/Native/StringTableBuilder.h" #include "llvm/DebugInfo/PDB/Native/TpiStream.h" #include "llvm/DebugInfo/PDB/Native/TpiStreamBuilder.h" #include "llvm/Object/COFF.h" Modified: vendor/lld/dist/ELF/Driver.h ============================================================================== --- vendor/lld/dist/ELF/Driver.h Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/Driver.h Wed May 3 20:26:46 2017 (r317767) @@ -64,8 +64,6 @@ enum { }; void printHelp(const char *Argv0); -std::vector parseHexstring(StringRef S); - std::string createResponseFile(const llvm::opt::InputArgList &Args); llvm::Optional findFromSearchPaths(StringRef Path); Modified: vendor/lld/dist/ELF/InputFiles.cpp ============================================================================== --- vendor/lld/dist/ELF/InputFiles.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/InputFiles.cpp Wed May 3 20:26:46 2017 (r317767) @@ -410,7 +410,7 @@ elf::ObjectFile::createInputSectio // Mergeable sections with relocations are tricky because relocations // need to be taken into account when comparing section contents for - // merging. It doesn't worth supporting such mergeable sections because + // merging. It's not worth supporting such mergeable sections because // they are rare and it'd complicates the internal design (we usually // have to determine if two sections are mergeable early in the link // process much before applying relocations). We simply handle mergeable Modified: vendor/lld/dist/ELF/LTO.cpp ============================================================================== --- vendor/lld/dist/ELF/LTO.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/LTO.cpp Wed May 3 20:26:46 2017 (r317767) @@ -105,11 +105,6 @@ BitcodeCompiler::~BitcodeCompiler() = de static void undefine(Symbol *S) { replaceBody(S, S->body()->getName(), /*IsLocal=*/false, STV_DEFAULT, S->body()->Type, nullptr); - // It shouldn't normally matter what the binding is, but if a bug in the LTO - // implementation causes it to fail to provide a definition for a symbol, - // setting the binding to STB_GLOBAL will cause the linker to report an - // undefined symbol error, even if the definition was weak. - S->Binding = STB_GLOBAL; } void BitcodeCompiler::add(BitcodeFile &F) { Modified: vendor/lld/dist/ELF/LinkerScript.cpp ============================================================================== --- vendor/lld/dist/ELF/LinkerScript.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/LinkerScript.cpp Wed May 3 20:26:46 2017 (r317767) @@ -428,13 +428,12 @@ void LinkerScript::fabricateDefaultComma if (AllocateHeader) StartAddr += elf::getHeaderSize(); - // The Sections with -T
are sorted in order of ascending address - // we must use this if it is lower than StartAddr as calls to setDot() must - // be monotonically increasing - if (!Config->SectionStartMap.empty()) { - uint64_t LowestSecStart = Config->SectionStartMap.begin()->second; - StartAddr = std::min(StartAddr, LowestSecStart); - } + // The Sections with -T
have been sorted in order of ascending + // address. We must lower StartAddr if the lowest -T
as + // calls to setDot() must be monotonically increasing. + for (auto& KV : Config->SectionStartMap) + StartAddr = std::min(StartAddr, KV.second); + Commands.push_back( make(".", [=] { return StartAddr; }, "")); @@ -444,17 +443,19 @@ void LinkerScript::fabricateDefaultComma if (!(Sec->Flags & SHF_ALLOC)) continue; + auto *OSCmd = make(Sec->Name); + OSCmd->Sec = Sec; + + // Prefer user supplied address over additional alignment constraint auto I = Config->SectionStartMap.find(Sec->Name); if (I != Config->SectionStartMap.end()) Commands.push_back( make(".", [=] { return I->second; }, "")); - - auto *OSCmd = make(Sec->Name); - OSCmd->Sec = Sec; - if (Sec->PageAlign) + else if (Sec->PageAlign) OSCmd->AddrExpr = [=] { return alignTo(Script->getDot(), Config->MaxPageSize); }; + Commands.push_back(OSCmd); if (Sec->Sections.size()) { auto *ISD = make(""); Modified: vendor/lld/dist/ELF/SymbolTable.cpp ============================================================================== --- vendor/lld/dist/ELF/SymbolTable.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/SymbolTable.cpp Wed May 3 20:26:46 2017 (r317767) @@ -279,9 +279,10 @@ Symbol *SymbolTable::addUndefined( return S; } if (Binding != STB_WEAK) { - if (S->body()->isShared() || S->body()->isLazy()) + SymbolBody *B = S->body(); + if (B->isShared() || B->isLazy() || B->isUndefined()) S->Binding = Binding; - if (auto *SS = dyn_cast(S->body())) + if (auto *SS = dyn_cast(B)) cast>(SS->File)->IsUsed = true; } if (auto *L = dyn_cast(S->body())) { Modified: vendor/lld/dist/ELF/Target.cpp ============================================================================== --- vendor/lld/dist/ELF/Target.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/Target.cpp Wed May 3 20:26:46 2017 (r317767) @@ -1324,8 +1324,8 @@ RelExpr AArch64TargetInfo::getRelExpr(ui return R_ABS; case R_AARCH64_TLSDESC_ADR_PAGE21: return R_TLSDESC_PAGE; - case R_AARCH64_TLSDESC_LD64_LO12_NC: - case R_AARCH64_TLSDESC_ADD_LO12_NC: + case R_AARCH64_TLSDESC_LD64_LO12: + case R_AARCH64_TLSDESC_ADD_LO12: return R_TLSDESC; case R_AARCH64_TLSDESC_CALL: return R_TLSDESC_CALL; @@ -1376,8 +1376,8 @@ bool AArch64TargetInfo::usesOnlyLowPageB case R_AARCH64_LDST32_ABS_LO12_NC: case R_AARCH64_LDST64_ABS_LO12_NC: case R_AARCH64_LDST8_ABS_LO12_NC: - case R_AARCH64_TLSDESC_ADD_LO12_NC: - case R_AARCH64_TLSDESC_LD64_LO12_NC: + case R_AARCH64_TLSDESC_ADD_LO12: + case R_AARCH64_TLSDESC_LD64_LO12: case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: return true; } @@ -1503,7 +1503,7 @@ void AArch64TargetInfo::relocateOne(uint break; case R_AARCH64_LD64_GOT_LO12_NC: case R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC: - case R_AARCH64_TLSDESC_LD64_LO12_NC: + case R_AARCH64_TLSDESC_LD64_LO12: checkAlignment<8>(Loc, Val, Type); or32le(Loc, (Val & 0xFF8) << 7); break; @@ -1543,7 +1543,7 @@ void AArch64TargetInfo::relocateOne(uint or32AArch64Imm(Loc, Val >> 12); break; case R_AARCH64_TLSLE_ADD_TPREL_LO12_NC: - case R_AARCH64_TLSDESC_ADD_LO12_NC: + case R_AARCH64_TLSDESC_ADD_LO12: or32AArch64Imm(Loc, Val); break; default: @@ -1555,8 +1555,8 @@ void AArch64TargetInfo::relaxTlsGdToLe(u uint64_t Val) const { // TLSDESC Global-Dynamic relocation are in the form: // adrp x0, :tlsdesc:v [R_AARCH64_TLSDESC_ADR_PAGE21] - // ldr x1, [x0, #:tlsdesc_lo12:v [R_AARCH64_TLSDESC_LD64_LO12_NC] - // add x0, x0, :tlsdesc_los:v [_AARCH64_TLSDESC_ADD_LO12_NC] + // ldr x1, [x0, #:tlsdesc_lo12:v [R_AARCH64_TLSDESC_LD64_LO12] + // add x0, x0, :tlsdesc_los:v [R_AARCH64_TLSDESC_ADD_LO12] // .tlsdesccall [R_AARCH64_TLSDESC_CALL] // blr x1 // And it can optimized to: @@ -1567,14 +1567,14 @@ void AArch64TargetInfo::relaxTlsGdToLe(u checkUInt<32>(Loc, Val, Type); switch (Type) { - case R_AARCH64_TLSDESC_ADD_LO12_NC: + case R_AARCH64_TLSDESC_ADD_LO12: case R_AARCH64_TLSDESC_CALL: write32le(Loc, 0xd503201f); // nop return; case R_AARCH64_TLSDESC_ADR_PAGE21: write32le(Loc, 0xd2a00000 | (((Val >> 16) & 0xffff) << 5)); // movz return; - case R_AARCH64_TLSDESC_LD64_LO12_NC: + case R_AARCH64_TLSDESC_LD64_LO12: write32le(Loc, 0xf2800000 | ((Val & 0xffff) << 5)); // movk return; default: @@ -1586,8 +1586,8 @@ void AArch64TargetInfo::relaxTlsGdToIe(u uint64_t Val) const { // TLSDESC Global-Dynamic relocation are in the form: // adrp x0, :tlsdesc:v [R_AARCH64_TLSDESC_ADR_PAGE21] - // ldr x1, [x0, #:tlsdesc_lo12:v [R_AARCH64_TLSDESC_LD64_LO12_NC] - // add x0, x0, :tlsdesc_los:v [_AARCH64_TLSDESC_ADD_LO12_NC] + // ldr x1, [x0, #:tlsdesc_lo12:v [R_AARCH64_TLSDESC_LD64_LO12] + // add x0, x0, :tlsdesc_los:v [R_AARCH64_TLSDESC_ADD_LO12] // .tlsdesccall [R_AARCH64_TLSDESC_CALL] // blr x1 // And it can optimized to: @@ -1597,7 +1597,7 @@ void AArch64TargetInfo::relaxTlsGdToIe(u // nop switch (Type) { - case R_AARCH64_TLSDESC_ADD_LO12_NC: + case R_AARCH64_TLSDESC_ADD_LO12: case R_AARCH64_TLSDESC_CALL: write32le(Loc, 0xd503201f); // nop break; @@ -1605,7 +1605,7 @@ void AArch64TargetInfo::relaxTlsGdToIe(u write32le(Loc, 0x90000000); // adrp relocateOne(Loc, R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, Val); break; - case R_AARCH64_TLSDESC_LD64_LO12_NC: + case R_AARCH64_TLSDESC_LD64_LO12: write32le(Loc, 0xf9400000); // ldr relocateOne(Loc, R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC, Val); break; Modified: vendor/lld/dist/ELF/Writer.cpp ============================================================================== --- vendor/lld/dist/ELF/Writer.cpp Wed May 3 20:26:43 2017 (r317766) +++ vendor/lld/dist/ELF/Writer.cpp Wed May 3 20:26:46 2017 (r317767) @@ -252,7 +252,7 @@ template void Writer: } else { if (!Script->Opt.HasSections) { fixSectionAlignments(); - Script->fabricateDefaultCommands(Config->MaxPageSize); + Script->fabricateDefaultCommands(AllocateHeader); } Script->synchronize(); Script->assignAddresses(Phdrs); Added: vendor/lld/dist/test/ELF/Inputs/weak-and-strong-undef.s ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lld/dist/test/ELF/Inputs/weak-and-strong-undef.s Wed May 3 20:26:46 2017 (r317767) @@ -0,0 +1 @@ + .weak foo Added: vendor/lld/dist/test/ELF/gdb-index-ranges.s ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lld/dist/test/ELF/gdb-index-ranges.s Wed May 3 20:26:46 2017 (r317767) @@ -0,0 +1,66 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld --gdb-index -e main %t.o -o %t +# RUN: llvm-dwarfdump -debug-dump=gdb_index %t | FileCheck %s + +# CHECK: .gnu_index contents: +# CHECK: Address area offset = 0x28, has 2 entries: +# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0 +# CHECK-NEXT: Low/High address = [0x201001, 0x201003) (Size: 0x2), CU id = 0 + +.section .text.foo1,"ax",@progbits +.Lfunc_begin0: + nop +.Lfunc_end0: + +.section .text.foo2,"ax",@progbits +.Lfunc_begin1: + nop + nop +.Lfunc_end1: + +.section .debug_abbrev,"",@progbits +.byte 1 # Abbreviation Code +.byte 17 # DW_TAG_compile_unit +.byte 0 # DW_CHILDREN_no +.byte 37 # DW_AT_producer +.byte 14 # DW_FORM_strp +.byte 19 # DW_AT_language +.byte 5 # DW_FORM_data2 +.byte 3 # DW_AT_name +.byte 14 # DW_FORM_strp +.byte 16 # DW_AT_stmt_list +.byte 23 # DW_FORM_sec_offset +.byte 27 # DW_AT_comp_dir +.byte 14 # DW_FORM_strp +.byte 17 # DW_AT_low_pc +.byte 1 # DW_FORM_addr +.byte 85 # DW_AT_ranges +.byte 23 # DW_FORM_sec_offset +.byte 0 # EOM(1) +.byte 0 # EOM(2) +.byte 0 # EOM(3) + +.section .debug_info,"",@progbits +.Lcu_begin0: +.long 38 # Length of Unit +.short 4 # DWARF version number +.long .debug_abbrev # Offset Into Abbrev. Section +.byte 8 # Address Size (in bytes) +.byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit +.long 0 # DW_AT_producer +.short 4 # DW_AT_language +.long 0 # DW_AT_name +.long 0 # DW_AT_stmt_list +.long 0 # DW_AT_comp_dir +.quad 0 # DW_AT_low_pc +.long .Ldebug_ranges0 # DW_AT_ranges + +.section .debug_ranges,"",@progbits +.Ldebug_ranges0: +.quad .Lfunc_begin0 +.quad .Lfunc_end0 +.quad .Lfunc_begin1 +.quad .Lfunc_end1 +.quad 0 +.quad 0 Added: vendor/lld/dist/test/ELF/sectionstart-noallochdr.s ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lld/dist/test/ELF/sectionstart-noallochdr.s Wed May 3 20:26:46 2017 (r317767) @@ -0,0 +1,23 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o --section-start .data=0x20 \ +# RUN: --section-start .bss=0x30 --section-start .text=0x10 -o %t1 +# RUN: llvm-objdump -section-headers %t1 | FileCheck %s + +# CHECK: Sections: +# CHECK-NEXT: Idx Name Size Address Type +# CHECK-NEXT: 0 00000000 0000000000000000 +# CHECK-NEXT: 1 .text 00000001 0000000000000010 TEXT DATA +# CHECK-NEXT: 2 .data 00000004 0000000000000020 DATA +# CHECK-NEXT: 3 .bss 00000004 0000000000000030 BSS + +.text +.globl _start +_start: + nop + +.data +.long 0 + +.bss +.zero 4 Added: vendor/lld/dist/test/ELF/weak-and-strong-undef.s ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/lld/dist/test/ELF/weak-and-strong-undef.s Wed May 3 20:26:46 2017 (r317767) @@ -0,0 +1,12 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/weak-and-strong-undef.s -o %t2.o +# RUN: not ld.lld %t1.o %t2.o -o %t 2>&1 | FileCheck %s +# RUN: not ld.lld %t2.o %t1.o -o %t 2>&1 | FileCheck %s + +# CHECK: error: undefined symbol: foo + +.long foo +.globl _start +_start: +ret