]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - binutils/readelf.c
Change sources over to using GPLv3
[thirdparty/binutils-gdb.git] / binutils / readelf.c
index 2aa6ef0e2f3cb86538dcfcc3ba280ddd8bbc8911..9305d04ffac3ce06114df17cd1c6a29cf32319ce 100644 (file)
@@ -1,5 +1,5 @@
 /* readelf.c -- display contents of an ELF format file
-   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+   Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
    Originally developed by Eric Youngdale <eric@andante.jic.com>
@@ -9,7 +9,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
   ELF file than is provided by objdump.  In particular it can display DWARF
   debugging information which (at the moment) objdump cannot.  */
 \f
+#include "sysdep.h"
 #include <assert.h>
-#include <sys/types.h>
 #include <sys/stat.h>
-#include <stdio.h>
 #include <time.h>
 
 /* for PATH_MAX */
 #define BFD64
 #endif
 
+#include "bfd.h"
+#include "bucomm.h"
 #include "dwarf.h"
 
 #include "elf/common.h"
 #include "elf/external.h"
 #include "elf/internal.h"
 
+
+/* Included here, before RELOC_MACROS_GEN_FUNC is defined, so that
+   we can obtain the H8 reloc numbers.  We need these for the
+   get_reloc_size() function.  We include h8.h again after defining
+   RELOC_MACROS_GEN_FUNC so that we get the naming function as well.  */
+
+#include "elf/h8.h"
+#undef _ELF_H8_H
+
+/* Undo the effects of #including reloc-macros.h.  */
+
+#undef START_RELOC_NUMBERS
+#undef RELOC_NUMBER
+#undef FAKE_RELOC
+#undef EMPTY_RELOC
+#undef END_RELOC_NUMBERS
+#undef _RELOC_MACROS_H
+
 /* The following headers use the elf/reloc-macros.h file to
    automatically generate relocation recognition functions
    such as elf_mips_reloc_type()  */
 #include "elf/m68k.h"
 #include "elf/m68hc11.h"
 #include "elf/mcore.h"
+#include "elf/mep.h"
 #include "elf/mips.h"
 #include "elf/mmix.h"
 #include "elf/mn10200.h"
 
 #include "aout/ar.h"
 
-#include "bucomm.h"
 #include "getopt.h"
 #include "libiberty.h"
 
@@ -615,6 +634,7 @@ guess_is_rela (unsigned long e_machine)
     case EM_M32C:
     case EM_M32R:
     case EM_MCORE:
+    case EM_CYGNUS_MEP:
     case EM_MMIX:
     case EM_MN10200:
     case EM_CYGNUS_MN10200:
@@ -691,7 +711,7 @@ slurp_rela_relocs (FILE *file,
       if (relas == NULL)
        {
          free (erelas);
-         error (_("out of memory parsing relocs"));
+         error (_("out of memory parsing relocs\n"));
          return 0;
        }
 
@@ -719,7 +739,7 @@ slurp_rela_relocs (FILE *file,
       if (relas == NULL)
        {
          free (erelas);
-         error (_("out of memory parsing relocs"));
+         error (_("out of memory parsing relocs\n"));
          return 0;
        }
 
@@ -763,7 +783,7 @@ slurp_rel_relocs (FILE *file,
       if (rels == NULL)
        {
          free (erels);
-         error (_("out of memory parsing relocs"));
+         error (_("out of memory parsing relocs\n"));
          return 0;
        }
 
@@ -791,7 +811,7 @@ slurp_rel_relocs (FILE *file,
       if (rels == NULL)
        {
          free (erels);
-         error (_("out of memory parsing relocs"));
+         error (_("out of memory parsing relocs\n"));
          return 0;
        }
 
@@ -1167,6 +1187,10 @@ dump_relocations (FILE *file,
        case EM_BLACKFIN:
          rtype = elf_bfin_reloc_type (type);
          break;
+
+       case EM_CYGNUS_MEP:
+         rtype = elf_mep_reloc_type (type);
+         break;
        }
 
       if (rtype == NULL)
@@ -1762,8 +1786,9 @@ get_machine_name (unsigned e_machine)
     case EM_NIOS32:            return "Altera Nios";
     case EM_ALTERA_NIOS2:      return "Altera Nios II";
     case EM_XC16X:             return "Infineon Technologies xc16x";
+    case EM_CYGNUS_MEP:         return "Toshiba MeP Media Engine";
     default:
-      snprintf (buff, sizeof (buff), _("<unknown>: %x"), e_machine);
+      snprintf (buff, sizeof (buff), _("<unknown>: 0x%x"), e_machine);
       return buff;
     }
 }
@@ -2015,11 +2040,9 @@ get_machine_flags (unsigned e_flags, unsigned e_machine)
          if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_M68000)
            strcat (buf, ", m68000");
          else if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_CPU32)
