diff --git a/0001-ELF-Support-package-metadata.patch b/0001-ELF-Support-package-metadata.patch new file mode 100644 index 0000000..31a3ab4 --- /dev/null +++ b/0001-ELF-Support-package-metadata.patch @@ -0,0 +1,170 @@ +From 2a5f3345e72b2c1a66d3714eaae37e7b05ef5c65 Mon Sep 17 00:00:00 2001 +From: Alex Brachet +Date: Mon, 8 Aug 2022 21:31:58 +0000 +Subject: [PATCH] [ELF] Support --package-metadata + +This was recently introduced in GNU linkers and it makes sense for +ld.lld to have the same support. This implementation omits checking if +the input string is valid json to reduce size bloat. + +Differential Revision: https://reviews.llvm.org/D131439 +--- + lld/ELF/Config.h | 1 + + lld/ELF/Driver.cpp | 1 + + lld/ELF/Options.td | 2 ++ + lld/ELF/SyntheticSections.cpp | 14 ++++++++++++++ + lld/ELF/SyntheticSections.h | 11 +++++++++++ + lld/ELF/Writer.cpp | 5 +++++ + lld/docs/ReleaseNotes.rst | 2 ++ + lld/test/ELF/package-metadata.s | 19 +++++++++++++++++++ + 8 files changed, 55 insertions(+) + create mode 100644 lld/test/ELF/package-metadata.s + +diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h +index 72b7be8165e0..38545d257a2b 100644 +--- a/lld/ELF/Config.h ++++ b/lld/ELF/Config.h +@@ -281,6 +281,7 @@ struct Configuration { + StringRef thinLTOJobs; + unsigned timeTraceGranularity; + int32_t splitStackAdjustSize; ++ StringRef packageMetadata; + + // The following config options do not directly correspond to any + // particular command line options. +diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp +index 54b487bdc243..39adc5d707d7 100644 +--- a/lld/ELF/Driver.cpp ++++ b/lld/ELF/Driver.cpp +@@ -1092,6 +1092,7 @@ static void readConfigs(opt::InputArgList &args) { + config->optimize = args::getInteger(args, OPT_O, 1); + config->orphanHandling = getOrphanHandling(args); + config->outputFile = args.getLastArgValue(OPT_o); ++ config->packageMetadata = args.getLastArgValue(OPT_package_metadata); + config->pie = args.hasFlag(OPT_pie, OPT_no_pie, false); + config->printIcfSections = + args.hasFlag(OPT_print_icf_sections, OPT_no_print_icf_sections, false); +diff --git a/lld/ELF/Options.td b/lld/ELF/Options.td +index cf2013a5f820..52f5485af1f4 100644 +--- a/lld/ELF/Options.td ++++ b/lld/ELF/Options.td +@@ -505,6 +505,8 @@ def z: JoinedOrSeparate<["-"], "z">, MetaVarName<"