* elfcode.h (elf_object_p): Rather than looking through an array
authorIan Lance Taylor <ian@airs.com>
Tue, 9 Nov 1993 21:08:58 +0000 (21:08 +0000)
committerIan Lance Taylor <ian@airs.com>
Tue, 9 Nov 1993 21:08:58 +0000 (21:08 +0000)
of architectures, get the ELF EM_xxx code from the backend
information.  Let the generic ELF target match any EM_xxx code not
matched by another ELF target.  Call elf_backend_object_p to let
the backend do more checks and set global information.
* libelf.h (struct elf_backend_data): Added elf_machine_code and
elf_backend_object_p fields.
(struct bfd_elf_arch_map): Removed.
(bfd_elf_arch_map, bfd_elf_arch_map_size): Don't declare.
* elf32-target.h, elf64-target.h: Initialize elf_machine_code
field with ELF_MACHINE_CODE.  Initialize elf_backend_object_p
field with elf_backend_object_p (if it is defined).
* elf32-gen.c, elf32-hppa.c, elf32-i386.c, elf32-i860.c,
elf32-m68k.c, elf32-m88k.c, elf32-mips.c, elf32-sparc.c,
elf64-gen.c (ELF_MACHINE_CODE): Defined.
* elf32-mips.c: Include ecoffswap.h to get ECOFF swapping
routines.
(mips_elf_object_p): Set the right machine number.
(mips_elf_ecoff_debug_swap): Defined.
(elf_backend_object_p): Defined to be mips_elf_object_p.
(elf_backend_ecoff_debug_swap): Defined to be
mips_elf_ecoff_debug_swap.
* elf.c (bfd_elf_arch_map, bfd_elf_arch_map_size): Removed.

* elf32-mips.c (elf_mips_howto_table): Don't complain on overflow
for R_MIPS_26.  Correct overflow detection requires matching the
upper four bits of the destination against the PC.  From Ted Lemon
<mellon@pepper.ncd.com>.

* elf32-hppa.c (elf_hppa_reloc_type_lookup): Return type
should point to const data.

bfd/elf32-hppa.c
bfd/elf32-target.h
bfd/elf64-target.h
bfd/libelf.h

