2002-04-04 07:10:00 +00:00
|
|
|
/* MIPS ELF specific backend routines.
|
2003-01-23 11:51:35 +00:00
|
|
|
Copyright 2002, 2003 Free Software Foundation, Inc.
|
2002-04-04 07:10:00 +00:00
|
|
|
|
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
|
|
|
|
|
This program 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; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program 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 this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
#include "elf/common.h"
|
|
|
|
#include "elf/internal.h"
|
|
|
|
|
2003-01-23 11:51:35 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_new_section_hook
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern void _bfd_mips_elf_symbol_processing
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asymbol *);
|
2004-02-09 08:04:00 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_name_local_section_symbols
|
|
|
|
(bfd *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_section_processing
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, Elf_Internal_Shdr *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_section_from_shdr
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, Elf_Internal_Shdr *, const char *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_fake_sections
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, Elf_Internal_Shdr *, asection *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_section_from_bfd_section
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *, int *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_add_symbol_hook
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *, const Elf_Internal_Sym *,
|
|
|
|
const char **, flagword *, asection **, bfd_vma *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_link_output_symbol_hook
|
2003-12-08 20:04:34 +00:00
|
|
|
(struct bfd_link_info *, const char *, Elf_Internal_Sym *,
|
|
|
|
asection *, struct elf_link_hash_entry *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_create_dynamic_sections
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_check_relocs
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_adjust_dynamic_symbol
|
2003-12-08 20:04:34 +00:00
|
|
|
(struct bfd_link_info *, struct elf_link_hash_entry *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_always_size_sections
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_size_dynamic_sections
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_relocate_section
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
|
|
|
|
Elf_Internal_Rela *, Elf_Internal_Sym *, asection **);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_finish_dynamic_symbol
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,
|
|
|
|
Elf_Internal_Sym *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_finish_dynamic_sections
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern void _bfd_mips_elf_final_write_processing
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, bfd_boolean);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern int _bfd_mips_elf_additional_program_headers
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_modify_segment_map
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern asection * _bfd_mips_elf_gc_mark_hook
|
2003-12-08 20:04:34 +00:00
|
|
|
(asection *, struct bfd_link_info *, Elf_Internal_Rela *,
|
|
|
|
struct elf_link_hash_entry *, Elf_Internal_Sym *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_gc_sweep_hook
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern void _bfd_mips_elf_copy_indirect_symbol
|
2003-12-08 20:04:34 +00:00
|
|
|
(const struct elf_backend_data *, struct elf_link_hash_entry *,
|
|
|
|
struct elf_link_hash_entry *);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern void _bfd_mips_elf_hide_symbol
|
2003-12-08 20:04:34 +00:00
|
|
|
(struct bfd_link_info *, struct elf_link_hash_entry *, bfd_boolean);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_ignore_discarded_relocs
|
2003-12-08 20:04:34 +00:00
|
|
|
(asection *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_find_nearest_line
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *, asymbol **, bfd_vma, const char **,
|
|
|
|
const char **, unsigned int *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_set_section_contents
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *, const void *, file_ptr, bfd_size_type);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *, struct bfd_link_order *,
|
|
|
|
bfd_byte *, bfd_boolean, asymbol **);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_final_link
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct bfd_link_info *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_merge_private_bfd_data
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, bfd *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_set_private_flags
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, flagword);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_print_private_bfd_data
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, void *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_discard_info
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, struct elf_reloc_cookie *, struct bfd_link_info *);
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_write_section
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *, bfd_byte *);
|
2002-04-04 07:10:00 +00:00
|
|
|
|
2002-11-30 08:39:46 +00:00
|
|
|
extern bfd_boolean _bfd_mips_elf_read_ecoff_info
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *, struct ecoff_debug_info *);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern bfd_reloc_status_type _bfd_mips_elf_gprel16_with_gp
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asymbol *, arelent *, asection *, bfd_boolean, void *, bfd_vma);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern bfd_reloc_status_type _bfd_mips_elf32_gprel16_reloc
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
bfd/
* elf32-mips.c (elf_mips_howto_table_rel): Replace all uses of
mips_elf_generic_reloc with _bfd_mips_elf_generic_reloc. Use
_bfd_mips_elf_hi16_reloc for R_MIPS_HI16 and R_MIPS_GNU_REL_HI16,
_bfd_mips_elf_lo16_reloc for R_MIPS_LO16 and R_MIPS_GNU_REL_LO16,
and _bfd_mips_elf_got16_reloc for R_MIPS_GOT16. Change rightshift
to 16 for R_MIPS_HI16 and R_MIPS_GNU_REL_HI16.
(mips_elf_generic_reloc, struct mips_hi16, mips_elf_hi16_reloc)
(mips_elf_lo16_reloc, mips_elf_got16_reloc): Delete.
(_bfd_mips_elf32_gprel16_reloc): Remove special case.
(mips_elf_gprel32_reloc, mips32_64bit_reloc): Likewise.
* elf64-mips.c (mips_elf64_howto_table_rel): Replace all uses of
mips_elf_generic_reloc with _bfd_mips_elf_generic_reloc. Use
_bfd_mips_elf_hi16_reloc for R_MIPS_HI16, _bfd_mips_elf_lo16_reloc
for R_MIPS_LO16 and _bfd_mips_elf_got16_reloc for R_MIPS_GOT16.
Change R_MIPS_HI16's rightshift to 16.
(mips_elf64_howto_table_rela): Replace all uses of
mips_elf_generic_reloc with _bfd_mips_elf_generic_reloc.
Use _bfd_mips_elf_generic_reloc for R_MIPS_GOT16 as well.
(mips_elf64_hi16_reloc, mips_elf64_got16_reloc): Delete.
(mips_elf64_shift6_reloc): Remove special case. Use
_bfd_mips_elf_generic_reloc instead of returning bfd_reloc_continue.
* elfn32-mips.c (prev_reloc_section): Delete.
(prev_reloc_address, prev_reloc_addend): Delete.
(elf_mips_howto_table_rel, elf_mips_howto_table_rela): As for
elf64-mips.c
(GET_RELOC_ADDEND, SET_RELOC_ADDEND): Delete.
(mips_elf_generic_reloc, struct mips_hi16, mips_elf_hi16_reloc)
(mips_elf_lo16_reloc, mips_elf_got16_reloc): Delete.
(mips_elf_gprel16_reloc): Delete use of GET_RELOC_ADDEND.
(mips_elf_literal_reloc, mips_elf_gprel32_reloc): Likewise.
(mips16_jump_reloc, mips16_gprel_reloc): Likewise.
(mips_elf_shift6_reloc): Likewise. Delete use of SET_RELOC_ADDEND.
* elfxx-mips.c (_bfd_mips_elf_gprel16_with_gp): Use
_bfd_relocate_contents to install an in-place addend.
(mips_hi16): New structure.
(mips_hi16_list): Moved from elf32-mips.c.
(_bfd_mips_elf_hi16_reloc, _bfd_mips_elf_got16_reloc): New functions.
(_bfd_mips_elf_lo16_reloc, _bfd_mips_elf_generic_reloc): New functions.
(mips_elf_calculate_relocation): Assume addend is unshifted.
(_bfd_mips_elf_relocate_section): Don't apply the howto rightshift
on top of the usual high-part shift. Don't shift the addend right
before calling mips_elf_calculate_relocation.
* elfxx-mips.h (_bfd_mips_elf_hi16_reloc): Declare.
(_bfd_mips_elf_got16_reloc, _bfd_mips_elf_lo16_reloc): Declare.
(_bfd_mips_elf_generic_reloc): Declare.
gas/
* config/tc-mips.c (mips_need_elf_addend_fixup): Delete.
(md_apply_fix3): Remove bfd_install_relocation workarounds.
(tc_gen_reloc): Likewise. Factor handling of pc-relative relocations
and treat fx_addnumber as relative to the relocation address.
gas/testsuite/
* gas/mips/mips16-jalx.d: Use -mabi=o64.
* gas/mips/mips16.d: Likewise.
* gas/mips/elf-rel17.[sd]: New test.
* gas/mips/mips.exp: Run it.
2003-12-18 10:23:10 +00:00
|
|
|
extern bfd_reloc_status_type _bfd_mips_elf_hi16_reloc
|
|
|
|
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
|
|
|
extern bfd_reloc_status_type _bfd_mips_elf_got16_reloc
|
|
|
|
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
|
|
|
extern bfd_reloc_status_type _bfd_mips_elf_lo16_reloc
|
|
|
|
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
|
|
|
extern bfd_reloc_status_type _bfd_mips_elf_generic_reloc
|
|
|
|
(bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **);
|
2002-04-04 07:10:00 +00:00
|
|
|
extern unsigned long _bfd_elf_mips_mach
|
2003-12-08 20:04:34 +00:00
|
|
|
(flagword);
|
2003-06-11 16:22:26 +00:00
|
|
|
extern bfd_boolean _bfd_mips_relax_section
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd *, asection *, struct bfd_link_info *, bfd_boolean *);
|
2003-06-11 16:22:26 +00:00
|
|
|
extern bfd_vma _bfd_mips_elf_sign_extend
|
2003-12-08 20:04:34 +00:00
|
|
|
(bfd_vma, int);
|
2003-07-25 14:35:56 +00:00
|
|
|
|
|
|
|
extern struct bfd_elf_special_section const _bfd_mips_elf_special_sections[];
|
2004-02-09 08:04:00 +00:00
|
|
|
#define elf_backend_name_local_section_symbols \
|
|
|
|
_bfd_mips_elf_name_local_section_symbols
|
2003-07-25 14:35:56 +00:00
|
|
|
#define elf_backend_special_sections _bfd_mips_elf_special_sections
|