head 1.10; access; symbols pkgsrc-2021Q3:1.9.0.2 pkgsrc-2021Q3-base:1.9 pkgsrc-2021Q2:1.8.0.10 pkgsrc-2021Q2-base:1.8 pkgsrc-2021Q1:1.8.0.8 pkgsrc-2021Q1-base:1.8 pkgsrc-2020Q4:1.8.0.6 pkgsrc-2020Q4-base:1.8 pkgsrc-2020Q3:1.8.0.4 pkgsrc-2020Q3-base:1.8 pkgsrc-2020Q2:1.8.0.2 pkgsrc-2020Q2-base:1.8 pkgsrc-2020Q1:1.7.0.2 pkgsrc-2020Q1-base:1.7 pkgsrc-2019Q4:1.7.0.4 pkgsrc-2019Q4-base:1.7 pkgsrc-2019Q3:1.3.0.2 pkgsrc-2019Q3-base:1.3 pkgsrc-2019Q2:1.2.0.2 pkgsrc-2019Q2-base:1.2 pkgsrc-2019Q1:1.1.0.2 pkgsrc-2019Q1-base:1.1; locks; strict; comment @// @; 1.10 date 2021.11.23.20.55.42; author wiz; state dead; branches; next 1.9; commitid 1fDG4kXskvkoGXhD; 1.9 date 2021.07.12.18.47.15; author adam; state Exp; branches; next 1.8; commitid 7eASzeZNvc8ciJ0D; 1.8 date 2020.04.18.08.00.50; author adam; state Exp; branches; next 1.7; commitid Xx94EFaiCx28bQ4C; 1.7 date 2019.11.03.12.40.40; author kamil; state Exp; branches; next 1.6; commitid L4baR9ndRQ836pJB; 1.6 date 2019.11.03.12.10.29; author kamil; state Exp; branches; next 1.5; commitid pSAz7RMpuekaVoJB; 1.5 date 2019.10.21.22.07.58; author rjs; state Exp; branches; next 1.4; commitid Ygr4vZyn5JnEEMHB; 1.4 date 2019.10.19.14.02.36; author adam; state dead; branches; next 1.3; commitid atcrPEYWAllc2uHB; 1.3 date 2019.09.08.20.49.11; author rjs; state Exp; branches; next 1.2; commitid C5zhokRaM6DjBfCB; 1.2 date 2019.06.02.08.37.39; author adam; state Exp; branches; next 1.1; commitid filMzNk3Kc2lHApB; 1.1 date 2019.02.01.16.30.00; author mgorny; state Exp; branches; next ; commitid D1ojZ6HAiRdVc5aB; desc @@ 1.10 log @llvm: update llvm and friends to 13.0.0 Tested on NetBSD-current and 9.1/amd64. Also update packages tightly coupled to llvm, if new versions are available. Mark creduce, include-what-you-use, and zig broken (waiting for a new release). Changes: Non-comprehensive list of changes in this release Windows Control-flow Enforcement Technology: the -ehcontguard option now emits valid unwind entrypoints which are validated when the context is being set during exception handling. Flang is now included in the binary packages released by LLVM. The debuginfo-test project has been renamed cross-project-tests and is now intended for testing components from multiple projects, not just debug information. The new “cross-project-tests” name replaces “debuginfo-test” in LLVM_ENABLE_PROJECTS, and a new check-cross-project-tests target has been added for running all tests in the project. The pre-existing check-debuginfo- test target remains for running just the debug information tests. (D95339 and D96513) Changes to the LLVM IR The inalloca attribute now has a mandatory type field, similar to byval and sret. The opaque pointer type ptr has been introduced. It is still in the process of being worked on and should not be used yet. Using the legacy pass manager for the optimization pipeline is deprecated and will be removed after LLVM 14. In the meantime, only minimal effort will be made to maintain the legacy pass manager for the optimization pipeline. Changes to building LLVM The build system now supports building multiple distributions, so that you can e.g. have one distribution containing just tools and another for libraries (to enable development). See Multi-distribution configurations for details. Changes to the AArch64 Backend Introduced assembly support for Armv9-A’s Realm Management Extension (RME) and Scalable Matrix Extension (SME). Produce proper cross-section relative relocations on COFF Fixed the calling convention on Windows for variadic functions involving floats in the fixed arguments Changes to the ARM Backend Produce proper cross-section relative relocations on COFF Changes to the Hexagon Target The Hexagon target now supports V68/HVX ISA. Changes to the C API The C API functions LLVMGetAlignment and LLVMSetAlignment now allow changing alignment on atomicrmw and cmpxchg instructions A new entry LLVMDIArgListMetadataKind was added to the LLVMMetadataKind enum, representing DIArgLists (D88175) Type attributes have been added to LLVM-C, introducing LLVMCreateTypeAttribute, LLVMGetTypeAttributeValue and LLVMIsTypeAttribute. (D977763’) The LTO_API_VERSION was bumped to 28, introducing a new function lto_set_debug_options for parsing LTO debug options (D92611) LLVMJITTargetSymbolFlags was renamed to LLVMJITSymbolTargetFlags (rG8d718a0bff73af066675a6258c01307937c33cf9) The C API received support for creating custom ORCv2 MaterializationUnits and APIs to retrieve an LLJIT instance’s linking layers. An ABI breaking change for LLVMOrcAbsoluteSymbols was introduced to make it consistent with LLVMOrcCreateCustomMaterializationUnit. (rGc8fc5e3ba942057d6c4cdcd1faeae69a28e7b671) The C API received support for adding ORCv2 object buffers directly to an object layer. (rG7b73cd684a8d5fb44d34064200f10e2723085c33) A breaking change to LLVMGetInlineAsm was introduced, adding a ninth argument LLVMBool CanThrow (D95745) The C API received support for calling into the new pass manager. (D102136) The C API function LLVMIntrinsicCopyOverloadedName has been deprecated. Please migrate to LLVMIntrinsicCopyOverloadedName2 which takes an extra module argument and which also handles unnamed types. (D99173) The C API received support for dumping objects from ORCv2 (rGcec8e69f01c3374cb38c6683058381b96fab8f89) A breaking change to LLVMOrcObjectTransformLayerTransformFunction was introduced, changing the order of the function pointer’s arguments. (rG8962c68ad007a525f9daa987c99eda57e0d0069a) The C API received support for accessing utilities from the LLJIT IRTransformLayer and ThreadSafeModule classes. (D103855) The C API received support for creating lazy-export MaterializationUnits (D104672) The C API function LLVMPassBuilderOptionsSetCoroutines was removed because couroutine passes have been enabled by default. (D105877) comdat noduplicates was renamed to comdat nodeduplicate and as a result, LLVMNoDuplicatesComdatSelectionKind was renamed to LLVMNoDeduplicateComdatSelectionKind. (D106319) Changes to the FastISel infrastructure FastISel no longer tracks killed registers, and instead leaves this to the register allocator. This means that hasTrivialKill() is removed, as well as the OpNIsKill parameters to the fastEmit_*() family of functions. Changes to the LLVM tools The options --build-id-link-{dir,input,output} have been deleted. (D96310) Support for in-order processors has been added to llvm-mca. (D94928) llvm-objdump supports -M {att,intel} now. --x86-asm-syntax is a deprecated internal option which will be removed in LLVM 14.0.0. (D101695) The llvm-readobj short aliases -s (previously --sections) and -t (previously --syms) have been changed to --syms and --section-details respectively, to match llvm-readelf. (D105055) The llvm-nm short aliases -M (--print-armap), -U (--defined-only), and -W (--no-weak) are now deprecated. Use the long form versions instead. The alias --just-symbol-name is now deprecated in favor of --format=just-symbols and -j. (D105330) In lli the default JIT engine switched from MCJIT (-jit-kind=mcjit) to ORC (-jit-kind=orc). (D98931) llvm-rc got support for invoking Clang to preprocess its input. (D100755) llvm-rc got a GNU windres compatible frontend, llvm-windres. (D100756) llvm-ml has improved compatibility with MS ml.exe, managing to assemble more asm files. Changes to LLDB LLDB executable is now included in pre-built LLVM binaries. LLDB now includes full featured support for AArch64 SVE register access. LLDB now supports AArch64 Pointer Authentication, allowing stack unwind with signed return address. LLDB now supports debugging programs on AArch64 Linux that use memory tagging (MTE). Added memory tag read and memory tag write commands. The memory region command will note when a region has memory tagging enabled. Synchronous and asynchronous tag faults are recognised. Synchronous tag faults have memory tag annotations in addition to the usual fault address. @ text @$NetBSD: patch-ELF_Driver.cpp,v 1.9 2021/07/12 18:47:15 adam Exp $ Add dummy option for an AArch64 erratum. --- ELF/Driver.cpp.orig 2020-10-07 10:10:48.000000000 +0000 +++ ELF/Driver.cpp @@@@ -135,7 +135,7 @@@@ static std::tuple ret = StringSwitch>(s) .Cases("aarch64elf", "aarch64linux", "aarch64_elf64_le_vec", - {ELF64LEKind, EM_AARCH64}) + "aarch64nbsd", {ELF64LEKind, EM_AARCH64}) .Cases("armelf", "armelf_linux_eabi", {ELF32LEKind, EM_ARM}) .Case("elf32_x86_64", {ELF32LEKind, EM_X86_64}) .Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS}) @@@@ -300,6 +300,9 @@@@ static void checkOptions() { if (config->emachine == EM_MIPS && config->gnuHash) error("the .gnu.hash section is not compatible with the MIPS target"); + if (config->fixCortexA53Errata835769 && config->emachine != EM_AARCH64) + error("--fix-cortex-a53-835769 is only supported on AArch64 targets"); + if (config->fixCortexA53Errata843419 && config->emachine != EM_AARCH64) error("--fix-cortex-a53-843419 is only supported on AArch64 targets"); @@@@ -937,6 +940,8 @@@@ static void readConfigs(opt::InputArgLis args.hasFlag(OPT_export_dynamic, OPT_no_export_dynamic, false); config->filterList = args::getStrings(args, OPT_filter); config->fini = args.getLastArgValue(OPT_fini, "_fini"); + config->fixCortexA53Errata835769 = args.hasArg(OPT_fix_cortex_a53_843419) && + !args.hasArg(OPT_relocatable); config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419) && !args.hasArg(OPT_relocatable); config->fixCortexA8 = @ 1.9 log @lld lldb: updated to 12.0.1 12.0.1 Non-comprehensive list of changes in this release ELF Improvements --dependency-file has been added. (Similar to cc -M -MF.) (D82437) --error-handling-script has been added to allow for user-defined handlers upon missing libraries. (D87758) --exclude-libs can now localize defined version symbols and bitcode referenced libcall symbols. (D94280) --gdb-index now works with DWARF v5 and --icf={safe,all}. (D85579) (D89751) --gdb-index --emit-relocs can now be used together. (D94354) --icf={safe,all} conservatively no longer fold text sections with LSDA. Previously ICF on -fexceptions code could be unsafe. (D84610) --icf={safe,all} can now fold two sections with relocations referencing aliased symbols. (D88830) --lto-pseudo-probe-for-profiling has been added. (D95056) --no-lto-whole-program-visibility has been added. (D92060) --oformat-binary has been fixed to respect LMA. (D85086) --reproduce includes --lto-sample-profile, --just-symbols, --call-graph-ordering-file, --retain-symbols-file files. -r --gc-sections is now supported. (D84131) A -u specified symbol will no longer change the binding to STB_WEAK. (D88945) --wrap support has been improved. + If foo is not referenced, there is no longer an undefined symbol __wrap_foo. + If __real_foo is not referenced, there is no longer an undefined symbol foo. SHF_LINK_ORDER sections can now have zero sh_link values. SHF_LINK_ORDER and non-SHF_LINK_ORDER sections can now be mixed within an input section description. (D84001) LOG2CEIL is now supported in linker scripts. (D84054) DEFINED has been fixed to check whether the symbol is defined. (D83758) An input section description may now have multiple SORT_*. The matched sections are ordered by radix sort with the keys being (SORT*, --sort-section, input order). (D91127) Users can now provide a GNU style linker script to convert .ctors into .init_array. (D91187) An empty output section can now be discarded even if it is assigned to a program header. (D92301) Non-SHF_ALLOC sections now have larger file offsets than SHF_ALLOC sections. (D85867) Some symbol versioning improvements. + Defined foo@@@@v1 now resolve undefined foo@@v1 (D92259) + Undefined foo@@v1 now gets an error (D92260) The AArch64 port now has support for STO_AARCH64_VARIANT_PCS and DT_AARCH64_VARIANT_PCS. (D93045) The AArch64 port now has support for R_AARCH64_LD64_GOTPAGE_LO15. The PowerPC64 port now detects missing R_PPC64_TLSGD/R_PPC64_TLSLD and disables TLS relaxation. This allows linking with object files produced by very old IBM XL compilers. (D92959) Many PowerPC PC-relative relocations are now supported. R_PPC_ADDR24 and R_PPC64_ADDR16_HIGH are now supported. powerpcle is now supported. Tested with FreeBSD loader and freestanding. (D93917) RISC-V: the first SHT_RISCV_ATTRIBUTES section is now retained. (D86309) LTO pipeline now defaults to the new PM if the CMake variable ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER is on. (D92885) @ text @d1 1 a1 1 $NetBSD: patch-ELF_Driver.cpp,v 1.8 2020/04/18 08:00:50 adam Exp $ @ 1.8 log @lld: updated to 10.0.0 Non-comprehensive list of changes in this release ELF Improvements Glob pattern, which you can use in linker scripts or version scripts, now supports ` and `[!…]. Except character classes New elf32btsmipn32_fbsd and elf32ltsmipn32_fbsd emulations are supported. Relax MIPS jalr and jr instructions marked by the R_MIPS_JALR relocation. For certain “undefined symbol” errors, a definition with a close spelling will be suggested. extern "C" is suggested if an undefined reference is mangled(unmangled) while there is a likely unmangled(mangled) definition. New -z noseparate-code, -z separate-code and -z separate-loadable-segments. -z noseparate-code is the default, which can reduce sizes of linked binaries by up to 3 times maxpagesize. -z force-bti and -z pac-plt are added for AArch64 Branch Target Identification and Pointer Authentication. --fix-cortex-a8 is added to fix erratum 657417. -z force-ibt and -z shstk are added for Intel Control-flow Enforcement Technology. PT_GNU_PROPERTY is added to help loaders locate the .note.gnu.property section. It may be used by a future Linux kernel. For --compress-debug-sections=zlib, -O0 and -O1 enable compression level 1 while -O2 enables compression level 6. -O1 Range extension thunks with addends are implemented for AArch64, PowerPC32 and PowerPC64. R_RISCV_ALIGN will be errored because linker relaxation for RISC-V is not supported. Pass -mno-relax to disable R_RISCV_ALIGN. The ARM port will no longer insert interworking thunks for non STT_FUNC symbols. The quality of PowerPC32 port has been greatly improved The PowerPC64 port supports non-preemptible IFUNC. lld creates a RO PT_LOAD and a RX PT_LOAD without a linker script. lld creates a unified RX PT_LOAD with a linker script. A future release will eliminate this difference and use a RO PT_LOAD and a RX PT_LOAD by default. The linker script case will require --no-rosegment to restore the current behavior. GNU style compressed debug sections .zdebug Breaking changes -Ttext=$base -Ttext-segment is no longer supported. Its meaning was different from GNU ld’s and could cause subtle bugs. MinGW Improvements Allow using custom .edata sections from input object files Don’t implicitly create import libraries unless requested Support merging multiple resource object files Demangle itanium symbol names in warnings/error messages Print source locations for undefined references and duplicate symbols, if possible Look for more filename patterns when resolving -l options Don’t error out on duplicate absolute symbols with the same value WebAssembly Improvements __data_end and __heap_base are no longer exported by default, as it’s best to keep them internal when possible. They can be explicitly exported with –export=__data_end and –export=__heap_base, respectively. wasm-ld now elides .bss sections when the memory is not imported @ text @d1 1 a1 1 $NetBSD: patch-ELF_Driver.cpp,v 1.7 2019/11/03 12:40:40 kamil Exp $ d5 1 a5 1 --- ELF/Driver.cpp.orig 2020-03-23 15:01:02.000000000 +0000 d7 1 a7 1 @@@@ -132,7 +132,7 @@@@ static std::tuplefixCortexA53Errata835769 = args.hasArg(OPT_fix_cortex_a53_843419); config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419); config->fixCortexA8 = args.hasArg(OPT_fix_cortex_a8); config->forceBTI = hasZOption(args, "force-bti"); @ 1.7 log @lld: Disable gnustack on NetBSD Fix corrupted text in description of cherry-picked patch for gnustack. @ text @d1 1 a1 4 $NetBSD: patch-ELF_Driver.cpp,v 1.6 2019/11/03 12:10:29 kamil Exp $ Cherry-pick upstream patch commit 2a0fcae3d4d1fd85d6ae8378d7c6f12430c0087d [lld] [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STACK d5 1 a5 1 --- ELF/Driver.cpp.orig 2019-07-17 14:54:02.000000000 +0000 d7 1 a7 1 @@@@ -129,7 +129,7 @@@@ static std::tuplegetValue()) + return GnuStackKind::Exec; + if (StringRef("noexecstack") == arg->getValue()) + return GnuStackKind::NoExec; + if (StringRef("nognustack") == arg->getValue()) + return GnuStackKind::None; + } + + // default + return GnuStackKind::NoExec; +} + static bool isKnownZFlag(StringRef s) { return s == "combreloc" || s == "copyreloc" || s == "defs" || s == "execstack" || s == "global" || s == "hazardplt" || @@@@ -380,6 +397,7 @@@@ static bool isKnownZFlag(StringRef s) { s == "keep-text-section-prefix" || s == "lazy" || s == "muldefs" || s == "nocombreloc" || s == "nocopyreloc" || s == "nodefaultlib" || s == "nodelete" || s == "nodlopen" || s == "noexecstack" || + s == "nognustack" || s == "nokeep-text-section-prefix" || s == "norelro" || s == "notext" || s == "now" || s == "origin" || s == "relro" || s == "retpolineplt" || s == "rodynamic" || s == "text" || s == "wxneeded" || @@@@ -828,6 +846,7 @@@@ static void readConfigs(opt::InputArgLis d32 2 a33 10 config->forceBTI = args.hasArg(OPT_force_bti); config->requireCET = args.hasArg(OPT_require_cet); @@@@ -921,6 +940,7 @@@@ static void readConfigs(opt::InputArgLis config->zCopyreloc = getZFlag(args, "copyreloc", "nocopyreloc", true); config->zExecstack = getZFlag(args, "execstack", "noexecstack", false); config->zGlobal = hasZOption(args, "global"); + config->zGnustack = getZGnuStack(args); config->zHazardplt = hasZOption(args, "hazardplt"); config->zIfuncNoplt = hasZOption(args, "ifunc-noplt"); config->zInitfirst = hasZOption(args, "initfirst"); @ 1.6 log @lld: Sync local patches with merged and pending patches upstream Cherry-pick upstream patch commit 2a0fcae3d4d1fd85d6ae8378d7c6f12430c0087d [lld] [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STAC dummy option for an AArch64 erratum. [LLD] Add NetBSD support as a new flavor of LLD (nb.lld) https://reviews.llvm.org/D69755 Clang >=clang-9.0.0nb3 is required. @ text @d1 1 a1 1 $NetBSD$ d4 1 a4 1 [lld] [ELF] Add '-z nognustack' opt to suppress emitting PT_GNU_STAC dummy option for an AArch64 erratum. @ 1.5 log @Restore NetBSD patches. Set correct link address for NetBSD/aarch64. Add a dummy option for an aarch64 erratum for gcc compatibility. @ text @d1 1 a1 1 $NetBSD: $ d3 2 a4 2 Add support for customizing LLD behavior on target triple. https://reviews.llvm.org/D56650 d6 1 a6 10 Add '-z nognustack' option to disable emitting PT_GNU_STACK. https://reviews.llvm.org/D56554 Alter defaults for NetBSD targets: * add default library search paths * force combined RO+RW segment due to ld.elf_so limitations * disable PT_GNU_STACK (meaningless on NetBSD) * disable 'new dtags', i.e. force RPATH instead of RUNPATH Add dummy handler for an AArch64 erratum. d10 1 a10 18 @@@@ -54,6 +54,7 @@@@ #include "llvm/Support/LEB128.h" #include "llvm/Support/Path.h" #include "llvm/Support/TarWriter.h" +#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include @@@@ -73,6 +74,8 @@@@ LinkerDriver *elf::driver; static void setConfigs(opt::InputArgList &args); static void readConfigs(opt::InputArgList &args); +static void appendDefaultSearchPaths(void); +static void setTargetTriple(StringRef argv0, opt::InputArgList &args); bool elf::link(ArrayRef args, bool canExitEarly, raw_ostream &error) { @@@@ -129,7 +132,7 @@@@ static std::tuplesingleRoRx && !script->hasSectionsCommand) error("-execute-only and -no-rosegment cannot be used together"); + } else if (config->targetTriple.isOSNetBSD()) { + // force-disable RO segment on NetBSD due to ld.elf_so limitations + config->singleRoRx = true; } if (config->zRetpolineplt && config->requireCET) @@@@ -373,6 +382,20 @@@@ static bool getZFlag(opt::InputArgList & d50 1 a50 1 @@@@ -380,6 +403,7 @@@@ static bool isKnownZFlag(StringRef s) { d54 1 a54 1 + s == "nognustack" || d58 1 a58 133 @@@@ -394,6 +418,56 @@@@ static void checkZOptions(opt::InputArgL error("unknown -z value: " + StringRef(arg->getValue())); } +static void appendDefaultSearchPaths() { + if (config->targetTriple.isOSNetBSD()) { + // NetBSD driver relies on the linker knowing the default search paths. + // Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp + // (NetBSD::NetBSD constructor) + switch (config->targetTriple.getArch()) { + case llvm::Triple::x86: + config->searchPaths.push_back("=/usr/lib/i386"); + break; + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: + switch (config->targetTriple.getEnvironment()) { + case llvm::Triple::EABI: + case llvm::Triple::GNUEABI: + config->searchPaths.push_back("=/usr/lib/eabi"); + break; + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: + config->searchPaths.push_back("=/usr/lib/eabihf"); + break; + default: + config->searchPaths.push_back("=/usr/lib/oabi"); + break; + } + break; +#if 0 // TODO + case llvm::Triple::mips64: + case llvm::Triple::mips64el: + if (tools::mips::hasMipsAbiArg(Args, "o32")) + config->searchPaths.push_back("=/usr/lib/o32"); + else if (tools::mips::hasMipsAbiArg(Args, "64")) + config->searchPaths.push_back("=/usr/lib/64"); + break; +#endif + case llvm::Triple::ppc: + config->searchPaths.push_back("=/usr/lib/powerpc"); + break; + case llvm::Triple::sparc: + config->searchPaths.push_back("=/usr/lib/sparc"); + break; + default: + break; + } + + config->searchPaths.push_back("=/usr/lib"); + } +} + void LinkerDriver::main(ArrayRef argsArr) { ELFOptTable parser; opt::InputArgList args = parser.parse(argsArr.slice(1)); @@@@ -408,6 +482,8 @@@@ void LinkerDriver::main(ArrayReftargetTriple.str()); + } if (const char *path = getReproduceOption(args)) { // Note that --reproduce is a debug option so you can ignore it @@@@ -442,6 +520,8 @@@@ void LinkerDriver::main(ArrayReftargetTriple = llvm::Triple(targetOpt); + return; + } else + error("Unsupported --target=" + targetOpt + ": " + targetError); + } + + // Secondly, try to get it from program name prefix + std::string ProgName = llvm::sys::path::stem(argv0); + size_t lastComponent = ProgName.rfind('-'); + if (lastComponent != std::string::npos) { + std::string prefix = ProgName.substr(0, lastComponent); + if (llvm::TargetRegistry::lookupTarget(prefix, targetError)) { + config->targetTriple = llvm::Triple(prefix); + return; + } + } + + // Finally, use the default target triple + config->targetTriple = llvm::Triple(getDefaultTargetTriple()); +} + // Initializes Config members by the command line options. static void readConfigs(opt::InputArgList &args) { errorHandler().verbose = args.hasArg(OPT_verbose); @@@@ -820,7 +928,8 @@@@ static void readConfigs(opt::InputArgLis config->callGraphProfileSort = args.hasFlag( OPT_call_graph_profile_sort, OPT_no_call_graph_profile_sort, true); config->enableNewDtags = - args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true); + args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, + !config->targetTriple.isOSNetBSD()); config->entry = args.getLastArgValue(OPT_entry); config->executeOnly = args.hasFlag(OPT_execute_only, OPT_no_execute_only, false); @@@@ -828,6 +937,7 @@@@ static void readConfigs(opt::InputArgLis d66 1 a66 1 @@@@ -921,6 +1031,7 @@@@ static void readConfigs(opt::InputArgLis a73 9 @@@@ -1234,7 +1345,7 @@@@ void LinkerDriver::inferMachineType() { // each target. static uint64_t getMaxPageSize(opt::InputArgList &args) { uint64_t val = args::getZOptionValue(args, OPT_z, "max-page-size", - target->defaultMaxPageSize); + lld::elf::target->defaultMaxPageSize); if (!isPowerOf2_64(val)) error("max-page-size: value isn't a power of 2"); if (config->nmagic || config->omagic) { @ 1.4 log @lld: remove unused patches @ text @d1 1 a1 1 $NetBSD: patch-ELF_Driver.cpp,v 1.3 2019/09/08 20:49:11 rjs Exp $ d15 3 a17 1 --- ELF/Driver.cpp.orig 2019-02-14 10:49:15.000000000 +0000 d27 27 a53 1 @@@@ -318,6 +319,9 @@@@ static void checkOptions() { d55 3 a57 1 if (Config->SingleRoRx && !Script->HasSectionsCommand) d59 1 a59 1 + } else if (Config->TargetTriple.isOSNetBSD()) { d61 1 a61 1 + Config->SingleRoRx = true; d63 4 d69 27 a95 10 @@@@ -352,6 +356,7 @@@@ static bool isKnownZFlag(StringRef S) { S == "keep-text-section-prefix" || S == "lazy" || S == "muldefs" || S == "nocombreloc" || S == "nocopyreloc" || S == "nodefaultlib" || S == "nodelete" || S == "nodlopen" || S == "noexecstack" || + S == "nognustack" || S == "nokeep-text-section-prefix" || S == "norelro" || S == "notext" || S == "now" || S == "origin" || S == "relro" || S == "retpolineplt" || S == "rodynamic" || S == "text" || S == "wxneeded" || @@@@ -365,6 +370,56 @@@@ static void checkZOptions(opt::InputArgL error("unknown -z value: " + StringRef(Arg->getValue())); d98 2 a99 2 +void LinkerDriver::appendDefaultSearchPaths() { + if (Config->TargetTriple.isOSNetBSD()) { d103 1 a103 1 + switch (Config->TargetTriple.getArch()) { d105 1 a105 1 + Config->SearchPaths.push_back("=/usr/lib/i386"); d111 1 a111 1 + switch (Config->TargetTriple.getEnvironment()) { d114 1 a114 1 + Config->SearchPaths.push_back("=/usr/lib/eabi"); d118 1 a118 1 + Config->SearchPaths.push_back("=/usr/lib/eabihf"); d121 1 a121 1 + Config->SearchPaths.push_back("=/usr/lib/oabi"); d129 1 a129 1 + Config->SearchPaths.push_back("=/usr/lib/o32"); d131 1 a131 1 + Config->SearchPaths.push_back("=/usr/lib/64"); d135 1 a135 1 + Config->SearchPaths.push_back("=/usr/lib/powerpc"); d138 1 a138 1 + Config->SearchPaths.push_back("=/usr/lib/sparc"); d144 1 a144 1 + Config->SearchPaths.push_back("=/usr/lib"); d148 4 a151 4 void LinkerDriver::main(ArrayRef ArgsArr) { ELFOptTable Parser; opt::InputArgList Args = Parser.parse(ArgsArr.slice(1)); @@@@ -378,6 +433,8 @@@@ void LinkerDriver::main(ArrayRefTargetTriple.str()); d170 1 a170 1 if (const char *Path = getReproduceOption(Args)) { d172 3 a174 1 @@@@ -412,6 +471,7 @@@@ void LinkerDriver::main(ArrayRefTargetTriple = llvm::Triple(TargetOpt); d195 1 a195 1 + error("Unsupported --target=" + TargetOpt + ": " + TargetError); d200 5 a204 5 + size_t LastComponent = ProgName.rfind('-'); + if (LastComponent != std::string::npos) { + std::string Prefix = ProgName.substr(0, LastComponent); + if (llvm::TargetRegistry::lookupTarget(Prefix, TargetError)) { + Config->TargetTriple = llvm::Triple(Prefix); d210 1 a210 1 + Config->TargetTriple = llvm::Triple(getDefaultTargetTriple()); d214 4 a217 4 void LinkerDriver::readConfigs(opt::InputArgList &Args) { errorHandler().Verbose = Args.hasArg(OPT_verbose); @@@@ -779,7 +867,8 @@@@ void LinkerDriver::readConfigs(opt::Inpu Config->CallGraphProfileSort = Args.hasFlag( d219 24 a242 17 Config->EnableNewDtags = - Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, true); + Args.hasFlag(OPT_enable_new_dtags, OPT_disable_new_dtags, + !Config->TargetTriple.isOSNetBSD()); Config->Entry = Args.getLastArgValue(OPT_entry); Config->ExecuteOnly = Args.hasFlag(OPT_execute_only, OPT_no_execute_only, false); @@@@ -869,6 +958,8 @@@@ void LinkerDriver::readConfigs(opt::Inpu Config->ZCombreloc = getZFlag(Args, "combreloc", "nocombreloc", true); Config->ZCopyreloc = getZFlag(Args, "copyreloc", "nocopyreloc", true); Config->ZExecstack = getZFlag(Args, "execstack", "noexecstack", false); + Config->ZNognustack = hasZOption(Args, "nognustack") || + Config->TargetTriple.isOSNetBSD(); Config->ZGlobal = hasZOption(Args, "global"); Config->ZHazardplt = hasZOption(Args, "hazardplt"); Config->ZInitfirst = hasZOption(Args, "initfirst"); @@@@ -1173,7 +1264,7 @@@@ void LinkerDriver::inferMachineType() { d244 5 a248 5 static uint64_t getMaxPageSize(opt::InputArgList &Args) { uint64_t Val = args::getZOptionValue(Args, OPT_z, "max-page-size", - Target->DefaultMaxPageSize); + lld::elf::Target->DefaultMaxPageSize); if (!isPowerOf2_64(Val)) d250 1 a250 1 return Val; @ 1.3 log @Fix setting configuration. @ text @d1 1 a1 1 $NetBSD: patch-ELF_Driver.cpp,v 1.2 2019/06/02 08:37:39 adam Exp $ @ 1.2 log @lld: updated to 8.0.0 lld 8.0.0: Non-comprehensive list of changes in this release ELF Improvements * lld now supports RISC-V. (r339364) * Default image base address has changed from 65536 to 2 MiB for i386 and 4 MiB for AArch64 to make lld-generated executables work better with automatic superpage promotion. FreeBSD can promote contiguous non-superpages to a superpage if they are aligned to the superpage size. (r342746) * lld now attempts to place a .note segment in the first page of a generated file, so that you can find some important information (.note.gnu.build-id in particular) in a core file even if a core file is truncated by ulimit. (r349524) * lld now reports an error if _GLOBAL_OFFSET_TABLE_ symbol is defined by an input object file, as the symbol is supposed to be synthesized by the linker. (r347854) * lld/Hexagon can now link Linux kernel and musl libc for Qualcomm Hexagon ISA. * Initial MSP430 ISA support has landed. * lld now uses the sigrie instruction as a trap instruction for MIPS targets. * lld now creates a TLS segment for AArch64 with a slightly larger alignment requirement, so that the loader makes a few bytes room before each TLS segment at runtime. The aim of this change is to make room to accomodate nonstandard Android TLS slots while keeping the compatibility with the standard AArch64 ABI. (r350681) * The following flags have been added: --call-graph-profile, --no-call-graph-profile, --warn-ifunc-textrel, -z interpose, -z global, -z nodefaultlib COFF Improvements * PDB GUID is set to hash of PDB contents instead to a random byte sequence for build reproducibility. * /pdbsourcepath: is now also used to make "cwd", "exe", "pdb" in the env block of PDB outputs absolute if they are relative, and to make paths to obj files referenced in PDB outputs absolute if they are relative. Together with the previous item, this makes it possible to generate executables and PDBs that are fully deterministic and independent of the absolute path to the build directory, so that different machines building the same code in different directories can produce exactly the same output. * The following flags have been added: /force:multiple * lld now can link against import libraries produced by GNU tools. * lld can create thunks for ARM and ARM64, to allow linking larger images (over 16 MB for ARM and over 128 MB for ARM64) * Several speed and memory usage improvements. * lld now creates debug info for typedefs. * lld can now link obj files produced by cl.exe /Z7 /Yc. * lld now understands %_PDB% and %_EXT% in /pdbaltpath:. * Undefined symbols are now printed in demangled form in addition to raw form. MinGW Improvements * lld can now automatically import data variables from DLLs without the use of the dllimport attribute. * lld can now use existing normal MinGW sysroots with import libraries and CRT startup object files for GNU binutils. lld can handle most object files produced by GCC, and thus works as a drop-in replacement for ld.bfd in such environments. (There are known issues with linking crtend.o from GCC in setups with DWARF exceptions though, where object files are linked in a different order than with GNU ld, inserting a DWARF exception table terminator too early.) * lld now supports COFF embedded directives for linking to nondefault libraries, just like for the normal COFF target. * Actually generate a codeview build id signature, even if not creating a PDB. Previously, the --build-id option did not actually generate a build id unless --pdb was specified. WebAssembly Improvements * Add initial support for creating shared libraries (-shared). Note: The shared library format is still under active development and may undergo significant changes in future versions. See: https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md @ text @d1 1 a1 1 $NetBSD: patch-ELF_Driver.cpp,v 1.1 2019/02/01 16:30:00 mgorny Exp $ d104 1 a104 1 + appendDefaultSearchPaths(); d121 9 a129 1 @@@@ -746,6 +805,34 @@@@ static void parseClangOption(StringRef O d164 1 a164 1 @@@@ -779,7 +866,8 @@@@ void LinkerDriver::readConfigs(opt::Inpu d174 1 a174 1 @@@@ -869,6 +957,8 @@@@ void LinkerDriver::readConfigs(opt::Inpu d183 1 a183 1 @@@@ -1173,7 +1263,7 @@@@ void LinkerDriver::inferMachineType() { @ 1.1 log @devel/lld: import lld-7.0.1 LLD is a linker from the LLVM project that is a drop-in replacement for system linkers and runs much faster than them. It also provides features that are useful for toolchain developers. @ text @d1 1 a1 1 $NetBSD$ d15 1 a15 1 --- ELF/Driver.cpp.orig 2018-07-31 21:58:26.000000000 +0000 d25 1 a25 1 @@@@ -309,6 +310,9 @@@@ static void checkOptions(opt::InputArgLi d35 1 a35 2 @@@@ -341,7 +345,7 @@@@ static bool isKnown(StringRef S) { S == "execstack" || S == "hazardplt" || S == "initfirst" || d37 3 a39 3 S == "nocombreloc" || S == "nocopyreloc" || S == "nodelete" || - S == "nodlopen" || S == "noexecstack" || + S == "nodlopen" || S == "noexecstack" || S == "nognustack" || d43 1 a43 1 @@@@ -355,6 +359,56 @@@@ static void checkZOptions(opt::InputArgL d100 1 a100 1 @@@@ -368,6 +422,29 @@@@ void LinkerDriver::main(ArrayRef> ErrOrWriter = + TarWriter::create(Path, path::stem(Path)); + if (ErrOrWriter) { + Tar = ErrOrWriter->get(); + Tar->append("response.txt", createResponseFile(Args)); + Tar->append("version.txt", getLLDVersion() + "\n"); + make>(std::move(*ErrOrWriter)); + } else { + error(Twine("--reproduce: failed to open ") + Path + ": " + + toString(ErrOrWriter.takeError())); + } + } + + + initLLVM(); + setTargetTriple(ArgsArr[0], Args); + readConfigs(Args); + checkZOptions(Args); d109 1 a109 1 @@@@ -383,8 +460,10 @@@@ void LinkerDriver::main(ArrayRef> ErrOrWriter = - TarWriter::create(Path, path::stem(Path)); - if (ErrOrWriter) { - Tar = ErrOrWriter->get(); - Tar->append("response.txt", createResponseFile(Args)); - Tar->append("version.txt", getLLDVersion() + "\n"); - make>(std::move(*ErrOrWriter)); - } else { - error(Twine("--reproduce: failed to open ") + Path + ": " + - toString(ErrOrWriter.takeError())); - } - } - - readConfigs(Args); - checkZOptions(Args); - initLLVM(); createFiles(Args); if (errorCount()) return; @@@@ -725,6 +785,34 @@@@ static void parseClangOption(StringRef O d156 3 a158 3 @@@@ -755,7 +843,8 @@@@ void LinkerDriver::readConfigs(opt::Inpu Args.hasFlag(OPT_eh_frame_hdr, OPT_no_eh_frame_hdr, false); Config->EmitRelocs = Args.hasArg(OPT_emit_relocs); d166 1 a166 1 @@@@ -842,6 +931,8 @@@@ void LinkerDriver::readConfigs(opt::Inpu d172 1 d175 1 a175 2 Config->ZKeepTextSectionPrefix = getZFlag( @@@@ -1137,7 +1228,7 @@@@ void LinkerDriver::inferMachineType() { @