binutils/binutils-2.29-filename-in-error-messages.patch
Nick Clifton 283a7e8f17 - Rebase on FSF binutils 2.29.
- Retire: binutils-2.20.51.0.10-ppc64-pie.patch
- Retire: binutils-2.27-ld-buffer-overflow.patch
- Retire: binutils-2.28-libiberty-bugfixes.patch
- Retire: binutils-gnu-build-notes.patch
- Retire: binutils-2.28-gas-comp_dir.patch
- Retire: binutils-2.28-ppc-dynamic-relocs.patch
- Retire: binutils-2.28-dynamic-section-warning.patch
- Retire: binutils-2.28-aarch64-copy-relocs.patch
- Retire: binutils-2.28-DW_AT_export_symbols.patch
2017-07-24 16:48:39 +01:00

74 lines
2.1 KiB
Diff

--- binutils.orig/binutils/readelf.c 2017-07-24 15:27:09.859116315 +0100
+++ binutils-2.29/binutils/readelf.c 2017-07-24 15:30:33.557770525 +0100
@@ -18414,39 +18414,49 @@ process_archive (char * file_name, FILE
static bfd_boolean
process_file (char * file_name)
{
+ char * name;
+ char * saved_program_name;
FILE * file;
struct stat statbuf;
char armag[SARMAG];
bfd_boolean ret = TRUE;
+ /* Overload program_name to include file_name. Doing this means
+ that warning/error messages will positively identify the file
+ concerned even when multiple instances of readelf are running. */
+ name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
+ sprintf (name, "%s: %s", program_name, file_name);
+ saved_program_name = program_name;
+ program_name = name;
+
if (stat (file_name, &statbuf) < 0)
{
if (errno == ENOENT)
- error (_("'%s': No such file\n"), file_name);
+ error (_("No such file\n"));
else
- error (_("Could not locate '%s'. System error message: %s\n"),
- file_name, strerror (errno));
- return FALSE;
+ error (_("Could not locate file. System error message: %s\n"),
+ strerror (errno));
+ goto done;
}
if (! S_ISREG (statbuf.st_mode))
{
- error (_("'%s' is not an ordinary file\n"), file_name);
- return FALSE;
+ error (_("Not an ordinary file\n"));
+ goto done;
}
file = fopen (file_name, "rb");
if (file == NULL)
{
- error (_("Input file '%s' is not readable.\n"), file_name);
- return FALSE;
+ error (_("Not readable\n"));
+ goto done;
}
if (fread (armag, SARMAG, 1, file) != 1)
{
- error (_("%s: Failed to read file's magic number\n"), file_name);
+ error (_("Failed to read file's magic number\n"));
fclose (file);
- return FALSE;
+ goto done;
}
current_file_size = (bfd_size_type) statbuf.st_size;
@@ -18474,7 +18484,10 @@ process_file (char * file_name)
}
fclose (file);
+ done:
current_file_size = 0;
+ free (program_name);
+ program_name = saved_program_name;
return ret;
}