Date: Wed, 27 Jun 2018 19:15:02 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r335728 - in vendor/lld/dist-release_60: COFF ELF ELF/Arch MinGW test/COFF test/ELF test/MinGW Message-ID: <201806271915.w5RJF2UH043254@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Wed Jun 27 19:15:02 2018 New Revision: 335728 URL: https://svnweb.freebsd.org/changeset/base/335728 Log: Vendor import of lld 6.0.1 release r335540: https://llvm.org/svn/llvm-project/lld/tags/RELEASE_601/final@335540 Modified: vendor/lld/dist-release_60/COFF/Config.h vendor/lld/dist-release_60/COFF/Driver.cpp vendor/lld/dist-release_60/COFF/DriverUtils.cpp vendor/lld/dist-release_60/COFF/Options.td vendor/lld/dist-release_60/ELF/Arch/Mips.cpp vendor/lld/dist-release_60/ELF/Config.h vendor/lld/dist-release_60/ELF/Driver.cpp vendor/lld/dist-release_60/MinGW/Driver.cpp vendor/lld/dist-release_60/MinGW/Options.td vendor/lld/dist-release_60/test/COFF/def-export-stdcall.s vendor/lld/dist-release_60/test/ELF/mips-26-n32-n64.s vendor/lld/dist-release_60/test/ELF/mips-plt-r6.s vendor/lld/dist-release_60/test/MinGW/driver.test Modified: vendor/lld/dist-release_60/COFF/Config.h ============================================================================== --- vendor/lld/dist-release_60/COFF/Config.h Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/COFF/Config.h Wed Jun 27 19:15:02 2018 (r335728) @@ -175,6 +175,7 @@ struct Configuration { bool AppContainer = false; bool MinGW = false; bool WarnLocallyDefinedImported = true; + bool KillAt = false; }; extern Configuration *Config; Modified: vendor/lld/dist-release_60/COFF/Driver.cpp ============================================================================== --- vendor/lld/dist-release_60/COFF/Driver.cpp Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/COFF/Driver.cpp Wed Jun 27 19:15:02 2018 (r335728) @@ -970,6 +970,10 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr if (Args.hasArg(OPT_lldsavetemps)) Config->SaveTemps = true; + // Handle /kill-at + if (Args.hasArg(OPT_kill_at)) + Config->KillAt = true; + // Handle /lldltocache if (auto *Arg = Args.getLastArg(OPT_lldltocache)) Config->LTOCache = Arg->getValue(); Modified: vendor/lld/dist-release_60/COFF/DriverUtils.cpp ============================================================================== --- vendor/lld/dist-release_60/COFF/DriverUtils.cpp Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/COFF/DriverUtils.cpp Wed Jun 27 19:15:02 2018 (r335728) @@ -561,6 +561,26 @@ static StringRef undecorate(StringRef Sym) { return Sym.startswith("_") ? Sym.substr(1) : Sym; } +// Convert stdcall/fastcall style symbols into unsuffixed symbols, +// with or without a leading underscore. (MinGW specific.) +static StringRef killAt(StringRef Sym, bool Prefix) { + if (Sym.empty()) + return Sym; + // Strip any trailing stdcall suffix + Sym = Sym.substr(0, Sym.find('@', 1)); + if (!Sym.startswith("@")) { + if (Prefix && !Sym.startswith("_")) + return Saver.save("_" + Sym); + return Sym; + } + // For fastcall, remove the leading @ and replace it with an + // underscore, if prefixes are used. + Sym = Sym.substr(1); + if (Prefix) + Sym = Saver.save("_" + Sym); + return Sym; +} + // Performs error checking on all /export arguments. // It also sets ordinals. void fixupExports() { @@ -590,6 +610,15 @@ void fixupExports() { E.ExportName = undecorate(E.Name); } else { E.ExportName = undecorate(E.ExtName.empty() ? E.Name : E.ExtName); + } + } + + if (Config->KillAt && Config->Machine == I386) { + for (Export &E : Config->Exports) { + E.Name = killAt(E.Name, true); + E.ExportName = killAt(E.ExportName, false); + E.ExtName = killAt(E.ExtName, true); + E.SymbolName = killAt(E.SymbolName, true); } } Modified: vendor/lld/dist-release_60/COFF/Options.td ============================================================================== --- vendor/lld/dist-release_60/COFF/Options.td Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/COFF/Options.td Wed Jun 27 19:15:02 2018 (r335728) @@ -121,6 +121,7 @@ def help_q : Flag<["/?", "-?"], "">, Alias<help>; def debug_ghash : F<"debug:ghash">; def debug_dwarf : F<"debug:dwarf">; def export_all_symbols : F<"export-all-symbols">; +def kill_at : F<"kill-at">; def lldmingw : F<"lldmingw">; def msvclto : F<"msvclto">; def output_def : Joined<["/", "-"], "output-def:">; Modified: vendor/lld/dist-release_60/ELF/Arch/Mips.cpp ============================================================================== --- vendor/lld/dist-release_60/ELF/Arch/Mips.cpp Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/ELF/Arch/Mips.cpp Wed Jun 27 19:15:02 2018 (r335728) @@ -296,7 +296,8 @@ template <class ELFT> void MIPS<ELFT>::writePltHeader( write32<E>(Buf + 20, 0x0018c082); // srl $24, $24, 2 } - write32<E>(Buf + 24, 0x0320f809); // jalr $25 + uint32_t JalrInst = Config->ZHazardplt ? 0x0320fc09 : 0x0320f809; + write32<E>(Buf + 24, JalrInst); // jalr.hb $25 or jalr $25 write32<E>(Buf + 28, 0x2718fffe); // subu $24, $24, 2 uint64_t GotPlt = InX::GotPlt->getVA(); @@ -330,9 +331,12 @@ void MIPS<ELFT>::writePlt(uint8_t *Buf, uint64_t GotPl return; } + uint32_t JrInst = isMipsR6() ? (Config->ZHazardplt ? 0x03200409 : 0x03200009) + : (Config->ZHazardplt ? 0x03200408 : 0x03200008); + write32<E>(Buf, 0x3c0f0000); // lui $15, %hi(.got.plt entry) write32<E>(Buf + 4, 0x8df90000); // l[wd] $25, %lo(.got.plt entry)($15) - write32<E>(Buf + 8, isMipsR6() ? 0x03200009 : 0x03200008); // jr $25 + write32<E>(Buf + 8, JrInst); // jr $25 / jr.hb $25 write32<E>(Buf + 12, 0x25f80000); // addiu $24, $15, %lo(.got.plt entry) writeRelocation<E>(Buf, GotPltEntryAddr + 0x8000, 16, 16); writeRelocation<E>(Buf + 4, GotPltEntryAddr, 16, 0); Modified: vendor/lld/dist-release_60/ELF/Config.h ============================================================================== --- vendor/lld/dist-release_60/ELF/Config.h Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/ELF/Config.h Wed Jun 27 19:15:02 2018 (r335728) @@ -151,6 +151,7 @@ struct Configuration { bool WarnMissingEntry; bool ZCombreloc; bool ZExecstack; + bool ZHazardplt; bool ZNocopyreloc; bool ZNodelete; bool ZNodlopen; Modified: vendor/lld/dist-release_60/ELF/Driver.cpp ============================================================================== --- vendor/lld/dist-release_60/ELF/Driver.cpp Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/ELF/Driver.cpp Wed Jun 27 19:15:02 2018 (r335728) @@ -668,6 +668,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args Config->WarnCommon = Args.hasArg(OPT_warn_common); Config->ZCombreloc = !hasZOption(Args, "nocombreloc"); Config->ZExecstack = hasZOption(Args, "execstack"); + Config->ZHazardplt = hasZOption(Args, "hazardplt"); Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc"); Config->ZNodelete = hasZOption(Args, "nodelete"); Config->ZNodlopen = hasZOption(Args, "nodlopen"); Modified: vendor/lld/dist-release_60/MinGW/Driver.cpp ============================================================================== --- vendor/lld/dist-release_60/MinGW/Driver.cpp Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/MinGW/Driver.cpp Wed Jun 27 19:15:02 2018 (r335728) @@ -154,6 +154,8 @@ bool mingw::link(ArrayRef<const char *> ArgsArr, raw_o Add("-debug:dwarf"); if (Args.hasArg(OPT_large_address_aware)) Add("-largeaddressaware"); + if (Args.hasArg(OPT_kill_at)) + Add("-kill-at"); if (Args.getLastArgValue(OPT_m) != "thumb2pe" && Args.getLastArgValue(OPT_m) != "arm64pe" && !Args.hasArg(OPT_dynamicbase)) Modified: vendor/lld/dist-release_60/MinGW/Options.td ============================================================================== --- vendor/lld/dist-release_60/MinGW/Options.td Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/MinGW/Options.td Wed Jun 27 19:15:02 2018 (r335728) @@ -14,6 +14,7 @@ def export_all_symbols: F<"export-all-symbols">, def gc_sections: F<"gc-sections">, HelpText<"Remove unused sections">; def icf: J<"icf=">, HelpText<"Identical code folding">; def image_base: S<"image-base">, HelpText<"Base address of the program">; +def kill_at: F<"kill-at">, HelpText<"Remove @n from exported symbols">; def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">, HelpText<"Root name of library to use">; def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">; @@ -51,6 +52,7 @@ def build_id: F<"build-id">; def disable_auto_image_base: F<"disable-auto-image-base">; def enable_auto_image_base: F<"enable-auto-image-base">; def enable_auto_import: F<"enable-auto-import">; +def end_group: J<"end-group">; def full_shutdown: Flag<["--"], "full-shutdown">; def high_entropy_va: F<"high-entropy-va">, HelpText<"Enable 64-bit ASLR">; def major_image_version: S<"major-image-version">; @@ -59,6 +61,7 @@ def no_seh: F<"no-seh">; def nxcompat: F<"nxcompat">, HelpText<"Enable data execution prevention">; def pic_executable: F<"pic-executable">; def sysroot: J<"sysroot">, HelpText<"Sysroot">; +def start_group: J<"start-group">; def tsaware: F<"tsaware">, HelpText<"Create Terminal Server aware executable">; def v: Flag<["-"], "v">, HelpText<"Display the version number">; def version: F<"version">, HelpText<"Display the version number and exit">; Modified: vendor/lld/dist-release_60/test/COFF/def-export-stdcall.s ============================================================================== --- vendor/lld/dist-release_60/test/COFF/def-export-stdcall.s Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/test/COFF/def-export-stdcall.s Wed Jun 27 19:15:02 2018 (r335728) @@ -46,7 +46,8 @@ # DECORATED-EXPORTS: Name: vectorcall@@8 -# RUN: echo -e "LIBRARY foo\nEXPORTS\n stdcall@8\n @fastcall@8" > %t.def +# GNU tools don't support vectorcall at the moment, but test it for completeness. +# RUN: echo -e "LIBRARY foo\nEXPORTS\n stdcall@8\n @fastcall@8\n vectorcall@@8" > %t.def # RUN: lld-link -lldmingw -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib # RUN: llvm-readobj %t.lib | FileCheck -check-prefix DECORATED-MINGW-IMPLIB %s # RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix DECORATED-MINGW-EXPORTS %s @@ -57,9 +58,39 @@ # DECORATED-MINGW-IMPLIB: Name type: noprefix # DECORATED-MINGW-IMPLIB-NEXT: __imp__stdcall@8 # DECORATED-MINGW-IMPLIB-NEXT: _stdcall@8 +# GNU tools don't support vectorcall, but this test is just to track that +# lld's behaviour remains consistent over time. +# DECORATED-MINGW-IMPLIB: Name type: name +# DECORATED-MINGW-IMPLIB-NEXT: __imp_vectorcall@@8 +# DECORATED-MINGW-IMPLIB-NEXT: vectorcall@@8 # DECORATED-MINGW-EXPORTS: Name: @fastcall@8 # DECORATED-MINGW-EXPORTS: Name: stdcall@8 +# DECORATED-MINGW-EXPORTS: Name: vectorcall@@8 + +# RUN: lld-link -lldmingw -kill-at -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck -check-prefix MINGW-KILL-AT-IMPLIB %s +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix MINGW-KILL-AT-EXPORTS %s + +# RUN: lld-link -lldmingw -kill-at -entry:dllmain -dll %t.obj -out:%t.dll -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck -check-prefix MINGW-KILL-AT-IMPLIB %s +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix MINGW-KILL-AT-EXPORTS %s + +# MINGW-KILL-AT-IMPLIB: Name type: noprefix +# MINGW-KILL-AT-IMPLIB: __imp__fastcall +# MINGW-KILL-AT-IMPLIB-NEXT: _fastcall +# MINGW-KILL-AT-IMPLIB: Name type: noprefix +# MINGW-KILL-AT-IMPLIB-NEXT: __imp__stdcall +# MINGW-KILL-AT-IMPLIB-NEXT: _stdcall +# GNU tools don't support vectorcall, but this test is just to track that +# lld's behaviour remains consistent over time. +# MINGW-KILL-AT-IMPLIB: Name type: noprefix +# MINGW-KILL-AT-IMPLIB-NEXT: __imp__vectorcall +# MINGW-KILL-AT-IMPLIB-NEXT: _vectorcall + +# MINGW-KILL-AT-EXPORTS: Name: fastcall +# MINGW-KILL-AT-EXPORTS: Name: stdcall +# MINGW-KILL-AT-EXPORTS: Name: vectorcall .def _stdcall@8; Modified: vendor/lld/dist-release_60/test/ELF/mips-26-n32-n64.s ============================================================================== --- vendor/lld/dist-release_60/test/ELF/mips-26-n32-n64.s Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/test/ELF/mips-26-n32-n64.s Wed Jun 27 19:15:02 2018 (r335728) @@ -5,8 +5,12 @@ # RUN: ld.lld %t-so.o -shared -o %t.so # RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o # RUN: ld.lld %t.o %t.so -o %t.exe -# RUN: llvm-objdump -d %t.exe | FileCheck %s +# RUN: llvm-objdump -d %t.exe | FileCheck %s --check-prefixes=CHECK,DEFAULT +# RUN: ld.lld %t-so.o -shared -o %t.so -z hazardplt +# RUN: ld.lld %t.o %t.so -o %t.exe -z hazardplt +# RUN: llvm-objdump -d %t.exe | FileCheck %s --check-prefixes=CHECK,HAZARDPLT + # REQUIRES: mips # CHECK: Disassembly of section .text: @@ -21,11 +25,13 @@ # CHECK-NEXT: 2001c: 03 0e c0 23 subu $24, $24, $14 # CHECK-NEXT: 20020: 03 e0 78 25 move $15, $ra # CHECK-NEXT: 20024: 00 18 c0 c2 srl $24, $24, 3 -# CHECK-NEXT: 20028: 03 20 f8 09 jalr $25 +# DEFAULT: 20028: 03 20 f8 09 jalr $25 +# HAZARDPLT: 20028: 03 20 fc 09 jalr.hb $25 # CHECK-NEXT: 2002c: 27 18 ff fe addiu $24, $24, -2 # CHECK-NEXT: 20030: 3c 0f 00 03 lui $15, 3 # CHECK-NEXT: 20034: 8d f9 00 18 lw $25, 24($15) -# CHECK-NEXT: 20038: 03 20 00 08 jr $25 +# DEFAULT: 20038: 03 20 00 08 jr $25 +# HAZARDPLT: 20038: 03 20 04 08 jr.hb $25 # CHECK-NEXT: 2003c: 25 f8 00 18 addiu $24, $15, 24 .text Modified: vendor/lld/dist-release_60/test/ELF/mips-plt-r6.s ============================================================================== --- vendor/lld/dist-release_60/test/ELF/mips-plt-r6.s Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/test/ELF/mips-plt-r6.s Wed Jun 27 19:15:02 2018 (r335728) @@ -6,7 +6,10 @@ # RUN: -mcpu=mips32r6 %S/Inputs/mips-dynamic.s -o %t2.o # RUN: ld.lld %t2.o -shared -o %t.so # RUN: ld.lld %t1.o %t.so -o %t.exe -# RUN: llvm-objdump -d %t.exe | FileCheck %s +# RUN: llvm-objdump -d %t.exe | FileCheck %s --check-prefixes=DEFAULT,CHECK +# RUN: ld.lld %t2.o -shared -o %t.so -z hazardplt +# RUN: ld.lld %t1.o %t.so -o %t.exe -z hazardplt +# RUN: llvm-objdump -d %t.exe | FileCheck %s --check-prefixes=HAZARDPLT,CHECK # REQUIRES: mips @@ -24,12 +27,14 @@ # CHECK-NEXT: 2001c: 03 1c c0 23 subu $24, $24, $gp # CHECK-NEXT: 20020: 03 e0 78 25 move $15, $ra # CHECK-NEXT: 20024: 00 18 c0 82 srl $24, $24, 2 -# CHECK-NEXT: 20028: 03 20 f8 09 jalr $25 +# DEFAULT: 20028: 03 20 f8 09 jalr $25 +# HAZARDPLT: 20028: 03 20 fc 09 jalr.hb $25 # CHECK-NEXT: 2002c: 27 18 ff fe addiu $24, $24, -2 # CHECK-NEXT: 20030: 3c 0f 00 03 aui $15, $zero, 3 # CHECK-NEXT: 20034: 8d f9 00 0c lw $25, 12($15) -# CHECK-NEXT: 20038: 03 20 00 09 jr $25 +# DEFAULT: 20038: 03 20 00 09 jr $25 +# HAZARDPLT: 20038: 03 20 04 09 jr.hb $25 # CHECK-NEXT: 2003c: 25 f8 00 0c addiu $24, $15, 12 .text Modified: vendor/lld/dist-release_60/test/MinGW/driver.test ============================================================================== --- vendor/lld/dist-release_60/test/MinGW/driver.test Wed Jun 27 19:14:58 2018 (r335727) +++ vendor/lld/dist-release_60/test/MinGW/driver.test Wed Jun 27 19:15:02 2018 (r335728) @@ -124,3 +124,7 @@ ICF-NONE: -opt:noicf RUN: ld.lld -### -m i386pep foo.o --icf=all | FileCheck -check-prefix ICF %s RUN: ld.lld -### -m i386pep foo.o -icf=all | FileCheck -check-prefix ICF %s ICF: -opt:icf + +RUN: ld.lld -### foo.o -m i386pe -shared --kill-at | FileCheck -check-prefix=KILL-AT %s +RUN: ld.lld -### foo.o -m i386pe -shared -kill-at | FileCheck -check-prefix=KILL-AT %s +KILL-AT: -kill-at
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806271915.w5RJF2UH043254>