llvm-project-netbsd: Sync patches with LLVM 2019-11-01

LLD nognustack has been merged upstream.
This commit is contained in:
Kamil Rytarowski 2019-11-01 18:15:59 +01:00
parent 0828246026
commit 7b4e45ad37
13 changed files with 29 additions and 162 deletions

View File

@ -8,15 +8,12 @@ SHA1 (llvm-7.0.1.src.tar.xz) = f97632fcc3186eb0d396492ef8acfc807648580f
RMD160 (llvm-7.0.1.src.tar.xz) = dae96c6f85afb60e73564dc40d02171d01ffdb8f
SHA512 (llvm-7.0.1.src.tar.xz) = ac43a3cb71a53deb55e3693653847cf20bf6f5d9056f224e6956c96d63bc59ebee9404f088eec9cabe65337b4607a905ef931354b373cf64e0004c6905a6b5df
Size (llvm-7.0.1.src.tar.xz) = 28311056 bytes
SHA1 (patch-clang_lib_Basic_Targets_OSTargets.h) = f4544fe5daf2febad4b5e9ff6b5d84a2d90b3c1e
SHA1 (patch-clang_lib_Driver_ToolChains_NetBSD.cpp) = 1a85c66c8b3aa5b467c41c0f98efeaf55865a06f
SHA1 (patch-clang_test_Sema_128bitfloat.cpp) = b3bd2d7cbb07a2d3c2ad14e75b3f91e0f5be43fc
SHA1 (patch-clang_tools_clang-format_CMakeLists.txt) = 3c9d9f1d5c7b6d9ec68ea537f4c4c3ec2e4899ca
SHA1 (patch-lld_CMakeLists.txt) = 3add301b0d0264622265b1f3c18eaed0665b11a6
SHA1 (patch-lld_ELF_Arch_AArch64.cpp) = 193e9d26cd8b5720465891e1b548e09be08b9eae
SHA1 (patch-lld_ELF_Config.h) = f625727b7b0ee4a7a60f5c7431ef15e533f56d5e
SHA1 (patch-lld_ELF_Driver.cpp) = abf9a12f3caa1d7134692d34540c6cef327072c0
SHA1 (patch-lld_ELF_Options.td) = 98c36caa39c5b207068aad2796e65b49dca52e13
SHA1 (patch-lld_ELF_Writer.cpp) = bf668a5f54b0d95b80c1c3bc3c99557d18c7e022
SHA1 (patch-lld_docs_ld.lld.1) = 3e7c0913b3f0f5c2a8539d17dfe383788710ffa1
SHA1 (patch-lld_test_ELF_gnustack.s) = 8410db9a2c57c53ac62453d533e4a17b250cfd07
SHA1 (patch-clang_lib_Basic_Targets_OSTargets.h) = 435a8b95936b37827fb9eed515faad9d978e3411
SHA1 (patch-clang_lib_Driver_ToolChains_NetBSD.cpp) = 3783663621709052758c7e41af34bdbc35680606
SHA1 (patch-clang_test_Sema_128bitfloat.cpp) = 4c9bec849623d24cbd9e1deb01a05251b7ba57f8
SHA1 (patch-clang_tools_clang-format_CMakeLists.txt) = d9c64d5dd140e04b6375a927555fb06750789641
SHA1 (patch-lld_CMakeLists.txt) = c6113b515c50a3fd71d4d64ad76c63a96d396300
SHA1 (patch-lld_ELF_Arch_AArch64.cpp) = 9f12e997e423a7356b43a2f717d06e079674e4bb
SHA1 (patch-lld_ELF_Config.h) = 9c674c6a1cfb55aa25941715afa1abefb38bdf39
SHA1 (patch-lld_ELF_Driver.cpp) = bbe40591fc4160b14b8350016a16d9d55a217d95
SHA1 (patch-lld_ELF_Options.td) = 573c1e79cee468192803e2deeeed30d3183f6ef0

View File

@ -1,6 +1,6 @@
$NetBSD$
--- clang/lib/Basic/Targets/OSTargets.h.orig 2019-10-23 20:24:27.393021814 +0000
--- clang/lib/Basic/Targets/OSTargets.h.orig 2019-10-23 20:24:27.000000000 +0000
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -436,12 +436,23 @@ protected:
Builder.defineMacro("__ELF__");

View File

