|
|
13ae24 |
--- binutils.orig/binutils/readelf.c 2018-01-22 15:48:10.450701702 +0000
|
|
|
13ae24 |
+++ binutils-2.30.0/binutils/readelf.c 2018-01-22 15:55:26.739588657 +0000
|
|
|
13ae24 |
@@ -19019,75 +19019,85 @@ process_file (char * file_name)
|
|
|
13ae24 |
Filedata * filedata = NULL;
|
|
|
13ae24 |
struct stat statbuf;
|
|
|
13ae24 |
char armag[SARMAG];
|
|
|
13ae24 |
- bfd_boolean ret = TRUE;
|
|
|
13ae24 |
+ bfd_boolean ret = FALSE;
|
|
|
13ae24 |
+ char * name;
|
|
|
13ae24 |
+ char * saved_program_name;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ /* Overload program_name to include file_name. Doing this means
|
|
|
13ae24 |
+ that warning/error messages will positively identify the file
|
|
|
13ae24 |
+ concerned even when multiple instances of readelf are running. */
|
|
|
13ae24 |
+ name = xmalloc (strlen (program_name) + strlen (file_name) + 3);
|
|
|
13ae24 |
+ sprintf (name, "%s: %s", program_name, file_name);
|
|
|
13ae24 |
+ saved_program_name = program_name;
|
|
|
13ae24 |
+ program_name = name;
|
|
|
13ae24 |
|
|
|
13ae24 |
if (stat (file_name, &statbuf) < 0)
|
|
|
13ae24 |
{
|
|
|
13ae24 |
if (errno == ENOENT)
|
|
|
13ae24 |
- error (_("'%s': No such file\n"), file_name);
|
|
|
13ae24 |
+ error (_("No such file\n"));
|
|
|
13ae24 |
else
|
|
|
13ae24 |
- error (_("Could not locate '%s'. System error message: %s\n"),
|
|
|
13ae24 |
- file_name, strerror (errno));
|
|
|
13ae24 |
- return FALSE;
|
|
|
13ae24 |
+ error (_("Could not locate file. System error message: %s\n"),
|
|
|
13ae24 |
+ strerror (errno));
|
|
|
13ae24 |
+ goto done;
|
|
|
13ae24 |
}
|
|
|
13ae24 |
|
|
|
13ae24 |
if (! S_ISREG (statbuf.st_mode))
|
|
|
13ae24 |
{
|
|
|
13ae24 |
- error (_("'%s' is not an ordinary file\n"), file_name);
|
|
|
13ae24 |
- return FALSE;
|
|
|
13ae24 |
+ error (_("Not an ordinary file\n"));
|
|
|
13ae24 |
+ goto done;
|
|
|
13ae24 |
}
|
|
|
13ae24 |
|
|
|
13ae24 |
filedata = calloc (1, sizeof * filedata);
|
|
|
13ae24 |
if (filedata == NULL)
|
|
|
13ae24 |
{
|
|
|
13ae24 |
error (_("Out of memory allocating file data structure\n"));
|
|
|
13ae24 |
- return FALSE;
|
|
|
13ae24 |
+ goto done;
|
|
|
13ae24 |
}
|
|
|
13ae24 |
|
|
|
13ae24 |
filedata->file_name = file_name;
|
|
|
13ae24 |
filedata->handle = fopen (file_name, "rb");
|
|
|
13ae24 |
if (filedata->handle == NULL)
|
|
|
13ae24 |
{
|
|
|
13ae24 |
- error (_("Input file '%s' is not readable.\n"), file_name);
|
|
|
13ae24 |
- free (filedata);
|
|
|
13ae24 |
- return FALSE;
|
|
|
13ae24 |
+ error (_("Not readable\n"));
|
|
|
13ae24 |
+ goto done;
|
|
|
13ae24 |
}
|
|
|
13ae24 |
|
|
|
13ae24 |
if (fread (armag, SARMAG, 1, filedata->handle) != 1)
|
|
|
13ae24 |
{
|
|
|
13ae24 |
- error (_("%s: Failed to read file's magic number\n"), file_name);
|
|
|
13ae24 |
- fclose (filedata->handle);
|
|
|
13ae24 |
- free (filedata);
|
|
|
13ae24 |
- return FALSE;
|
|
|
13ae24 |
- }
|
|
|
13ae24 |
-
|
|
|
13ae24 |
- filedata->file_size = (bfd_size_type) statbuf.st_size;
|
|
|
13ae24 |
-
|
|
|
13ae24 |
- if (memcmp (armag, ARMAG, SARMAG) == 0)
|
|
|
13ae24 |
- {
|
|
|
13ae24 |
- if (! process_archive (filedata, FALSE))
|
|
|
13ae24 |
- ret = FALSE;
|
|
|
13ae24 |
- }
|
|
|
13ae24 |
- else if (memcmp (armag, ARMAGT, SARMAG) == 0)
|
|
|
13ae24 |
- {
|
|
|
13ae24 |
- if ( ! process_archive (filedata, TRUE))
|
|
|
13ae24 |
- ret = FALSE;
|
|
|
13ae24 |
+ error (_("Failed to read file's magic number\n"));
|
|
|
13ae24 |
}
|
|
|
13ae24 |
else
|
|
|
13ae24 |
{
|
|
|
13ae24 |
- if (do_archive_index)
|
|
|
13ae24 |
- error (_("File %s is not an archive so its index cannot be displayed.\n"),
|
|
|
13ae24 |
- file_name);
|
|
|
13ae24 |
+ filedata->file_size = (bfd_size_type) statbuf.st_size;
|
|
|
13ae24 |
|
|
|
13ae24 |
- rewind (filedata->handle);
|
|
|
13ae24 |
- archive_file_size = archive_file_offset = 0;
|
|
|
13ae24 |
-
|
|
|
13ae24 |
- if (! process_object (filedata))
|
|
|
13ae24 |
- ret = FALSE;
|
|
|
13ae24 |
+ if (memcmp (armag, ARMAG, SARMAG) == 0)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ if (process_archive (filedata, FALSE))
|
|
|
13ae24 |
+ ret = TRUE;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ else if (memcmp (armag, ARMAGT, SARMAG) == 0)
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ if (process_archive (filedata, TRUE))
|
|
|
13ae24 |
+ ret = TRUE;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
+ else
|
|
|
13ae24 |
+ {
|
|
|
13ae24 |
+ if (do_archive_index)
|
|
|
13ae24 |
+ error (_("Not an archive so its index cannot be displayed.\n"));
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ rewind (filedata->handle);
|
|
|
13ae24 |
+ archive_file_size = archive_file_offset = 0;
|
|
|
13ae24 |
+
|
|
|
13ae24 |
+ if (process_object (filedata))
|
|
|
13ae24 |
+ ret = TRUE;
|
|
|
13ae24 |
+ }
|
|
|
13ae24 |
}
|
|
|
13ae24 |
|
|
|
13ae24 |
fclose (filedata->handle);
|
|
|
13ae24 |
+ done:
|
|
|
13ae24 |
free (filedata);
|
|
|
13ae24 |
+ free (program_name);
|
|
|
13ae24 |
+ program_name = saved_program_name;
|
|
|
13ae24 |
|
|
|
13ae24 |
return ret;
|
|
|
13ae24 |
}
|