aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-mips.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>1999-07-07 19:23:22 +0000
committerMark Mitchell <mark@codesourcery.com>1999-07-07 19:23:22 +0000
commit103186c62b99755e1bbf5ceb1b3b004c82bcf293 (patch)
tree430d70163c0fec41cab1b1e695cdc80f2653d59c /bfd/elf64-mips.c
parentc7ac6ff835615a523fe86575cd5fae3f93f88430 (diff)
downloadgdb-103186c62b99755e1bbf5ceb1b3b004c82bcf293.zip
gdb-103186c62b99755e1bbf5ceb1b3b004c82bcf293.tar.gz
gdb-103186c62b99755e1bbf5ceb1b3b004c82bcf293.tar.bz2
* elf-bfd.h (_bfd_mips_elf_section_from_shdr): Constify.
(_bfd_mips_elf_create_dynamic_sections): New function. (_bfd_mips_elf_add_symbol_hook): Likewise. (_bfd_mips_elf_adjust_dynamic_symbol): Likewise. (_bfd_mips_elf_finish_dynamic_symbol): Likewise. (_bfd_mips_elf_finish_dynamic_sections): Likewise. (_bfd_mips_elf_gc_mark_hook): Likewise. (_bfd_mips_elf_gc_sweep_hook): Likewise. (_bfd_mips_elf_always_size_sections): Likewise. (_bfd_mips_elf_size_dynamic_sections): Likewise. (_bfd_mips_elf_check_relocs): Likewise. (_bfd_mips_elf_link_hash_table_create): Likewise. (_bfd_mips_elf_print_private_data): Likewise. (_bfd_mips_elf_link_output_symbol_hook): Likewise. (_bfd_mips_elf_final_link): Likewise. (_bfd_mips_elf_additional_program_headers): Likewise. (_bfd_mips_elf_modify_segment_map): Likewise. (_bfd_mips_elf_relocate_section): Likewise. * elf32-mips.c (mips_elf32_object_p): Move contents into _bfd_mips_elf_object_p. (mips_elf_additional_program_headers): Rename to _bfd_mips_elf_additional_program_headers. (mips_elf_modify_segment_map): Rename to _bfd_mips_elf_modify_segment_map. (elf_mips_abi_name): Change prototype. (mips_elf32_section_from_shdr): Merge into _bfd_mips_elf_section_from_shdr. (mips_elf32_section_processing): Merge into _bfd_mips_elf_section_processing. (mips_elf_final_link): Rename to _bfd_mips_elf_final_link. Invoke the right back-end ELF linker. (mips_elf_relocate_section): Rename to _bfd_mips_elf_relocate_section. Clean up. Adjust for 64-bit code. (mips_elf_link_output_symbol_hook): Rename to _bfd_mips_elf_link_output_symbol_hook. (mips_elf_create_dynamic_section): Rename to _bfd_mips_elf_create_dynamic_section. (mips_elf_check_relocs): Rename to _bfd_mips_elf_check_relocs. Adjust for 64-bit code. Use mips_elf_got_section. (mips_elf_adjust_dynamic_symbol): Rename to _bfd_mips_elf_adjust_dynamic_symbol. Use mips_elf_allocate_dynamic_relocations. (mips_elf_finish_dynamic_symbol): Rename to _bfd_mips_elf_finish_dynamic_symbol. Use mips_elf_got_section. Adjust for 64-bit code. (mips_elf_finish_dynamic_sections): Rename to _bfd_mips_elf_finish_dynamic_sections. Adjust for 64-bit code. (mips_elf_always_size_sections): Rename to _bfd_mips_elf_always_size_sections. (mips_elf_add_symbol_hook): Rename to _bfd_mips_elf_add_symbol_hook. (mips_elf_next_lo16_addend): Constify. (mips_elf_calculate_relocation): Likewise. (mips_elf_obtain_contents): Likewise. (mips_elf_perform_relocation): Likewise. (mips_elf_create_dynamic_relocation): Likewise. (mips_elf_allocate_dynamic_relocations): New function. (MIPS_ELF_REL_DYN_SECTION_NAME): New macro. (MIPS_ELF_REL_SIZE): Likewise. (MIPS_ELF_DYN_SIZE): Likewise. (MIPS_ELF_GOT_SIZE): Likewise. (MIPS_ELF_SYM_SIZE): Likewise. (MIPS_ELF_LOG_FILE_ALIGN): Likewise. (MIPS_ELF_GET_WORD): Likewise. (MIPS_ELF_PUT_WORD): Likewise. (MIPS_ELF_ADD_DYNAMIC_ENTRY): Likewise. (STUB_LW): Conditionalize for 64-bit value. (elf_mips_howto_table): Add R_MIPS_HIGHER and R_MIPS_HIGHEST entries. (_bfd_mips_elf_merge_private_bfd_data): Merge e_ident[EI_CLASS]. Check it for inconsistency. (_bfd_mips_elf_print_private_bfd_data): Print ABI=64 for 64-bit ABI. (_bfd_mips_elf_fake_sections): Remove duplicate handling of .msym. (mips_elf_global_got_index): Use MIPS_ELF_GOT_SIZE. (mips_elf_got_offset_from_index): Use misp_elf_got_section. (mips_elf_create_local_got_entry): Use MIPS_ELF_GOT_SIZE. (mips_elf_local_got_index): Likewise. (mips_elf_got_page): Likewise. (mips_elf_got_info): Likewise. (mips_elf_create_dynamic_relocation): Handle 32-bit/64-bit split. (ELF_DYNAMIC_INTERPRETER): Handle 64-bit code. (mips_elf_create_dynamic_sections): Use MIPS_ELF_LOG_FILE_ALIGN, instead of constant `2'. (mips_elf_create_got_section): Tidy. Use MIPS_ELF_GOT_SIZE. (mips_elf_create_msym_section): Use MIPS_ELF_LOG_FILE_ALIGN. (mips_elf_size_dynamic_sections): Use MIPS_ELF_REL_DYN_SECTION_NAME, MIPS_ELF_GOT_SIZE, MIPS_ELF_ADD_DYNAMIC_ENTRY. Remove #if 0'd code. Adjust all releveant entries in elf backend table. * elf64-mips.c (mips_elf64_section_from_shdr): Remove. (mips_elf64_section_processing): Likewise. Adjust elf backend entries to use _bfd_mips_elf variants now publicly available.
Diffstat (limited to 'bfd/elf64-mips.c')
-rw-r--r--bfd/elf64-mips.c165
1 files changed, 47 insertions, 118 deletions
diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c
index 79b172f..0e388ef 100644
--- a/bfd/elf64-mips.c
+++ b/bfd/elf64-mips.c
@@ -1,6 +1,8 @@
/* MIPS-specific support for 64-bit ELF
Copyright 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
Ian Lance Taylor, Cygnus Support
+ Linker support added by Mark Mitchell, CodeSourcery, LLC.
+ <mark@codesourcery.com>
This file is part of BFD, the Binary File Descriptor library.
@@ -74,10 +76,6 @@ static boolean mips_elf64_slurp_one_reloc_table
static boolean mips_elf64_slurp_reloc_table
PARAMS ((bfd *, asection *, asymbol **, boolean));
static void mips_elf64_write_relocs PARAMS ((bfd *, asection *, PTR));
-static boolean mips_elf64_section_from_shdr
- PARAMS ((bfd *, Elf_Internal_Shdr *, char *));
-static boolean mips_elf64_section_processing
- PARAMS ((bfd *, Elf_Internal_Shdr *));
static boolean mips_elf64_slurp_armap PARAMS ((bfd *));
static boolean mips_elf64_write_armap
PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int));
@@ -86,6 +84,9 @@ static boolean mips_elf64_write_armap
from smaller values. Start with zero, widen, *then* decrement. */
#define MINUS_ONE (((bfd_vma)0) - 1)
+/* The number of local .got entries we reserve. */
+#define MIPS_RESERVED_GOTNO (2)
+
/* The relocation table used for SHT_REL sections. */
static reloc_howto_type mips_elf64_howto_table_rel[] =
@@ -1814,115 +1815,6 @@ mips_elf64_write_relocs (abfd, sec, data)
== count);
}
-/* Handle a 64-bit MIPS ELF specific section. */
-
-static boolean
-mips_elf64_section_from_shdr (abfd, hdr, name)
- bfd *abfd;
- Elf_Internal_Shdr *hdr;
- char *name;
-{
- if (! _bfd_mips_elf_section_from_shdr (abfd, hdr, name))
- return false;
-
- /* For a SHT_MIPS_OPTIONS section, look for a ODK_REGINFO entry, and
- set the gp value based on what we find. We may see both
- SHT_MIPS_REGINFO and SHT_MIPS_OPTIONS/ODK_REGINFO; in that case,
- they should agree. */
- if (hdr->sh_type == SHT_MIPS_OPTIONS)
- {
- bfd_byte *contents, *l, *lend;
-
- contents = (bfd_byte *) bfd_malloc (hdr->sh_size);
- if (contents == NULL)
- return false;
- if (! bfd_get_section_contents (abfd, hdr->bfd_section, contents,
- (file_ptr) 0, hdr->sh_size))
- {
- free (contents);
- return false;
- }
- l = contents;
- lend = contents + hdr->sh_size;
- while (l + sizeof (Elf_External_Options) <= lend)
- {
- Elf_Internal_Options intopt;
-
- bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
- &intopt);
- if (intopt.kind == ODK_REGINFO)
- {
- Elf64_Internal_RegInfo intreg;
-
- bfd_mips_elf64_swap_reginfo_in
- (abfd,
- ((Elf64_External_RegInfo *)
- (l + sizeof (Elf_External_Options))),
- &intreg);
- elf_gp (abfd) = intreg.ri_gp_value;
- }
- l += intopt.size;
- }
- free (contents);
- }
-
- return true;
-}
-
-/* Work over a section just before writing it out. We update the GP
- value in the SHT_MIPS_OPTIONS section based on the value we are
- using. */
-
-static boolean
-mips_elf64_section_processing (abfd, hdr)
- bfd *abfd;
- Elf_Internal_Shdr *hdr;
-{
- if (hdr->sh_type == SHT_MIPS_OPTIONS
- && hdr->bfd_section != NULL
- && elf_section_data (hdr->bfd_section) != NULL
- && elf_section_data (hdr->bfd_section)->tdata != NULL)
- {
- bfd_byte *contents, *l, *lend;
-
- /* We stored the section contents in the elf_section_data tdata
- field in the set_section_contents routine. We save the
- section contents so that we don't have to read them again.
- At this point we know that elf_gp is set, so we can look
- through the section contents to see if there is an
- ODK_REGINFO structure. */
-
- contents = (bfd_byte *) elf_section_data (hdr->bfd_section)->tdata;
- l = contents;
- lend = contents + hdr->sh_size;
- while (l + sizeof (Elf_External_Options) <= lend)
- {
- Elf_Internal_Options intopt;
-
- bfd_mips_elf_swap_options_in (abfd, (Elf_External_Options *) l,
- &intopt);
- if (intopt.kind == ODK_REGINFO)
- {
- bfd_byte buf[8];
-
- if (bfd_seek (abfd,
- (hdr->sh_offset
- + (l - contents)
- + sizeof (Elf_External_Options)
- + (sizeof (Elf64_External_RegInfo) - 8)),
- SEEK_SET) == -1)
- return false;
- bfd_h_put_64 (abfd, elf_gp (abfd), buf);
- if (bfd_write (buf, 1, 8, abfd) != 8)
- return false;
- }
- l += intopt.size;
- }
- }
-
- return _bfd_mips_elf_section_processing (abfd, hdr);
-}
-
/* Irix 6 defines a brand new archive map format, so that they can
have archives more than 4 GB in size. */
@@ -2215,29 +2107,66 @@ const struct elf_size_info mips_elf64_size_info =
#define TARGET_BIG_NAME "elf64-bigmips"
#define ELF_ARCH bfd_arch_mips
#define ELF_MACHINE_CODE EM_MIPS
+
#define ELF_MAXPAGESIZE 0x1000
+
+#define elf_backend_collect true
+#define elf_backend_type_change_ok true
+#define elf_backend_can_gc_sections true
#define elf_backend_size_info mips_elf64_size_info
#define elf_backend_object_p _bfd_mips_elf_object_p
-#define elf_backend_section_from_shdr mips_elf64_section_from_shdr
+#define elf_backend_section_from_shdr _bfd_mips_elf_section_from_shdr
#define elf_backend_fake_sections _bfd_mips_elf_fake_sections
#define elf_backend_section_from_bfd_section \
_bfd_mips_elf_section_from_bfd_section
-#define elf_backend_section_processing mips_elf64_section_processing
+#define elf_backend_section_processing _bfd_mips_elf_section_processing
#define elf_backend_symbol_processing _bfd_mips_elf_symbol_processing
+#define elf_backend_additional_program_headers \
+ _bfd_mips_elf_additional_program_headers
+#define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map
#define elf_backend_final_write_processing \
_bfd_mips_elf_final_write_processing
#define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap
-
+#define elf_backend_add_symbol_hook _bfd_mips_elf_add_symbol_hook
+#define elf_backend_create_dynamic_sections \
+ _bfd_mips_elf_create_dynamic_sections
+#define elf_backend_check_relocs _bfd_mips_elf_check_relocs
+#define elf_backend_adjust_dynamic_symbol \
+ _bfd_mips_elf_adjust_dynamic_symbol
+#define elf_backend_always_size_sections \
+ _bfd_mips_elf_always_size_sections
+#define elf_backend_size_dynamic_sections \
+ _bfd_mips_elf_size_dynamic_sections
+#define elf_backend_relocate_section _bfd_mips_elf_relocate_section
+#define elf_backend_link_output_symbol_hook \
+ _bfd_mips_elf_link_output_symbol_hook
+#define elf_backend_finish_dynamic_symbol \
+ _bfd_mips_elf_finish_dynamic_symbol
+#define elf_backend_finish_dynamic_sections \
+ _bfd_mips_elf_finish_dynamic_sections
+#define elf_backend_gc_mark_hook _bfd_mips_elf_gc_mark_hook
+#define elf_backend_gc_sweep_hook _bfd_mips_elf_gc_sweep_hook
+#define elf_backend_got_header_size (4*MIPS_RESERVED_GOTNO)
+#define elf_backend_plt_header_size 0
+
+/* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit
+ MIPS-specific function only applies to IRIX5, which had no 64-bit
+ ABI. */
#define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line
-#define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
-#define bfd_elf64_bfd_reloc_type_lookup mips_elf64_reloc_type_lookup
#define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents
+#define bfd_elf64_bfd_link_hash_table_create \
+ _bfd_mips_elf_link_hash_table_create
+#define bfd_elf64_bfd_final_link _bfd_mips_elf_final_link
#define bfd_elf64_bfd_copy_private_bfd_data \
_bfd_mips_elf_copy_private_bfd_data
#define bfd_elf64_bfd_merge_private_bfd_data \
_bfd_mips_elf_merge_private_bfd_data
#define bfd_elf64_bfd_set_private_flags _bfd_mips_elf_set_private_flags
+#define bfd_elf64_bfd_print_private_bfd_data \
+ _bfd_mips_elf_print_private_bfd_data
+#define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound
+#define bfd_elf64_bfd_reloc_type_lookup mips_elf64_reloc_type_lookup
#define bfd_elf64_archive_functions
#define bfd_elf64_archive_slurp_armap mips_elf64_slurp_armap
#define bfd_elf64_archive_slurp_extended_name_table \