@ -1,6 +1,6 @@
$NetBSD$
--- clang/lib/Driver/ToolChains/NetBSD.cpp.orig 2019-10-23 20:24:27.467144768 +0000
--- clang/lib/Driver/ToolChains/NetBSD.cpp.orig 2019-10-23 20:24:27.000000000 +0000
+++ clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -266,7 +266,7 @@ void netbsd::Linker::ConstructJob(Compil
unsigned Major, Minor, Micro;

View File

@ -1,6 +1,6 @@
$NetBSD$
--- clang/test/Sema/128bitfloat.cpp.orig 2019-10-23 20:24:29.833664183 +0000
--- clang/test/Sema/128bitfloat.cpp.orig 2019-10-23 20:24:29.000000000 +0000
+++ clang/test/Sema/128bitfloat.cpp
@@ -4,6 +4,8 @@
// RUN: %clang_cc1 -triple i686-windows-gnu -verify -std=c++11 %s

View File

@ -1,6 +1,6 @@
$NetBSD$
--- clang/tools/clang-format/CMakeLists.txt.orig 2019-10-23 20:24:30.090438326 +0000
--- clang/tools/clang-format/CMakeLists.txt.orig 2019-10-23 20:24:30.000000000 +0000
+++ clang/tools/clang-format/CMakeLists.txt
@@ -37,5 +37,5 @@ install(PROGRAMS clang-format.py
DESTINATION share/clang

View File

@ -1,6 +1,6 @@
$NetBSD$
--- lld/CMakeLists.txt.orig 2019-10-23 20:24:31.965882195 +0000
--- lld/CMakeLists.txt.orig 2019-10-23 20:24:31.000000000 +0000
+++ lld/CMakeLists.txt
@@ -85,7 +85,6 @@ Please install Python or specify the PYT
endif()

View File

@ -1,6 +1,6 @@
$NetBSD$
--- lld/ELF/Arch/AArch64.cpp.orig 2019-10-23 20:24:31.973047369 +0000
--- lld/ELF/Arch/AArch64.cpp.orig 2019-10-23 20:24:31.000000000 +0000
+++ lld/ELF/Arch/AArch64.cpp
@@ -67,9 +67,12 @@ AArch64::AArch64() {
pltHeaderSize = 32;

View File

@ -1,6 +1,6 @@
$NetBSD$
--- lld/ELF/Config.h.orig 2019-10-23 20:24:31.975278079 +0000
--- lld/ELF/Config.h.orig 2019-11-01 18:04:25.969170065 +0000
+++ lld/ELF/Config.h
@@ -13,6 +13,7 @@
#include "llvm/ADT/MapVector.h"
@ -10,17 +10,7 @@ $NetBSD$
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Support/CachePruning.h"
#include "llvm/Support/CodeGen.h"
@@ -64,6 +65,9 @@ enum class ARMVFPArgKind { Default, Base
// For -z noseparate-code, -z separate-code and -z separate-loadable-segments.
enum class SeparateSegmentKind { None, Code, Loadable };
+// For -z *stack
+enum class GnuStackKind { None, Exec, NoExec };
+
struct SymbolVersion {
llvm::StringRef name;
bool isExternCpp;
@@ -147,6 +151,7 @@ struct Configuration {
@@ -150,6 +151,7 @@ struct Configuration {
bool enableNewDtags;
bool executeOnly;
bool exportDynamic;
@ -28,23 +18,7 @@ $NetBSD$
bool fixCortexA53Errata843419;
bool fixCortexA8;
bool forceBTI;
@@ -208,6 +213,7 @@ struct Configuration {
bool zNodefaultlib;
bool zNodelete;
bool zNodlopen;
+ bool zNognustack;
bool zNow;
bool zOrigin;
bool zRelro;
@@ -216,6 +222,7 @@ struct Configuration {
bool zRetpolineplt;
bool zWxneeded;
DiscardPolicy discard;
+ GnuStackKind zGnustack;
ICFLevel icf;
OrphanHandlingPolicy orphanHandling;
SortSectionPolicy sortSection;
@@ -306,6 +313,10 @@ struct Configuration {
@@ -311,6 +313,10 @@ struct Configuration {
// 4 for ELF32, 8 for ELF64.
int wordsize;

View File

@ -1,6 +1,6 @@
$NetBSD$
--- lld/ELF/Driver.cpp.orig 2019-10-23 20:24:31.976090112 +0000
--- lld/ELF/Driver.cpp.orig 2019-11-01 18:04:25.969815957 +0000
+++ lld/ELF/Driver.cpp
@@ -55,6 +55,7 @@
#include "llvm/Support/LEB128.h"
@ -48,37 +48,7 @@ $NetBSD$
}
if (config->zRetpolineplt && config->requireCET)
@@ -394,6 +403,20 @@ static SeparateSegmentKind getZSeparate(
return SeparateSegmentKind::None;
}
+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" ||
@@ -401,7 +424,7 @@ static bool isKnownZFlag(StringRef s) {
s == "keep-text-section-prefix" || s == "lazy" || s == "muldefs" ||
s == "separate-code" || s == "separate-loadable-segments" ||
s == "nocombreloc" || s == "nocopyreloc" || s == "nodefaultlib" ||
- s == "nodelete" || s == "nodlopen" || s == "noexecstack" ||
+ s == "nodelete" || s == "nodlopen" || s == "noexecstack" || s == "nognustack" ||
s == "nokeep-text-section-prefix" || s == "norelro" ||
s == "noseparate-code" || s == "notext" || s == "now" ||
s == "origin" || s == "relro" || s == "retpolineplt" ||
@@ -417,6 +440,56 @@ static void checkZOptions(opt::InputArgL
@@ -431,6 +440,56 @@ static void checkZOptions(opt::InputArgL
error("unknown -z value: " + StringRef(arg->getValue()));
}
@ -135,7 +105,7 @@ $NetBSD$
void LinkerDriver::main(ArrayRef<const char *> argsArr) {
ELFOptTable parser;
opt::InputArgList args = parser.parse(argsArr.slice(1));
@@ -431,6 +504,8 @@ void LinkerDriver::main(ArrayRef<const c
@@ -445,6 +504,8 @@ void LinkerDriver::main(ArrayRef<const c
return;
}
@ -144,7 +114,7 @@ $NetBSD$
// Handle -v or -version.
//
// A note about "compatible with GNU linkers" message: this is a hack for
@@ -446,8 +521,10 @@ void LinkerDriver::main(ArrayRef<const c
@@ -460,8 +521,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.
@ -156,7 +126,7 @@ $NetBSD$
if (const char *path = getReproduceOption(args)) {
// Note that --reproduce is a debug option so you can ignore it
@@ -465,6 +542,8 @@ void LinkerDriver::main(ArrayRef<const c
@@ -479,6 +542,8 @@ void LinkerDriver::main(ArrayRef<const c
readConfigs(args);
@ -165,7 +135,7 @@ $NetBSD$
// 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))
@@ -812,6 +891,34 @@ static void parseClangOption(StringRef o
@@ -826,6 +891,34 @@ static void parseClangOption(StringRef o
error(msg + ": " + StringRef(err).trim());
}
@ -200,7 +170,7 @@ $NetBSD$
// Initializes Config members by the command line options.
static void readConfigs(opt::InputArgList &args) {
errorHandler().verbose = args.hasArg(OPT_verbose);
@@ -851,7 +958,8 @@ static void readConfigs(opt::InputArgLis
@@ -865,7 +958,8 @@ static void readConfigs(opt::InputArgLis
config->callGraphProfileSort = args.hasFlag(
OPT_call_graph_profile_sort, OPT_no_call_graph_profile_sort, true);
config->enableNewDtags =
@ -210,7 +180,7 @@ $NetBSD$
config->entry = args.getLastArgValue(OPT_entry);
config->executeOnly =
args.hasFlag(OPT_execute_only, OPT_no_execute_only, false);
@@ -859,6 +967,7 @@ static void readConfigs(opt::InputArgLis
@@ -873,6 +967,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");
@ -218,15 +188,7 @@ $NetBSD$
config->fixCortexA53Errata843419 = args.hasArg(OPT_fix_cortex_a53_843419);
config->fixCortexA8 = args.hasArg(OPT_fix_cortex_a8);
config->forceBTI = args.hasArg(OPT_force_bti);
@@ -951,6 +1060,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");
@@ -1269,7 +1379,7 @@ void LinkerDriver::inferMachineType() {
@@ -1286,7 +1381,7 @@ void LinkerDriver::inferMachineType() {
// each target.
static uint64_t getMaxPageSize(opt::InputArgList &args) {
uint64_t val = args::getZOptionValue(args, OPT_z, "max-page-size",

View File

@ -1,6 +1,6 @@
$NetBSD$
--- lld/ELF/Options.td.orig 2019-10-23 20:24:31.979154507 +0000
--- lld/ELF/Options.td.orig 2019-11-01 18:04:25.971104878 +0000
+++ lld/ELF/Options.td
@@ -168,6 +168,9 @@ defm filter: Eq<"filter", "Set DT_FILTER
@ -12,7 +12,7 @@ $NetBSD$
def fix_cortex_a53_843419: F<"fix-cortex-a53-843419">,
HelpText<"Apply fixes for AArch64 Cortex-A53 erratum 843419">;
@@ -346,6 +349,8 @@ defm symbol_ordering_file:
@@ -350,6 +353,8 @@ defm symbol_ordering_file:
defm sysroot: Eq<"sysroot", "Set the system root">;

View File

@ -1,29 +0,0 @@
$NetBSD$
--- lld/ELF/Writer.cpp.orig 2019-10-23 20:24:31.984556869 +0000
+++ lld/ELF/Writer.cpp
@@ -2172,14 +2172,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

View File

@ -1,15 +0,0 @@
$NetBSD$
--- lld/docs/ld.lld.1.orig 2019-10-23 20:24:36.059771858 +0000
+++ lld/docs/ld.lld.1
@@ -654,6 +654,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.
.Pp
.It Cm norelro
Do not indicate that portions of the object shold be mapped read-only

View File

@ -1,22 +0,0 @@
$NetBSD$
--- lld/test/ELF/gnustack.s.orig 2019-10-23 20:24:36.334197305 +0000
+++ lld/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: