|
|
be6651 |
--- binutils-2.27.orig/binutils/readelf.c 2017-01-16 11:51:05.043922264 +0000
|
|
|
be6651 |
+++ binutils-2.27/binutils/readelf.c 2017-01-16 12:01:34.389053872 +0000
|
|
|
be6651 |
@@ -16733,39 +16733,49 @@ process_archive (char * file_name, FILE
|
|
|
be6651 |
static int
|
|
|
be6651 |
process_file (char * file_name)
|
|
|
be6651 |
{
|
|
|
be6651 |
+ char * name;
|
|
|
be6651 |
+ char * saved_program_name;
|
|
|
be6651 |
FILE * file;
|
|
|
be6651 |
struct stat statbuf;
|
|
|
be6651 |
char armag[SARMAG];
|
|
|
be6651 |
- int ret;
|
|
|
be6651 |
+ int ret = 1;
|
|
|
be6651 |
+
|
|
|
be6651 |
+ /* Overload program_name to include file_name. Doing this means
|
|
|
be6651 |
+ that warning/error messages will positively identify the file
|
|
|
be6651 |
+ concerned even when multiple instances of readelf are running. */
|
|
|
be6651 |
+ name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
|
|
|
be6651 |
+ sprintf (name, "%s: %s", program_name, file_name);
|
|
|
be6651 |
+ saved_program_name = program_name;
|
|
|
be6651 |
+ program_name = name;
|
|
|
be6651 |
|
|
|
be6651 |
if (stat (file_name, &statbuf) < 0)
|
|
|
be6651 |
{
|
|
|
be6651 |
if (errno == ENOENT)
|
|
|
be6651 |
- error (_("'%s': No such file\n"), file_name);
|
|
|
be6651 |
+ error (_("No such file\n"));
|
|
|
be6651 |
else
|
|
|
be6651 |
- error (_("Could not locate '%s'. System error message: %s\n"),
|
|
|
be6651 |
- file_name, strerror (errno));
|
|
|
be6651 |
- return 1;
|
|
|
be6651 |
+ error (_("Could not locate file. System error message: %s\n"),
|
|
|
be6651 |
+ strerror (errno));
|
|
|
be6651 |
+ goto done;
|
|
|
be6651 |
}
|
|
|
be6651 |
|
|
|
be6651 |
if (! S_ISREG (statbuf.st_mode))
|
|
|
be6651 |
{
|
|
|
be6651 |
- error (_("'%s' is not an ordinary file\n"), file_name);
|
|
|
be6651 |
- return 1;
|
|
|
be6651 |
+ error (_("Not an ordinary file\n"));
|
|
|
be6651 |
+ goto done;
|
|
|
be6651 |
}
|
|
|
be6651 |
|
|
|
be6651 |
file = fopen (file_name, "rb");
|
|
|
be6651 |
if (file == NULL)
|
|
|
be6651 |
{
|
|
|
be6651 |
- error (_("Input file '%s' is not readable.\n"), file_name);
|
|
|
be6651 |
- return 1;
|
|
|
be6651 |
+ error (_("Not readable\n"));
|
|
|
be6651 |
+ goto done;
|
|
|
be6651 |
}
|
|
|
be6651 |
|
|
|
be6651 |
if (fread (armag, SARMAG, 1, file) != 1)
|
|
|
be6651 |
{
|
|
|
be6651 |
- error (_("%s: Failed to read file's magic number\n"), file_name);
|
|
|
be6651 |
+ error (_("Failed to read file's magic number\n"));
|
|
|
be6651 |
fclose (file);
|
|
|
be6651 |
- return 1;
|
|
|
be6651 |
+ goto done;
|
|
|
be6651 |
}
|
|
|
be6651 |
|
|
|
be6651 |
current_file_size = (bfd_size_type) statbuf.st_size;
|
|
|
be6651 |
@@ -16777,8 +16787,7 @@ process_file (char * file_name)
|
|
|
be6651 |
else
|
|
|
be6651 |
{
|
|
|
be6651 |
if (do_archive_index)
|
|
|
be6651 |
- error (_("File %s is not an archive so its index cannot be displayed.\n"),
|
|
|
be6651 |
- file_name);
|
|
|
be6651 |
+ error (_("Not an archive so its index cannot be displayed\n"));
|
|
|
be6651 |
|
|
|
be6651 |
rewind (file);
|
|
|
be6651 |
archive_file_size = archive_file_offset = 0;
|
|
|
be6651 |
@@ -16787,7 +16796,10 @@ process_file (char * file_name)
|
|
|
be6651 |
|
|
|
be6651 |
fclose (file);
|
|
|
be6651 |
|
|
|
be6651 |
+ done:
|
|
|
be6651 |
current_file_size = 0;
|
|
|
be6651 |
+ free (program_name);
|
|
|
be6651 |
+ program_name = saved_program_name;
|
|
|
be6651 |
return ret;
|
|
|
be6651 |
}
|
|
|
be6651 |
|