forked from Imagelibrary/binutils-gdb
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:
28
ld/ldmisc.c
28
ld/ldmisc.c
@@ -70,7 +70,7 @@
|
||||
void
|
||||
vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
|
||||
{
|
||||
bool fatal = false;
|
||||
bool isfatal = false;
|
||||
const char *scan;
|
||||
int arg_type;
|
||||
unsigned int arg_count = 0;
|
||||
@@ -282,7 +282,7 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
|
||||
|
||||
case 'F':
|
||||
/* Error is fatal. */
|
||||
fatal = true;
|
||||
isfatal = true;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
@@ -324,7 +324,7 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
|
||||
if (abfd != NULL)
|
||||
{
|
||||
if (!bfd_generic_link_read_symbols (abfd))
|
||||
einfo (_("%F%P: %pB: could not read symbols: %E\n"), abfd);
|
||||
fatal (_("%P: %pB: could not read symbols: %E\n"), abfd);
|
||||
|
||||
asymbols = bfd_get_outsymbols (abfd);
|
||||
}
|
||||
@@ -587,7 +587,7 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning)
|
||||
if (is_warning && config.fatal_warnings)
|
||||
config.make_executable = false;
|
||||
|
||||
if (fatal)
|
||||
if (isfatal)
|
||||
xexit (1);
|
||||
}
|
||||
|
||||
@@ -620,6 +620,21 @@ einfo (const char *fmt, ...)
|
||||
fflush (stderr);
|
||||
}
|
||||
|
||||
/* Fatal error. */
|
||||
|
||||
void
|
||||
fatal (const char *fmt, ...)
|
||||
{
|
||||
va_list arg;
|
||||
|
||||
fflush (stdout);
|
||||
va_start (arg, fmt);
|
||||
vfinfo (stderr, fmt, arg, true);
|
||||
va_end (arg);
|
||||
fflush (stderr);
|
||||
xexit (1);
|
||||
}
|
||||
|
||||
/* The buffer size for each command-line option warning. */
|
||||
#define CMDLINE_WARNING_SIZE 256
|
||||
|
||||
@@ -698,7 +713,7 @@ output_unknown_cmdline_warnings (void)
|
||||
void
|
||||
info_assert (const char *file, unsigned int line)
|
||||
{
|
||||
einfo (_("%F%P: internal error %s %d\n"), file, line);
|
||||
fatal (_("%P: internal error %s %d\n"), file, line);
|
||||
}
|
||||
|
||||
/* ('m' for map) Format info message and print on map. */
|
||||
@@ -767,8 +782,7 @@ ld_abort (const char *file, int line, const char *fn)
|
||||
else
|
||||
einfo (_("%P: internal error: aborting at %s:%d\n"),
|
||||
file, line);
|
||||
einfo (_("%F%P: please report this bug\n"));
|
||||
xexit (1);
|
||||
fatal (_("%P: please report this bug\n"));
|
||||
}
|
||||
|
||||
/* Decode a hexadecimal character. Return -1 on error. */
|
||||
|
||||
Reference in New Issue
Block a user