diff options
author | Ian Lance Taylor <ian@airs.com> | 1994-05-20 16:04:59 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1994-05-20 16:04:59 +0000 |
commit | 497c543457bbdabe61c03733d2a44167bf354dae (patch) | |
tree | 4c2207e298b66fa12ea3ecd088a3e5b2c6d6b640 /bfd/elf32-mips.c | |
parent | 09985c960d737684e85d60dcc5796e2f1e8b6b45 (diff) | |
download | gdb-497c543457bbdabe61c03733d2a44167bf354dae.zip gdb-497c543457bbdabe61c03733d2a44167bf354dae.tar.gz gdb-497c543457bbdabe61c03733d2a44167bf354dae.tar.bz2 |
* elf.c (_bfd_elf_make_section_from_shdr): New function, based on
code repeated three times in bfd_section_from_shdr in elfcode.h.
* libelf.h (_bfd_elf_make_section_from_shdr): Declare.
* elfcode.h (bfd_section_from_shdr): Use new function
_bfd_elf_make_section_from_shdr to create BFD sections. If a
reloc section does not use the main symbol table, or it is part of
the process image, treat it as a normal section, not relocs.
* elf32-mips.c (mips_elf_section_from_shdr): Use new function
_bfd_elf_make_section_from_shdr.
Diffstat (limited to 'bfd/elf32-mips.c')
-rw-r--r-- | bfd/elf32-mips.c | 93 |
1 files changed, 32 insertions, 61 deletions
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 7f4930d..1794210 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -795,6 +795,8 @@ mips_elf_section_from_shdr (abfd, hdr, name) Elf32_Internal_Shdr *hdr; char *name; { + asection *newsect; + /* There ought to be a place to keep ELF backend specific flags, but at the moment there isn't one. We just keep track of the sections by their name, instead. Fortunately, the ABI gives @@ -835,60 +837,33 @@ mips_elf_section_from_shdr (abfd, hdr, name) return false; } - if (hdr->rawdata == NULL) - { - asection *newsect; - - newsect = bfd_make_section (abfd, name); - if (newsect != NULL) - { - newsect->filepos = hdr->sh_offset; - newsect->flags |= SEC_HAS_CONTENTS; - newsect->vma = hdr->sh_addr; - newsect->_raw_size = hdr->sh_size; - newsect->alignment_power = bfd_log2 (hdr->sh_addralign); - - if (hdr->sh_flags & SHF_ALLOC) - { - newsect->flags |= SEC_ALLOC; - newsect->flags |= SEC_LOAD; - } - - if (!(hdr->sh_flags & SHF_WRITE)) - newsect->flags |= SEC_READONLY; - - if (hdr->sh_flags & SHF_EXECINSTR) - newsect->flags |= SEC_CODE; - else if (newsect->flags & SEC_ALLOC) - newsect->flags |= SEC_DATA; - - if (hdr->sh_type == SHT_MIPS_DEBUG) - newsect->flags |= SEC_DEBUGGING; + if (! _bfd_elf_make_section_from_shdr (abfd, hdr, name)) + return false; + newsect = (asection *) hdr->rawdata; - hdr->rawdata = (void *) newsect; + if (hdr->sh_type == SHT_MIPS_DEBUG) + { + if (! bfd_set_section_flags (abfd, newsect, + (bfd_get_section_flags (abfd, newsect) + | SEC_DEBUGGING))) + return false; + } - /* FIXME: We should record the sh_info field for a .gptab - section. */ + /* FIXME: We should record sh_info for a .gptab section. */ - /* For a .reginfo section, set the gp value in the tdata - information from the contents of this section. We need - the gp value while processing relocs, so we just get it - now. */ - if (hdr->sh_type == SHT_MIPS_REGINFO) - { - Elf32_External_RegInfo ext; - Elf32_RegInfo s; + /* For a .reginfo section, set the gp value in the tdata information + from the contents of this section. We need the gp value while + processing relocs, so we just get it now. */ + if (hdr->sh_type == SHT_MIPS_REGINFO) + { + Elf32_External_RegInfo ext; + Elf32_RegInfo s; - if (bfd_get_section_contents (abfd, newsect, (PTR) &ext, - (file_ptr) 0, - sizeof ext) == false) - return false; - bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s); - elf_gp (abfd) = s.ri_gp_value; - } - } - else - hdr->rawdata = (void *) bfd_get_section_by_name (abfd, name); + if (! bfd_get_section_contents (abfd, newsect, (PTR) &ext, + (file_ptr) 0, sizeof ext)) + return false; + bfd_mips_elf32_swap_reginfo_in (abfd, &ext, &s); + elf_gp (abfd) = s.ri_gp_value; } return true; @@ -1201,20 +1176,15 @@ mips_elf_final_link (abfd, info) _bfd_generic_link_write_global_symbol, (PTR) &wginfo); - /* Remove empty sections. Also drop the .options section, since it - has special semantics which I haven't bothered to figure out. - Also drop the .gptab sections, which also require special - handling which is not currently done. Removing the .gptab - sections is required for Irix 5 compatibility; I don't know about - the other sections. */ + /* Drop the .options section, since it has special semantics which I + haven't bothered to figure out. Also drop the .gptab sections, + which also require special handling which is not currently done. + Removing the .gptab sections is required for Irix 5 + compatibility; I don't know about .options. */ secpp = &abfd->sections; while (*secpp != NULL) { - if (((*secpp)->_raw_size == 0 - && strcmp ((*secpp)->name, ".data") != 0 - && strcmp ((*secpp)->name, ".text") != 0 - && strcmp ((*secpp)->name, ".bss") != 0) - || strcmp ((*secpp)->name, ".options") == 0 + if (strcmp ((*secpp)->name, ".options") == 0 || strncmp ((*secpp)->name, ".gptab", 6) == 0) { *secpp = (*secpp)->next; @@ -1694,6 +1664,7 @@ static const struct ecoff_debug_swap mips_elf_ecoff_debug_swap = #define ELF_ARCH bfd_arch_mips #define ELF_MACHINE_CODE EM_MIPS #define ELF_MAXPAGESIZE 0x10000 +#define elf_backend_collect true #define elf_info_to_howto 0 #define elf_info_to_howto_rel mips_info_to_howto_rel #define elf_backend_sym_is_global mips_elf_sym_is_global |