-           {
-             strcat (buf, ", cpu32");
-             if (e_flags & EF_M68K_CPU32_FIDO_A)
-               strcat (buf, ", fido_a");
-           }
+           strcat (buf, ", cpu32");
+         else if ((e_flags & EF_M68K_ARCH_MASK) == EF_M68K_FIDO)
+           strcat (buf, ", fido_a");
          else
            {
              char const *isa = _("unknown");
@@ -2731,11 +2754,11 @@ static struct option options[] =
 };
 
 static void
-usage (void)
+usage (FILE *stream)
 {
-  fprintf (stdout, _("Usage: readelf <option(s)> elf-file(s)\n"));
-  fprintf (stdout, _(" Display information about the contents of ELF format files\n"));
-  fprintf (stdout, _(" Options are:\n\
+  fprintf (stream, _("Usage: readelf <option(s)> elf-file(s)\n"));
+  fprintf (stream, _(" Display information about the contents of ELF format files\n"));
+  fprintf (stream, _(" Options are:\n\
   -a --all               Equivalent to: -h -l -S -s -r -d -V -A -I\n\
   -h --file-header       Display the ELF file header\n\
   -l --program-headers   Display the program headers\n\
@@ -2759,19 +2782,21 @@ usage (void)
   --debug-dump[=line,=info,=abbrev,=pubnames,=aranges,=macro,=frames,=str,=loc,=Ranges]\n\
                          Display the contents of DWARF2 debug sections\n"));
 #ifdef SUPPORT_DISASSEMBLY
-  fprintf (stdout, _("\
+  fprintf (stream, _("\
   -i --instruction-dump=<number>\n\
                          Disassemble the contents of section <number>\n"));
 #endif
-  fprintf (stdout, _("\
+  fprintf (stream, _("\
   -I --histogram         Display histogram of bucket list lengths\n\
   -W --wide              Allow output width to exceed 80 characters\n\
   @<file>                Read options from <file>\n\
   -H --help              Display this information\n\
   -v --version           Display the version number of readelf\n"));
-  fprintf (stdout, _("Report bugs to %s\n"), REPORT_BUGS_TO);
+  
+  if (REPORT_BUGS_TO[0] && stream == stdout)
+    fprintf (stdout, _("Report bugs to %s\n"), REPORT_BUGS_TO);
 
-  exit (0);
+  exit (stream == stdout ? 0 : 1);
 }
 
 /* Record the fact that the user wants the contents of section number
@@ -2789,7 +2814,7 @@ request_dump (unsigned int section, int type)
       new_dump_sects = calloc (section + 1, 1);
 
       if (new_dump_sects == NULL)
-       error (_("Out of memory allocating dump request table."));
+       error (_("Out of memory allocating dump request table.\n"));
       else
        {
          /* Copy current flag settings.  */
@@ -2817,11 +2842,11 @@ request_dump_byname (const char *section, int type)
 
   new_request = malloc (sizeof (struct dump_list_entry));
   if (!new_request)
-    error (_("Out of memory allocating dump request table."));
+    error (_("Out of memory allocating dump request table.\n"));
 
   new_request->name = strdup (section);
   if (!new_request->name)
-    error (_("Out of memory allocating dump request table."));
+    error (_("Out of memory allocating dump request table.\n"));
 
   new_request->type = type;
 
@@ -2835,7 +2860,7 @@ parse_args (int argc, char **argv)
   int c;
 
   if (argc < 2)
-    usage ();
+    usage (stderr);
 
   while ((c = getopt_long
          (argc, argv, "ersuahnldSDAINtgw::x:i:vVWH", options, NULL)) != EOF)
@@ -2849,7 +2874,7 @@ parse_args (int argc, char **argv)
          /* Long options.  */
          break;
        case 'H':
-         usage ();
+         usage (stdout);
          break;
 
        case 'a':
@@ -3090,7 +3115,7 @@ parse_args (int argc, char **argv)
          error (_("Invalid option '-%c'\n"), c);
          /* Drop through.  */
        case '?':
-         usage ();
+         usage (stderr);
        }
     }
 
@@ -3098,11 +3123,11 @@ parse_args (int argc, char **argv)
       && !do_segments && !do_header && !do_dump && !do_version
       && !do_histogram && !do_debugging && !do_arch && !do_notes
       && !do_section_groups)
-    usage ();
+    usage (stderr);
   else if (argc < 3)
     {
       warn (_("Nothing to do.\n"));
-      usage ();
+      usage (stderr);
     }
 }
 
@@ -3487,18 +3512,21 @@ process_program_headers (FILE *file)
              sec = find_section (".dynamic");
              if (sec == NULL || sec->sh_size == 0)
                {
-                 error (_("no .dynamic section in the dynamic segment"));
+                 error (_("no .dynamic section in the dynamic segment\n"));
                  break;
                }
 
+             if (sec->sh_type == SHT_NOBITS)
+               break;
+
              dynamic_addr = sec->sh_offset;
              dynamic_size = sec->sh_size;
 
              if (dynamic_addr < segment->p_offset
                  || dynamic_addr > segment->p_offset + segment->p_filesz)
-               warn (_("the .dynamic section is not contained within the dynamic segment"));
+               warn (_("the .dynamic section is not contained within the dynamic segment\n"));
              else if (dynamic_addr > segment->p_offset)
-               warn (_("the .dynamic section is not the first section in the dynamic segment."));
+               warn (_("the .dynamic section is not the first section in the dynamic segment.\n"));
            }
          else
            {
@@ -3519,10 +3547,11 @@ process_program_headers (FILE *file)
              int ret = snprintf (fmt, sizeof (fmt), "%%%ds", PATH_MAX);
 
              if (ret >= (int) sizeof (fmt) || ret < 0)
-               error (_("Internal error: failed to create format string to display program interpreter"));
+               error (_("Internal error: failed to create format string to display program interpreter\n"));
 
              program_interpreter[0] = 0;
-             fscanf (file, fmt, program_interpreter);
+             if (fscanf (file, fmt, program_interpreter) <= 0)
+               error (_("Unable to read program interpreter name\n"));
 
              if (do_segments)
                printf (_("\n      [Requesting program interpreter: %s]"),
@@ -5839,7 +5868,7 @@ process_dynamic_section (FILE *file)
          else
            {
              if (fseek (file, 0, SEEK_END))
-               error (_("Unable to seek to end of file!"));
+               error (_("Unable to seek to end of file!\n"));
 
              section.sh_size = ftell (file) - section.sh_offset;
            }
@@ -6845,6 +6874,8 @@ get_symbol_type (unsigned int type)
     case STT_FILE:     return "FILE";
     case STT_COMMON:   return "COMMON";
     case STT_TLS:      return "TLS";
+    case STT_RELC:      return "RELC";
+    case STT_SRELC:     return "SRELC";
     default:
       if (type >= STT_LOPROC && type <= STT_HIPROC)
        {
@@ -7035,7 +7066,7 @@ process_symbol_table (FILE *file)
                                     sizeof nb + sizeof nc)),
                 SEEK_SET))
        {
-         error (_("Unable to seek to start of dynamic information"));
+         error (_("Unable to seek to start of dynamic information\n"));
          return 0;
        }
 
@@ -7261,7 +7292,7 @@ process_symbol_table (FILE *file)
                              check_def = 0;
                            }
                          else if (! is_nobits)
-                           error (_("bad dynamic symbol"));
+                           error (_("bad dynamic symbol\n"));
                          else
                            check_def = 1;
                        }
