From 70ecb3842d3c4b2836c8b007743d996a2d6bef16 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 28 Jan 2010 15:25:20 +0000 Subject: [PATCH] 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. * gas/pe/aligncomm-c.d: Dump all sections. * ld-sh/refdbg-0-dso.d: Dump all sections. --- binutils/ChangeLog | 13 ++++- binutils/objdump.c | 101 +++++++++++++++++++++++++++++-------- gas/testsuite/ChangeLog | 5 ++ gas/testsuite/gas/pe/aligncomm-c.d | 4 +- gas/testsuite/gas/s390/s390.exp | 15 +++--- ld/testsuite/ChangeLog | 5 ++ ld/testsuite/ld-sh/refdbg-0-dso.d | 2 +- 7 files changed, 115 insertions(+), 30 deletions(-) diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 27890fb..fab15bb 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,10 +1,21 @@ +2010-01-28 Nick Clifton + + 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 * Makefile.am (bin2c): Add libintl dependance and library. * Makefile.in: Regenerate. 2010-01-21 Andreas Krebbel - + * readelf.c (get_machine_flags): Handle EF_S390_HIGH_GPRS. 2010-01-19 Ian Lance Taylor diff --git a/binutils/objdump.c b/binutils/objdump.c index 0334d70..b53d4eb 100644 --- a/binutils/objdump.c +++ b/binutils/objdump.c @@ -1,6 +1,6 @@ /* 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. @@ -117,13 +117,16 @@ static const char *prefix; /* --prefix */ 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; @@ -326,17 +329,78 @@ nonfatal (const char *msg) 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); + } +} + static void dump_section_header (bfd *abfd, asection *section, @@ -1782,7 +1846,7 @@ disassemble_section (bfd *abfd, asection *section, void *inf) /* 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; @@ -3193,12 +3257,7 @@ main (int argc, char **argv) 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; @@ -3409,6 +3468,8 @@ main (int argc, char **argv) display_file (argv[optind++], target); } + free_only_list (); + END_PROGRESS (program_name); return exit_status; diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 75e6054..66b030d 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-01-28 Nick Clifton + + PR 11225 + * gas/pe/aligncomm-c.d: Dump all sections. + 2010-01-27 Dave Korn * gas/pe/section-align-1.s: New test source file. diff --git a/gas/testsuite/gas/pe/aligncomm-c.d b/gas/testsuite/gas/pe/aligncomm-c.d index f9dc3a8..2336f44 100755 --- a/gas/testsuite/gas/pe/aligncomm-c.d +++ b/gas/testsuite/gas/pe/aligncomm-c.d @@ -1,8 +1,8 @@ -#objdump: -s -j .drectve +#objdump: -s #name: aligned common C # Test the aligned form of the .comm pseudo-op. .*: .* -# No .drectve section emitted. \ No newline at end of file +# No .drectve section emitted. diff --git a/gas/testsuite/gas/s390/s390.exp b/gas/testsuite/gas/s390/s390.exp index 4820013..fae071c 100644 --- a/gas/testsuite/gas/s390/s390.exp +++ b/gas/testsuite/gas/s390/s390.exp @@ -4,12 +4,15 @@ 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 { diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 224aa93..9e3e0f1 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-01-28 Nick Clifton + + PR 11225 + * ld-sh/refdbg-0-dso.d: Dump all sections. + 2010-01-26 H.J. Lu PR ld/11218 diff --git a/ld/testsuite/ld-sh/refdbg-0-dso.d b/ld/testsuite/ld-sh/refdbg-0-dso.d index c38fe3e..a8ec206 100644 --- a/ld/testsuite/ld-sh/refdbg-0-dso.d +++ b/ld/testsuite/ld-sh/refdbg-0-dso.d @@ -1,7 +1,7 @@ #source: refdbglib.s #as: -little #ld: -shared -EL -#objdump: -drj.text +#objdump: -dr #target: sh*-*-linux* sh*-*-netbsd* .*: +file format elf32-sh.* -- 2.7.4