Sync with base:
- Accept both `--foo bar` and `--foo=bar` styles options. - Add support for -z initfirst. - Generate __data_start symbol that marks the start of .data when __data_start is referenced from code being linked. From Brad (maintainer)
This commit is contained in:
parent
4d2170ccd3
commit
9b536d7f79
@ -1,4 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.190 2018/10/23 08:59:59 ajacoutot Exp $
|
||||
# $OpenBSD: Makefile,v 1.191 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
# XXX: Remember to bump MODCLANG_VERSION in lang/clang/clang.port.mk when
|
||||
# updating this port.
|
||||
@ -19,7 +19,7 @@ PKGNAME = llvm-${LLVM_V}
|
||||
PKGSPEC-main = llvm-=${LLVM_V}
|
||||
PKGNAME-main = llvm-${LLVM_V}
|
||||
PKGNAME-python = py-llvm-${LLVM_V}
|
||||
REVISION-main = 9
|
||||
REVISION-main = 10
|
||||
REVISION-python = 1
|
||||
CATEGORIES = devel
|
||||
DISTFILES = llvm-${LLVM_V}.src${EXTRACT_SUFX} \
|
||||
|
15
devel/llvm/patches/patch-tools_lld_ELF_Config_h
Normal file
15
devel/llvm/patches/patch-tools_lld_ELF_Config_h
Normal file
@ -0,0 +1,15 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_Config_h,v 1.4 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
Add support for -z initfirst.
|
||||
|
||||
Index: tools/lld/ELF/Config.h
|
||||
--- tools/lld/ELF/Config.h.orig
|
||||
+++ tools/lld/ELF/Config.h
|
||||
@@ -151,6 +151,7 @@ struct Configuration {
|
||||
bool WarnMissingEntry;
|
||||
bool ZCombreloc;
|
||||
bool ZExecstack;
|
||||
+ bool ZInitfirst;
|
||||
bool ZHazardplt;
|
||||
bool ZNocopyreloc;
|
||||
bool ZNodelete;
|
@ -1,6 +1,7 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_Driver_cpp,v 1.9 2018/09/16 06:09:16 ajacoutot Exp $
|
||||
$OpenBSD: patch-tools_lld_ELF_Driver_cpp,v 1.10 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
- Enable PIE by default.
|
||||
- Add support for -z initfirst.
|
||||
- Fix --exclude-libs option.
|
||||
|
||||
Index: tools/lld/ELF/Driver.cpp
|
||||
@ -16,7 +17,15 @@ Index: tools/lld/ELF/Driver.cpp
|
||||
Config->PrintGcSections =
|
||||
Args.hasFlag(OPT_print_gc_sections, OPT_no_print_gc_sections, false);
|
||||
Config->Rpath = getRpath(Args);
|
||||
@@ -957,7 +958,7 @@ static void excludeLibs(opt::InputArgList &Args, Array
|
||||
@@ -668,6 +669,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args
|
||||
Config->WarnCommon = Args.hasArg(OPT_warn_common);
|
||||
Config->ZCombreloc = !hasZOption(Args, "nocombreloc");
|
||||
Config->ZExecstack = hasZOption(Args, "execstack");
|
||||
+ Config->ZInitfirst = hasZOption(Args, "initfirst");
|
||||
Config->ZHazardplt = hasZOption(Args, "hazardplt");
|
||||
Config->ZNocopyreloc = hasZOption(Args, "nocopyreloc");
|
||||
Config->ZNodelete = hasZOption(Args, "nodelete");
|
||||
@@ -957,7 +959,7 @@ static void excludeLibs(opt::InputArgList &Args, Array
|
||||
if (Optional<StringRef> Archive = getArchiveName(File))
|
||||
if (All || Libs.count(path::filename(*Archive)))
|
||||
for (Symbol *Sym : File->getSymbols())
|
||||
|
121
devel/llvm/patches/patch-tools_lld_ELF_Options_td
Normal file
121
devel/llvm/patches/patch-tools_lld_ELF_Options_td
Normal file
@ -0,0 +1,121 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_Options_td,v 1.1 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
Accept both `--foo bar` and `--foo=bar` styles options.
|
||||
|
||||
GNU linkers by convention supports both `--foo bar` and `--foo=bar` styles
|
||||
for all long options that take arguments.
|
||||
|
||||
Index: tools/lld/ELF/Options.td
|
||||
--- tools/lld/ELF/Options.td.orig
|
||||
+++ tools/lld/ELF/Options.td
|
||||
@@ -4,14 +4,14 @@ include "llvm/Option/OptParser.td"
|
||||
// two can precede the option name except those that start with 'o'.
|
||||
class F<string name>: Flag<["--", "-"], name>;
|
||||
class J<string name>: Joined<["--", "-"], name>;
|
||||
-class S<string name>: Separate<["--", "-"], name>;
|
||||
|
||||
multiclass Eq<string name> {
|
||||
def "": Separate<["--", "-"], name>;
|
||||
def _eq: Joined<["--", "-"], name # "=">, Alias<!cast<Separate>(NAME)>;
|
||||
}
|
||||
|
||||
-def auxiliary: S<"auxiliary">, HelpText<"Set DT_AUXILIARY field to the specified name">;
|
||||
+defm auxiliary: Eq<"auxiliary">,
|
||||
+ HelpText<"Set DT_AUXILIARY field to the specified name">;
|
||||
|
||||
def Bsymbolic: F<"Bsymbolic">, HelpText<"Bind defined symbols locally">;
|
||||
|
||||
@@ -52,7 +52,7 @@ def as_needed: F<"as-needed">,
|
||||
HelpText<"Only set DT_NEEDED for shared libraries if used">;
|
||||
|
||||
// -chroot doesn't have a help text because it is an internal option.
|
||||
-def chroot: S<"chroot">;
|
||||
+defm chroot: Eq<"chroot">;
|
||||
|
||||
def color_diagnostics: F<"color-diagnostics">,
|
||||
HelpText<"Use colors in diagnostics">;
|
||||
@@ -76,7 +76,7 @@ def discard_locals: F<"discard-locals">,
|
||||
def discard_none: F<"discard-none">,
|
||||
HelpText<"Keep all symbols in the symbol table">;
|
||||
|
||||
-def dynamic_linker: S<"dynamic-linker">,
|
||||
+defm dynamic_linker: Eq<"dynamic-linker">,
|
||||
HelpText<"Which dynamic linker to use">;
|
||||
|
||||
defm dynamic_list: Eq<"dynamic-list">,
|
||||
@@ -264,7 +264,7 @@ defm retain_symbols_file: Eq<"retain-symbols-file">,
|
||||
|
||||
defm script: Eq<"script">, HelpText<"Read linker script">;
|
||||
|
||||
-def section_start: S<"section-start">, MetaVarName<"<address>">,
|
||||
+defm section_start: Eq<"section-start">, MetaVarName<"<address>">,
|
||||
HelpText<"Set address of section">;
|
||||
|
||||
def shared: F<"shared">, HelpText<"Build a shared object">;
|
||||
@@ -281,7 +281,7 @@ def strip_all: F<"strip-all">, HelpText<"Strip all sym
|
||||
|
||||
def strip_debug: F<"strip-debug">, HelpText<"Strip debugging information">;
|
||||
|
||||
-def symbol_ordering_file: S<"symbol-ordering-file">,
|
||||
+defm symbol_ordering_file: Eq<"symbol-ordering-file">,
|
||||
HelpText<"Layout sections in the order specified by symbol file">;
|
||||
|
||||
defm sysroot: Eq<"sysroot">, HelpText<"Set the system root">;
|
||||
@@ -348,7 +348,7 @@ def alias_emit_relocs: Flag<["-"], "q">, Alias<emit_re
|
||||
def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
|
||||
def alias_export_dynamic_E: Flag<["-"], "E">, Alias<export_dynamic>;
|
||||
def alias_filter: Separate<["-"], "F">, Alias<filter>;
|
||||
-def alias_format_b: S<"b">, Alias<format>;
|
||||
+def alias_format_b: Separate<["-"], "b">, Alias<format>;
|
||||
def alias_library: JoinedOrSeparate<["-"], "l">, Alias<library>;
|
||||
def alias_library_path: JoinedOrSeparate<["-"], "L">, Alias<library_path>;
|
||||
def alias_omagic: Flag<["-"], "N">, Alias<omagic>;
|
||||
@@ -365,8 +365,8 @@ def alias_strip_all: Flag<["-"], "s">, Alias<strip_all
|
||||
def alias_strip_debug_S: Flag<["-"], "S">, Alias<strip_debug>;
|
||||
def alias_trace: Flag<["-"], "t">, Alias<trace>;
|
||||
def alias_trace_symbol_y : JoinedOrSeparate<["-"], "y">, Alias<trace_symbol>;
|
||||
-def alias_Ttext_segment: S<"Ttext-segment">, Alias<Ttext>;
|
||||
-def alias_Ttext_segment_eq: J<"Ttext-segment=">, Alias<Ttext>;
|
||||
+def alias_Ttext_segment: Separate<["-", "--"], "Ttext-segment">, Alias<Ttext>;
|
||||
+def alias_Ttext_segment_eq: Joined<["-", "--"], "Ttext-segment=">, Alias<Ttext>;
|
||||
def alias_undefined_u: JoinedOrSeparate<["-"], "u">, Alias<undefined>;
|
||||
def alias_version_V: Flag<["-"], "V">, Alias<version>;
|
||||
|
||||
@@ -386,7 +386,7 @@ def lto_newpm_passes: J<"lto-newpm-passes=">,
|
||||
def lto_partitions: J<"lto-partitions=">,
|
||||
HelpText<"Number of LTO codegen partitions">;
|
||||
def disable_verify: F<"disable-verify">;
|
||||
-def mllvm: S<"mllvm">;
|
||||
+defm mllvm: Eq<"mllvm">;
|
||||
def opt_remarks_filename: Separate<["--"], "opt-remarks-filename">,
|
||||
HelpText<"YAML output file for optimization remarks">;
|
||||
def opt_remarks_with_hotness: Flag<["--"], "opt-remarks-with-hotness">,
|
||||
@@ -396,7 +396,7 @@ defm plugin_opt: Eq<"plugin-opt">,
|
||||
def save_temps: F<"save-temps">;
|
||||
def thinlto_cache_dir: J<"thinlto-cache-dir=">,
|
||||
HelpText<"Path to ThinLTO cached object file directory">;
|
||||
-def thinlto_cache_policy: S<"thinlto-cache-policy">,
|
||||
+defm thinlto_cache_policy: Eq<"thinlto-cache-policy">,
|
||||
HelpText<"Pruning policy for the ThinLTO cache">;
|
||||
def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number of ThinLTO jobs">;
|
||||
|
||||
@@ -407,8 +407,7 @@ def thinlto_jobs: J<"thinlto-jobs=">, HelpText<"Number
|
||||
// just ignore the option on lld side as it's easier. In fact, the linker could
|
||||
// be called 'ld' and understanding which linker is used would require parsing of
|
||||
// --version output.
|
||||
-def plugin: S<"plugin">;
|
||||
-def plugin_eq: J<"plugin=">;
|
||||
+defm plugin: Eq<"plugin">;
|
||||
|
||||
// Options listed below are silently ignored for now for compatibility.
|
||||
def allow_shlib_undefined: F<"allow-shlib-undefined">;
|
||||
@@ -424,8 +423,7 @@ def no_keep_memory: F<"no-keep-memory">;
|
||||
def no_mmap_output_file: F<"no-mmap-output-file">;
|
||||
def no_warn_common: F<"no-warn-common">;
|
||||
def no_warn_mismatch: F<"no-warn-mismatch">;
|
||||
-def rpath_link: S<"rpath-link">;
|
||||
-def rpath_link_eq: J<"rpath-link=">;
|
||||
+defm rpath_link: Eq<"rpath-link">;
|
||||
def sort_common: F<"sort-common">;
|
||||
def stats: F<"stats">;
|
||||
def warn_execstack: F<"warn-execstack">;
|
16
devel/llvm/patches/patch-tools_lld_ELF_Symbols_cpp
Normal file
16
devel/llvm/patches/patch-tools_lld_ELF_Symbols_cpp
Normal file
@ -0,0 +1,16 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_Symbols_cpp,v 1.1 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
Generate __data_start symbol that marks the start of .data when __data_start
|
||||
is referenced from code being linked.
|
||||
|
||||
Index: tools/lld/ELF/Symbols.cpp
|
||||
--- tools/lld/ELF/Symbols.cpp.orig
|
||||
+++ tools/lld/ELF/Symbols.cpp
|
||||
@@ -29,6 +29,7 @@ using namespace lld;
|
||||
using namespace lld::elf;
|
||||
|
||||
Defined *ElfSym::Bss;
|
||||
+Defined *ElfSym::Data;
|
||||
Defined *ElfSym::Etext1;
|
||||
Defined *ElfSym::Etext2;
|
||||
Defined *ElfSym::Edata1;
|
15
devel/llvm/patches/patch-tools_lld_ELF_Symbols_h
Normal file
15
devel/llvm/patches/patch-tools_lld_ELF_Symbols_h
Normal file
@ -0,0 +1,15 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_Symbols_h,v 1.1 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
Index: tools/lld/ELF/Symbols.h
|
||||
--- tools/lld/ELF/Symbols.h.orig
|
||||
+++ tools/lld/ELF/Symbols.h
|
||||
@@ -313,6 +313,9 @@ struct ElfSym {
|
||||
// __bss_start
|
||||
static Defined *Bss;
|
||||
|
||||
+ // __data_start
|
||||
+ static Defined *Data;
|
||||
+
|
||||
// etext and _etext
|
||||
static Defined *Etext1;
|
||||
static Defined *Etext2;
|
@ -1,5 +1,6 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_SyntheticSections_cpp,v 1.7 2018/10/23 08:59:59 ajacoutot Exp $
|
||||
$OpenBSD: patch-tools_lld_ELF_SyntheticSections_cpp,v 1.8 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
- Add support for -z initfirst.
|
||||
- When merging sections into the output, lld tries to adjust the alignment of
|
||||
the section to be at least as large as the entry size of the section.
|
||||
This causes a later check that validates the alignment to fail if the
|
||||
@ -13,7 +14,16 @@ $OpenBSD: patch-tools_lld_ELF_SyntheticSections_cpp,v 1.7 2018/10/23 08:59:59 aj
|
||||
Index: tools/lld/ELF/SyntheticSections.cpp
|
||||
--- tools/lld/ELF/SyntheticSections.cpp.orig
|
||||
+++ tools/lld/ELF/SyntheticSections.cpp
|
||||
@@ -2512,7 +2512,9 @@ void elf::mergeSections() {
|
||||
@@ -1034,6 +1034,8 @@ template <class ELFT> void DynamicSection<ELFT>::final
|
||||
uint32_t DtFlags1 = 0;
|
||||
if (Config->Bsymbolic)
|
||||
DtFlags |= DF_SYMBOLIC;
|
||||
+ if (Config->ZInitfirst)
|
||||
+ DtFlags1 |= DF_1_INITFIRST;
|
||||
if (Config->ZNodelete)
|
||||
DtFlags1 |= DF_1_NODELETE;
|
||||
if (Config->ZNodlopen)
|
||||
@@ -2512,7 +2514,9 @@ void elf::mergeSections() {
|
||||
continue;
|
||||
|
||||
StringRef OutsecName = getOutputSectionName(MS);
|
||||
@ -24,7 +34,7 @@ Index: tools/lld/ELF/SyntheticSections.cpp
|
||||
|
||||
auto I = llvm::find_if(MergeSections, [=](MergeSyntheticSection *Sec) {
|
||||
// While we could create a single synthetic section for two different
|
||||
@@ -2571,6 +2573,9 @@ void ARMExidxSentinelSection::writeTo(uint8_t *Buf) {
|
||||
@@ -2571,6 +2575,9 @@ void ARMExidxSentinelSection::writeTo(uint8_t *Buf) {
|
||||
// The sentinel has to be removed if there are no other .ARM.exidx entries.
|
||||
bool ARMExidxSentinelSection::empty() const {
|
||||
OutputSection *OS = getParent();
|
||||
|
@ -1,4 +1,4 @@
|
||||
$OpenBSD: patch-tools_lld_ELF_Writer_cpp,v 1.7 2018/08/21 06:56:09 ajacoutot Exp $
|
||||
$OpenBSD: patch-tools_lld_ELF_Writer_cpp,v 1.8 2018/10/25 09:25:38 ajacoutot Exp $
|
||||
|
||||
- Merge '.openbsd.randomdata.*' sections into a single '.openbsd.randomdata'
|
||||
section when linking, as we do when using ld from binutils.
|
||||
@ -18,7 +18,15 @@ Index: tools/lld/ELF/Writer.cpp
|
||||
StringRef Prefix = V.drop_back();
|
||||
if (S->Name.startswith(V) || S->Name == Prefix)
|
||||
return Prefix;
|
||||
@@ -487,7 +488,7 @@ template <class ELFT> void Writer<ELFT>::run() {
|
||||
@@ -219,6 +220,7 @@ void elf::addReservedSymbols() {
|
||||
};
|
||||
|
||||
ElfSym::Bss = Add("__bss_start", 0);
|
||||
+ ElfSym::Data = Add("__data_start", 0);
|
||||
ElfSym::End1 = Add("end", -1);
|
||||
ElfSym::End2 = Add("_end", -1);
|
||||
ElfSym::Etext1 = Add("etext", -1);
|
||||
@@ -487,7 +489,7 @@ template <class ELFT> void Writer<ELFT>::run() {
|
||||
|
||||
static bool shouldKeepInSymtab(SectionBase *Sec, StringRef SymName,
|
||||
const Symbol &B) {
|
||||
@ -27,7 +35,7 @@ Index: tools/lld/ELF/Writer.cpp
|
||||
return false;
|
||||
|
||||
// If sym references a section in a discarded group, don't keep it.
|
||||
@@ -643,7 +644,11 @@ static bool isRelroSection(const OutputSection *Sec) {
|
||||
@@ -643,7 +645,11 @@ static bool isRelroSection(const OutputSection *Sec) {
|
||||
// However, if "-z now" is given, the lazy symbol resolution is
|
||||
// disabled, which enables us to put it into RELRO.
|
||||
if (Sec == InX::GotPlt->getParent())
|
||||
@ -39,3 +47,13 @@ Index: tools/lld/ELF/Writer.cpp
|
||||
|
||||
// .dynamic section contains data for the dynamic linker, and
|
||||
// there's no need to write to it at runtime, so it's better to put
|
||||
@@ -914,6 +920,9 @@ template <class ELFT> void Writer<ELFT>::setReservedSy
|
||||
|
||||
if (ElfSym::Bss)
|
||||
ElfSym::Bss->Section = findSection(".bss");
|
||||
+
|
||||
+ if (ElfSym::Data)
|
||||
+ ElfSym::Data->Section = findSection(".data");
|
||||
|
||||
// Setup MIPS _gp_disp/__gnu_local_gp symbols which should
|
||||
// be equal to the _gp symbol's value.
|
||||
|
Loading…
x
Reference in New Issue
Block a user