aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorfincs <fincs.alt1@gmail.com>2016-12-16 13:42:02 +1030
committerAlan Modra <amodra@gmail.com>2016-12-16 13:49:03 +1030
commit221855059a11ab76aa909a5df4104354f9384139 (patch)
treee1bd030fe42b33167faff27c3df182cc6843054d /ld
parent4c4067e410581fe5c6190407b4fd410e7b71f9e4 (diff)
downloadgdb-221855059a11ab76aa909a5df4104354f9384139.zip
gdb-221855059a11ab76aa909a5df4104354f9384139.tar.gz
gdb-221855059a11ab76aa909a5df4104354f9384139.tar.bz2
Implement and document --gc-keep-exported
include/ * bfdlink.h (struct bfd_link_info): Add gc_keep_exported. bfd/ * elflink.c (bfd_elf_gc_mark_dynamic_ref_symbol): Add handling for info->gc_keep_exported. (bfd_elf_gc_sections): Likewise. ld/ * ld.texinfo: Document --gc-keep-exported. * ldlex.h (enum option_values): Add OPTION_GC_KEEP_EXPORTED. * lexsup.c (parse_args): Add handling for --gc-keep-exported.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog6
-rw-r--r--ld/ld.texinfo12
-rw-r--r--ld/ldlex.h1
-rw-r--r--ld/lexsup.c6
4 files changed, 25 insertions, 0 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 086434a..8463c7c 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-16 fincs <fincs.alt1@gmail.com>
+
+ * ld.texinfo: Document --gc-keep-exported.
+ * ldlex.h (enum option_values): Add OPTION_GC_KEEP_EXPORTED.
+ * lexsup.c (parse_args): Add handling for --gc-keep-exported.
+
2016-12-14 Yury Norov <ynorov@caviumnetworks.com>
* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add tests for tiny and
diff --git a/ld/ld.texinfo b/ld/ld.texinfo
index ec7ff1b..17503eb 100644
--- a/ld/ld.texinfo
+++ b/ld/ld.texinfo
@@ -1558,6 +1558,18 @@ default behaviour (of not listing the sections that are removed) can
be restored by specifying @samp{--no-print-gc-sections} on the command
line.
+@kindex --gc-keep-exported
+@cindex garbage collection
+@item --gc-keep-exported
+When @samp{--gc-sections} is enabled, this option prevents garbage
+collection of unused input sections that contain global symbols having
+default or protected visibility. This option is intended to be used for
+executables where unreferenced sections would otherwise be garbage
+collected regardless of the external visibility of contained symbols.
+Note that this option has no effect when linking shared objects since
+it is already the default behaviour. This option is only supported for
+ELF format targets.
+
@kindex --print-output-format
@cindex output format
@item --print-output-format
diff --git a/ld/ldlex.h b/ld/ldlex.h
index 52f7198..fd29008 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -101,6 +101,7 @@ enum option_values
OPTION_NO_GC_SECTIONS,
OPTION_PRINT_GC_SECTIONS,
OPTION_NO_PRINT_GC_SECTIONS,
+ OPTION_GC_KEEP_EXPORTED,
OPTION_HASH_SIZE,
OPTION_CHECK_SECTIONS,
OPTION_NO_CHECK_SECTIONS,
diff --git a/ld/lexsup.c b/ld/lexsup.c
index fb0b47f..8ff5d1f 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -335,6 +335,9 @@ static const struct ld_option ld_options[] =
{ {"no-print-gc-sections", no_argument, NULL, OPTION_NO_PRINT_GC_SECTIONS},
'\0', NULL, N_("Do not list removed unused sections"),
TWO_DASHES },
+ { {"gc-keep-exported", no_argument, NULL, OPTION_GC_KEEP_EXPORTED},
+ '\0', NULL, N_("Keep exported symbols when removing unused sections"),
+ TWO_DASHES },
{ {"hash-size=<NUMBER>", required_argument, NULL, OPTION_HASH_SIZE},
'\0', NULL, N_("Set default hash table size close to <NUMBER>"),
TWO_DASHES },
@@ -861,6 +864,9 @@ parse_args (unsigned argc, char **argv)
case OPTION_PRINT_GC_SECTIONS:
link_info.print_gc_sections = TRUE;
break;
+ case OPTION_GC_KEEP_EXPORTED:
+ link_info.gc_keep_exported = TRUE;
+ break;
case OPTION_HELP:
help ();
xexit (0);