You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.4 KiB

--- binutils-2.27.orig/binutils/readelf.c 2017-01-16 11:51:05.043922264 +0000
+++ binutils-2.27/binutils/readelf.c 2017-01-16 12:01:34.389053872 +0000
@@ -16733,39 +16733,49 @@ process_archive (char * file_name, FILE
static int
process_file (char * file_name)
{
+ char * name;
+ char * saved_program_name;
FILE * file;
struct stat statbuf;
char armag[SARMAG];
- int ret;
+ int ret = 1;
+
+ /* 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 1;
+ 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 1;
+ 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 1;
+ 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 1;
+ goto done;
}
current_file_size = (bfd_size_type) statbuf.st_size;
@@ -16777,8 +16787,7 @@ process_file (char * file_name)
else
{
if (do_archive_index)
- error (_("File %s is not an archive so its index cannot be displayed.\n"),
- file_name);
+ error (_("Not an archive so its index cannot be displayed\n"));
rewind (file);
archive_file_size = archive_file_offset = 0;
@@ -16787,7 +16796,10 @@ process_file (char * file_name)
fclose (file);
+ done:
current_file_size = 0;
+ free (program_name);
+ program_name = saved_program_name;
return ret;
}