pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/devel/lld



Module Name:    pkgsrc
Committed By:   rjs
Date:           Mon Oct 21 22:07:58 UTC 2019

Modified Files:
        pkgsrc/devel/lld: Makefile distinfo
Added Files:
        pkgsrc/devel/lld/patches: patch-ELF_Arch_AArch64.cpp patch-ELF_Config.h
            patch-ELF_Driver.cpp patch-ELF_Options.td patch-ELF_Writer.cpp
            patch-docs_ld.lld.1 patch-test_ELF_gnustack.s

Log Message:
Restore NetBSD patches.

Set correct link address for NetBSD/aarch64.
Add a dummy option for an aarch64 erratum for gcc compatibility.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 pkgsrc/devel/lld/Makefile
cvs rdiff -u -r1.5 -r1.6 pkgsrc/devel/lld/distinfo
cvs rdiff -u -r0 -r1.1 pkgsrc/devel/lld/patches/patch-ELF_Arch_AArch64.cpp
cvs rdiff -u -r0 -r1.4 pkgsrc/devel/lld/patches/patch-ELF_Config.h \
    pkgsrc/devel/lld/patches/patch-docs_ld.lld.1
cvs rdiff -u -r0 -r1.5 pkgsrc/devel/lld/patches/patch-ELF_Driver.cpp
cvs rdiff -u -r0 -r1.3 pkgsrc/devel/lld/patches/patch-ELF_Options.td \
    pkgsrc/devel/lld/patches/patch-ELF_Writer.cpp \
    pkgsrc/devel/lld/patches/patch-test_ELF_gnustack.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/lld/Makefile
