]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Nominal ARM support.
authorRoland McGrath <roland@redhat.com>
Wed, 15 Apr 2009 01:44:45 +0000 (18:44 -0700)
committerRoland McGrath <roland@redhat.com>
Wed, 15 Apr 2009 09:10:30 +0000 (02:10 -0700)
17 files changed:
NEWS
backends/ChangeLog
backends/Makefile.am
backends/arm_attrs.c [new file with mode: 0644]
backends/arm_auxv.c [new file with mode: 0644]
backends/arm_corenote.c [new file with mode: 0644]
backends/arm_init.c
backends/arm_regs.c [new file with mode: 0644]
backends/arm_retval.c [new file with mode: 0644]
backends/arm_symbol.c
backends/ia64_symbol.c
libcpu/ChangeLog
libcpu/Makefile.am
libelf/ChangeLog
libelf/elf.h
src/ChangeLog
src/readelf.c

diff --git a/NEWS b/NEWS
index 98c26ea6269a1862a59c51547a9bc4fa67bb456f..5effc77a9938e34420aabe1f4a3d3b9436ab3b9a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 Version 0.141:
 
-libebl: sparc backend fixes
+libebl: sparc backend fixes;
+       some more arm backend support
 libdwfl: fix dwfl_module_build_id for prelinked DSO case;
         fixes in core file support;
         dwfl_module_getsym interface improved for non-address symbols
index 4b48a8fa481c509eb464326255168e4444c9118d..d5afa1b6ff7df07699784af4b496471c7dff5b25 100644 (file)
@@ -1,3 +1,22 @@
+2009-04-14  Roland McGrath  <roland@redhat.com>
+
+       * arm_retval.c: New file.
+       * arm_attrs.c: New file.
+       * Makefile.am (arm_SRCS): Add them.
+       * arm_symbol.c (arm_segment_type_name): New function.
+       (arm_section_type_name): New function.
+       (arm_machine_flag_check): New function.
+       * arm_init.c (arm_init): Initialize those hooks.
+
+       * arm_regs.c: New file.
+       * arm_corenote.c: New file.
+       * arm_auxv.c: New file.
+       * Makefile.am (arm_SRCS): Add them.
+       * arm_init.c (arm_init): Initialize core_note, register_info,
+       and auxv_info hooks.
+
+       * ia64_symbol.c (ia64_section_type_name): Remove "SHT_" prefixes.
+
 2009-04-01  Roland McGrath  <roland@redhat.com>
 
        * sparc_reloc.def: Update table.
index 5b552946c805f442536c2b02fe9717712e02cc83..6d7eb667c8aee4fc8d9ac6fcf056942f0fc025d5 100644 (file)
@@ -1,6 +1,6 @@
 ## Process this file with automake to create Makefile.in
 ##
-## Copyright (C) 2000-2006, 2007, 2008 Red Hat, Inc.
+## Copyright (C) 2000-2009 Red Hat, Inc.
 ## This file is part of Red Hat elfutils.
 ##
 ## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -85,7 +85,8 @@ alpha_SRCS = alpha_init.c alpha_symbol.c alpha_retval.c alpha_regs.c \
 libebl_alpha_pic_a_SOURCES = $(alpha_SRCS)
 am_libebl_alpha_pic_a_OBJECTS = $(alpha_SRCS:.c=.os)
 
-arm_SRCS = arm_init.c arm_symbol.c
+arm_SRCS = arm_init.c arm_symbol.c arm_regs.c arm_corenote.c \
+          arm_auxv.c arm_attrs.c arm_retval.c
 libebl_arm_pic_a_SOURCES = $(arm_SRCS)
 am_libebl_arm_pic_a_OBJECTS = $(arm_SRCS:.c=.os)
 
diff --git a/backends/arm_attrs.c b/backends/arm_attrs.c
new file mode 100644 (file)
index 0000000..84f4d45
--- /dev/null
@@ -0,0 +1,242 @@
+/* Object attribute tags for ARM.
+   Copyright (C) 2009 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils 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; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include <dwarf.h>
+
+#define BACKEND arm_
+#include "libebl_CPU.h"
+
+#define KNOWN_VALUES(...) do                           \
+  {                                                    \
+    static const char *table[] = { __VA_ARGS__ };      \
+    if (value < sizeof table / sizeof table[0])                \
+      *value_name = table[value];                      \
+  } while (0)
+
+bool
+arm_check_object_attribute (ebl, vendor, tag, value, tag_name, value_name)
+     Ebl *ebl __attribute__ ((unused));
+     const char *vendor;
+     int tag;
+     uint64_t value __attribute__ ((unused));
+     const char **tag_name;
+     const char **value_name;
+{
+  if (!strcmp (vendor, "aeabi"))
+    switch (tag)
+      {
+      case 4:
+       *tag_name = "CPU_raw_name";
+       return true;
+      case 5:
+       *tag_name = "CPU_name";
+       return true;
+      case 6:
+       *tag_name = "CPU_arch";
+       KNOWN_VALUES ("Pre-v4",
+                     "v4",
+                     "v4T",
+                     "v5T",
+                     "v5TE",
+                     "v5TEJ",
+                     "v6",
+                     "v6KZ",
+                     "v6T2",
+                     "v6K",
+                     "v7",
+                     "v6-M",
+                     "v6S-M");
+       return true;
+      case 7:
+       *tag_name = "CPU_arch_profile";
+       switch (value)
+         {
+         case 'A':
+           *value_name = "Application";
+           break;
+         case 'R':
+           *value_name = "Realtime";
+           break;
+         case 'M':
+           *value_name = "Microcontroller";
+           break;
+         }
+       return true;
+      case 8:
+       *tag_name = "ARM_ISA_use";
+       KNOWN_VALUES ("No", "Yes");
+       return true;
+      case 9:
+       *tag_name = "THUMB_ISA_use";
+       KNOWN_VALUES ("No", "Thumb-1", "Thumb-2");
+       return true;
+      case 10:
+       *tag_name = "VFP_arch";
+       KNOWN_VALUES ("No", "VFPv1", "VFPv2", "VFPv3", "VFPv3-D16");
+       return true;
+      case 11:
+       *tag_name = "WMMX_arch";
+       KNOWN_VALUES ("No", "WMMXv1", "WMMXv2");
+       return true;
+      case 12:
+       *tag_name = "Advanced_SIMD_arch";
+       KNOWN_VALUES ("No", "NEONv1");
+       return true;
+      case 13:
+       *tag_name = "PCS_config";
+       KNOWN_VALUES ("None",
+                     "Bare platform",
+                     "Linux application",
+                     "Linux DSO",
+                     "PalmOS 2004",
+                     "PalmOS (reserved)",
+                     "SymbianOS 2004",
+                     "SymbianOS (reserved)");
+       return true;
+      case 14:
+       *tag_name = "ABI_PCS_R9_use";
+       KNOWN_VALUES ("V6", "SB", "TLS", "Unused");
+       return true;
+      case 15:
+       *tag_name = "ABI_PCS_RW_data";
+       KNOWN_VALUES ("Absolute", "PC-relative", "SB-relative", "None");
+       return true;
+      case 16:
+       *tag_name = "ABI_PCS_RO_data";
+       KNOWN_VALUES ("Absolute", "PC-relative", "None");
+       return true;
+      case 17:
+       *tag_name = "ABI_PCS_GOT_use";
+       KNOWN_VALUES ("None", "direct", "GOT-indirect");
+       return true;
+      case 18:
+       *tag_name = "ABI_PCS_wchar_t";
+       return true;
+      case 19:
+       *tag_name = "ABI_FP_rounding";
+       KNOWN_VALUES ("Unused", "Needed");
+       return true;
+      case 20:
+       *tag_name = "ABI_FP_denormal";
+       KNOWN_VALUES ("Unused", "Needed", "Sign only");
+       return true;
+      case 21:
+       *tag_name = "ABI_FP_exceptions";
+       KNOWN_VALUES ("Unused", "Needed");
+       return true;
+      case 22:
+       *tag_name = "ABI_FP_user_exceptions";
+       KNOWN_VALUES ("Unused", "Needed");
+       return true;
+      case 23:
+       *tag_name = "ABI_FP_number_model";
+       KNOWN_VALUES ("Unused", "Finite", "RTABI", "IEEE 754");
+       return true;
+      case 24:
+       *tag_name = "ABI_align8_needed";
+       KNOWN_VALUES ("No", "Yes", "4-byte");
+       return true;
+      case 25:
+       *tag_name = "ABI_align8_preserved";
+       KNOWN_VALUES ("No", "Yes, except leaf SP", "Yes");
+       return true;
+      case 26:
+       *tag_name = "ABI_enum_size";
+       KNOWN_VALUES ("Unused", "small", "int", "forced to int");
+       return true;
+      case 27:
+       *tag_name = "ABI_HardFP_use";
+       KNOWN_VALUES ("as VFP_arch", "SP only", "DP only", "SP and DP");
+       return true;
+      case 28:
+       *tag_name = "ABI_VFP_args";
+       KNOWN_VALUES ("AAPCS", "VFP registers", "custom");
+       return true;
+      case 29:
+       *tag_name = "ABI_WMMX_args";
+       KNOWN_VALUES ("AAPCS", "WMMX registers", "custom");
+       return true;
+      case 30:
+       *tag_name = "ABI_optimization_goals";
+       KNOWN_VALUES ("None",
+                     "Prefer Speed",
+                     "Aggressive Speed",
+                     "Prefer Size",
+                     "Aggressive Size",
+                     "Prefer Debug",
+                     "Aggressive Debug");
+       return true;
+      case 31:
+       *tag_name = "ABI_FP_optimization_goals";
+       KNOWN_VALUES ("None",
+                     "Prefer Speed",
+                     "Aggressive Speed",
+                     "Prefer Size",
+                     "Aggressive Size",
+                     "Prefer Accuracy",
+                     "Aggressive Accuracy");
+       return true;
+      case 34:
+       *tag_name = "CPU_unaligned_access";
+       KNOWN_VALUES ("None", "v6");
+       return true;
+      case 36:
+       *tag_name = "VFP_HP_extension";
+       KNOWN_VALUES ("Not Allowed", "Allowed");
+       return true;
+      case 38:
+       *tag_name = "ABI_FP_16bit_format";
+       KNOWN_VALUES ("None", "IEEE 754", "Alternative Format");
+       return true;
+      case 64:
+       *tag_name = "nodefaults";
+       return true;
+      case 65:
+       *tag_name = "also_compatible_with";
+       return true;
+      case 66:
+       *tag_name = "T2EE_use";
+       KNOWN_VALUES ("Not Allowed", "Allowed");
+       return true;
+      case 67:
+       *tag_name = "conformance";
+       return true;
+      case 68:
+       *tag_name = "Virtualization_use";
+       KNOWN_VALUES ("Not Allowed", "Allowed");
+       return true;
+      case 70:
+       *tag_name = "MPextension_use";
+       KNOWN_VALUES ("Not Allowed", "Allowed");
+       return true;
+      }
+
+  return false;
+}
diff --git a/backends/arm_auxv.c b/backends/arm_auxv.c
new file mode 100644 (file)
index 0000000..728f940
--- /dev/null
@@ -0,0 +1,46 @@
+/* ARM-specific auxv handling.
+   Copyright (C) 2009 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils 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; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#define BACKEND arm_
+#include "libebl_CPU.h"
+
+int
+EBLHOOK(auxv_info) (GElf_Xword a_type, const char **name, const char **format)
+{
+  if (a_type != AT_HWCAP)
+    return 0;
+
+  *name = "HWCAP";
+  *format = "b"
+    "swp\0" "half\0" "thumb\0" "26bit\0"
+    "fast-mult\0" "fpa\0" "vfp\0" "edsp\0"
+    "java\0" "iwmmxt\0"
+    "\0";
+  return 1;
+}
diff --git a/backends/arm_corenote.c b/backends/arm_corenote.c
new file mode 100644 (file)
index 0000000..6f2d3a3
--- /dev/null
@@ -0,0 +1,73 @@
+/* ARM specific core note handling.
+   Copyright (C) 2009 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils 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; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <elf.h>
+#include <inttypes.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#define BACKEND arm_
+#include "libebl_CPU.h"
+
+
+static const Ebl_Register_Location prstatus_regs[] =
+  {
+    { .offset = 0, .regno = 0, .count = 16, .bits = 32 },      /* r0..r15 */
+    { .offset = 16 * 4, .regno = 128, .count = 1, .bits = 32 }, /* cpsr */
+  };
+#define PRSTATUS_REGS_SIZE     (18 * 4)
+
+#define PRSTATUS_REGSET_ITEMS                                                \
+  {                                                                          \
+    .name = "orig_r0", .type = ELF_T_SWORD, .format = 'd',                   \
+    .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (4 * 17),        \
+    .group = "register"                                                              \
+  }
+
+static const Ebl_Register_Location fpregset_regs[] =
+  {
+    { .offset = 0, .regno = 96, .count = 8, .bits = 96 }, /* f0..f7 */
+  };
+#define FPREGSET_SIZE  140
+
+#define        ULONG                   uint32_t
+#define PID_T                  int32_t
+#define        UID_T                   uint16_t
+#define        GID_T                   uint16_t
+#define ALIGN_ULONG            4
+#define ALIGN_PID_T            4
+#define ALIGN_UID_T            2
+#define ALIGN_GID_T            2
+#define TYPE_ULONG             ELF_T_WORD
+#define TYPE_PID_T             ELF_T_SWORD
+#define TYPE_UID_T             ELF_T_HALF
+#define TYPE_GID_T             ELF_T_HALF
+
+#include "linux-core-note.c"
index 172af198f44b7dccd6555937936eddd3349d33bf..15c0ee673978dd8a79103ba9f7dd9be2d057f5bc 100644 (file)
@@ -1,5 +1,5 @@
 /* Initialization of Arm specific backend library.
-   Copyright (C) 2002, 2005 Red Hat, Inc.
+   Copyright (C) 2002, 2005, 2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -50,7 +50,15 @@ arm_init (elf, machine, eh, ehlen)
   /* We handle it.  */
   eh->name = "ARM";
   arm_init_reloc (eh);
+  HOOK (eh, segment_type_name);
+  HOOK (eh, section_type_name);
+  HOOK (eh, machine_flag_check);
   HOOK (eh, reloc_simple_type);
+  HOOK (eh, register_info);
+  HOOK (eh, core_note);
+  HOOK (eh, auxv_info);
+  HOOK (eh, check_object_attribute);
+  HOOK (eh, return_value_location);
 
   return MODVERSION;
 }
diff --git a/backends/arm_regs.c b/backends/arm_regs.c
new file mode 100644 (file)
index 0000000..b7351ce
--- /dev/null
@@ -0,0 +1,98 @@
+/* Register names and numbers for ARM DWARF.
+   Copyright (C) 2009 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils 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; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <string.h>
+#include <dwarf.h>
+
+#define BACKEND arm_
+#include "libebl_CPU.h"
+
+ssize_t
+arm_register_info (Ebl *ebl __attribute__ ((unused)),
+                  int regno, char *name, size_t namelen,
+                  const char **prefix, const char **setname,
+                  int *bits, int *type)
+{
+  if (name == NULL)
+    return 129;
+
+  if (regno < 0 || regno > 128 || namelen < 5)
+    return -1;
+
+  *prefix = NULL;
+  *bits = 32;
+  *type = DW_ATE_signed;
+  *setname = "integer";
+
+  switch (regno)
+    {
+    case 0 ... 9:
+      name[0] = 'r';
+      name[1] = regno + '0';
+      namelen = 2;
+      break;
+
+    case 10 ... 12:
+      name[0] = 'r';
+      name[1] = '1';
+      name[2] = regno % 10 + '0';
+      namelen = 3;
+      break;
+
+    case 13 ... 15:
+      *type = DW_ATE_address;
+      name[0] = "slp"[regno - 13];
+      name[1] = "prc"[regno - 13];
+      namelen = 2;
+      break;
+
+    case 16 + 0 ... 16 + 7:
+      regno += 96 - 16;
+      /* Fall through.  */
+    case 96 + 0 ... 96 + 7:
+      *setname = "FPA";
+      *type = DW_ATE_float;
+      *bits = 96;
+      name[0] = 'f';
+      name[1] = regno - 96 + '0';
+      namelen = 2;
+      break;
+
+    case 128:
+      *type = DW_ATE_unsigned;
+      return stpcpy (name, "spsr") + 1 - name;
+
+    default:
+      *setname = NULL;
+      return 0;
+    }
+
+  name[namelen++] = '\0';
+  return namelen;
+}
diff --git a/backends/arm_retval.c b/backends/arm_retval.c
new file mode 100644 (file)
index 0000000..4ffc6e7
--- /dev/null
@@ -0,0 +1,138 @@
+/* Function return value location for ARM EABI.
+   Copyright (C) 2009 Red Hat, Inc.
+   This file is part of Red Hat elfutils.
+
+   Red Hat elfutils 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; version 2 of the License.
+
+   Red Hat elfutils is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License along
+   with Red Hat elfutils; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+   Red Hat elfutils is an included package of the Open Invention Network.
+   An included package of the Open Invention Network is a package for which
+   Open Invention Network licensees cross-license their patents.  No patent
+   license is granted, either expressly or impliedly, by designation as an
+   included package.  Should you wish to participate in the Open Invention
+   Network licensing program, please visit www.openinventionnetwork.com
+   <http://www.openinventionnetwork.com>.  */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <assert.h>
+#include <dwarf.h>
+
+#define BACKEND arm_
+#include "libebl_CPU.h"
+
+
+/* r0, or pair r0, r1, or aggregate up to r0-r3.  */
+static const Dwarf_Op loc_intreg[] =
+  {
+    { .atom = DW_OP_reg0 }, { .atom = DW_OP_piece, .number = 4 },
+    { .atom = DW_OP_reg1 }, { .atom = DW_OP_piece, .number = 4 },
+    { .atom = DW_OP_reg2 }, { .atom = DW_OP_piece, .number = 4 },
+    { .atom = DW_OP_reg3 }, { .atom = DW_OP_piece, .number = 4 },
+  };
+#define nloc_intreg    1
+#define nloc_intregs(n)        (2 * (n))
+
+/* The return value is a structure and is actually stored in stack space
+   passed in a hidden argument by the caller.  But, the compiler
+   helpfully returns the address of that space in r0.  */
+static const Dwarf_Op loc_aggregate[] =
+  {
+    { .atom = DW_OP_breg0, .number = 0 }
+  };
+#define nloc_aggregate 1
+
+
+int
+arm_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp)
+{
+  /* Start with the function's type, and get the DW_AT_type attribute,
+     which is the type of the return value.  */
+
+  Dwarf_Attribute attr_mem;
+  Dwarf_Attribute *attr = dwarf_attr_integrate (functypedie, DW_AT_type,
+                                               &attr_mem);
+  if (attr == NULL)
+    /* The function has no return value, like a `void' function in C.  */
+    return 0;
+
+  Dwarf_Die die_mem;
+  Dwarf_Die *typedie = dwarf_formref_die (attr, &die_mem);
+  int tag = dwarf_tag (typedie);
+
+  /* Follow typedefs and qualifiers to get to the actual type.  */
+  while (tag == DW_TAG_typedef
+        || tag == DW_TAG_const_type || tag == DW_TAG_volatile_type
+        || tag == DW_TAG_restrict_type || tag == DW_TAG_mutable_type)
+    {
+      attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
+      typedie = dwarf_formref_die (attr, &die_mem);
+      tag = dwarf_tag (typedie);
+    }
+
+  Dwarf_Word size;
+  switch (tag)
+    {
+    case -1:
+      return -1;
+
+    case DW_TAG_subrange_type:
+      if (! dwarf_hasattr_integrate (typedie, DW_AT_byte_size))
+       {
+         attr = dwarf_attr_integrate (typedie, DW_AT_type, &attr_mem);
+         typedie = dwarf_formref_die (attr, &die_mem);
+         tag = dwarf_tag (typedie);
+       }
+      /* Fall through.  */
+
+    case DW_TAG_base_type:
+    case DW_TAG_enumeration_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_ptr_to_member_type:
+      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                &attr_mem), &size) != 0)
+       {
+         if (tag == DW_TAG_pointer_type || tag == DW_TAG_ptr_to_member_type)
+           size = 4;
+         else
+           return -1;
+       }
+      if (size <= 16)
+       {
+       intreg:
+         *locp = loc_intreg;
+         return size <= 4 ? nloc_intreg : nloc_intregs ((size + 3) / 4);
+       }
+
+    aggregate:
+      *locp = loc_aggregate;
+      return nloc_aggregate;
+
+    case DW_TAG_structure_type:
+    case DW_TAG_class_type:
+    case DW_TAG_union_type:
+    case DW_TAG_array_type:
+      if (dwarf_formudata (dwarf_attr_integrate (typedie, DW_AT_byte_size,
+                                                &attr_mem), &size) == 0
+         && size > 0 && size <= 4)
+       goto intreg;
+      goto aggregate;
+    }
+
+  /* XXX We don't have a good way to return specific errors from ebl calls.
+     This value means we do not understand the type, but it is well-formed
+     DWARF and might be valid.  */
+  return -2;
+}
index 6d2f56d3b100aac9145e7ad57091f733f14fd086..e08874bbab8f08e446b2719506e7835e2c82205a 100644 (file)
@@ -1,7 +1,6 @@
 /* Arm specific symbolic name handling.
-   Copyright (C) 2002, 2005 Red Hat, Inc.
+   Copyright (C) 2002-2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
-   Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
    Red Hat elfutils is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by the
 #define BACKEND                arm_
 #include "libebl_CPU.h"
 
+
+const char *
+arm_segment_type_name (int segment, char *buf __attribute__ ((unused)),
+                      size_t len __attribute__ ((unused)))
+{
+  switch (segment)
+    {
+    case PT_ARM_EXIDX:
+      return "ARM_EXIDX";
+    }
+  return NULL;
+}
+
+/* Return symbolic representation of section type.  */
+const char *
+arm_section_type_name (int type,
+                      char *buf __attribute__ ((unused)),
+                      size_t len __attribute__ ((unused)))
+{
+  switch (type)
+    {
+    case SHT_ARM_EXIDX:
+      return "ARM_EXIDX";
+    case SHT_ARM_PREEMPTMAP:
+      return "ARM_PREEMPTMAP";
+    case SHT_ARM_ATTRIBUTES:
+      return "ARM_ATTRIBUTES";
+    }
+
+  return NULL;
+}
+
+/* Check whether machine flags are valid.  */
+bool
+arm_machine_flag_check (GElf_Word flags)
+{
+  switch (flags & EF_ARM_EABIMASK)
+    {
+    case EF_ARM_EABI_UNKNOWN:
+    case EF_ARM_EABI_VER1:
+    case EF_ARM_EABI_VER2:
+    case EF_ARM_EABI_VER3:
+    case EF_ARM_EABI_VER4:
+    case EF_ARM_EABI_VER5:
+      break;
+    default:
+      return false;
+    }
+
+  return ((flags &~ (EF_ARM_EABIMASK
+                    | EF_ARM_RELEXEC
+                    | EF_ARM_HASENTRY
+                    | EF_ARM_INTERWORK
+                    | EF_ARM_APCS_26
+                    | EF_ARM_APCS_FLOAT
+                    | EF_ARM_PIC
+                    | EF_ARM_ALIGN8
+                    | EF_ARM_NEW_ABI
+                    | EF_ARM_OLD_ABI
+                    | EF_ARM_SOFT_FLOAT
+                    | EF_ARM_VFP_FLOAT
+                    | EF_ARM_MAVERICK_FLOAT
+                    | EF_ARM_SYMSARESORTED
+                    | EF_ARM_DYNSYMSUSESEGIDX
+                    | EF_ARM_MAPSYMSFIRST
+                    | EF_ARM_EABIMASK
+                    | EF_ARM_BE8
+                    | EF_ARM_LE8)) == 0);
+}
+
 /* Check for the simple reloc types.  */
 Elf_Type
 arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type)
index 2609db0f4c56c76f4e8047dda8271056d55e8336..1edef8b568eef4fd243cf7c12840923fcc3a72e3 100644 (file)
@@ -1,5 +1,5 @@
 /* IA-64 specific symbolic name handling.
-   Copyright (C) 2002, 2003, 2005, 2006, 2007 Red Hat, Inc.
+   Copyright (C) 2002-2009 Red Hat, Inc.
    This file is part of Red Hat elfutils.
    Written by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -102,9 +102,9 @@ ia64_section_type_name (int type,
   switch (type)
     {
     case SHT_IA_64_EXT:
-      return "SHT_IA_64_EXT";
+      return "IA_64_EXT";
     case SHT_IA_64_UNWIND:
-      return "SHT_IA_64_UNWIND";
+      return "IA_64_UNWIND";
     }
 
   return NULL;
index 12400f6bc596afa7ed41e32f934bdc5bebdae2ff..738af57a4ca146f1750dc60a31ce5f6ddf840a47 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-14  Roland McGrath  <roland@redhat.com>
+
+       * Makefile.am (AM_CFLAGS): Add -fdollars-in-identifiers; it is not the
+       default on every machine.
+
 2009-01-23  Roland McGrath  <roland@redhat.com>
 
        * Makefile.am (i386_parse_CFLAGS): Use quotes around command
index e47dc0b02aace9e9be186fbf9aca921ccca9d3ff..923556f6f1076ecaf3aab73f62c28dc354db69cc 100644 (file)
@@ -31,6 +31,7 @@ else
 AM_CFLAGS =
 endif
 AM_CFLAGS += -Wall -Wshadow -Wunused -Wextra -std=gnu99 -fpic \
+            -fdollars-in-identifiers \
             $($(*F)_CFLAGS) \
             $(if $($(*F)_no_Werror),,-Werror)
 INCLUDES = -I$(srcdir) -I$(srcdir)/../lib -I$(srcdir)/../libelf \
index d3b2b1e83be7862f81b666f0cad37b4bdcf2aaeb..bfc3ee5f16e19d61fe17315e5b8c70c09693fe08 100644 (file)
@@ -1,3 +1,7 @@
+2009-04-14  Roland McGrath  <roland@redhat.com>
+
+       * elf.h: Update from glibc.
+
 2009-04-01  Roland McGrath  <roland@redhat.com>
 
        * elf.h: Update from glibc.
index 6259350260e3e094b56f697cf19fafb49f9c4d28..062ef00f57e8531146a5f514ceda1cd80a604473 100644 (file)
@@ -2205,42 +2205,62 @@ typedef Elf32_Addr Elf32_Conflict;
 /* ARM specific declarations */
 
 /* Processor specific flags for the ELF header e_flags field.  */