@@ -7344,7 +7375,7 @@ process_symbol_table (FILE *file)
       lengths = calloc (nbuckets, sizeof (*lengths));
       if (lengths == NULL)
        {
-         error (_("Out of memory"));
+         error (_("Out of memory\n"));
          return 0;
        }
       for (hn = 0; hn < nbuckets; ++hn)
@@ -7360,7 +7391,7 @@ process_symbol_table (FILE *file)
       counts = calloc (maxlength + 1, sizeof (*counts));
       if (counts == NULL)
        {
-         error (_("Out of memory"));
+         error (_("Out of memory\n"));
          return 0;
        }
 
@@ -7409,7 +7440,7 @@ process_symbol_table (FILE *file)
                                     sizeof nb)),
                 SEEK_SET))
        {
-         error (_("Unable to seek to start of dynamic information"));
+         error (_("Unable to seek to start of dynamic information\n"));
          return 0;
        }
 
@@ -7433,7 +7464,7 @@ process_symbol_table (FILE *file)
                  + offset_from_vma (file, buckets_vma, 4)),
                 SEEK_SET))
        {
-         error (_("Unable to seek to start of dynamic information"));
+         error (_("Unable to seek to start of dynamic information\n"));
          return 0;
        }
 
@@ -7463,7 +7494,7 @@ process_symbol_table (FILE *file)
                                           + 4 * (ngnubuckets + maxchain), 4)),
                 SEEK_SET))
        {
-         error (_("Unable to seek to start of dynamic information"));
+         error (_("Unable to seek to start of dynamic information\n"));
          return 0;
        }
 
@@ -7487,7 +7518,7 @@ process_symbol_table (FILE *file)
                  + offset_from_vma (file, buckets_vma + 4 * ngnubuckets, 4)),
                 SEEK_SET))
        {
-         error (_("Unable to seek to start of dynamic information"));
+         error (_("Unable to seek to start of dynamic information\n"));
          return 0;
        }
 
@@ -7499,7 +7530,7 @@ process_symbol_table (FILE *file)
       lengths = calloc (ngnubuckets, sizeof (*lengths));
       if (lengths == NULL)
        {
-         error (_("Out of memory"));
+         error (_("Out of memory\n"));
          return 0;
        }
 
@@ -7524,7 +7555,7 @@ process_symbol_table (FILE *file)
       counts = calloc (maxlength + 1, sizeof (*counts));
       if (counts == NULL)
        {
-         error (_("Out of memory"));
+         error (_("Out of memory\n"));
          return 0;
        }
 
@@ -7636,6 +7667,7 @@ disassemble_section (Elf_Internal_Shdr *section, FILE *file)
 static int
 dump_section (Elf_Internal_Shdr *section, FILE *file)
 {
+  Elf_Internal_Shdr *relsec;
   bfd_size_type bytes;
   bfd_vma addr;
   unsigned char *data;
@@ -7659,6 +7691,26 @@ dump_section (Elf_Internal_Shdr *section, FILE *file)
   if (!start)
     return 0;
 
+  /* If the section being dumped has relocations against it the user might
+     be expecting these relocations to have been applied.  Check for this
+     case and issue a warning message in order to avoid confusion.
+     FIXME: Maybe we ought to have an option that dumps a section with
+     relocs applied ?  */
+  for (relsec = section_headers;
+       relsec < section_headers + elf_header.e_shnum;
+       ++relsec)
+    {
+      if ((relsec->sh_type != SHT_RELA && relsec->sh_type != SHT_REL)
+         || SECTION_HEADER_INDEX (relsec->sh_info) >= elf_header.e_shnum
+         || SECTION_HEADER (relsec->sh_info) != section
+         || relsec->sh_size == 0
+         || SECTION_HEADER_INDEX (relsec->sh_link) >= elf_header.e_shnum)
+       continue;
+
+      printf (_(" NOTE: This section has relocations against it, but these have NOT been applied to this dump.\n"));
+      break;
+    }
+  
   data = start;
 
   while (bytes)
@@ -7700,9 +7752,47 @@ dump_section (Elf_Internal_Shdr *section, FILE *file)
 
   free (start);
 
+  putchar ('\n');
   return 1;
 }
 
+/* Return the number of bytes affected by a given reloc.
+   This information is architecture and reloc dependent.
+   Returns 4 by default, although this is not always correct.
+   It should return 0 if a decision cannot be made.
+   FIXME: This is not the correct way to solve this problem.
+   The proper way is to have target specific reloc sizing functions
+   created by the reloc-macros.h header, in the same way that it
+   already creates the reloc naming functions.  */
+
+static unsigned int
+get_reloc_size (Elf_Internal_Rela * reloc)
+{
+  switch (elf_header.e_machine)
+    {
+    case EM_H8S:
+    case EM_H8_300:
+    case EM_H8_300H:
+    case EM_H8_500:
+      switch (ELF32_R_TYPE (reloc->r_info))
+       {
+         /* PR gas/3800 - without this information we do not correctly
+            decode the debug information generated by the h8300 assembler.  */
+       case R_H8_DIR16:
+         return 2;
+       default:
+         return 4;
+       }
+    default:
+      /* FIXME: We need to extend this switch statement to cope with other
+        architecture's relocs.  (When those relocs are used against debug
+        sections, and when their size is not 4).  But see the multiple
+        inclusions of <elf/h8.h> for an example of the hoops that we need
+        to jump through in order to obtain the reloc numbers.  */
+      return 4;
+    }
+}
+
 /* Apply addends of RELA relocations.  */
 
 static int
