[lld] r280729 - [ELF] Add support for -no-gc-sections flag

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 6 11:28:49 PDT 2016


Author: phosek
Date: Tue Sep  6 13:28:49 2016
New Revision: 280729

URL: http://llvm.org/viewvc/llvm-project?rev=280729&view=rev
Log:
[ELF] Add support for -no-gc-sections flag

This flag is supported by both BFD ld and gold and is occasionally
used to negate the effect of -gc-sections flag.

Differential Revision: https://reviews.llvm.org/D24270

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Options.td

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=280729&r1=280728&r2=280729&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Sep  6 13:28:49 2016
@@ -400,7 +400,7 @@ void LinkerDriver::readConfigs(opt::Inpu
   Config->EnableNewDtags = !Args.hasArg(OPT_disable_new_dtags);
   Config->ExportDynamic = Args.hasArg(OPT_export_dynamic);
   Config->FatalWarnings = Args.hasArg(OPT_fatal_warnings);
-  Config->GcSections = Args.hasArg(OPT_gc_sections);
+  Config->GcSections = getArg(Args, OPT_gc_sections, OPT_no_gc_sections, false);
   Config->ICF = Args.hasArg(OPT_icf);
   Config->NoGnuUnique = Args.hasArg(OPT_no_gnu_unique);
   Config->NoUndefinedVersion = Args.hasArg(OPT_no_undefined_version);

Modified: lld/trunk/ELF/Options.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Options.td?rev=280729&r1=280728&r2=280729&view=diff
==============================================================================
--- lld/trunk/ELF/Options.td (original)
+++ lld/trunk/ELF/Options.td Tue Sep  6 13:28:49 2016
@@ -106,6 +106,9 @@ def no_as_needed: F<"no-as-needed">,
 def no_demangle: F<"no-demangle">,
   HelpText<"Do not demangle symbol names">;
 
+def no_gc_sections: F<"no-gc-sections">,
+  HelpText<"Disable garbage collection of unused sections">;
+
 def no_gnu_unique: F<"no-gnu-unique">,
   HelpText<"Disable STB_GNU_UNIQUE symbol binding">;
 




More information about the llvm-commits mailing list