-#define EF_ARM_RELEXEC     0x01
-#define EF_ARM_HASENTRY    0x02
-#define EF_ARM_INTERWORK   0x04
-#define EF_ARM_APCS_26     0x08
-#define EF_ARM_APCS_FLOAT  0x10
-#define EF_ARM_PIC         0x20
-#define EF_ARM_ALIGN8      0x40                /* 8-bit structure alignment is in use */
-#define EF_ARM_NEW_ABI     0x80
-#define EF_ARM_OLD_ABI     0x100
+#define EF_ARM_RELEXEC         0x01
+#define EF_ARM_HASENTRY                0x02
+#define EF_ARM_INTERWORK       0x04
+#define EF_ARM_APCS_26         0x08
+#define EF_ARM_APCS_FLOAT      0x10
+#define EF_ARM_PIC             0x20
+#define EF_ARM_ALIGN8          0x40 /* 8-bit structure alignment is in use */
+#define EF_ARM_NEW_ABI         0x80
+#define EF_ARM_OLD_ABI         0x100
+#define EF_ARM_SOFT_FLOAT      0x200
+#define EF_ARM_VFP_FLOAT       0x400
+#define EF_ARM_MAVERICK_FLOAT  0x800
+
 
 /* Other constants defined in the ARM ELF spec. version B-01.  */
 /* NB. These conflict with values defined above.  */
 #define EF_ARM_SYMSARESORTED   0x04
-#define EF_ARM_DYNSYMSUSESEGIDX 0x08
+#define EF_ARM_DYNSYMSUSESEGIDX        0x08
 #define EF_ARM_MAPSYMSFIRST    0x10
 #define EF_ARM_EABIMASK                0XFF000000
 
-#define EF_ARM_EABI_VERSION(flags) ((flags) & EF_ARM_EABIMASK)
-#define EF_ARM_EABI_UNKNOWN  0x00000000
-#define EF_ARM_EABI_VER1     0x01000000
-#define EF_ARM_EABI_VER2     0x02000000
+/* Constants defined in AAELF.  */
+#define EF_ARM_BE8         0x00800000
+#define EF_ARM_LE8         0x00400000
+
+#define EF_ARM_EABI_VERSION(flags)     ((flags) & EF_ARM_EABIMASK)
+#define EF_ARM_EABI_UNKNOWN    0x00000000
+#define EF_ARM_EABI_VER1       0x01000000
+#define EF_ARM_EABI_VER2       0x02000000
+#define EF_ARM_EABI_VER3       0x03000000
+#define EF_ARM_EABI_VER4       0x04000000
+#define EF_ARM_EABI_VER5       0x05000000
 
-/* Additional symbol types for Thumb */
-#define STT_ARM_TFUNC      0xd
+/* Additional symbol types for Thumb.  */
+#define STT_ARM_TFUNC          STT_LOPROC /* A Thumb function.  */
+#define STT_ARM_16BIT          STT_HIPROC /* A Thumb label.  */
 
 /* ARM-specific values for sh_flags */
-#define SHF_ARM_ENTRYSECT  0x10000000   /* Section contains an entry point */
-#define SHF_ARM_COMDEF     0x80000000   /* Section may be multiply defined
-                                          in the input to a link step */
+#define SHF_ARM_ENTRYSECT      0x10000000 /* Section contains an entry point */
+#define SHF_ARM_COMDEF         0x80000000 /* Section may be multiply defined
+                                             in the input to a link step.  */
 
 /* ARM-specific program header flags */
-#define PF_ARM_SB          0x10000000   /* Segment contains the location
-                                          addressed by the static base */
+#define PF_ARM_SB              0x10000000 /* Segment contains the location
+                                             addressed by the static base. */
+#define PF_ARM_PI              0x20000000 /* Position-independent segment.  */
+#define PF_ARM_ABS             0x40000000 /* Absolute segment.  */
 
 /* Processor specific values for the Phdr p_type field.  */
-#define PT_ARM_EXIDX   0x70000001      /* .ARM.exidx segment */
+#define PT_ARM_EXIDX           (PT_LOPROC + 1) /* ARM unwind segment.  */
+
+/* Processor specific values for the Shdr sh_type field.  */
+#define SHT_ARM_EXIDX          (SHT_LOPROC + 1) /* ARM unwind section.  */
+#define SHT_ARM_PREEMPTMAP     (SHT_LOPROC + 2) /* Preemption details.  */
+#define SHT_ARM_ATTRIBUTES     (SHT_LOPROC + 3) /* ARM attributes section.  */
+
 
 /* ARM relocs.  */
 
