{ {"init", required_argument, NULL, OPTION_INIT},
'\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
{ {"Map", required_argument, NULL, OPTION_MAP},
- '\0', N_("[FILE]"), N_("Write a map file (default: <outputname>.map)"), ONE_DASH },
+ '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH },
{ {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
'\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
{ {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
'\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
{ {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
'\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
+ { {"export-dynamic-symbol", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL},
+ '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES },
+ { {"export-dynamic-symbol-list", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST},
+ '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES },
{ {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
'\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
{ {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
'\0', NULL, N_("Warn if start of section changes due to alignment"),
TWO_DASHES },
{ {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
- '\0', NULL, N_("Warn if outpout has DT_TEXTREL"),
+ '\0', NULL,
+#if DEFAULT_LD_TEXTREL_CHECK_WARNING
+ N_("Warn if outpout has DT_TEXTREL (default)"),
+#else
+ N_("Warn if outpout has DT_TEXTREL"),
+#endif
TWO_DASHES },
{ {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
'\0', NULL, NULL, NO_HELP },
dynamic_list_data,
dynamic_list
} opt_dynamic_list = dynamic_list_unset;
+ struct bfd_elf_dynamic_list *export_list = NULL;
shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
longopts = (struct option *)
ldfile_open_command_file (optarg);
saved_script_handle = hold_script_handle;
parser_input = input_dynamic_list;
+ current_dynamic_list_p = &link_info.dynamic_list;
yyparse ();
}
if (opt_dynamic_list != dynamic_list_data)
opt_dynamic_list = dynamic_list;
break;
+ case OPTION_EXPORT_DYNAMIC_SYMBOL:
+ {
+ struct bfd_elf_version_expr *expr
+ = lang_new_vers_pattern (NULL, xstrdup (optarg), NULL,
+ FALSE);
+ lang_append_dynamic_list (&export_list, expr);
+ }
+ break;
+ case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST:
+ /* This option indicates a small script that only specifies
+ an export list. Read it, but don't assume that we've
+ seen a linker script. */
+ {
+ FILE *hold_script_handle;
+
+ hold_script_handle = saved_script_handle;
+ ldfile_open_command_file (optarg);
+ saved_script_handle = hold_script_handle;
+ parser_input = input_dynamic_list;
+ current_dynamic_list_p = &export_list;
+ yyparse ();
+ }
+ break;
case OPTION_WARN_COMMON:
config.warn_common = TRUE;
break;
/* Run a couple of checks on the map filename. */
if (config.map_filename)
{
- /* If name has been provided then use the
- output filename with a .map extension. */
if (config.map_filename[0] == 0)
{
- /* FIXME: This is a memory leak as the string is never freed. */
- if (asprintf (&config.map_filename, "%s.map", output_filename) < 0)
- einfo (_("%F%P: %s: can not create name of map file: %E\n"));
+ einfo (_("%P: no file/directory name provided for map output; ignored\n"));
+ config.map_filename = NULL;
}
else
{
struct stat s;
/* If the map filename is actually a directory then create
- a file inside it, again based upon the output filename. */
+ a file inside it, based upon the output filename. */
if (stat (config.map_filename, &s) >= 0
&& S_ISDIR (s.st_mode))
{
char * new_name;
- /* FIXME: Another memory leak. */
+ /* FIXME: This is a (trivial) memory leak. */
if (asprintf (&new_name, "%s/%s.map",
config.map_filename, output_filename) < 0)
- einfo (_("%F%P: %s: can not create name of map file: %E\n"));
+ {
+ /* If this alloc fails then something is probably very
+ wrong. Better to halt now rather than continue on
+ into more problems. */
+ einfo (_("%P%F: cannot create name for linker map file: %E\n"));
+ new_name = NULL;
+ }
+
config.map_filename = new_name;
}
}
&& command_line.check_section_addresses < 0)
command_line.check_section_addresses = 0;
+ if (export_list)
+ {
+ struct bfd_elf_version_expr *head = export_list->head.list;
+ struct bfd_elf_version_expr *next;
+
+ /* For --export-dynamic-symbol[-list]:
+ 1. When building executable, treat like --dynamic-list.
+ 2. When building shared object:
+ a. If -Bsymbolic or --dynamic-list are used, treat like
+ --dynamic-list.
+ b. Otherwise, ignored.
+ */
+ if (!bfd_link_relocatable (&link_info)
+ && (bfd_link_executable (&link_info)
+ || opt_symbolic != symbolic_unset
+ || opt_dynamic_list != dynamic_list_unset))
+ {
+ /* Append the export list to link_info.dynamic_list. */
+ if (link_info.dynamic_list)
+ {
+ for (next = head; next->next != NULL; next = next->next)
+ ;
+ next->next = link_info.dynamic_list->head.list;
+ link_info.dynamic_list->head.list = head;
+ }
+ else
+ link_info.dynamic_list = export_list;
+
+ if (opt_dynamic_list != dynamic_list_data)
+ opt_dynamic_list = dynamic_list;
+ }
+ else
+ {
+ /* Free the export list. */
+ for (; head->next != NULL; head = next)
+ {
+ next = head->next;
+ free (head);
+ }
+ free (export_list);
+ }
+ }
+
switch (opt_dynamic_list)
{
case dynamic_list_unset: