mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
PR 32603, ld -w misbehaviour
ld -w currently causes segmentation faults and other misbehaviour since it changes einfo with %F in the format string (fatal error) to not exit. This patch fixes that by introducing a new variant of einfo called "fatal" that always exits, and replaces all einfo calls using %F with a call to fatal without the %F. I considered modifying einfo to inspect the first 2 or 4 chars in the format string, looking for %F, but decided that was probably a bad idea given that translators might have moved the %F. It's also a little nicer to inform the compiler of a function that doesn't return. The patch also fixes some formatting nits, and makes use of %pA to print section names in a couple of places in aix.em.
This commit is contained in:
27
ld/plugin.c
27
ld/plugin.c
@@ -252,7 +252,7 @@ plugin_opt_plugin (const char *plugin)
|
||||
newplug->name = plugin;
|
||||
newplug->dlhandle = dlopen (plugin, RTLD_NOW);
|
||||
if (!newplug->dlhandle)
|
||||
einfo (_("%F%P: %s: error loading plugin: %s\n"), plugin, dlerror ());
|
||||
fatal (_("%P: %s: error loading plugin: %s\n"), plugin, dlerror ());
|
||||
|
||||
/* Check if plugin has been loaded already. */
|
||||
while (curplug)
|
||||
@@ -343,7 +343,7 @@ plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
|
||||
}
|
||||
}
|
||||
report_error:
|
||||
einfo (_("%F%P: could not create dummy IR bfd: %E\n"));
|
||||
fatal (_("%P: could not create dummy IR bfd: %E\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -425,7 +425,7 @@ asymbol_from_plugin_symbol (bfd *abfd, asymbol *asym,
|
||||
unsigned char visibility;
|
||||
|
||||
if (!elfsym)
|
||||
einfo (_("%F%P: %s: non-ELF symbol in ELF BFD!\n"), asym->name);
|
||||
fatal (_("%P: %s: non-ELF symbol in ELF BFD!\n"), asym->name);
|
||||
|
||||
if (ldsym->def == LDPK_COMMON)
|
||||
{
|
||||
@@ -436,7 +436,7 @@ asymbol_from_plugin_symbol (bfd *abfd, asymbol *asym,
|
||||
switch (ldsym->visibility)
|
||||
{
|
||||
default:
|
||||
einfo (_("%F%P: unknown ELF symbol visibility: %d!\n"),
|
||||
fatal (_("%P: unknown ELF symbol visibility: %d!\n"),
|
||||
ldsym->visibility);
|
||||
return LDPS_ERR;
|
||||
|
||||
@@ -558,7 +558,7 @@ get_view (const void *handle, const void **viewp)
|
||||
|
||||
/* FIXME: einfo should support %lld. */
|
||||
if ((off_t) size != input->filesize)
|
||||
einfo (_("%F%P: unsupported input file size: %s (%ld bytes)\n"),
|
||||
fatal (_("%P: unsupported input file size: %s (%ld bytes)\n"),
|
||||
input->name, (long) input->filesize);
|
||||
|
||||
/* Check the cached view buffer. */
|
||||
@@ -834,7 +834,7 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
|
||||
&& blhe->type != bfd_link_hash_common)
|
||||
{
|
||||
/* We should not have a new, indirect or warning symbol here. */
|
||||
einfo (_("%F%P: %s: plugin symbol table corrupt (sym type %d)\n"),
|
||||
fatal (_("%P: %s: plugin symbol table corrupt (sym type %d)\n"),
|
||||
called_plugin->name, blhe->type);
|
||||
}
|
||||
|
||||
@@ -986,13 +986,14 @@ message (int level, const char *format, ...)
|
||||
case LDPL_ERROR:
|
||||
default:
|
||||
{
|
||||
char *newfmt = concat (level == LDPL_FATAL ? "%F" : "%X",
|
||||
_("%P: error: "), format, "\n",
|
||||
char *newfmt = concat (_("%X%P: error: "), format, "\n",
|
||||
(const char *) NULL);
|
||||
fflush (stdout);
|
||||
vfinfo (stderr, newfmt, args, true);
|
||||
fflush (stderr);
|
||||
free (newfmt);
|
||||
if (level == LDPL_FATAL)
|
||||
fatal ("");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1135,14 +1136,14 @@ plugin_load_plugins (void)
|
||||
if (!onloadfn)
|
||||
onloadfn = (ld_plugin_onload) dlsym (curplug->dlhandle, "_onload");
|
||||
if (!onloadfn)
|
||||
einfo (_("%F%P: %s: error loading plugin: %s\n"),
|
||||
fatal (_("%P: %s: error loading plugin: %s\n"),
|
||||
curplug->name, dlerror ());
|
||||
set_tv_plugin_args (curplug, &my_tv[tv_header_size]);
|
||||
called_plugin = curplug;
|
||||
rv = (*onloadfn) (my_tv);
|
||||
called_plugin = NULL;
|
||||
if (rv != LDPS_OK)
|
||||
einfo (_("%F%P: %s: plugin error: %d\n"), curplug->name, rv);
|
||||
fatal (_("%P: %s: plugin error: %d\n"), curplug->name, rv);
|
||||
curplug = curplug->next;
|
||||
}
|
||||
|
||||
@@ -1206,7 +1207,7 @@ plugin_strdup (bfd *abfd, const char *str)
|
||||
strlength = strlen (str) + 1;
|
||||
copy = bfd_alloc (abfd, strlength);
|
||||
if (copy == NULL)
|
||||
einfo (_("%F%P: plugin_strdup failed to allocate memory: %s\n"),
|
||||
fatal (_("%P: plugin_strdup failed to allocate memory: %s\n"),
|
||||
bfd_get_error ());
|
||||
memcpy (copy, str, strlength);
|
||||
return copy;
|
||||
@@ -1248,7 +1249,7 @@ plugin_object_p (bfd *ibfd, bool known_used)
|
||||
|
||||
input = bfd_alloc (abfd, sizeof (*input));
|
||||
if (input == NULL)
|
||||
einfo (_("%F%P: plugin failed to allocate memory for input: %s\n"),
|
||||
fatal (_("%P: plugin failed to allocate memory for input: %s\n"),
|
||||
bfd_get_error ());
|
||||
|
||||
if (!bfd_plugin_open_input (ibfd, &file))
|
||||
@@ -1277,7 +1278,7 @@ plugin_object_p (bfd *ibfd, bool known_used)
|
||||
|
||||
if (plugin_call_claim_file (&file, &claimed, &claim_file_handler_v2,
|
||||
known_used))
|
||||
einfo (_("%F%P: %s: plugin reported error claiming file\n"),
|
||||
fatal (_("%P: %s: plugin reported error claiming file\n"),
|
||||
plugin_error_plugin ());
|
||||
|
||||
if (input->fd != -1
|
||||
|
||||
Reference in New Issue
Block a user