diff options
author | Ian Lance Taylor <ian@airs.com> | 1996-08-30 22:09:51 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1996-08-30 22:09:51 +0000 |
commit | c86158e591edd8450f49f8cd75f82e4313d4b6d8 (patch) | |
tree | e17ece37589761df543fb981c2c1dd6391dab4e5 | |
parent | 787d66bb4d1d8ded6de1a1f3bf7b3d32ec516b20 (diff) | |
download | gdb-c86158e591edd8450f49f8cd75f82e4313d4b6d8.zip gdb-c86158e591edd8450f49f8cd75f82e4313d4b6d8.tar.gz gdb-c86158e591edd8450f49f8cd75f82e4313d4b6d8.tar.bz2 |
Add SH ELF support.
* elf32-sh.c: New file.
* elf.c (prep_headers): Handle bfd_arch_sh.
* elfcode.h (write_relocs): Handle absolute symbol.
* elf-bfd.h (_bfd_elf32_link_read_relocs): Declare.
(_bfd_elf64_link_read_relocs): Declare.
* elflink.h (NAME(_bfd_elf,link_read_relocs)): Rename from
elf_link_read_relocs. Make globally visible. Change all
callers.
(elf_link_input_bfd): Get external symbols from cache in
symtab_hdr->contents. Get contents from cache in
elf_section_data.
* elfxx-target.h (bfD_elfNN_bfd_relax_section): Only define if not
already defined.
* reloc.c: Define BFD_RELOC_SH_* relocs.
* libbfd-in.h (_bfd_sh_align_load_span): Declare.
* coff-sh.c (sh_insns_conflict): Fix a return value.
(_bfd_sh_align_load_span): New globally visible function, broken
out of sh_align_load.
(sh_align_load): Call _bfd_sh_align_load_span.
(sh_swap_insns): Change relocs parameter to PTR.
* bfd-in2.h, libbfd.h: Rebuild.
* targets.c (bfd_elf32_sh_vec): Declare.
(bfd_elf32_shl_vec): Declare.
* config.bfd (sh-*-elf*): New target.
* configure.in (bfd_elf32_sh_vec): New target vector.
(bfd_elf32_shl_vec): New target vector.
* configure: Rebuild.
* Makefile.in: Rebuild dependencies.
(BFD32_BACKENDS): Add elf32-sh.o.
(BFD32_BACKENDS_CFILES): Add elf32-sh.c.
* elf.c (map_sections_to_segments): Check that LMA does not skip a
page before checking D_PAGED.
-rw-r--r-- | bfd/.Sanitize | 1 | ||||
-rw-r--r-- | bfd/ChangeLog | 35 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 31 | ||||
-rw-r--r-- | bfd/elflink.h | 69 | ||||
-rw-r--r-- | bfd/libbfd.h | 30 | ||||
-rw-r--r-- | bfd/reloc.c | 49 |
6 files changed, 188 insertions, 27 deletions
diff --git a/bfd/.Sanitize b/bfd/.Sanitize index a356221..2113c38 100644 --- a/bfd/.Sanitize +++ b/bfd/.Sanitize @@ -153,6 +153,7 @@ elf32-m68k.c elf32-m88k.c elf32-mips.c elf32-ppc.c +elf32-sh.c elf32-sparc.c elf32.c elf64-alpha.c diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 7d81018..5f058e1 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,40 @@ Fri Aug 30 11:49:19 1996 Ian Lance Taylor <ian@cygnus.com> + Add SH ELF support. + * elf32-sh.c: New file. + * elf.c (prep_headers): Handle bfd_arch_sh. + * elfcode.h (write_relocs): Handle absolute symbol. + * elf-bfd.h (_bfd_elf32_link_read_relocs): Declare. + (_bfd_elf64_link_read_relocs): Declare. + * elflink.h (NAME(_bfd_elf,link_read_relocs)): Rename from + elf_link_read_relocs. Make globally visible. Change all + callers. + (elf_link_input_bfd): Get external symbols from cache in + symtab_hdr->contents. Get contents from cache in + elf_section_data. + * elfxx-target.h (bfD_elfNN_bfd_relax_section): Only define if not + already defined. + * reloc.c: Define BFD_RELOC_SH_* relocs. + * libbfd-in.h (_bfd_sh_align_load_span): Declare. + * coff-sh.c (sh_insns_conflict): Fix a return value. + (_bfd_sh_align_load_span): New globally visible function, broken + out of sh_align_load. + (sh_align_load): Call _bfd_sh_align_load_span. + (sh_swap_insns): Change relocs parameter to PTR. + * bfd-in2.h, libbfd.h: Rebuild. + * targets.c (bfd_elf32_sh_vec): Declare. + (bfd_elf32_shl_vec): Declare. + * config.bfd (sh-*-elf*): New target. + * configure.in (bfd_elf32_sh_vec): New target vector. + (bfd_elf32_shl_vec): New target vector. + * configure: Rebuild. + * Makefile.in: Rebuild dependencies. + (BFD32_BACKENDS): Add elf32-sh.o. + (BFD32_BACKENDS_CFILES): Add elf32-sh.c. + + * elf.c (map_sections_to_segments): Check that LMA does not skip a + page before checking D_PAGED. + * ihex.c (ihex_scan): Removed unnecessary extbase variable. (ihex_write_object_contents): Remove extbase; always use segbase instead. diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index f4c273f..0ab5432 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1216,6 +1216,9 @@ enum bfd_architecture bfd_arch_arm, /* Advanced Risc Machines ARM */ bfd_arch_ns32k, /* National Semiconductors ns32000 */ bfd_arch_w65, /* WDC 65816 */ + /* start-sanitize-v850 */ + bfd_arch_v850, /* NEC V850 */ + /* end-sanitize-v850 */ /* start-sanitize-arc */ bfd_arch_arc, /* Argonaut RISC Core */ #define bfd_mach_arc_base 0 @@ -1765,6 +1768,30 @@ not stored in the instruction. */ BFD_RELOC_ARM_IN_POOL, BFD_RELOC_ARM_OFFSET_IMM8, BFD_RELOC_ARM_HWLITERAL, + BFD_RELOC_ARM_THUMB_ADD, + BFD_RELOC_ARM_THUMB_IMM, + BFD_RELOC_ARM_THUMB_SHIFT, + BFD_RELOC_ARM_THUMB_OFFSET, + +/* Hitachi SH relocs. Not all of these appear in object files. */ + BFD_RELOC_SH_PCDISP8BY2, + BFD_RELOC_SH_PCDISP12BY2, + BFD_RELOC_SH_IMM4, + BFD_RELOC_SH_IMM4BY2, + BFD_RELOC_SH_IMM4BY4, + BFD_RELOC_SH_IMM8, + BFD_RELOC_SH_IMM8BY2, + BFD_RELOC_SH_IMM8BY4, + BFD_RELOC_SH_PCRELIMM8BY2, + BFD_RELOC_SH_PCRELIMM8BY4, + BFD_RELOC_SH_SWITCH16, + BFD_RELOC_SH_SWITCH32, + BFD_RELOC_SH_USES, + BFD_RELOC_SH_COUNT, + BFD_RELOC_SH_ALIGN, + BFD_RELOC_SH_CODE, + BFD_RELOC_SH_DATA, + BFD_RELOC_SH_LABEL, /* start-sanitize-arc */ /* Argonaut RISC Core (ARC) relocs. @@ -1802,6 +1829,10 @@ assumed to be 0. */ BFD_RELOC_D10V_18_PCREL, /* end-sanitize-d10v */ +/* NEC V850 relocs. */ + BFD_RELOC_V850_9_PCREL, + BFD_RELOC_V850_22_PCREL, + BFD_RELOC_UNUSED }; typedef enum bfd_reloc_code_real bfd_reloc_code_real_type; reloc_howto_type * diff --git a/bfd/elflink.h b/bfd/elflink.h index 27398a4..6326121 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -23,8 +23,6 @@ static boolean elf_link_add_object_symbols PARAMS ((bfd *, struct bfd_link_info *)); static boolean elf_link_add_archive_symbols PARAMS ((bfd *, struct bfd_link_info *)); -static Elf_Internal_Rela *elf_link_read_relocs - PARAMS ((bfd *, asection *, PTR, Elf_Internal_Rela *, boolean)); static boolean elf_export_symbol PARAMS ((struct elf_link_hash_entry *, PTR)); static boolean elf_adjust_dynamic_symbol @@ -961,9 +959,10 @@ elf_link_add_object_symbols (abfd, info) if ((o->flags & SEC_ALLOC) == 0) continue; - internal_relocs = elf_link_read_relocs (abfd, o, (PTR) NULL, - (Elf_Internal_Rela *) NULL, - info->keep_memory); + internal_relocs = (NAME(_bfd_elf,link_read_relocs) + (abfd, o, (PTR) NULL, + (Elf_Internal_Rela *) NULL, + info->keep_memory)); if (internal_relocs == NULL) goto error_return; @@ -1163,8 +1162,9 @@ elf_add_dynamic_entry (info, tag, val) value is allocated using either malloc or bfd_alloc, according to the KEEP_MEMORY argument. */ -static Elf_Internal_Rela * -elf_link_read_relocs (abfd, o, external_relocs, internal_relocs, keep_memory) +Elf_Internal_Rela * +NAME(_bfd_elf,link_read_relocs) (abfd, o, external_relocs, internal_relocs, + keep_memory) bfd *abfd; asection *o; PTR external_relocs; @@ -2728,6 +2728,7 @@ elf_link_input_bfd (finfo, input_bfd) Elf_Internal_Shdr *symtab_hdr; size_t locsymcount; size_t extsymoff; + Elf_External_Sym *external_syms; Elf_External_Sym *esym; Elf_External_Sym *esymend; Elf_Internal_Sym *isym; @@ -2758,16 +2759,23 @@ elf_link_input_bfd (finfo, input_bfd) } /* Read the local symbols. */ - if (locsymcount > 0 - && (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_read (finfo->external_syms, sizeof (Elf_External_Sym), + if (symtab_hdr->contents != NULL) + external_syms = (Elf_External_Sym *) symtab_hdr->contents; + else if (locsymcount == 0) + external_syms = NULL; + else + { + external_syms = finfo->external_syms; + if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 + || (bfd_read (external_syms, sizeof (Elf_External_Sym), locsymcount, input_bfd) - != locsymcount * sizeof (Elf_External_Sym)))) - return false; + != locsymcount * sizeof (Elf_External_Sym))) + return false; + } /* Swap in the local symbols and write out the ones which we know are going into the output file. */ - esym = finfo->external_syms; + esym = external_syms; esymend = esym + locsymcount; isym = finfo->internal_syms; pindex = finfo->indices; @@ -2807,7 +2815,7 @@ elf_link_input_bfd (finfo, input_bfd) *ppsection = isec; /* Don't output the first, undefined, symbol. */ - if (esym == finfo->external_syms) + if (esym == external_syms) continue; /* If we are stripping all symbols, we don't want to output this @@ -2873,6 +2881,8 @@ elf_link_input_bfd (finfo, input_bfd) /* Relocate the contents of each section. */ for (o = input_bfd->sections; o != NULL; o = o->next) { + bfd_byte *contents; + if (! o->linker_mark) { /* This section was omitted from the link. */ @@ -2891,20 +2901,28 @@ elf_link_input_bfd (finfo, input_bfd) continue; } - /* Read the contents of the section. */ - if (! bfd_get_section_contents (input_bfd, o, finfo->contents, - (file_ptr) 0, o->_raw_size)) - return false; + /* Get the contents of the section. They have been cached by a + relaxation routine. Note that o is a section in an input + file, so the contents field will not have been set by any of + the routines which work on output files. */ + if (elf_section_data (o)->this_hdr.contents != NULL) + contents = elf_section_data (o)->this_hdr.contents; + else + { + contents = finfo->contents; + if (! bfd_get_section_contents (input_bfd, o, contents, + (file_ptr) 0, o->_raw_size)) + return false; + } if ((o->flags & SEC_RELOC) != 0) { Elf_Internal_Rela *internal_relocs; /* Get the swapped relocs. */ - internal_relocs = elf_link_read_relocs (input_bfd, o, - finfo->external_relocs, - finfo->internal_relocs, - false); + internal_relocs = (NAME(_bfd_elf,link_read_relocs) + (input_bfd, o, finfo->external_relocs, + finfo->internal_relocs, false)); if (internal_relocs == NULL && o->reloc_count > 0) return false; @@ -2930,8 +2948,7 @@ elf_link_input_bfd (finfo, input_bfd) the addend to be adjusted. */ if (! (*relocate_section) (output_bfd, finfo->info, - input_bfd, o, - finfo->contents, + input_bfd, o, contents, internal_relocs, finfo->internal_syms, finfo->sections)) @@ -3104,7 +3121,7 @@ elf_link_input_bfd (finfo, input_bfd) if (elf_section_data (o)->stab_info == NULL) { if (! bfd_set_section_contents (output_bfd, o->output_section, - finfo->contents, o->output_offset, + contents, o->output_offset, (o->_cooked_size != 0 ? o->_cooked_size : o->_raw_size))) @@ -3114,7 +3131,7 @@ elf_link_input_bfd (finfo, input_bfd) { if (! _bfd_write_section_stabs (output_bfd, o, &elf_section_data (o)->stab_info, - finfo->contents)) + contents)) return false; } } diff --git a/bfd/libbfd.h b/bfd/libbfd.h index eb34a43..28ce15b 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -506,6 +506,14 @@ extern boolean _bfd_ecoff_get_accumulated_ss PARAMS ((PTR, bfd_byte *)); extern bfd_vma _bfd_get_gp_value PARAMS ((bfd *)); extern void _bfd_set_gp_value PARAMS ((bfd *, bfd_vma)); +/* Function shared by the COFF and ELF SH backends, which have no + other common header files. */ + +extern boolean _bfd_sh_align_load_span + PARAMS ((bfd *, asection *, bfd_byte *, + boolean (*) (bfd *, asection *, PTR, bfd_byte *, bfd_vma), + PTR, bfd_vma **, bfd_vma *, bfd_vma, bfd_vma, boolean *)); + /* And more follows */ void @@ -703,6 +711,28 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_ARM_IN_POOL", "BFD_RELOC_ARM_OFFSET_IMM8", "BFD_RELOC_ARM_HWLITERAL", + "BFD_RELOC_ARM_THUMB_ADD", + "BFD_RELOC_ARM_THUMB_IMM", + "BFD_RELOC_ARM_THUMB_SHIFT", + "BFD_RELOC_ARM_THUMB_OFFSET", + "BFD_RELOC_SH_PCDISP8BY2", + "BFD_RELOC_SH_PCDISP12BY2", + "BFD_RELOC_SH_IMM4", + "BFD_RELOC_SH_IMM4BY2", + "BFD_RELOC_SH_IMM4BY4", + "BFD_RELOC_SH_IMM8", + "BFD_RELOC_SH_IMM8BY2", + "BFD_RELOC_SH_IMM8BY4", + "BFD_RELOC_SH_PCRELIMM8BY2", + "BFD_RELOC_SH_PCRELIMM8BY4", + "BFD_RELOC_SH_SWITCH16", + "BFD_RELOC_SH_SWITCH32", + "BFD_RELOC_SH_USES", + "BFD_RELOC_SH_COUNT", + "BFD_RELOC_SH_ALIGN", + "BFD_RELOC_SH_CODE", + "BFD_RELOC_SH_DATA", + "BFD_RELOC_SH_LABEL", /* start-sanitize-arc */ "BFD_RELOC_ARC_B22_PCREL", "BFD_RELOC_ARC_B26", diff --git a/bfd/reloc.c b/bfd/reloc.c index d5575ce..4b3e0ee 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -1,5 +1,5 @@ /* BFD support for handling relocation entries. - Copyright (C) 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc. + Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -2149,10 +2149,57 @@ ENUMX BFD_RELOC_ARM_OFFSET_IMM8 ENUMX BFD_RELOC_ARM_HWLITERAL +ENUMX + BFD_RELOC_ARM_THUMB_ADD +ENUMX + BFD_RELOC_ARM_THUMB_IMM +ENUMX + BFD_RELOC_ARM_THUMB_SHIFT +ENUMX + BFD_RELOC_ARM_THUMB_OFFSET ENUMDOC These relocs are only used within the ARM assembler. They are not (at present) written to any object files. +ENUM + BFD_RELOC_SH_PCDISP8BY2 +ENUMX + BFD_RELOC_SH_PCDISP12BY2 +ENUMX + BFD_RELOC_SH_IMM4 +ENUMX + BFD_RELOC_SH_IMM4BY2 +ENUMX + BFD_RELOC_SH_IMM4BY4 +ENUMX + BFD_RELOC_SH_IMM8 +ENUMX + BFD_RELOC_SH_IMM8BY2 +ENUMX + BFD_RELOC_SH_IMM8BY4 +ENUMX + BFD_RELOC_SH_PCRELIMM8BY2 +ENUMX + BFD_RELOC_SH_PCRELIMM8BY4 +ENUMX + BFD_RELOC_SH_SWITCH16 +ENUMX + BFD_RELOC_SH_SWITCH32 +ENUMX + BFD_RELOC_SH_USES +ENUMX + BFD_RELOC_SH_COUNT +ENUMX + BFD_RELOC_SH_ALIGN +ENUMX + BFD_RELOC_SH_CODE +ENUMX + BFD_RELOC_SH_DATA +ENUMX + BFD_RELOC_SH_LABEL +ENUMDOC + Hitachi SH relocs. Not all of these appear in object files. + COMMENT {* start-sanitize-arc *} ENUM |