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