index 1bbc075a3417a35941193c059348e82d6e59382b..16673f14e358a31422e779223f85d29b11519778 100644 (file)
@@ -1,5 +1,8 @@
 2009-04-14  Roland McGrath  <roland@redhat.com>
 
+       * readelf.c (print_attributes): Treat SHT_ARM_ATTRIBUTES on EM_ARM
+       like SHT_GNU_ATTRIBUTES.
+
        * readelf.c (handle_core_registers): Fix error message.
 
        * strip.c (handle_elf: check_preserved): Don't note any change when
index 05382239f9984d397939706b42959feda48b7d5f..773fc7d780f4ceee544ff386b41136ecaf2235a7 100644 (file)
@@ -2824,7 +2824,9 @@ print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr)
       GElf_Shdr shdr_mem;
       GElf_Shdr *shdr = gelf_getshdr (scn, &shdr_mem);
 
-      if (shdr == NULL || shdr->sh_type != SHT_GNU_ATTRIBUTES)
+      if (shdr == NULL || (shdr->sh_type != SHT_GNU_ATTRIBUTES
+                          && (shdr->sh_type != SHT_ARM_ATTRIBUTES
+                              || ehdr->e_machine != EM_ARM)))
        continue;
 
       printf (gettext ("\
@@ -2871,8 +2873,9 @@ print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr)
 
          printf (gettext ("  %-13s  %4" PRIu32 "\n"), name, len);
 
-         if (q - name == sizeof "gnu"
-             && !memcmp (name, "gnu", sizeof "gnu"))
+         if (shdr->sh_type != SHT_GNU_ATTRIBUTES
+             || (q - name == sizeof "gnu"
+                 && !memcmp (name, "gnu", sizeof "gnu")))
            while (q < p)
              {
                const unsigned char *const sub = q;