@@ -7712,14 +7802,13 @@ debug_apply_rela_addends (void *file,
 {
   Elf_Internal_Shdr *relsec;
   unsigned char *end = start + section->sh_size;
-  /* FIXME: The relocation field size is relocation type dependent.  */
-  unsigned int reloc_size = 4;
 
   if (!is_relocatable)
     return 1;
 
-  if (section->sh_size < reloc_size)
-    return 1;
+  /* SH uses RELA but uses in place value instead of the addend field.  */
+  if (elf_header.e_machine == EM_SH)
+    return 0;
 
   for (relsec = section_headers;
        relsec < section_headers + elf_header.e_shnum;
@@ -7748,6 +7837,16 @@ debug_apply_rela_addends (void *file,
       for (rp = rela; rp < rela + nrelas; ++rp)
        {
          unsigned char *loc;
+         unsigned int reloc_size;
+
+         reloc_size = get_reloc_size (rp);
+         if (reloc_size == 0)
+           {
+             warn (_("skipping relocation of unknown size against offset 0x%lx in section %s\n"),
+                   (unsigned long) rp->r_offset,
+                   SECTION_NAME (section));
+             continue;
+           }
 
          loc = start + rp->r_offset;
          if ((loc + reloc_size) > end)
@@ -8198,8 +8297,166 @@ display_arm_attribute (unsigned char *p)
   return p;
 }
 
+
+static unsigned char *
+display_gnu_attribute (unsigned char *p,
+                      unsigned char *(*display_proc_gnu_attribute)
+                           (unsigned char *, int))
+{
+  int tag;
+  unsigned int len;
+  int val;
+  int type;
+
+  tag = read_uleb128 (p, &len);
+  p += len;
+
+  /* Tag_compatibility is the only generic GNU attribute defined at
+     present.  */
+  if (tag == 32)
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("flag = %d, vendor = %s\n", val, p);
+      p += strlen((char *)p) + 1;
+      return p;
+    }
+
+  if ((tag & 2) == 0 && display_proc_gnu_attribute)
+    return display_proc_gnu_attribute (p, tag);
+
+  if (tag & 1)
+    type = 1; /* String.  */
+  else
+    type = 2; /* uleb128.  */
+  printf ("  Tag_unknown_%d: ", tag);
+
+  if (type == 1)
+    {
+      printf ("\"%s\"\n", p);
+      p += strlen ((char *)p) + 1;
+    }
+  else
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("%d (0x%x)\n", val, val);
+    }
+
+  return p;
+}
+
+static unsigned char *
+display_power_gnu_attribute (unsigned char *p, int tag)
+{
+  int type;
+  unsigned int len;
+  int val;
+
+  if (tag == Tag_GNU_Power_ABI_FP)
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("  Tag_GNU_Power_ABI_FP: ");
+      switch (val)
+       {
+       case 0:
+         printf ("Hard or soft float\n");
+         break;
+       case 1:
+         printf ("Hard float\n");
+         break;
+       case 2:
+         printf ("Soft float\n");
+         break;
+       default:
+         printf ("??? (%d)\n", val);
+         break;
+       }
+      return p;
+   }
+
+  if (tag & 1)
+    type = 1; /* String.  */
+  else
+    type = 2; /* uleb128.  */
+  printf ("  Tag_unknown_%d: ", tag);
+
+  if (type == 1)
+    {
+      printf ("\"%s\"\n", p);
+      p += strlen ((char *)p) + 1;
+    }
+  else
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("%d (0x%x)\n", val, val);
+    }
+
+  return p;
+}
+
+static unsigned char *
+display_mips_gnu_attribute (unsigned char *p, int tag)
+{
+  int type;
+  unsigned int len;
+  int val;
+
+  if (tag == Tag_GNU_MIPS_ABI_FP)
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("  Tag_GNU_MIPS_ABI_FP: ");
+      switch (val)
+       {
+       case 0:
+         printf ("Hard or soft float\n");
+         break;
+       case 1:
+         printf ("Hard float (-mdouble-float)\n");
+         break;
+       case 2:
+         printf ("Hard float (-msingle-float)\n");
+         break;
+       case 3:
+         printf ("Soft float\n");
+         break;
+       default:
+         printf ("??? (%d)\n", val);
+         break;
+       }
+      return p;
+   }
+
+  if (tag & 1)
+    type = 1; /* String.  */
+  else
+    type = 2; /* uleb128.  */
+  printf ("  Tag_unknown_%d: ", tag);
+
+  if (type == 1)
+    {
+      printf ("\"%s\"\n", p);
+      p += strlen ((char *)p) + 1;
+    }
+  else
+    {
+      val = read_uleb128 (p, &len);
+      p += len;
+      printf ("%d (0x%x)\n", val, val);
+    }
+
+  return p;
+}
+
 static int
