diff options
Diffstat (limited to 'lld/ELF/Driver.cpp')
-rw-r--r-- | lld/ELF/Driver.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index e6c700dcb76..5999fc21533 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -394,6 +394,20 @@ static SeparateSegmentKind getZSeparate(opt::InputArgList &args) { 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" || @@ -402,6 +416,7 @@ static bool isKnownZFlag(StringRef s) { s == "separate-code" || s == "separate-loadable-segments" || s == "nocombreloc" || s == "nocopyreloc" || s == "nodefaultlib" || 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" || @@ -951,6 +966,7 @@ static void readConfigs(opt::InputArgList &args) { 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"); |