+2010-01-28 Nick Clifton <nickc@redhat.com>
+
+ PR 11225
+ * objdump.c (only): Replace with linked list.
+ (only_size, only_used): Replace with only_list.
+ (process_section_p): Set seen field on matches sections.
+ (add_only): New function.
+ (free_only_list): New function.
+ (disassemble_section): Check only_list.
+ (main): Use add_only and free_only_list.
+
2010-01-26 Tristan Gingold <gingold@adacore.com>
* Makefile.am (bin2c): Add libintl dependance and library.
* Makefile.in: Regenerate.
2010-01-21 Andreas Krebbel <Andreas.Krebbel@de.ibm.com>
-
+
* readelf.c (get_machine_flags): Handle EF_S390_HIGH_GPRS.
2010-01-19 Ian Lance Taylor <iant@google.com>
/* objdump.c -- dump information about an object file.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Binutils.
static int prefix_strip; /* --prefix-strip */
static size_t prefix_length;
-/* Pointer to an array of section names provided by
- one or more "-j secname" command line options. */
-static char **only;
-/* The total number of slots in the only[] array. */
-static size_t only_size = 0;
-/* The number of occupied slots in the only[] array. */
-static size_t only_used = 0;
+/* A structure to record the sections mentioned in -j switches. */
+struct only
+{
+ const char * name; /* The name of the section. */
+ bfd_boolean seen; /* A flag to indicate that the section has been found in one or more input files. */
+ struct only * next; /* Pointer to the next structure in the list. */
+};
+/* Pointer to an array of 'only' structures.
+ This pointer is NULL if the -j switch has not been used. */
+static struct only * only_list = NULL;
/* Variables for handling include file path table. */
static const char **include_paths;
static bfd_boolean
process_section_p (asection * section)
{
- size_t i;
+ struct only * only;
- if (only == NULL)
+ if (only_list == NULL)
return TRUE;
- for (i = 0; i < only_used; i++)
- if (strcmp (only [i], section->name) == 0)
- return TRUE;
+ for (only = only_list; only; only = only->next)
+ if (strcmp (only->name, section->name) == 0)
+ {
+ only->seen = TRUE;
+ return TRUE;
+ }
return FALSE;
}
+
+/* Add an entry to the 'only' list. */
+
+static void
+add_only (char * name)
+{
+ struct only * only;
+
+ /* First check to make sure that we do not
+ already have an entry for this name. */
+ for (only = only_list; only; only = only->next)
+ if (strcmp (only->name, name) == 0)
+ return;
+
+ only = xmalloc (sizeof * only);
+ only->name = name;
+ only->seen = FALSE;
+ only->next = only_list;
+ only_list = only;
+}
+
+/* Release the memory used by the 'only' list.
+ PR 11225: Issue a warning message for unseen sections.
+ Only do this if none of the sections were seen. This is mainly to support
+ tools like the GAS testsuite where an object file is dumped with a list of
+ generic section names known to be present in a range of different file
+ formats. */
+
+static void
+free_only_list (void)
+{
+ bfd_boolean at_least_one_seen = FALSE;
+ struct only * only;
+ struct only * next;
+
+ if (only_list == NULL)
+ return;
+
+ for (only = only_list; only; only = only->next)
+ if (only->seen)
+ {
+ at_least_one_seen = TRUE;
+ break;
+ }
+
+ for (only = only_list; only; only = next)
+ {
+ if (! at_least_one_seen)
+ {
+ non_fatal (_("Section '%s' mentioned in a -j option, but not found in any input file"),
+ only->name);
+ exit_status = 1;
+ }
+ next = only->next;
+ free (only);
+ }
+}
+
\f
static void
dump_section_header (bfd *abfd, asection *section,
/* Sections that do not contain machine
code are not normally disassembled. */
if (! disassemble_all
- && only == NULL
+ && only_list == NULL
&& ((section->flags & (SEC_CODE | SEC_HAS_CONTENTS))
!= (SEC_CODE | SEC_HAS_CONTENTS)))
return;
disassembler_options = optarg;
break;
case 'j':
- if (only_used == only_size)
- {
- only_size += 8;
- only = (char **) xrealloc (only, only_size * sizeof (char *));
- }
- only [only_used++] = optarg;
+ add_only (optarg);
break;
case 'F':
display_file_offsets = TRUE;
display_file (argv[optind++], target);
}
+ free_only_list ();
+
END_PROGRESS (program_name);
return exit_status;
if [expr [istarget "s390-*-*"] || [istarget "s390x-*-*"]] then {
- run_dump_test "esa-g5" "{as -m31}"
- run_dump_test "esa-z900" "{as -m31} {as -march=z900}"
- run_dump_test "esa-z990" "{as -m31} {as -march=z990}"
- run_dump_test "esa-z9-109" "{as -m31} {as -march=z9-109}"
- run_dump_test "esa-reloc" "{as -m31}"
- run_dump_test "esa-operands" "{as -m31}"
+ # s390x-ibm-tpf target does not support a 32-bit target.
+ if { ! [istarget "s390x-*-tpf*"] } then {
+ run_dump_test "esa-g5" "{as -m31}"
+ run_dump_test "esa-z900" "{as -m31} {as -march=z900}"
+ run_dump_test "esa-z990" "{as -m31} {as -march=z990}"
+ run_dump_test "esa-z9-109" "{as -m31} {as -march=z9-109}"
+ run_dump_test "esa-reloc" "{as -m31}"
+ run_dump_test "esa-operands" "{as -m31}"
+ }
# # PIC is only supported on ELF targets.
# if { ([istarget "*-*-elf*"] || [istarget "*-*-linux*"] ) } then {