index 68c85fdc398e0e0e57510c1ef0cbe104ba77c823..87cc948ab32195090440313b8292b7b7d21f9574 100644 (file)
@@ -1585,7 +1585,7 @@ DEFUN (hppa_elf_reloc, (abfd, reloc_entry, symbol_in, data, input_section, outpu
 
 }
 
-static reloc_howto_type *
+static const reloc_howto_type *
 elf_hppa_reloc_type_lookup (arch, code)
      bfd_arch_info_type *arch;
      bfd_reloc_code_real_type code;
@@ -2236,13 +2236,15 @@ hppa_elf_build_arg_reloc_stub (abfd, output_bfd, reloc_entry, stub_types)
   if (!stub_desc->stub_contents)
     {
       stub_desc->allocated_size = STUB_BUFFER_INCR;
-      stub_desc->stub_contents = (char *) xmalloc (STUB_BUFFER_INCR);
+      stub_desc->stub_contents = (char *) bfd_xmalloc (STUB_BUFFER_INCR);
     }
   else if ((stub_desc->allocated_size - stub_desc->real_size) < STUB_MAX_SIZE)
     {
       stub_desc->allocated_size = stub_desc->allocated_size + STUB_BUFFER_INCR;
-      stub_desc->stub_contents = (char *) xrealloc (stub_desc->stub_contents,
-                                                   stub_desc->allocated_size);
+      stub_desc->stub_contents = (char *) realloc (stub_desc->stub_contents,
+                                                  stub_desc->allocated_size);
+      if (stub_desc->stub_contents == NULL)
+       abort ();
     }
 
   stub_desc->stub_secp = (int *) (stub_desc->stub_contents + stub_desc->real_size);
@@ -3148,12 +3150,10 @@ hppa_elf_get_section_contents (abfd, section, location, offset, count)
      be generated. */
   else if (strcmp (section->name, ".hppa_symextn") == 0)
     {
-      /* If this is the first time through and there are no output 
-        sections, then read the contents of the symbol extension section
-        from disk.  */
-      if (! symext_chain_built
-         || ((section->output_section == NULL)
-             && (abfd->direction == read_direction)))
+      /* If there are no output sections, then read the contents of the 
+        symbol extension section from disk.  */
+      if (section->output_section == NULL
+         && abfd->direction == read_direction)
        {
          return bfd_generic_get_section_contents (abfd, section, location,
                                                   offset, count);
@@ -3165,17 +3165,22 @@ hppa_elf_get_section_contents (abfd, section, location, offset, count)
       else if (! symext_chain_built)
        {
          int i;
-         int *symtab_map = elf_sym_extra(section->output_section->owner);
+         int *symtab_map =
+           (int *) elf_sym_extra(section->output_section->owner);
          
          for (i = 0; i < section->output_section->owner->symcount; i++ )
            {
              elf_hppa_tc_symbol(section->output_section->owner,
-                                section->output_section->owner->outsymbols[i],
+                                ((elf_symbol_type *)
+                                 section->output_section->owner->outsymbols[i]),
                                 symtab_map[i]);
            }
          symext_chain_built++;
          elf_hppa_tc_make_sections (section->output_section->owner, NULL);
        }
+
+      /* At this point we know that the symbol extension section has been
+        built.  We just need to copy it into the user's buffer.  */
       if (count == 0)
        return true;
       
@@ -3501,6 +3506,7 @@ DEFUN (elf32_hppa_backend_section_from_bfd_section, (abfd, hdr, asect, retval),
 #define TARGET_BIG_SYM         bfd_elf32_hppa_vec
 #define TARGET_BIG_NAME                "elf32-hppa"
 #define ELF_ARCH               bfd_arch_hppa
+#define ELF_MACHINE_CODE       EM_HPPA
 #define ELF_MAXPAGESIZE                0x1000
 
 #include "elf32-target.h"
index 9b1c832e5c45118c845190b14fc87a84860354b4..2711fbd3d5e81ac48e56926128feaf515d16fe56 100644 (file)
@@ -61,6 +61,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define ELF_MAXPAGESIZE 1
 #endif
 
+#ifndef elf_backend_object_p
+#define elf_backend_object_p           0       /* elf_backend_object_p */
+#endif
 #ifndef elf_backend_symbol_processing
 #define elf_backend_symbol_processing  0       /* elf_backend_symbol_processing */
 #endif
@@ -92,9 +95,11 @@ static CONST struct elf_backend_data elf32_bed =
 #endif
   0,                           /* elf_64_p */
   ELF_ARCH,                    /* arch */
+  ELF_MACHINE_CODE,            /* elf_machine_code */
   ELF_MAXPAGESIZE,             /* maxpagesize */
   elf_info_to_howto,           /* elf_info_to_howto */
   elf_info_to_howto_rel,       /* elf_info_to_howto_rel */
+  elf_backend_object_p,                        /* elf_backend_object_p */
   elf_backend_symbol_processing,       /* elf_backend_symbol_processing */
   elf_backend_symbol_table_processing, /* elf_backend_symbol_table_processing */
   elf_backend_section_processing,      /* elf_backend_section_processing */
index 790e4a6d3003f71489c6f726adfd4f9fba44610a..8ada3b98ab42b3cea2c0d67474aae9aff6c381a6 100644 (file)
@@ -59,6 +59,9 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #define ELF_MAXPAGESIZE 1
 #endif
 
+#ifndef elf_backend_object_p
+#define elf_backend_object_p           0       /* elf_backend_object_p */
+#endif
 #ifndef elf_backend_symbol_processing
 #define elf_backend_symbol_processing  0       /* elf_backend_symbol_processing */
 #endif
@@ -90,9 +93,11 @@ static CONST struct elf_backend_data elf64_bed =
 #endif
   1,                           /* elf_64_p */
   ELF_ARCH,                    /* arch */
+  ELF_MACHINE_CODE,            /* elf_machine_code */
   ELF_MAXPAGESIZE,             /* maxpagesize */
   elf_info_to_howto,           /* elf_info_to_howto */
   elf_info_to_howto_rel,       /* elf_info_to_howto_rel */
+  elf_backend_object_p,                        /* elf_backend_object_p */
   elf_backend_symbol_processing,       /* elf_backend_symbol_processing */
   elf_backend_symbol_table_processing, /* elf_backend_symbol_table_processing */
   elf_backend_section_processing,      /* elf_backend_section_processing */
index 2c0969a9abd004756f5e42e13970d4f916e768cd..4d58293c53275e93ab121b8f1b72743fff60cba7 100644 (file)
@@ -77,6 +77,9 @@ struct elf_backend_data
   /* The architecture for this backend.  */
   enum bfd_architecture arch;
 
+  /* The ELF machine code (EM_xxxx) for this backend.  */
+  int elf_machine_code;
+
   /* The maximum page size for this backend.  */
   bfd_vma maxpagesize;
 
@@ -93,6 +96,14 @@ struct elf_backend_data
   /* The remaining functions are hooks which are called only if they
      are not NULL.  */
 
+  /* A function to permit a backend specific check on whether a
+     particular BFD format is relevant for an object file, and to
+     permit the backend to set any global information it wishes.  When
+     this is called elf_elfheader is set, but anything else should be
+     used with caution.  If this returns false, the check_format
+     routine will return a wrong_format error.  */
+  boolean (*elf_backend_object_p) PARAMS ((bfd *));
+
   /* A function to do additional symbol processing when reading the
      ELF symbol table.  This is where any processor-specific special
      section indices are handled.  */
@@ -142,14 +153,6 @@ struct elf_sym_extra
 
 typedef struct elf_sym_extra Elf_Sym_Extra;
 
-struct bfd_elf_arch_map {
-  enum bfd_architecture bfd_arch;
-  int elf_arch;
-};
-
-extern const struct bfd_elf_arch_map bfd_elf_arch_map[];
-extern const int bfd_elf_arch_map_size;
-
 struct bfd_elf_section_data {
   Elf_Internal_Shdr this_hdr;
   Elf_Internal_Shdr rel_hdr;
This page took 0.029445 seconds and 4 git commands to generate.