-process_arm_specific (FILE *file)
+process_attributes (FILE *file, const char *public_name,
+                   unsigned int proc_type,
+                   unsigned char *(*display_pub_attribute) (unsigned char *),
+                   unsigned char *(*display_proc_gnu_attribute)
+                        (unsigned char *, int))
 {
   Elf_Internal_Shdr *sect;
   unsigned char *contents;
@@ -8214,7 +8471,7 @@ process_arm_specific (FILE *file)
        i < elf_header.e_shnum;
        i++, sect++)
     {
-      if (sect->sh_type != SHT_ARM_ATTRIBUTES)
+      if (sect->sh_type != proc_type && sect->sh_type != SHT_GNU_ATTRIBUTES)
        continue;
 
       contents = get_data (NULL, file, sect->sh_offset, 1, sect->sh_size,
@@ -8231,6 +8488,7 @@ process_arm_specific (FILE *file)
            {
              int namelen;
              bfd_boolean public_section;
+             bfd_boolean gnu_section;
 
              section_len = byte_get (p, 4);
              p += 4;
@@ -8242,10 +8500,14 @@ process_arm_specific (FILE *file)
                }
              len -= section_len;
              printf ("Attribute Section: %s\n", p);
-             if (strcmp ((char *)p, "aeabi") == 0)
+             if (public_name && strcmp ((char *)p, public_name) == 0)
                public_section = TRUE;
              else
                public_section = FALSE;
+             if (strcmp ((char *)p, "gnu") == 0)
+               gnu_section = TRUE;
+             else
+               gnu_section = FALSE;
              namelen = strlen ((char *)p) + 1;
              p += namelen;
              section_len -= namelen + 4;
@@ -8294,7 +8556,13 @@ process_arm_specific (FILE *file)
                  if (public_section)
                    {
                      while (p < end)
-                       p = display_arm_attribute(p);
+                       p = display_pub_attribute (p);
+                   }
+                 else if (gnu_section)
+                   {
+                     while (p < end)
+                       p = display_gnu_attribute (p,
+                                                  display_proc_gnu_attribute);
                    }
                  else
                    {
@@ -8315,6 +8583,20 @@ process_arm_specific (FILE *file)
   return 1;
 }
 
+static int
+process_arm_specific (FILE *file)
+{
+  return process_attributes (file, "aeabi", SHT_ARM_ATTRIBUTES,
+                            display_arm_attribute, NULL);
+}
+
+static int
+process_power_specific (FILE *file)
+{
+  return process_attributes (file, NULL, SHT_GNU_ATTRIBUTES, NULL,
+                            display_power_gnu_attribute);
+}
+
 static int
 process_mips_specific (FILE *file)
 {
@@ -8325,6 +8607,9 @@ process_mips_specific (FILE *file)
   size_t options_offset = 0;
   size_t conflicts_offset = 0;
 
+  process_attributes (file, NULL, SHT_GNU_ATTRIBUTES, NULL,
+                     display_mips_gnu_attribute);
+
   /* We have a lot of special sections.  Thanks SGI!  */
   if (dynamic_section == NULL)
     /* No information available.  */
@@ -8458,7 +8743,7 @@ process_mips_specific (FILE *file)
          iopt = cmalloc ((sect->sh_size / sizeof (eopt)), sizeof (*iopt));
          if (iopt == NULL)
            {
-             error (_("Out of memory"));
+             error (_("Out of memory\n"));
              return 0;
            }
 
@@ -8643,14 +8928,14 @@ process_mips_specific (FILE *file)
 
       if (dynamic_symbols == NULL)
        {
-         error (_("conflict list found without a dynamic symbol table"));
+         error (_("conflict list found without a dynamic symbol table\n"));
          return 0;
        }
 
       iconf = cmalloc (conflictsno, sizeof (*iconf));
       if (iconf == NULL)
        {
-         error (_("Out of memory"));
+         error (_("Out of memory\n"));
          return 0;
        }
 
@@ -9090,6 +9375,9 @@ process_arch_specific (FILE *file)
     case EM_MIPS_RS3_LE:
       return process_mips_specific (file);
       break;
+    case EM_PPC:
+      return process_power_specific (file);
+      break;
     default:
       break;
     }
@@ -9607,7 +9895,7 @@ main (int argc, char **argv)
       /* Make a copy of the dump_sects array.  */
       cmdline_dump_sects = malloc (num_dump_sects);
       if (cmdline_dump_sects == NULL)
-       error (_("Out of memory allocating dump request table."));
+       error (_("Out of memory allocating dump request table.\n"));
       else
        {
          memcpy (cmdline_dump_sects, dump_sects, num_dump_sects);