#include "elf/mmix.h"
#include "elf/mn10200.h"
#include "elf/mn10300.h"
-#include "elf/ms1.h"
+#include "elf/mt.h"
#include "elf/msp430.h"
#include "elf/or32.h"
#include "elf/pj.h"
static struct group *section_groups;
static struct group **section_headers_groups;
+/* A linked list of the section names for which dumps were requested
+ by name. */
+struct dump_list_entry
+{
+ char *name;
+ int type;
+ struct dump_list_entry *next;
+};
+static struct dump_list_entry *dump_sects_byname;
+
/* A dynamic array of flags indicating for which sections a hex dump
has been requested (via the -x switch) and/or a disassembly dump
(via the -i switch). */
/* A dynamic array of flags indicating for which sections a dump of
some kind has been requested. It is reset on a per-object file
- basis and then initialised from the cmdline_dump_sects array and
- the results of interpreting the -w switch. */
+ basis and then initialised from the cmdline_dump_sects array,
+ the results of interpreting the -w switch, and the
+ dump_sects_byname list. */
char *dump_sects = NULL;
unsigned int num_dump_sects = 0;
case EM_XTENSA_OLD:
case EM_M32R:
case EM_M32C:
- case EM_MS1:
+ case EM_MT:
case EM_BLACKFIN:
return TRUE;
rtype = elf_m32c_reloc_type (type);
break;
- case EM_MS1:
- rtype = elf_ms1_reloc_type (type);
+ case EM_MT:
+ rtype = elf_mt_reloc_type (type);
break;
case EM_BLACKFIN:
case EM_XTENSA_OLD:
case EM_XTENSA: return "Tensilica Xtensa Processor";
case EM_M32C: return "Renesas M32c";
- case EM_MS1: return "Morpho Techologies MS1 processor";
+ case EM_MT: return "Morpho Techologies MT processor";
+ case EM_BLACKFIN: return "Analog Devices Blackfin";
default:
snprintf (buff, sizeof (buff), _("<unknown>: %x"), e_machine);
return buff;
return;
}
+/* Request a dump by section name. */
+
+static void
+request_dump_byname (const char *section, int type)
+{
+ struct dump_list_entry *new_request;
+
+ new_request = malloc (sizeof (struct dump_list_entry));
+ if (!new_request)
+ error (_("Out of memory allocating dump request table."));
+
+ new_request->name = strdup (section);
+ if (!new_request->name)
+ error (_("Out of memory allocating dump request table."));
+
+ new_request->type = type;
+
+ new_request->next = dump_sects_byname;
+ dump_sects_byname = new_request;
+}
+
static void
parse_args (int argc, char **argv)
{
do_dump++;
section = strtoul (optarg, & cp, 0);
if (! *cp && section >= 0)
- {
- request_dump (section, HEX_DUMP);
- break;
- }
- goto oops;
+ request_dump (section, HEX_DUMP);
+ else
+ request_dump_byname (optarg, HEX_DUMP);
+ break;
case 'w':
do_dump++;
if (optarg == 0)
do_wide++;
break;
default:
+#ifdef SUPPORT_DISASSEMBLY
oops:
+#endif
/* xgettext:c-format */
error (_("Invalid option '-%c'\n"), c);
/* Drop through. */
}
static const char *
+get_mips_symbol_other (unsigned int other)
+{
+ switch (other)
+ {
+ case STO_OPTIONAL: return "OPTIONAL";
+ case STO_MIPS16: return "MIPS16";
+ default: return NULL;
+ }
+}
+
+static const char *
+get_symbol_other (unsigned int other)
+{
+ const char * result = NULL;
+ static char buff [32];
+
+ if (other == 0)
+ return "";
+
+ switch (elf_header.e_machine)
+ {
+ case EM_MIPS:
+ result = get_mips_symbol_other (other);
+ default:
+ break;
+ }
+
+ if (result)
+ return result;
+
+ snprintf (buff, sizeof buff, _("<other>: %x"), other);
+ return buff;
+}
+
+static const char *
get_symbol_index_type (unsigned int type)
{
static char buff[32];
printf (" %6s", get_symbol_type (ELF_ST_TYPE (psym->st_info)));
printf (" %6s", get_symbol_binding (ELF_ST_BIND (psym->st_info)));
printf (" %3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym->st_other)));
+ /* Check to see if any other bits in the st_other field are set.
+ Note - displaying this information disrupts the layout of the
+ table being generated, but for the moment this case is very rare. */
+ if (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other))
+ printf (" [%s] ", get_symbol_other (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other)));
printf (" %3.3s ", get_symbol_index_type (psym->st_shndx));
if (VALID_DYNAMIC_NAME (psym->st_name))
print_symbol (25, GET_DYNAMIC_NAME (psym->st_name));
printf (" %-7s", get_symbol_type (ELF_ST_TYPE (psym->st_info)));
printf (" %-6s", get_symbol_binding (ELF_ST_BIND (psym->st_info)));
printf (" %-3s", get_symbol_visibility (ELF_ST_VISIBILITY (psym->st_other)));
+ /* Check to see if any other bits in the st_other field are set.
+ Note - displaying this information disrupts the layout of the
+ table being generated, but for the moment this case is very rare. */
+ if (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other))
+ printf (" [%s] ", get_symbol_other (psym->st_other ^ ELF_ST_VISIBILITY (psym->st_other)));
printf (" %4s ", get_symbol_index_type (psym->st_shndx));
print_symbol (25, psym->st_name < strtab_size
? strtab + psym->st_name : "<corrupt>");
return result;
}
+/* Set DUMP_SECTS for all sections where dumps were requested
+ based on section name. */
+
+static void
+initialise_dumps_byname (void)
+{
+ struct dump_list_entry *cur;
+
+ for (cur = dump_sects_byname; cur; cur = cur->next)
+ {
+ unsigned int i;
+ int any;
+
+ for (i = 0, any = 0; i < elf_header.e_shnum; i++)
+ if (streq (SECTION_NAME (section_headers + i), cur->name))
+ {
+ request_dump (i, cur->type);
+ any = 1;
+ }
+
+ if (!any)
+ warn (_("Section '%s' was not dumped because it does not exist!\n"),
+ cur->name);
+ }
+}
+
static void
process_section_contents (FILE *file)
{
if (! do_dump)
return;
+ initialise_dumps_byname ();
+
for (i = 0, section = section_headers;
i < elf_header.e_shnum && i < num_dump_sects;
i++, section++)