* ldlang.h (lang_input_statement_type): Add whole_archive field.
* ldlang.c (new_afile): Set whole_archive field.
(load_symbols): Check input file specific whole_archive field
rather than global variable.
* ld.texinfo, ld.1: Document --no-whole-archive.
PR 9094.
+Tue Feb 27 12:55:46 1996 Ian Lance Taylor <ian@cygnus.com>
+
+ * lexsup.c (parse_args): Recognize --no-whole-archive.
+ * ldlang.h (lang_input_statement_type): Add whole_archive field.
+ * ldlang.c (new_afile): Set whole_archive field.
+ (load_symbols): Check input file specific whole_archive field
+ rather than global variable.
+ * ld.texinfo, ld.1: Document --no-whole-archive.
+
Tue Feb 20 16:07:00 1996 Ian Lance Taylor <ian@cygnus.com>
* configure.tgt: Correct gldi960 to gld960.
.RB "[\|" \-warn\-constructors "\|]"
.RB "[\|" \-warn\-once "\|]"
.RB "[\|" \-\-whole\-archive "\|]"
+.RB "[\|" \-\-no\-whole\-archive "\|]"
.RB "[\|" \-X "\|]"
.RB "[\|" \-x "\|]"
.ad b
.TP
.B \-\-whole\-archive
-For each archive mentioned on the command line, include every object
-file in the archive in the link, rather than searching the archive for
-the required object files. This is normally used to turn an archive
-file into a shared library, forcing every object to be included in the
-resulting shared library.
+For each archive mentioned on the command line after the
+.B \-\-whole\-archive
+option, include every object file in the archive in the link, rather
+than searching the archive for the required object files. This is
+normally used to turn an archive file into a shared library, forcing
+every object to be included in the resulting shared library.
+
+.TP
+.B \-\-no\-whole\-archive
+Turn off the effect of the
+.B \-\-whole\-archive
+option for archives which appear later on the command line.
.TP
.B \-X
[ -( [ archives ] -) ]
[ --start-group [ archives ] --end-group ]
[ -split-by-reloc @var{count} ] [ -split-by-file ]
- [ --whole-archive ]
+ [ --whole-archive ] [ --no-whole-archive ]
@end smallexample
This plethora of command-line options may seem intimidating, but in
@kindex --whole-archive
@cindex including an entire archive
-For each archive mentioned on the command line, include every object
-file in the archive in the link, rather than searching the archive for
-the required object files. This is normally used to turn an archive
-file into a shared library, forcing every object to be included in the
-resulting shared library.
+For each archive mentioned on the command line after the
+@code{--whole-archive} option, include every object file in the archive
+in the link, rather than searching the archive for the required object
+files. This is normally used to turn an archive file into a shared
+library, forcing every object to be included in the resulting shared
+library.
+
+@kindex --no-whole-archive
+Turn off the effect of the @code{--whole-archive} option for archives
+which appear later on the command line.
@kindex -X
@cindex local symbols, deleting
p->symbol_count = 0;
p->common_output_section = (asection *) NULL;
p->dynamic = config.dynamic_link;
+ p->whole_archive = whole_archive;
p->loaded = false;
lang_statement_append (&input_file_chain,
(lang_statement_union_type *) p,
break;
case bfd_archive:
- if (whole_archive)
+ if (entry->whole_archive)
{
bfd *member = bfd_openr_next_archived_file (entry->the_bfd,
(bfd *) NULL);
} lang_output_statement_type;
+/* This structure holds a list of program headers describing segments
+ in which this section should be placed. */
+
+struct lang_output_section_phdr_list
+{
+ struct lang_output_section_phdr_list *next;
+ const char *name;
+ boolean used;
+};
+
typedef struct lang_output_section_statement_struct
{
lang_statement_header_type header;
int subsection_alignment; /* alignment of components */
int section_alignment; /* alignment of start of section */
- union etree_union *load_base;
+ union etree_union *load_base;
+
+ struct lang_output_section_phdr_list *phdrs;
} lang_output_section_statement_type;
Also default text_start to after this file's bss. */
boolean just_syms_flag;
-
+
+ /* Whether to search for this entry as a dynamic archive. */
+ boolean dynamic;
+
+ /* Whether to include the entire contents of an archive. */
+ boolean whole_archive;
+
boolean loaded;
-
/* unsigned int globals_in_this_file;*/
const char *target;
boolean real;
lang_group_statement_type group_statement;
} lang_statement_union_type;
+/* This structure holds information about a program header, from the
+ PHDRS command in the linker script. */
+
+struct lang_phdr
+{
+ struct lang_phdr *next;
+ const char *name;
+ unsigned long type;
+ boolean filehdr;
+ boolean phdrs;
+ etree_type *at;
+ etree_type *flags;
+};
+
extern lang_output_section_statement_type *abs_output_section;
extern boolean lang_has_input_file;
extern etree_type *base;
extern lang_statement_list_type *stat_ptr;
extern boolean delete_output_file_on_failure;
+extern const char *entry_symbol;
+extern boolean entry_from_cmdline;
+
extern void lang_init PARAMS ((void));
extern struct memory_region_struct *lang_memory_region_lookup
PARAMS ((const char *const));
extern void lang_final PARAMS ((void));
extern void lang_process PARAMS ((void));
extern void lang_section_start PARAMS ((const char *, union etree_union *));
-extern void lang_add_entry PARAMS ((const char *, int));
+extern void lang_add_entry PARAMS ((const char *, boolean));
extern void lang_add_target PARAMS ((const char *));
extern void lang_add_wild PARAMS ((const char *const , const char *const));
extern void lang_add_map PARAMS ((const char *));
PARAMS ((lang_statement_list_type *ptr, asection *section,
lang_output_section_statement_type *output,
lang_input_statement_type *file));
+extern void lang_new_phdr
+ PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
+ etree_type *));
+extern void lang_section_in_phdr PARAMS ((const char *));
#endif
as if it were the argument of an option with character code 1. */
const char *shortopts =
- "-a:A:B::b:c:de:F::G:gh:iL:l:Mm:NnO:o:R:rSsT:tu:VvXxY:y:z:()";
+ "-a:A:b:c:de:F::G:gh:iL:l:Mm:NnO:o:R:rSsT:tu:VvXxY:y:z:()";
/* 150 isn't special; it's just an arbitrary non-ASCII char value. */
#define OPTION_NO_KEEP_MEMORY (OPTION_MAP + 1)
#define OPTION_NOINHIBIT_EXEC (OPTION_NO_KEEP_MEMORY + 1)
#define OPTION_NON_SHARED (OPTION_NOINHIBIT_EXEC + 1)
-#define OPTION_OFORMAT (OPTION_NON_SHARED + 1)
+#define OPTION_NO_WHOLE_ARCHIVE (OPTION_NON_SHARED + 1)
+#define OPTION_OFORMAT (OPTION_NO_WHOLE_ARCHIVE + 1)
#define OPTION_RELAX (OPTION_OFORMAT + 1)
#define OPTION_RETAIN_SYMBOLS_FILE (OPTION_RELAX + 1)
#define OPTION_RPATH (OPTION_RETAIN_SYMBOLS_FILE + 1)
-#define OPTION_SHARED (OPTION_RPATH + 1)
+#define OPTION_RPATH_LINK (OPTION_RPATH + 1)
+#define OPTION_SHARED (OPTION_RPATH_LINK + 1)
#define OPTION_SONAME (OPTION_SHARED + 1)
#define OPTION_SORT_COMMON (OPTION_SONAME + 1)
#define OPTION_STATS (OPTION_SORT_COMMON + 1)
{"help", no_argument, NULL, OPTION_HELP},
{"Map", required_argument, NULL, OPTION_MAP},
{"no-keep-memory", no_argument, NULL, OPTION_NO_KEEP_MEMORY},
+ {"no-whole-archive", no_argument, NULL, OPTION_NO_WHOLE_ARCHIVE},
{"noinhibit-exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
{"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
{"non_shared", no_argument, NULL, OPTION_NON_SHARED},
{"relax", no_argument, NULL, OPTION_RELAX},
{"retain-symbols-file", required_argument, NULL, OPTION_RETAIN_SYMBOLS_FILE},
{"rpath", required_argument, NULL, OPTION_RPATH},
+ {"rpath-link", required_argument, NULL, OPTION_RPATH_LINK},
{"shared", no_argument, NULL, OPTION_SHARED},
{"soname", required_argument, NULL, OPTION_SONAME},
{"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
einfo ("%P%F: unrecognized -a option `%s'\n", optarg);
break;
case OPTION_ASSERT:
- /* FIXME: We just ignore these, except for pure-text, but we
- should handle them. */
+ /* FIXME: We just ignore these, but we should handle them. */
if (strcmp (optarg, "definitions") == 0)
;
else if (strcmp (optarg, "nodefinitions") == 0)
else if (strcmp (optarg, "nosymbolic") == 0)
;
else if (strcmp (optarg, "pure-text") == 0)
- {
- /* FIXME: This is wrong. We do it this way as a hack to
- support SunOS4, on which gcc -shared will pass
- -assert pure-text to the linker. The SunOS linker
- will automatically create a shared library if there
- are any undefined symbols, but our linker does not
- know how to do that (it seems to require an extra
- pass over the relocs). */
- link_info.shared = true;
- }
+ ;
else
einfo ("%P%F: unrecognized -assert option `%s'\n", optarg);
break;
command_line.export_dynamic = true;
break;
case 'e':
- lang_add_entry (optarg, 1);
+ lang_add_entry (optarg, true);
break;
case 'F':
/* Ignore. */
case 'N':
config.text_read_only = false;
config.magic_demand_paged = false;
+ config.dynamic_link = false;
break;
case 'n':
config.magic_demand_paged = false;
+ config.dynamic_link = false;
break;
case OPTION_NO_KEEP_MEMORY:
link_info.keep_memory = false;
case OPTION_NOINHIBIT_EXEC:
force_make_executable = true;
break;
+ case OPTION_NO_WHOLE_ARCHIVE:
+ whole_archive = false;
+ break;
case 'O':
/* FIXME "-O<non-digits> <value>" used to set the address of
section <non-digits>. Was this for compatibility with
command_line.rpath = buf;
}
break;
+ case OPTION_RPATH_LINK:
+ if (command_line.rpath_link == NULL)
+ command_line.rpath_link = buystring (optarg);
+ else
+ {
+ char *buf;
+
+ buf = xmalloc (strlen (command_line.rpath_link)
+ + strlen (optarg)
+ + 2);
+ sprintf (buf, "%s:%s", command_line.rpath_link, optarg);
+ free (command_line.rpath_link);
+ command_line.rpath_link = buf;
+ }
+ break;
case OPTION_RELAX:
command_line.relax = true;
break;