head 1.3; access; symbols pkgsrc-2021Q2:1.2.0.14 pkgsrc-2021Q2-base:1.2 pkgsrc-2021Q1:1.2.0.12 pkgsrc-2021Q1-base:1.2 pkgsrc-2020Q4:1.2.0.10 pkgsrc-2020Q4-base:1.2 pkgsrc-2020Q3:1.2.0.8 pkgsrc-2020Q3-base:1.2 pkgsrc-2020Q2:1.2.0.6 pkgsrc-2020Q2-base:1.2 pkgsrc-2020Q1:1.2.0.2 pkgsrc-2020Q1-base:1.2 pkgsrc-2019Q4:1.2.0.4 pkgsrc-2019Q4-base:1.2; locks; strict; comment @// @; 1.3 date 2021.07.12.18.47.15; author adam; state dead; branches; next 1.2; commitid 7eASzeZNvc8ciJ0D; 1.2 date 2019.11.03.12.40.40; author kamil; state Exp; branches; next 1.1; commitid L4baR9ndRQ836pJB; 1.1 date 2019.11.03.12.11.27; author kamil; state Exp; branches; next ; commitid TWPAPOLQlso9WoJB; desc @@ 1.3 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 @$NetBSD: patch-tools_nb.lld_nb.lld.cpp,v 1.2 2019/11/03 12:40:40 kamil Exp $ [LLD] Add NetBSD support as a new flavor of LLD (nb.lld) https://reviews.llvm.org/D69755 Disable gnustack for NetBSD. --- tools/nb.lld/nb.lld.cpp.orig 2019-11-03 12:31:14.712069007 +0000 +++ tools/nb.lld/nb.lld.cpp @@@@ -0,0 +1,221 @@@@ +//===- nb.lld.cpp - NetBSD LLD standalone linker --------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// The NetBSD flavor of LLD. +// +// This code wraps the default ELF/UNIX lld variation with NetBSD specific +// customization. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/Triple.h" +#include "llvm/Option/ArgList.h" +#include "llvm/Option/Option.h" +#include "llvm/Support/Host.h" +#include "llvm/Support/InitLLVM.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/Program.h" +#include "llvm/Support/TargetRegistry.h" +#include "llvm/Support/TargetSelect.h" +#include "llvm/Support/WithColor.h" +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; +using namespace llvm::sys; + +#define LLD_PROGNAME "ld.lld" + +namespace { +enum ID { + OPT_INVALID = 0, // This is not an option ID. +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES) \ + OPT_##ID, +#include "Options.inc" +#undef OPTION +}; + +#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; +#include "Options.inc" +#undef PREFIX + +const opt::OptTable::Info InfoTable[] = { +#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ + HELPTEXT, METAVAR, VALUES) \ + { \ + PREFIX, NAME, HELPTEXT, \ + METAVAR, OPT_##ID, opt::Option::KIND##Class, \ + PARAM, FLAGS, OPT_##GROUP, \ + OPT_##ALIAS, ALIASARGS, VALUES}, +#include "Options.inc" +#undef OPTION +}; + +class SLLDOptTable : public opt::OptTable { +public: + SLLDOptTable() : OptTable(InfoTable) {} +}; +} // namespace + +static Triple targetTriple; + +static void setTargetTriple(StringRef argv0, opt::InputArgList &args) { + std::string targetError; + + // Firstly, 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)) { + targetTriple = llvm::Triple(prefix); + return; + } + } + + // Secondly, use the default target triple + targetTriple = llvm::Triple(getDefaultTargetTriple()); +} + +static void appendSearchPath(std::vector &args, const char *path) { + args.push_back("--library-path"); + args.push_back(path); +} + +static void appendTargetCustomization(std::vector &args) { + // force-disable RO segment on NetBSD due to ld.elf_so limitations + args.push_back("--no-rosegment"); + + // disable superfluous RUNPATH on NetBSD + args.push_back("--disable-new-dtags"); + + // disable gnustack + args.push_back("-znognustack"); + + // set default image base address + switch (targetTriple.getArch()) { + case llvm::Triple::aarch64: + case llvm::Triple::aarch64_be: + args.push_back("--image-base=0x200100000"); + break; + default: + break; + } + + // 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 (targetTriple.getArch()) { + case llvm::Triple::x86: + appendSearchPath(args, "=/usr/lib/i386"); + break; + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: + switch (targetTriple.getEnvironment()) { + case llvm::Triple::EABI: + case llvm::Triple::GNUEABI: + appendSearchPath(args, "=/usr/lib/eabi"); + break; + case llvm::Triple::EABIHF: + case llvm::Triple::GNUEABIHF: + appendSearchPath(args, "=/usr/lib/eabihf"); + break; + default: + appendSearchPath(args, "=/usr/lib/oabi"); + break; + } + break; +#if 0 // TODO + case llvm::Triple::mips64: + case llvm::Triple::mips64el: + if (tools::mips::hasMipsAbiArg(Args, "o32")) { + appendSearchPath(args, "=/usr/lib/o32"); + } else if (tools::mips::hasMipsAbiArg(Args, "64")) { + appendSearchPath(args, "=/usr/lib/64"); + } + break; +#endif + case llvm::Triple::ppc: + appendSearchPath(args, "=/usr/lib/powerpc"); + break; + case llvm::Triple::sparc: + appendSearchPath(args, "=/usr/lib/sparc"); + break; + default: + break; + } + + appendSearchPath(args, "=/usr/lib"); +} + +int main(int argc, const char **argv) { + bool printTarget = false; + + InitLLVM X(argc, argv); + + auto Program = sys::findProgramByName(LLD_PROGNAME); + if (!Program) { + WithColor::error() << "unable to find `" << LLD_PROGNAME + << "' in PATH: " << Program.getError().message() << "\n"; + return 1; + } + + ArrayRef argsArr = makeArrayRef(argv, argc); + + SLLDOptTable parser; + unsigned MAI; + unsigned MAC; + opt::InputArgList args = parser.ParseArgs(argsArr.slice(1), MAI, MAC); + + // Append to -v or -version the target information from slld. + if (args.hasArg(OPT_v) || args.hasArg(OPT_version)) + printTarget = true; + + InitializeAllTargets(); + setTargetTriple(argsArr[0], args); + + if (!targetTriple.isOSNetBSD()) { + WithColor::error() << "invalid NetBSD target: " << targetTriple.str() + << "\n"; + } + + argc--; + argv++; + + std::vector Argv; + Argv.push_back(*Program); + + // Prepend original arguments with the target options. + appendTargetCustomization(Argv); + + // Append original options. + // Trim -flavor option. + if (argc > 1 && argv[0] == StringRef("-flavor")) { + if (argc <= 2) + WithColor::error() << "missing arg value for '-flavor'\n"; + argc -= 2; + argv += 2; + } + + for (int i = 0; i < argc; ++i) + Argv.push_back(argv[i]); + + std::string ErrMsg; + int Result = sys::ExecuteAndWait(*Program, Argv, None, {}, 0, 0, &ErrMsg); + if (Result < 0) { + WithColor::error() << ErrMsg << "\n"; + return 1; + } + + if (printTarget) + WithColor::note() << "Target: " << targetTriple.str() << "\n"; + + return Result; +} @ 1.2 log @lld: Disable gnustack on NetBSD Fix corrupted text in description of cherry-picked patch for gnustack. @ text @d1 1 a1 1 $NetBSD: patch-tools_nb.lld_nb.lld.cpp,v 1.1 2019/11/03 12:11:27 kamil Exp $ @ 1.1 log @lld: Include new patches @ text @d1 1 a1 1 $NetBSD$ d6 3 a8 1 --- tools/nb.lld/nb.lld.cpp.orig 2019-11-03 11:46:29.311435568 +0000 d10 1 a10 1 @@@@ -0,0 +1,218 @@@@ d107 3 @