diff -u pkgsrc/devel/lld/Makefile:1.8 pkgsrc/devel/lld/Makefile:1.9
--- pkgsrc/devel/lld/Makefile:1.8       Mon Oct 21 19:20:18 2019
+++ pkgsrc/devel/lld/Makefile   Mon Oct 21 22:07:58 2019
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.8 2019/10/21 19:20:18 mgorny Exp $
+# $NetBSD: Makefile,v 1.9 2019/10/21 22:07:58 rjs Exp $
 
 DISTNAME=      lld-9.0.0.src
 PKGNAME=       ${DISTNAME:S/.src//}
+PKGREVISION=   1
 CATEGORIES=    devel
 MASTER_SITES=  http://releases.llvm.org/${PKGVERSION_NOREV}/
 EXTRACT_SUFX=  .tar.xz

Index: pkgsrc/devel/lld/distinfo
diff -u pkgsrc/devel/lld/distinfo:1.5 pkgsrc/devel/lld/distinfo:1.6
--- pkgsrc/devel/lld/distinfo:1.5       Sat Oct 19 14:01:36 2019
+++ pkgsrc/devel/lld/distinfo   Mon Oct 21 22:07:58 2019
@@ -1,7 +1,14 @@
-$NetBSD: distinfo,v 1.5 2019/10/19 14:01:36 adam Exp $
+$NetBSD: distinfo,v 1.6 2019/10/21 22:07:58 rjs Exp $
 
 SHA1 (lld-9.0.0.src.tar.xz) = 021a8c38cf27d63db37d939c7cdec46ffd627be2
 RMD160 (lld-9.0.0.src.tar.xz) = d46b068f4de55d174be71e061aa38f7d4d1499dc
 SHA512 (lld-9.0.0.src.tar.xz) = bc4812232840ef5edbd8edf1d1a329e85a4bfd3a7859fe322e11dd053435e722c6f1140a718fd2b3524ee9783a357178d2ba30d12519847bd3acc294698007f3
 Size (lld-9.0.0.src.tar.xz) = 1100608 bytes
 SHA1 (patch-CMakeLists.txt) = df8e32f5f23bf2f2615a891177f61dc65359e955
+SHA1 (patch-ELF_Arch_AArch64.cpp) = 45eb8f69b92f8ba764372993363dbce88b50a310
+SHA1 (patch-ELF_Config.h) = 760658ef2d90e8d44ae6c1ef76a183613f445264
+SHA1 (patch-ELF_Driver.cpp) = eaf5a3cd01a82421205831dce86db92bfb4001bc
+SHA1 (patch-ELF_Options.td) = 8e228dee43511efc7fd6107e817288067c393145
+SHA1 (patch-ELF_Writer.cpp) = 210b0a8b60885456cb037d9925c504874efd0e35
+SHA1 (patch-docs_ld.lld.1) = a6865d0099216094422aede3d65f43ee6fee22fe
+SHA1 (patch-test_ELF_gnustack.s) = 22f5eb19e588cc0c1055fd932d7a7b22ecd70e20

Added files:

Index: pkgsrc/devel/lld/patches/patch-ELF_Arch_AArch64.cpp
diff -u /dev/null pkgsrc/devel/lld/patches/patch-ELF_Arch_AArch64.cpp:1.1
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-ELF_Arch_AArch64.cpp Mon Oct 21 22:07:58 2019
@@ -0,0 +1,22 @@
+$NetBSD: patch-ELF_Arch_AArch64.cpp,v 1.1 2019/10/21 22:07:58 rjs Exp $
+
+Set correct base address on NetBSD.
+
+--- ELF/Arch/AArch64.cpp.orig  2019-07-16 05:50:45.000000000 +0000
++++ ELF/Arch/AArch64.cpp
+@@ -66,9 +66,12 @@ AArch64::AArch64() {
+   pltHeaderSize = 32;
+   defaultMaxPageSize = 65536;
+ 
+-  // Align to the 2 MiB page size (known as a superpage or huge page).
+-  // FreeBSD automatically promotes 2 MiB-aligned allocations.
+-  defaultImageBase = 0x200000;
++  if (config->targetTriple.isOSNetBSD())
++    defaultImageBase = 0x200100000;
++  else
++    // Align to the 2 MiB page size (known as a superpage or huge page).
++    // FreeBSD automatically promotes 2 MiB-aligned allocations.
++    defaultImageBase = 0x200000;
+ 
+   needsThunks = true;
+ }

Index: pkgsrc/devel/lld/patches/patch-ELF_Config.h
diff -u /dev/null pkgsrc/devel/lld/patches/patch-ELF_Config.h:1.4
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-ELF_Config.h Mon Oct 21 22:07:58 2019
@@ -0,0 +1,65 @@
+$NetBSD: patch-ELF_Config.h,v 1.4 2019/10/21 22:07:58 rjs Exp $
+
+Add support for customizing LLD behavior on target triple.
+https://reviews.llvm.org/D56650
+
+Add '-z nognustack' option to disable emitting PT_GNU_STACK.
+https://reviews.llvm.org/D56554
+
+Add dummy option for an AArch64 erratum.
+
+--- ELF/Config.h.orig  2019-07-16 05:50:45.000000000 +0000
++++ ELF/Config.h
+@@ -13,6 +13,7 @@
+ #include "llvm/ADT/MapVector.h"
+ #include "llvm/ADT/StringRef.h"
+ #include "llvm/ADT/StringSet.h"
++#include "llvm/ADT/Triple.h"
+ #include "llvm/BinaryFormat/ELF.h"
+ #include "llvm/Support/CachePruning.h"
+ #include "llvm/Support/CodeGen.h"
+@@ -61,6 +62,9 @@ enum class Target2Policy { Abs, Rel, Got
+ // For tracking ARM Float Argument PCS
+ enum class ARMVFPArgKind { Default, Base, VFP, ToolChain };
+ 
++// For -z *stack
++enum class GnuStackKind { None, Exec, NoExec };
++
+ struct SymbolVersion {
+   llvm::StringRef name;
+   bool isExternCpp;
+@@ -146,6 +150,7 @@ struct Configuration {
+   bool enableNewDtags;
+   bool executeOnly;
+   bool exportDynamic;
++  bool fixCortexA53Errata835769;
+   bool fixCortexA53Errata843419;
+   bool forceBTI;
+   bool formatBinary = false;
+@@ -206,6 +211,7 @@ struct Configuration {
+   bool zNodefaultlib;
+   bool zNodelete;
+   bool zNodlopen;
++  bool zNognustack;
+   bool zNow;
+   bool zOrigin;
+   bool zRelro;
+@@ -214,6 +220,7 @@ struct Configuration {
+   bool zRetpolineplt;
+   bool zWxneeded;
+   DiscardPolicy discard;
++  GnuStackKind zGnustack;
+   ICFLevel icf;
+   OrphanHandlingPolicy orphanHandling;
+   SortSectionPolicy sortSection;
+@@ -304,6 +311,10 @@ struct Configuration {
+ 
+   // 4 for ELF32, 8 for ELF64.
+   int wordsize;
++
++  // Target triple, inferred from program name or defaulted to LLVM
++  // default target.
++  llvm::Triple targetTriple;
+ };
+ 
+ // The only instance of Configuration struct.
Index: pkgsrc/devel/lld/patches/patch-docs_ld.lld.1
diff -u /dev/null pkgsrc/devel/lld/patches/patch-docs_ld.lld.1:1.4
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-docs_ld.lld.1        Mon Oct 21 22:07:58 2019
@@ -0,0 +1,18 @@
+$NetBSD: patch-docs_ld.lld.1,v 1.4 2019/10/21 22:07:58 rjs Exp $
+
+Add '-z nognustack' option to disable emitting PT_GNU_STACK.
+https://reviews.llvm.org/D56554
+
+--- docs/ld.lld.1.orig 2019-01-17 13:46:36.000000000 +0000
++++ docs/ld.lld.1
+@@ -511,6 +511,10 @@ Set the
+ .Dv DF_1_NOOPEN
+ flag to indicate that the object may not be opened by
+ .Xr dlopen 3 .
++.It Cm nognustack
++Do not emit the
++.Dv PT_GNU_STACK
++segment.
+ .It Cm norelro
+ Do not indicate that portions of the object shold be mapped read-only
+ after initial relocation processing.

Index: pkgsrc/devel/lld/patches/patch-ELF_Driver.cpp
diff -u /dev/null pkgsrc/devel/lld/patches/patch-ELF_Driver.cpp:1.5
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-ELF_Driver.cpp       Mon Oct 21 22:07:58 2019
@@ -0,0 +1,250 @@
+$NetBSD: patch-ELF_Driver.cpp,v 1.5 2019/10/21 22:07:58 rjs Exp $
+
+Add support for customizing LLD behavior on target triple.
+https://reviews.llvm.org/D56650
+
+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.
+
+--- ELF/Driver.cpp.orig        2019-07-17 14:54:02.000000000 +0000
++++ ELF/Driver.cpp
+@@ -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 <cstdlib>
+@@ -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<const char *> args, bool canExitEarly,
+                raw_ostream &error) {
+@@ -129,7 +132,7 @@ static std::tuple<ELFKind, uint16_t, uin
+   std::pair<ELFKind, uint16_t> ret =
+       StringSwitch<std::pair<ELFKind, uint16_t>>(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})
+@@ -296,6 +299,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");
+ 
+@@ -336,6 +342,9 @@ static void checkOptions() {
+ 
+     if (config->singleRoRx && !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 &
+   return Default;
+ }
+ 
++static GnuStackKind getZGnuStack(opt::InputArgList &args) {
++  for (auto *arg : args.filtered_reverse(OPT_z)) {
++    if (StringRef("execstack") == arg->getValue())
++      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 +403,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" ||
+@@ -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<const char *> argsArr) {
+   ELFOptTable parser;
+   opt::InputArgList args = parser.parse(argsArr.slice(1));
+@@ -408,6 +482,8 @@ void LinkerDriver::main(ArrayRef<const c
+     return;
+   }
+ 
++  setTargetTriple(argsArr[0], args);
++
+   // Handle -v or -version.
+   //
+   // A note about "compatible with GNU linkers" message: this is a hack for
+@@ -423,8 +499,10 @@ void LinkerDriver::main(ArrayRef<const c
+   // lot of "configure" scripts out there that are generated by old version
+   // of Libtool. We cannot convince every software developer to migrate to
+   // the latest version and re-generate scripts. So we have this hack.
+-  if (args.hasArg(OPT_v) || args.hasArg(OPT_version))
++  if (args.hasArg(OPT_v) || args.hasArg(OPT_version)) {
+     message(getLLDVersion() + " (compatible with GNU linkers)");
++    message("Target: " + config->targetTriple.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(ArrayRef<const c
+ 
+   readConfigs(args);
+ 
++  appendDefaultSearchPaths();
++
+   // The behavior of -v or --version is a bit strange, but this is
+   // needed for compatibility with GNU linkers.
+   if (args.hasArg(OPT_v) && !args.hasArg(OPT_INPUT))
+@@ -781,6 +861,34 @@ static void parseClangOption(StringRef o
+   error(msg + ": " + StringRef(err).trim());
+ }
+ 
++static void setTargetTriple(StringRef argv0, opt::InputArgList &args) {
++  std::string targetError;
++
++  // Firstly, see if user specified explicit --target
++  StringRef targetOpt = args.getLastArgValue(OPT_target);
++  if (!targetOpt.empty()) {
++    if (llvm::TargetRegistry::lookupTarget(targetOpt, targetError)) {
++      config->targetTriple = 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
+       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);
+   config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419);
+   config->forceBTI = args.hasArg(OPT_force_bti);
+   config->requireCET = args.hasArg(OPT_require_cet);
+@@ -921,6 +1031,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");
+@@ -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) {

Index: pkgsrc/devel/lld/patches/patch-ELF_Options.td
diff -u /dev/null pkgsrc/devel/lld/patches/patch-ELF_Options.td:1.3
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-ELF_Options.td       Mon Oct 21 22:07:58 2019
@@ -0,0 +1,28 @@
+$NetBSD: patch-ELF_Options.td,v 1.3 2019/10/21 22:07:58 rjs Exp $
+
+Add support for customizing LLD behavior on target triple.
+https://reviews.llvm.org/D56650
+
+Add support for a dummy AArch64 erratum.
+
+--- ELF/Options.td.orig        2019-02-20 08:21:37.000000000 +0000
++++ ELF/Options.td
+@@ -160,6 +160,9 @@ defm filter: Eq<"filter", "Set DT_FILTER
+ 
+ defm fini: Eq<"fini", "Specify a finalizer function">, MetaVarName<"<symbol>">;
+ 
++def fix_cortex_a53_835769: F<"fix-cortex-a53-835769">,
++  HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 835769">;
++
+ def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
+   HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
+ 
+@@ -316,6 +319,8 @@ defm symbol_ordering_file:
+ 
+ defm sysroot: Eq<"sysroot", "Set the system root">;
+ 
++defm target: Eq<"target", "Apply configuration defaults for a given target">;
++
+ def target1_rel: F<"target1-rel">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_REL32">;
+ 
+ def target1_abs: F<"target1-abs">, HelpText<"Interpret R_ARM_TARGET1 as R_ARM_ABS32 (default)">;
Index: pkgsrc/devel/lld/patches/patch-ELF_Writer.cpp
diff -u /dev/null pkgsrc/devel/lld/patches/patch-ELF_Writer.cpp:1.3
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-ELF_Writer.cpp       Mon Oct 21 22:07:58 2019
@@ -0,0 +1,32 @@
+$NetBSD: patch-ELF_Writer.cpp,v 1.3 2019/10/21 22:07:58 rjs Exp $
+
+Add '-z nognustack' option to disable emitting PT_GNU_STACK.
+https://reviews.llvm.org/D56554
+
+--- ELF/Writer.cpp.orig        2019-09-06 11:20:15.000000000 +0000
++++ ELF/Writer.cpp
+@@ -2160,14 +2160,16 @@ std::vector<PhdrEntry *> Writer<ELFT>::c
+   if (OutputSection *cmd = findSection(".openbsd.randomdata", partNo))
+     addHdr(PT_OPENBSD_RANDOMIZE, cmd->getPhdrFlags())->add(cmd);
+ 
+-  // PT_GNU_STACK is a special section to tell the loader to make the
+-  // pages for the stack non-executable. If you really want an executable
+-  // stack, you can pass -z execstack, but that's not recommended for
+-  // security reasons.
+-  unsigned perm = PF_R | PF_W;
+-  if (config->zExecstack)
+-    perm |= PF_X;
+-  addHdr(PT_GNU_STACK, perm)->p_memsz = config->zStackSize;
++  if (config->zGnustack != GnuStackKind::None) {
++    // PT_GNU_STACK is a special section to tell the loader to make the
++    // pages for the stack non-executable. If you really want an executable
++    // stack, you can pass -z execstack, but that's not recommended for
++    // security reasons.
++    unsigned perm = PF_R | PF_W;
++    if (config->zGnustack == GnuStackKind::Exec)
++      perm |= PF_X;
++    addHdr(PT_GNU_STACK, perm)->p_memsz = config->zStackSize;
++  }
+ 
+   // PT_OPENBSD_WXNEEDED is a OpenBSD-specific header to mark the executable
+   // is expected to perform W^X violations, such as calling mprotect(2) or
Index: pkgsrc/devel/lld/patches/patch-test_ELF_gnustack.s
diff -u /dev/null pkgsrc/devel/lld/patches/patch-test_ELF_gnustack.s:1.3
--- /dev/null   Mon Oct 21 22:07:58 2019
+++ pkgsrc/devel/lld/patches/patch-test_ELF_gnustack.s  Mon Oct 21 22:07:58 2019
@@ -0,0 +1,25 @@
+$NetBSD: patch-test_ELF_gnustack.s,v 1.3 2019/10/21 22:07:58 rjs Exp $
+
+Add '-z nognustack' option to disable emitting PT_GNU_STACK.
+https://reviews.llvm.org/D56554
+
+--- test/ELF/gnustack.s.orig   2019-05-01 05:49:01.000000000 +0000
++++ test/ELF/gnustack.s
+@@ -10,6 +10,9 @@
+ # RUN: ld.lld %t1 -o %t -z noexecstack
+ # RUN: llvm-readobj --program-headers -S %t | FileCheck --check-prefix=RW %s
+ 
++# RUN: ld.lld %t1 -o %t -z noexecstack
++# RUN: llvm-readobj --program-headers -S %t | FileCheck --check-prefix=NOGNUSTACK %s
++
+ # RW:      Type: PT_GNU_STACK
+ # RW-NEXT: Offset: 0x0
+ # RW-NEXT: VirtualAddress: 0x0
+@@ -35,5 +38,7 @@
+ # RWX-NEXT: ]
+ # RWX-NEXT: Alignment: 0
+ 
++# NOGNUSTACK-NOT: Type: PT_GNU_STACK
++
+ .globl _start
+ _start:



Home | Main Index | Thread Index | Old Index