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 /bfd/elflink.h | |
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.
Diffstat (limited to 'bfd/elflink.h')
-rw-r--r-- | bfd/elflink.h | 69 |
1 files changed, 43 insertions, 26 deletions
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; } } |