aboutsummaryrefslogtreecommitdiff
path: root/ld/lexsup.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>1998-07-02 02:52:31 +0000
committerRichard Henderson <rth@redhat.com>1998-07-02 02:52:31 +0000
commit71b012a810fd03d0aa05cd6d0fc874abdafdfc61 (patch)
tree9e7f3f420f28a3b345bc89fffde1b161c9a2df56 /ld/lexsup.c
parent5ea0771f4ca8d8c43f3379dc70e4071325e7d68c (diff)
downloadgdb-71b012a810fd03d0aa05cd6d0fc874abdafdfc61.zip
gdb-71b012a810fd03d0aa05cd6d0fc874abdafdfc61.tar.gz
gdb-71b012a810fd03d0aa05cd6d0fc874abdafdfc61.tar.bz2
* ld.h (args_type): Add gc_sections.
* ldgram.y (ldgram_had_keep, KEEP): New. (input_section_spec_no_keep): Rename from old input_section_spec. (input_section_spec): New. Recognize KEEP. * ldlang.c (wild_section): Handle keep sections. (lang_gc_wild_section, lang_gc_wild_file, lang_gc_wild): New. (lang_gc_sections_1, lang_gc_sections): New. (lang_process): Invoke lang_gc_sections. (lang_add_wild): Add keep argument. Update all callers. * ldlang.h (lang_wild_statement_struct): Add keep_sections. * ldlex.l (KEEP): Match it. * ldmain.c (main): Error on -r and --gc-sections. * lexsup.c: Add --gc-sections. * scripttempl/elf.sc: Merge .text.* etc sections appropriately. Mark startup sections with KEEP. * scripttempl/elfppc.sc: Likewise. * ld.texinfo: Update for --gc-sections and KEEP.
Diffstat (limited to 'ld/lexsup.c')
-rw-r--r--ld/lexsup.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 28b7e09..3a03f20 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -111,6 +111,8 @@ int parsing_defsym = 0;
#define OPTION_WHOLE_ARCHIVE (OPTION_SPLIT_BY_FILE + 1)
#define OPTION_WRAP (OPTION_WHOLE_ARCHIVE + 1)
#define OPTION_FORCE_EXE_SUFFIX (OPTION_WRAP + 1)
+#define OPTION_GC_SECTIONS (OPTION_FORCE_EXE_SUFFIX + 1)
+#define OPTION_NO_GC_SECTIONS (OPTION_GC_SECTIONS + 1)
/* The long options. This structure is used for both the option
parsing and the help text. */
@@ -163,6 +165,12 @@ static const struct ld_option ld_options[] =
'F', N_("SHLIB"), N_("Filter for shared object symbol table"), TWO_DASHES },
{ {NULL, no_argument, NULL, '\0'},
'g', NULL, N_("Ignored"), ONE_DASH },
+ { {"gc-sections", no_argument, NULL, OPTION_GC_SECTIONS},
+ '\0', NULL, N_("Remove unused sections on certain targets"),
+ TWO_DASHES },
+ { {"no-gc-sections", no_argument, NULL, OPTION_NO_GC_SECTIONS},
+ '\0', NULL, N_("(Don't) Remove unused sections on certain targets"),
+ TWO_DASHES },
{ {"gpsize", required_argument, NULL, 'G'},
'G', N_("SIZE"), N_("Small data size (if no size, same as --shared)"),
TWO_DASHES },
@@ -575,6 +583,9 @@ parse_args (argc, argv)
case 'g':
/* Ignore. */
break;
+ case OPTION_GC_SECTIONS:
+ command_line.gc_sections = true;
+ break;
case OPTION_HELP:
help ();
xexit (0);
@@ -604,6 +615,9 @@ parse_args (argc, argv)
config.magic_demand_paged = false;
config.dynamic_link = false;
break;
+ case OPTION_NO_GC_SECTIONS:
+ command_line.gc_sections = false;
+ break;
case OPTION_NO_KEEP_MEMORY:
link_info.keep_memory = false;
break;
@@ -701,7 +715,10 @@ parse_args (argc, argv)
link_info.strip = strip_all;
break;
case OPTION_SHARED:
- link_info.shared = true;
+ if (config.has_shared)
+ link_info.shared = true;
+ else
+ einfo (_("%P%F: -shared not supported\n"));
break;
case 'h': /* Used on Solaris. */
case OPTION_SONAME: