X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf64-mips.c;h=743444240aa7e3b23a9c09d0ad4fbaa6f84f6918;hb=e19f872c5bec6fbb9476abdc4ea5cee44da598e2;hp=00c312c8d8c6e1dcbce4627aeae8f7ec3c05f209;hpb=2ee563b53258d390d7446e90a67f465d504ae44c;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 00c312c8d8..743444240a 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -1,5 +1,5 @@ /* MIPS-specific support for 64-bit ELF - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Ian Lance Taylor, Cygnus Support Linker support added by Mark Mitchell, CodeSourcery, LLC. @@ -62,64 +62,72 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "ecoffswap.h" static void mips_elf64_swap_reloc_in - PARAMS ((bfd *, const Elf64_Mips_External_Rel *, - Elf64_Mips_Internal_Rel *)); + (bfd *, const Elf64_Mips_External_Rel *, Elf64_Mips_Internal_Rela *); static void mips_elf64_swap_reloca_in - PARAMS ((bfd *, const Elf64_Mips_External_Rela *, - Elf64_Mips_Internal_Rela *)); + (bfd *, const Elf64_Mips_External_Rela *, Elf64_Mips_Internal_Rela *); static void mips_elf64_swap_reloc_out - PARAMS ((bfd *, const Elf64_Mips_Internal_Rel *, - Elf64_Mips_External_Rel *)); + (bfd *, const Elf64_Mips_Internal_Rela *, Elf64_Mips_External_Rel *); static void mips_elf64_swap_reloca_out - PARAMS ((bfd *, const Elf64_Mips_Internal_Rela *, - Elf64_Mips_External_Rela *)); + (bfd *, const Elf64_Mips_Internal_Rela *, Elf64_Mips_External_Rela *); static void mips_elf64_be_swap_reloc_in - PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rel *)); + (bfd *, const bfd_byte *, Elf_Internal_Rela *); static void mips_elf64_be_swap_reloc_out - PARAMS ((bfd *, const Elf_Internal_Rel *, bfd_byte *)); + (bfd *, const Elf_Internal_Rela *, bfd_byte *); static void mips_elf64_be_swap_reloca_in - PARAMS ((bfd *, const bfd_byte *, Elf_Internal_Rela *)); + (bfd *, const bfd_byte *, Elf_Internal_Rela *); static void mips_elf64_be_swap_reloca_out - PARAMS ((bfd *, const Elf_Internal_Rela *, bfd_byte *)); + (bfd *, const Elf_Internal_Rela *, bfd_byte *); static reloc_howto_type *bfd_elf64_bfd_reloc_type_lookup - PARAMS ((bfd *, bfd_reloc_code_real_type)); + (bfd *, bfd_reloc_code_real_type); static reloc_howto_type *mips_elf64_rtype_to_howto - PARAMS ((unsigned int, boolean)); + (unsigned int, bfd_boolean); static void mips_elf64_info_to_howto_rel - PARAMS ((bfd *, arelent *, Elf64_Internal_Rel *)); + (bfd *, arelent *, Elf_Internal_Rela *); static void mips_elf64_info_to_howto_rela - PARAMS ((bfd *, arelent *, Elf64_Internal_Rela *)); -static long mips_elf64_get_reloc_upper_bound PARAMS ((bfd *, asection *)); -static boolean mips_elf64_slurp_one_reloc_table - PARAMS ((bfd *, asection *, asymbol **, const Elf_Internal_Shdr *)); -static boolean mips_elf64_slurp_reloc_table - PARAMS ((bfd *, asection *, asymbol **, boolean)); -static void mips_elf64_write_relocs PARAMS ((bfd *, asection *, PTR)); + (bfd *, arelent *, Elf_Internal_Rela *); +static long mips_elf64_get_reloc_upper_bound + (bfd *, asection *); +static long mips_elf64_canonicalize_reloc + (bfd *, asection *, arelent **, asymbol **); +static long mips_elf64_get_dynamic_reloc_upper_bound + (bfd *); +static long mips_elf64_canonicalize_dynamic_reloc + (bfd *, arelent **, asymbol **); +static bfd_boolean mips_elf64_slurp_one_reloc_table + (bfd *, asection *, Elf_Internal_Shdr *, bfd_size_type, arelent *, + asymbol **, bfd_boolean); +static bfd_boolean mips_elf64_slurp_reloc_table + (bfd *, asection *, asymbol **, bfd_boolean); +static void mips_elf64_write_relocs + (bfd *, asection *, void *); static void mips_elf64_write_rel - PARAMS((bfd *, asection *, Elf_Internal_Shdr *, int *, PTR)); + (bfd *, asection *, Elf_Internal_Shdr *, int *, void *); static void mips_elf64_write_rela - PARAMS((bfd *, asection *, Elf_Internal_Shdr *, int *, PTR)); -static bfd_reloc_status_type mips_elf64_hi16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + (bfd *, asection *, Elf_Internal_Shdr *, int *, void *); static bfd_reloc_status_type mips_elf64_gprel16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static bfd_reloc_status_type mips_elf64_literal_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static bfd_reloc_status_type mips_elf64_gprel32_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static bfd_reloc_status_type mips_elf64_shift6_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static bfd_reloc_status_type mips_elf64_got16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static bfd_reloc_status_type mips16_jump_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); static bfd_reloc_status_type mips16_gprel_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); -static boolean mips_elf64_assign_gp PARAMS ((bfd *, bfd_vma *)); + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +static bfd_boolean mips_elf64_assign_gp + (bfd *, bfd_vma *); static bfd_reloc_status_type mips_elf64_final_gp - PARAMS ((bfd *, asymbol *, boolean, char **, bfd_vma *)); -static boolean mips_elf64_object_p PARAMS ((bfd *)); -static irix_compat_t elf64_mips_irix_compat PARAMS ((bfd *)); + (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *); +static bfd_boolean mips_elf64_object_p + (bfd *); +static irix_compat_t elf64_mips_irix_compat + (bfd *); +static bfd_boolean elf64_mips_grok_prstatus + (bfd *, Elf_Internal_Note *); +static bfd_boolean elf64_mips_grok_psinfo + (bfd *, Elf_Internal_Note *); extern const bfd_target bfd_elf64_bigmips_vec; extern const bfd_target bfd_elf64_littlemips_vec; @@ -140,201 +148,201 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 0, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_NONE", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 16 bit relocation. */ HOWTO (R_MIPS_16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 32 bit relocation. */ HOWTO (R_MIPS_32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_32", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 32 bit symbol relative relocation. */ HOWTO (R_MIPS_REL32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_REL32", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 26 bit jump address. */ HOWTO (R_MIPS_26, /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ /* This needs complex overflow detection, because the upper 36 bits must match the PC + 4. */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_26", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x03ffffff, /* src_mask */ 0x03ffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* R_MIPS_HI16 and R_MIPS_LO16 are unsupported for NewABI REL. However, the native IRIX6 tools use them, so we try our best. */ /* High 16 bits of symbol value. */ HOWTO (R_MIPS_HI16, /* type */ - 0, /* rightshift */ + 16, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - mips_elf64_hi16_reloc, /* special_function */ + _bfd_mips_elf_hi16_reloc, /* special_function */ "R_MIPS_HI16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Low 16 bits of symbol value. */ HOWTO (R_MIPS_LO16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_lo16_reloc, /* special_function */ "R_MIPS_LO16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* GP relative reference. */ HOWTO (R_MIPS_GPREL16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ mips_elf64_gprel16_reloc, /* special_function */ "R_MIPS_GPREL16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Reference to literal section. */ HOWTO (R_MIPS_LITERAL, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ mips_elf64_literal_reloc, /* special_function */ "R_MIPS_LITERAL", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Reference to global offset table. */ HOWTO (R_MIPS_GOT16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - mips_elf64_got16_reloc, /* special_function */ + _bfd_mips_elf_got16_reloc, /* special_function */ "R_MIPS_GOT16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 16 bit PC relative reference. */ HOWTO (R_MIPS_PC16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - true, /* pc_relative */ + TRUE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_PC16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - true), /* pcrel_offset */ + TRUE), /* pcrel_offset */ /* 16 bit call through global offset table. */ HOWTO (R_MIPS_CALL16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_CALL16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 32 bit GP relative reference. */ HOWTO (R_MIPS_GPREL32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ mips_elf64_gprel32_reloc, /* special_function */ "R_MIPS_GPREL32", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ EMPTY_HOWTO (13), EMPTY_HOWTO (14), @@ -345,135 +353,135 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 5, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 6, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_SHIFT5", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x000007c0, /* src_mask */ 0x000007c0, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* A 6 bit shift field. */ HOWTO (R_MIPS_SHIFT6, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 6, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 6, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ mips_elf64_shift6_reloc, /* special_function */ "R_MIPS_SHIFT6", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x000007c4, /* src_mask */ 0x000007c4, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 64 bit relocation. */ HOWTO (R_MIPS_64, /* type */ 0, /* rightshift */ 4, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_64", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ MINUS_ONE, /* src_mask */ MINUS_ONE, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Displacement in the global offset table. */ HOWTO (R_MIPS_GOT_DISP, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_DISP", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Displacement to page pointer in the global offset table. */ HOWTO (R_MIPS_GOT_PAGE, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_PAGE", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Offset from page pointer in the global offset table. */ HOWTO (R_MIPS_GOT_OFST, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_OFST", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* High 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_GOT_HI16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_HI16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Low 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_GOT_LO16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_LO16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ - /* 64 bit substraction. */ + /* 64 bit subtraction. */ HOWTO (R_MIPS_SUB, /* type */ 0, /* rightshift */ 4, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_SUB", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ MINUS_ONE, /* src_mask */ MINUS_ONE, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Insert the addend as an instruction. */ /* FIXME: Not handled correctly. */ @@ -481,15 +489,15 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_INSERT_A", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Insert the addend as an instruction, and change all relocations to refer to the old instruction at the address. */ @@ -498,15 +506,15 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_INSERT_B", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Delete a 32 bit instruction. */ /* FIXME: Not handled correctly. */ @@ -514,15 +522,15 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_DELETE", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* The MIPS ELF64 ABI Draft wants us to support these for REL relocations. We don't, because @@ -538,59 +546,59 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_CALL_HI16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Low 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_CALL_LO16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_CALL_LO16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x0000ffff, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Section displacement, used by an associated event location section. */ HOWTO (R_MIPS_SCN_DISP, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_SCN_DISP", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ HOWTO (R_MIPS_REL16, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_REL16", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffff, /* src_mask */ 0xffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* These two are obsolete. */ EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE), @@ -602,15 +610,15 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_RELGOT", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0xffffffff, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Protected jump conversion. This is an optimization hint. No relocation is required for correctness. */ @@ -618,15 +626,15 @@ static reloc_howto_type mips_elf64_howto_table_rel[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_JALR", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x00000000, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ }; /* The relocation table used for SHT_RELA sections. */ @@ -638,198 +646,198 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 0, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_NONE", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 16 bit relocation. */ HOWTO (R_MIPS_16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 32 bit relocation. */ HOWTO (R_MIPS_32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_32", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 32 bit symbol relative relocation. */ HOWTO (R_MIPS_REL32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_REL32", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 26 bit jump address. */ HOWTO (R_MIPS_26, /* type */ 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ /* This needs complex overflow detection, because the upper 36 bits must match the PC + 4. */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_26", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x03ffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* High 16 bits of symbol value. */ HOWTO (R_MIPS_HI16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_HI16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Low 16 bits of symbol value. */ HOWTO (R_MIPS_LO16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_LO16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* GP relative reference. */ HOWTO (R_MIPS_GPREL16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ mips_elf64_gprel16_reloc, /* special_function */ "R_MIPS_GPREL16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Reference to literal section. */ HOWTO (R_MIPS_LITERAL, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ mips_elf64_literal_reloc, /* special_function */ "R_MIPS_LITERAL", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Reference to global offset table. */ HOWTO (R_MIPS_GOT16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - mips_elf64_got16_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 16 bit PC relative reference. */ HOWTO (R_MIPS_PC16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - true, /* pc_relative */ + TRUE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_PC16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - true), /* pcrel_offset */ + TRUE), /* pcrel_offset */ /* 16 bit call through global offset table. */ HOWTO (R_MIPS_CALL16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_CALL16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 32 bit GP relative reference. */ HOWTO (R_MIPS_GPREL32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ mips_elf64_gprel32_reloc, /* special_function */ "R_MIPS_GPREL32", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ EMPTY_HOWTO (13), EMPTY_HOWTO (14), @@ -840,135 +848,135 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 5, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 6, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_SHIFT5", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x000007c0, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* A 6 bit shift field. */ HOWTO (R_MIPS_SHIFT6, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 6, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 6, /* bitpos */ complain_overflow_bitfield, /* complain_on_overflow */ mips_elf64_shift6_reloc, /* special_function */ "R_MIPS_SHIFT6", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x000007c4, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* 64 bit relocation. */ HOWTO (R_MIPS_64, /* type */ 0, /* rightshift */ 4, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_64", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ MINUS_ONE, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Displacement in the global offset table. */ HOWTO (R_MIPS_GOT_DISP, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_DISP", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Displacement to page pointer in the global offset table. */ HOWTO (R_MIPS_GOT_PAGE, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_PAGE", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Offset from page pointer in the global offset table. */ HOWTO (R_MIPS_GOT_OFST, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_OFST", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* High 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_GOT_HI16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_HI16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Low 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_GOT_LO16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_GOT_LO16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ - /* 64 bit substraction. */ + /* 64 bit subtraction. */ HOWTO (R_MIPS_SUB, /* type */ 0, /* rightshift */ 4, /* size (0 = byte, 1 = short, 2 = long) */ 64, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_SUB", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ MINUS_ONE, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Insert the addend as an instruction. */ /* FIXME: Not handled correctly. */ @@ -976,15 +984,15 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_INSERT_A", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Insert the addend as an instruction, and change all relocations to refer to the old instruction at the address. */ @@ -993,15 +1001,15 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_INSERT_B", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Delete a 32 bit instruction. */ /* FIXME: Not handled correctly. */ @@ -1009,104 +1017,104 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_DELETE", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Get the higher value of a 64 bit addend. */ HOWTO (R_MIPS_HIGHER, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_HIGHER", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Get the highest value of a 64 bit addend. */ HOWTO (R_MIPS_HIGHEST, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_HIGHEST", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* High 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_CALL_HI16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_CALL_HI16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Low 16 bits of displacement in global offset table. */ HOWTO (R_MIPS_CALL_LO16, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_CALL_LO16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x0000ffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Section displacement, used by an associated event location section. */ HOWTO (R_MIPS_SCN_DISP, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_SCN_DISP", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ HOWTO (R_MIPS_REL16, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_REL16", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* These two are obsolete. */ EMPTY_HOWTO (R_MIPS_ADD_IMMEDIATE), @@ -1118,15 +1126,15 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_RELGOT", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0xffffffff, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ /* Protected jump conversion. This is an optimization hint. No relocation is required for correctness. */ @@ -1134,15 +1142,15 @@ static reloc_howto_type mips_elf64_howto_table_rela[] = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 32, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ - bfd_elf_generic_reloc, /* special_function */ + _bfd_mips_elf_generic_reloc, /* special_function */ "R_MIPS_JALR", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0x00000000, /* dst_mask */ - false), /* pcrel_offset */ + FALSE), /* pcrel_offset */ }; /* The reloc used for the mips16 jump instruction. */ @@ -1151,7 +1159,7 @@ static reloc_howto_type elf_mips16_jump_howto = 2, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 26, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ /* This needs complex overflow @@ -1159,10 +1167,10 @@ static reloc_howto_type elf_mips16_jump_howto = bits must match the PC. */ mips16_jump_reloc, /* special_function */ "R_MIPS16_26", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x3ffffff, /* src_mask */ 0x3ffffff, /* dst_mask */ - false); /* pcrel_offset */ + FALSE); /* pcrel_offset */ /* The reloc used for the mips16 gprel instruction. */ static reloc_howto_type elf_mips16_gprel_howto = @@ -1170,15 +1178,15 @@ static reloc_howto_type elf_mips16_gprel_howto = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 16, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_signed, /* complain_on_overflow */ mips16_gprel_reloc, /* special_function */ "R_MIPS16_GPREL", /* name */ - true, /* partial_inplace */ + TRUE, /* partial_inplace */ 0x07ff001f, /* src_mask */ 0x07ff001f, /* dst_mask */ - false); /* pcrel_offset */ + FALSE); /* pcrel_offset */ /* GNU extension to record C++ vtable hierarchy */ static reloc_howto_type elf_mips_gnu_vtinherit_howto = @@ -1186,15 +1194,15 @@ static reloc_howto_type elf_mips_gnu_vtinherit_howto = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ NULL, /* special_function */ "R_MIPS_GNU_VTINHERIT", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false); /* pcrel_offset */ + FALSE); /* pcrel_offset */ /* GNU extension to record C++ vtable member usage */ static reloc_howto_type elf_mips_gnu_vtentry_howto = @@ -1202,23 +1210,53 @@ static reloc_howto_type elf_mips_gnu_vtentry_howto = 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ - false, /* pc_relative */ + FALSE, /* pc_relative */ 0, /* bitpos */ complain_overflow_dont, /* complain_on_overflow */ _bfd_elf_rel_vtable_reloc_fn, /* special_function */ "R_MIPS_GNU_VTENTRY", /* name */ - false, /* partial_inplace */ + FALSE, /* partial_inplace */ 0, /* src_mask */ 0, /* dst_mask */ - false); /* pcrel_offset */ + FALSE); /* pcrel_offset */ + +/* 16 bit offset for pc-relative branches. */ +static reloc_howto_type elf_mips_gnu_rel16_s2 = + HOWTO (R_MIPS_GNU_REL16_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MIPS_GNU_REL16_S2", /* name */ + TRUE, /* partial_inplace */ + 0x0000ffff, /* src_mask */ + 0x0000ffff, /* dst_mask */ + TRUE); /* pcrel_offset */ + +/* 16 bit offset for pc-relative branches. */ +static reloc_howto_type elf_mips_gnu_rela16_s2 = + HOWTO (R_MIPS_GNU_REL16_S2, /* type */ + 2, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + TRUE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + _bfd_mips_elf_generic_reloc, /* special_function */ + "R_MIPS_GNU_REL16_S2", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0x0000ffff, /* dst_mask */ + TRUE); /* pcrel_offset */ /* Swap in a MIPS 64-bit Rel reloc. */ static void -mips_elf64_swap_reloc_in (abfd, src, dst) - bfd *abfd; - const Elf64_Mips_External_Rel *src; - Elf64_Mips_Internal_Rel *dst; +mips_elf64_swap_reloc_in (bfd *abfd, const Elf64_Mips_External_Rel *src, + Elf64_Mips_Internal_Rela *dst) { dst->r_offset = H_GET_64 (abfd, src->r_offset); dst->r_sym = H_GET_32 (abfd, src->r_sym); @@ -1226,15 +1264,14 @@ mips_elf64_swap_reloc_in (abfd, src, dst) dst->r_type3 = H_GET_8 (abfd, src->r_type3); dst->r_type2 = H_GET_8 (abfd, src->r_type2); dst->r_type = H_GET_8 (abfd, src->r_type); + dst->r_addend = 0; } /* Swap in a MIPS 64-bit Rela reloc. */ static void -mips_elf64_swap_reloca_in (abfd, src, dst) - bfd *abfd; - const Elf64_Mips_External_Rela *src; - Elf64_Mips_Internal_Rela *dst; +mips_elf64_swap_reloca_in (bfd *abfd, const Elf64_Mips_External_Rela *src, + Elf64_Mips_Internal_Rela *dst) { dst->r_offset = H_GET_64 (abfd, src->r_offset); dst->r_sym = H_GET_32 (abfd, src->r_sym); @@ -1248,10 +1285,8 @@ mips_elf64_swap_reloca_in (abfd, src, dst) /* Swap out a MIPS 64-bit Rel reloc. */ static void -mips_elf64_swap_reloc_out (abfd, src, dst) - bfd *abfd; - const Elf64_Mips_Internal_Rel *src; - Elf64_Mips_External_Rel *dst; +mips_elf64_swap_reloc_out (bfd *abfd, const Elf64_Mips_Internal_Rela *src, + Elf64_Mips_External_Rel *dst) { H_PUT_64 (abfd, src->r_offset, dst->r_offset); H_PUT_32 (abfd, src->r_sym, dst->r_sym); @@ -1264,10 +1299,8 @@ mips_elf64_swap_reloc_out (abfd, src, dst) /* Swap out a MIPS 64-bit Rela reloc. */ static void -mips_elf64_swap_reloca_out (abfd, src, dst) - bfd *abfd; - const Elf64_Mips_Internal_Rela *src; - Elf64_Mips_External_Rela *dst; +mips_elf64_swap_reloca_out (bfd *abfd, const Elf64_Mips_Internal_Rela *src, + Elf64_Mips_External_Rela *dst) { H_PUT_64 (abfd, src->r_offset, dst->r_offset); H_PUT_32 (abfd, src->r_sym, dst->r_sym); @@ -1281,12 +1314,10 @@ mips_elf64_swap_reloca_out (abfd, src, dst) /* Swap in a MIPS 64-bit Rel reloc. */ static void -mips_elf64_be_swap_reloc_in (abfd, src, dst) - bfd *abfd; - const bfd_byte *src; - Elf_Internal_Rel *dst; +mips_elf64_be_swap_reloc_in (bfd *abfd, const bfd_byte *src, + Elf_Internal_Rela *dst) { - Elf64_Mips_Internal_Rel mirel; + Elf64_Mips_Internal_Rela mirel; mips_elf64_swap_reloc_in (abfd, (const Elf64_Mips_External_Rel *) src, @@ -1294,19 +1325,20 @@ mips_elf64_be_swap_reloc_in (abfd, src, dst) dst[0].r_offset = mirel.r_offset; dst[0].r_info = ELF64_R_INFO (mirel.r_sym, mirel.r_type); + dst[0].r_addend = 0; dst[1].r_offset = mirel.r_offset; dst[1].r_info = ELF64_R_INFO (mirel.r_ssym, mirel.r_type2); + dst[1].r_addend = 0; dst[2].r_offset = mirel.r_offset; dst[2].r_info = ELF64_R_INFO (STN_UNDEF, mirel.r_type3); + dst[2].r_addend = 0; } /* Swap in a MIPS 64-bit Rela reloc. */ static void -mips_elf64_be_swap_reloca_in (abfd, src, dst) - bfd *abfd; - const bfd_byte *src; - Elf_Internal_Rela *dst; +mips_elf64_be_swap_reloca_in (bfd *abfd, const bfd_byte *src, + Elf_Internal_Rela *dst) { Elf64_Mips_Internal_Rela mirela; @@ -1328,22 +1360,22 @@ mips_elf64_be_swap_reloca_in (abfd, src, dst) /* Swap out a MIPS 64-bit Rel reloc. */ static void -mips_elf64_be_swap_reloc_out (abfd, src, dst) - bfd *abfd; - const Elf_Internal_Rel *src; - bfd_byte *dst; +mips_elf64_be_swap_reloc_out (bfd *abfd, const Elf_Internal_Rela *src, + bfd_byte *dst) { - Elf64_Mips_Internal_Rel mirel; + Elf64_Mips_Internal_Rela mirel; mirel.r_offset = src[0].r_offset; BFD_ASSERT(src[0].r_offset == src[1].r_offset); +#if 0 BFD_ASSERT(src[0].r_offset == src[2].r_offset); +#endif mirel.r_type = ELF64_MIPS_R_TYPE (src[0].r_info); mirel.r_sym = ELF64_R_SYM (src[0].r_info); - mirel.r_type2 = ELF64_MIPS_R_TYPE2 (src[1].r_info); + mirel.r_type2 = ELF64_MIPS_R_TYPE (src[1].r_info); mirel.r_ssym = ELF64_MIPS_R_SSYM (src[1].r_info); - mirel.r_type3 = ELF64_MIPS_R_TYPE3 (src[2].r_info); + mirel.r_type3 = ELF64_MIPS_R_TYPE (src[2].r_info); mips_elf64_swap_reloc_out (abfd, &mirel, (Elf64_Mips_External_Rel *) dst); @@ -1352,10 +1384,8 @@ mips_elf64_be_swap_reloc_out (abfd, src, dst) /* Swap out a MIPS 64-bit Rela reloc. */ static void -mips_elf64_be_swap_reloca_out (abfd, src, dst) - bfd *abfd; - const Elf_Internal_Rela *src; - bfd_byte *dst; +mips_elf64_be_swap_reloca_out (bfd *abfd, const Elf_Internal_Rela *src, + bfd_byte *dst) { Elf64_Mips_Internal_Rela mirela; @@ -1369,89 +1399,19 @@ mips_elf64_be_swap_reloca_out (abfd, src, dst) BFD_ASSERT(src[1].r_addend == 0); BFD_ASSERT(src[2].r_addend == 0); - mirela.r_type2 = ELF64_MIPS_R_TYPE2 (src[1].r_info); + mirela.r_type2 = ELF64_MIPS_R_TYPE (src[1].r_info); mirela.r_ssym = ELF64_MIPS_R_SSYM (src[1].r_info); - mirela.r_type3 = ELF64_MIPS_R_TYPE3 (src[2].r_info); + mirela.r_type3 = ELF64_MIPS_R_TYPE (src[2].r_info); mips_elf64_swap_reloca_out (abfd, &mirela, (Elf64_Mips_External_Rela *) dst); } -/* Do a R_MIPS_HI16 relocation. */ - -static bfd_reloc_status_type -mips_elf64_hi16_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *reloc_entry; - asymbol *symbol; - PTR data ATTRIBUTE_UNUSED; - asection *input_section; - bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; -{ - /* If we're relocating, and this is an external symbol, we don't - want to change anything. */ - if (output_bfd != (bfd *) NULL - && (symbol->flags & BSF_SECTION_SYM) == 0 - && (! reloc_entry->howto->partial_inplace - || reloc_entry->addend == 0)) - { - reloc_entry->address += input_section->output_offset; - return bfd_reloc_ok; - } - - if (((reloc_entry->addend & 0xffff) + 0x8000) & ~0xffff) - reloc_entry->addend += 0x8000; - - return bfd_reloc_continue; -} - -/* Do a R_MIPS_GOT16 reloc. This is a reloc against the global offset - table used for PIC code. If the symbol is an external symbol, the - instruction is modified to contain the offset of the appropriate - entry in the global offset table. If the symbol is a section - symbol, the next reloc is a R_MIPS_LO16 reloc. The two 16 bit - addends are combined to form the real addend against the section - symbol; the GOT16 is modified to contain the offset of an entry in - the global offset table, and the LO16 is modified to offset it - appropriately. Thus an offset larger than 16 bits requires a - modified value in the global offset table. - - This implementation suffices for the assembler, but the linker does - not yet know how to create global offset tables. */ - -static bfd_reloc_status_type -mips_elf64_got16_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; -{ - /* If we're relocating, and this is a local symbol, we can handle it - just like an R_MIPS_HI16. */ - if (output_bfd != (bfd *) NULL - && (symbol->flags & BSF_SECTION_SYM) != 0) - return mips_elf64_hi16_reloc (abfd, reloc_entry, symbol, data, - input_section, output_bfd, error_message); - - - /* Otherwise we try to handle it as R_MIPS_GOT_DISP. */ - return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, - input_section, output_bfd, error_message); -} - -/* Set the GP value for OUTPUT_BFD. Returns false if this is a +/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a dangerous relocation. */ -static boolean -mips_elf64_assign_gp (output_bfd, pgp) - bfd *output_bfd; - bfd_vma *pgp; +static bfd_boolean +mips_elf64_assign_gp (bfd *output_bfd, bfd_vma *pgp) { unsigned int count; asymbol **sym; @@ -1460,14 +1420,14 @@ mips_elf64_assign_gp (output_bfd, pgp) /* If we've already figured out what GP will be, just return it. */ *pgp = _bfd_get_gp_value (output_bfd); if (*pgp) - return true; + return TRUE; count = bfd_get_symcount (output_bfd); sym = bfd_get_outsymbols (output_bfd); /* The linker script will have created a symbol named `_gp' with the appropriate value. */ - if (sym == (asymbol **) NULL) + if (sym == NULL) i = count; else { @@ -1490,28 +1450,24 @@ mips_elf64_assign_gp (output_bfd, pgp) /* Only get the error once. */ *pgp = 4; _bfd_set_gp_value (output_bfd, *pgp); - return false; + return FALSE; } - return true; + return TRUE; } /* We have to figure out the gp value, so that we can adjust the symbol value correctly. We look up the symbol _gp in the output BFD. If we can't find it, we're stuck. We cache it in the ELF target data. We don't need to adjust the symbol value for an - external symbol if we are producing relocateable output. */ + external symbol if we are producing relocatable output. */ static bfd_reloc_status_type -mips_elf64_final_gp (output_bfd, symbol, relocateable, error_message, pgp) - bfd *output_bfd; - asymbol *symbol; - boolean relocateable; - char **error_message; - bfd_vma *pgp; +mips_elf64_final_gp (bfd *output_bfd, asymbol *symbol, bfd_boolean relocatable, + char **error_message, bfd_vma *pgp) { if (bfd_is_und_section (symbol->section) - && ! relocateable) + && ! relocatable) { *pgp = 0; return bfd_reloc_undefined; @@ -1519,13 +1475,13 @@ mips_elf64_final_gp (output_bfd, symbol, relocateable, error_message, pgp) *pgp = _bfd_get_gp_value (output_bfd); if (*pgp == 0 - && (! relocateable + && (! relocatable || (symbol->flags & BSF_SECTION_SYM) != 0)) { - if (relocateable) + if (relocatable) { /* Make up a value. */ - *pgp = symbol->section->output_section->vma + 0x4000; + *pgp = symbol->section->output_section->vma /*+ 0x4000*/; _bfd_set_gp_value (output_bfd, *pgp); } else if (!mips_elf64_assign_gp (output_bfd, pgp)) @@ -1543,95 +1499,79 @@ mips_elf64_final_gp (output_bfd, symbol, relocateable, error_message, pgp) become the offset from the gp register. */ static bfd_reloc_status_type -mips_elf64_gprel16_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +mips_elf64_gprel16_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, + void *data, asection *input_section, bfd *output_bfd, + char **error_message) { - boolean relocateable; + bfd_boolean relocatable; bfd_reloc_status_type ret; bfd_vma gp; - /* If we're relocating, and this is an external symbol with no - addend, we don't want to change anything. We will only have an - addend if this is a newly created reloc, not read from an ELF - file. */ - if (output_bfd != (bfd *) NULL + /* If we're relocating, and this is an external symbol, we don't want + to change anything. */ + if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 - && (! reloc_entry->howto->partial_inplace - || reloc_entry->addend == 0)) + && (symbol->flags & BSF_LOCAL) != 0) { reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; } - if (output_bfd != (bfd *) NULL) - relocateable = true; + if (output_bfd != NULL) + relocatable = TRUE; else { - relocateable = false; + relocatable = FALSE; output_bfd = symbol->section->output_section->owner; } - ret = mips_elf64_final_gp (output_bfd, symbol, relocateable, error_message, + ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message, &gp); if (ret != bfd_reloc_ok) return ret; return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry, - input_section, relocateable, + input_section, relocatable, data, gp); } /* Do a R_MIPS_LITERAL relocation. */ static bfd_reloc_status_type -mips_elf64_literal_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +mips_elf64_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, + void *data, asection *input_section, bfd *output_bfd, + char **error_message) { - boolean relocateable; + bfd_boolean relocatable; bfd_reloc_status_type ret; bfd_vma gp; /* If we're relocating, and this is an external symbol, we don't want to change anything. */ - if (output_bfd != (bfd *) NULL + if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 - && (! reloc_entry->howto->partial_inplace - || reloc_entry->addend == 0)) + && (symbol->flags & BSF_LOCAL) != 0) { reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; } /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */ - if (output_bfd != (bfd *) NULL) - relocateable = true; + if (output_bfd != NULL) + relocatable = TRUE; else { - relocateable = false; + relocatable = FALSE; output_bfd = symbol->section->output_section->owner; } - ret = mips_elf64_final_gp (output_bfd, symbol, relocateable, error_message, + ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message, &gp); if (ret != bfd_reloc_ok) return ret; return _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry, - input_section, relocateable, + input_section, relocatable, data, gp); } @@ -1639,51 +1579,41 @@ mips_elf64_literal_reloc (abfd, reloc_entry, symbol, data, input_section, become the offset from the gp register. */ static bfd_reloc_status_type -mips_elf64_gprel32_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, + void *data, asection *input_section, bfd *output_bfd, + char **error_message) { - boolean relocateable; + bfd_boolean relocatable; bfd_reloc_status_type ret; bfd_vma gp; bfd_vma relocation; - unsigned long val; + bfd_vma val; + bfd_size_type sz; - /* If we're relocating, and this is an external symbol with no - addend, we don't want to change anything. We will only have an - addend if this is a newly created reloc, not read from an ELF - file. */ - if (output_bfd != (bfd *) NULL + /* If we're relocating, and this is an external symbol, we don't want + to change anything. */ + if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 - && reloc_entry->addend == 0) + && (symbol->flags & BSF_LOCAL) != 0) { *error_message = (char *) _("32bits gp relative relocation occurs for an external symbol"); return bfd_reloc_outofrange; } - if (output_bfd != (bfd *) NULL) - { - relocateable = true; - gp = _bfd_get_gp_value (output_bfd); - } + if (output_bfd != NULL) + relocatable = TRUE; else { - relocateable = false; + relocatable = FALSE; output_bfd = symbol->section->output_section->owner; - - ret = mips_elf64_final_gp (output_bfd, symbol, relocateable, - error_message, &gp); - if (ret != bfd_reloc_ok) - return ret; } + ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, + error_message, &gp); + if (ret != bfd_reloc_ok) + return ret; + if (bfd_is_com_section (symbol->section)) relocation = 0; else @@ -1692,30 +1622,29 @@ mips_elf64_gprel32_reloc (abfd, reloc_entry, symbol, data, input_section, relocation += symbol->section->output_section->vma; relocation += symbol->section->output_offset; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; - if (reloc_entry->howto->src_mask == 0) - { - /* This case arises with the 64-bit MIPS ELF ABI. */ - val = 0; - } - else - val = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); - /* Set val to the offset into the section or symbol. */ - val += reloc_entry->addend; + val = reloc_entry->addend; + + if (reloc_entry->howto->partial_inplace) + val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); /* Adjust val for the final section location and GP value. If we - are producing relocateable output, we don't want to do this for + are producing relocatable output, we don't want to do this for an external symbol. */ - if (! relocateable + if (! relocatable || (symbol->flags & BSF_SECTION_SYM) != 0) val += relocation - gp; - bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address); + if (reloc_entry->howto->partial_inplace) + bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address); + else + reloc_entry->addend = val; - if (relocateable) + if (relocatable) reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; @@ -1725,47 +1654,30 @@ mips_elf64_gprel32_reloc (abfd, reloc_entry, symbol, data, input_section, the rest is at bits 6-10. The bitpos already got right by the howto. */ static bfd_reloc_status_type -mips_elf64_shift6_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *reloc_entry; - asymbol *symbol; - PTR data ATTRIBUTE_UNUSED; - asection *input_section; - bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; +mips_elf64_shift6_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, + void *data, asection *input_section, bfd *output_bfd, + char **error_message) { - /* If we're relocating, and this is an external symbol, we don't - want to change anything. */ - if (output_bfd != (bfd *) NULL - && (symbol->flags & BSF_SECTION_SYM) == 0 - && (! reloc_entry->howto->partial_inplace - || reloc_entry->addend == 0)) + if (reloc_entry->howto->partial_inplace) { - reloc_entry->address += input_section->output_offset; - return bfd_reloc_ok; + reloc_entry->addend = ((reloc_entry->addend & 0x00007c0) + | (reloc_entry->addend & 0x00000800) >> 9); } - reloc_entry->addend = (reloc_entry->addend & 0x00007c0) - | (reloc_entry->addend & 0x00000800) >> 9; - - return bfd_reloc_continue; + return _bfd_mips_elf_generic_reloc (abfd, reloc_entry, symbol, data, + input_section, output_bfd, + error_message); } /* Handle a mips16 jump. */ static bfd_reloc_status_type -mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *reloc_entry; - asymbol *symbol; - PTR data ATTRIBUTE_UNUSED; - asection *input_section; - bfd *output_bfd; - char **error_message ATTRIBUTE_UNUSED; +mips16_jump_reloc (bfd *abfd ATTRIBUTE_UNUSED, arelent *reloc_entry, + asymbol *symbol, void *data ATTRIBUTE_UNUSED, + asection *input_section, bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) { - if (output_bfd != (bfd *) NULL + if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 && (! reloc_entry->howto->partial_inplace || reloc_entry->addend == 0)) @@ -1776,13 +1688,13 @@ mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section, /* FIXME. */ { - static boolean warned; + static bfd_boolean warned; if (! warned) (*_bfd_error_handler) (_("Linking mips16 objects into %s format is not supported"), bfd_get_target (input_section->output_section->owner)); - warned = true; + warned = TRUE; } return bfd_reloc_undefined; @@ -1791,77 +1703,92 @@ mips16_jump_reloc (abfd, reloc_entry, symbol, data, input_section, /* Handle a mips16 GP relative reloc. */ static bfd_reloc_status_type -mips16_gprel_reloc (abfd, reloc_entry, symbol, data, input_section, - output_bfd, error_message) - bfd *abfd; - arelent *reloc_entry; - asymbol *symbol; - PTR data; - asection *input_section; - bfd *output_bfd; - char **error_message; +mips16_gprel_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, + void *data, asection *input_section, bfd *output_bfd, + char **error_message) { - boolean relocateable; + bfd_boolean relocatable; bfd_reloc_status_type ret; bfd_vma gp; - unsigned short extend, insn; - unsigned long final; + unsigned short extend = 0; + unsigned short insn = 0; + bfd_signed_vma val; + bfd_vma relocation; + bfd_size_type sz; /* If we're relocating, and this is an external symbol with no - addend, we don't want to change anything. We will only have an - addend if this is a newly created reloc, not read from an ELF - file. */ + addend, we don't want to change anything. */ if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 - && reloc_entry->addend == 0) + && (symbol->flags & BSF_LOCAL) != 0) { reloc_entry->address += input_section->output_offset; return bfd_reloc_ok; } if (output_bfd != NULL) - relocateable = true; + relocatable = TRUE; else { - relocateable = false; + relocatable = FALSE; output_bfd = symbol->section->output_section->owner; } - ret = mips_elf64_final_gp (output_bfd, symbol, relocateable, error_message, + ret = mips_elf64_final_gp (output_bfd, symbol, relocatable, error_message, &gp); if (ret != bfd_reloc_ok) return ret; - if (reloc_entry->address > input_section->_cooked_size) + sz = input_section->rawsize ? input_section->rawsize : input_section->size; + if (reloc_entry->address > sz) return bfd_reloc_outofrange; - /* Pick up the mips16 extend instruction and the real instruction. */ - extend = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address); - insn = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address + 2); - - /* Stuff the current addend back as a 32 bit value, do the usual - relocation, and then clean up. */ - bfd_put_32 (abfd, - (bfd_vma) (((extend & 0x1f) << 11) - | (extend & 0x7e0) - | (insn & 0x1f)), - (bfd_byte *) data + reloc_entry->address); - - ret = _bfd_mips_elf_gprel16_with_gp (abfd, symbol, reloc_entry, - input_section, relocateable, data, gp); - - final = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address); - bfd_put_16 (abfd, - (bfd_vma) ((extend & 0xf800) - | ((final >> 11) & 0x1f) - | (final & 0x7e0)), - (bfd_byte *) data + reloc_entry->address); - bfd_put_16 (abfd, - (bfd_vma) ((insn & 0xffe0) - | (final & 0x1f)), - (bfd_byte *) data + reloc_entry->address + 2); + if (bfd_is_com_section (symbol->section)) + relocation = 0; + else + relocation = symbol->value; - return ret; + relocation += symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + + /* Set val to the offset into the section or symbol. */ + val = reloc_entry->addend; + + if (reloc_entry->howto->partial_inplace) + { + /* Pick up the mips16 extend instruction and the real instruction. */ + extend = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address); + insn = bfd_get_16 (abfd, (bfd_byte *) data + reloc_entry->address + 2); + val += ((extend & 0x1f) << 11) | (extend & 0x7e0) | (insn & 0x1f); + } + + _bfd_mips_elf_sign_extend(val, 16); + + /* Adjust val for the final section location and GP value. If we + are producing relocatable output, we don't want to do this for + an external symbol. */ + if (! relocatable + || (symbol->flags & BSF_SECTION_SYM) != 0) + val += relocation - gp; + + if (reloc_entry->howto->partial_inplace) + { + bfd_put_16 (abfd, + (extend & 0xf800) | ((val >> 11) & 0x1f) | (val & 0x7e0), + (bfd_byte *) data + reloc_entry->address); + bfd_put_16 (abfd, + (insn & 0xffe0) | (val & 0x1f), + (bfd_byte *) data + reloc_entry->address + 2); + } + else + reloc_entry->addend = val; + + if (relocatable) + reloc_entry->address += input_section->output_offset; + else if (((val & ~0xffff) != ~0xffff) && ((val & ~0xffff) != 0)) + return bfd_reloc_overflow; + + return bfd_reloc_ok; } /* A mapping from BFD reloc types to MIPS ELF reloc types. */ @@ -1913,9 +1840,8 @@ static const struct elf_reloc_map mips_reloc_map[] = /* Given a BFD reloc type, return a howto structure. */ static reloc_howto_type * -bfd_elf64_bfd_reloc_type_lookup (abfd, code) - bfd *abfd ATTRIBUTE_UNUSED; - bfd_reloc_code_real_type code; +bfd_elf64_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, + bfd_reloc_code_real_type code) { unsigned int i; /* FIXME: We default to RELA here instead of choosing the right @@ -1939,18 +1865,18 @@ bfd_elf64_bfd_reloc_type_lookup (abfd, code) return &elf_mips_gnu_vtinherit_howto; case BFD_RELOC_VTABLE_ENTRY: return &elf_mips_gnu_vtentry_howto; + case BFD_RELOC_16_PCREL_S2: + return &elf_mips_gnu_rela16_s2; default: bfd_set_error (bfd_error_bad_value); return NULL; } } -/* Given a MIPS Elf64_Internal_Rel, fill in an arelent structure. */ +/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ static reloc_howto_type * -mips_elf64_rtype_to_howto (r_type, rela_p) - unsigned int r_type; - boolean rela_p; +mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p) { switch (r_type) { @@ -1962,6 +1888,11 @@ mips_elf64_rtype_to_howto (r_type, rela_p) return &elf_mips_gnu_vtinherit_howto; case R_MIPS_GNU_VTENTRY: return &elf_mips_gnu_vtentry_howto; + case R_MIPS_GNU_REL16_S2: + if (rela_p) + return &elf_mips_gnu_rela16_s2; + else + return &elf_mips_gnu_rel16_s2; default: BFD_ASSERT (r_type < (unsigned int) R_MIPS_max); if (rela_p) @@ -1975,19 +1906,17 @@ mips_elf64_rtype_to_howto (r_type, rela_p) /* Prevent relocation handling by bfd for MIPS ELF64. */ static void -mips_elf64_info_to_howto_rel (abfd, cache_ptr, dst) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *cache_ptr ATTRIBUTE_UNUSED; - Elf64_Internal_Rel *dst ATTRIBUTE_UNUSED; +mips_elf64_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, + arelent *cache_ptr ATTRIBUTE_UNUSED, + Elf_Internal_Rela *dst ATTRIBUTE_UNUSED) { BFD_ASSERT (0); } static void -mips_elf64_info_to_howto_rela (abfd, cache_ptr, dst) - bfd *abfd ATTRIBUTE_UNUSED; - arelent *cache_ptr ATTRIBUTE_UNUSED; - Elf64_Internal_Rela *dst ATTRIBUTE_UNUSED; +mips_elf64_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, + arelent *cache_ptr ATTRIBUTE_UNUSED, + Elf_Internal_Rela *dst ATTRIBUTE_UNUSED) { BFD_ASSERT (0); } @@ -1996,59 +1925,128 @@ mips_elf64_info_to_howto_rela (abfd, cache_ptr, dst) to three relocs, we must tell the user to allocate more space. */ static long -mips_elf64_get_reloc_upper_bound (abfd, sec) - bfd *abfd ATTRIBUTE_UNUSED; - asection *sec; +mips_elf64_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, asection *sec) { return (sec->reloc_count * 3 + 1) * sizeof (arelent *); } -/* Read the relocations from one reloc section. */ +static long +mips_elf64_get_dynamic_reloc_upper_bound (bfd *abfd) +{ + return _bfd_elf_get_dynamic_reloc_upper_bound (abfd) * 3; +} + +/* We must also copy more relocations than the corresponding functions + in elf.c would, so the two following functions are slightly + modified from elf.c, that multiply the external relocation count by + 3 to obtain the internal relocation count. */ -static boolean -mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) - bfd *abfd; - asection *asect; - asymbol **symbols; - const Elf_Internal_Shdr *rel_hdr; +static long +mips_elf64_canonicalize_reloc (bfd *abfd, sec_ptr section, + arelent **relptr, asymbol **symbols) { - PTR allocated = NULL; + arelent *tblptr; + unsigned int i; + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + + if (! bed->s->slurp_reloc_table (abfd, section, symbols, FALSE)) + return -1; + + tblptr = section->relocation; + for (i = 0; i < section->reloc_count * 3; i++) + *relptr++ = tblptr++; + + *relptr = NULL; + + return section->reloc_count * 3; +} + +static long +mips_elf64_canonicalize_dynamic_reloc (bfd *abfd, arelent **storage, + asymbol **syms) +{ + bfd_boolean (*slurp_relocs) (bfd *, asection *, asymbol **, bfd_boolean); + asection *s; + long ret; + + if (elf_dynsymtab (abfd) == 0) + { + bfd_set_error (bfd_error_invalid_operation); + return -1; + } + + slurp_relocs = get_elf_backend_data (abfd)->s->slurp_reloc_table; + ret = 0; + for (s = abfd->sections; s != NULL; s = s->next) + { + if (elf_section_data (s)->this_hdr.sh_link == elf_dynsymtab (abfd) + && (elf_section_data (s)->this_hdr.sh_type == SHT_REL + || elf_section_data (s)->this_hdr.sh_type == SHT_RELA)) + { + arelent *p; + long count, i; + + if (! (*slurp_relocs) (abfd, s, syms, TRUE)) + return -1; + count = s->size / elf_section_data (s)->this_hdr.sh_entsize * 3; + p = s->relocation; + for (i = 0; i < count; i++) + *storage++ = p++; + ret += count; + } + } + + *storage = NULL; + + return ret; +} + +/* Read the relocations from one reloc section. This is mostly copied + from elfcode.h, except for the changes to expand one external + relocation to 3 internal ones. We must unfortunately set + reloc_count to the number of external relocations, because a lot of + generic code seems to depend on this. */ + +static bfd_boolean +mips_elf64_slurp_one_reloc_table (bfd *abfd, asection *asect, + Elf_Internal_Shdr *rel_hdr, + bfd_size_type reloc_count, + arelent *relents, asymbol **symbols, + bfd_boolean dynamic) +{ + void *allocated; bfd_byte *native_relocs; - arelent *relents; arelent *relent; - bfd_vma count; bfd_vma i; int entsize; - reloc_howto_type *howto_table; + bfd_boolean rela_p; - allocated = (PTR) bfd_malloc (rel_hdr->sh_size); + allocated = bfd_malloc (rel_hdr->sh_size); if (allocated == NULL) - return false; + return FALSE; if (bfd_seek (abfd, rel_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_bread (allocated, rel_hdr->sh_size, abfd) != rel_hdr->sh_size)) + || (bfd_bread (allocated, rel_hdr->sh_size, abfd) + != rel_hdr->sh_size)) goto error_return; - native_relocs = (bfd_byte *) allocated; - - relents = asect->relocation + asect->reloc_count; + native_relocs = allocated; entsize = rel_hdr->sh_entsize; BFD_ASSERT (entsize == sizeof (Elf64_Mips_External_Rel) || entsize == sizeof (Elf64_Mips_External_Rela)); - count = rel_hdr->sh_size / entsize; - if (entsize == sizeof (Elf64_Mips_External_Rel)) - howto_table = mips_elf64_howto_table_rel; + rela_p = FALSE; else - howto_table = mips_elf64_howto_table_rela; + rela_p = TRUE; - relent = relents; - for (i = 0; i < count; i++, native_relocs += entsize) + for (i = 0, relent = relents; + i < reloc_count; + i++, native_relocs += entsize) { Elf64_Mips_Internal_Rela rela; - boolean used_sym, used_ssym; + bfd_boolean used_sym, used_ssym; int ir; if (entsize == sizeof (Elf64_Mips_External_Rela)) @@ -2056,25 +2054,14 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) (Elf64_Mips_External_Rela *) native_relocs, &rela); else - { - Elf64_Mips_Internal_Rel rel; - - mips_elf64_swap_reloc_in (abfd, - (Elf64_Mips_External_Rel *) native_relocs, - &rel); - rela.r_offset = rel.r_offset; - rela.r_sym = rel.r_sym; - rela.r_ssym = rel.r_ssym; - rela.r_type3 = rel.r_type3; - rela.r_type2 = rel.r_type2; - rela.r_type = rel.r_type; - rela.r_addend = 0; - } + mips_elf64_swap_reloc_in (abfd, + (Elf64_Mips_External_Rel *) native_relocs, + &rela); - /* Each entry represents up to three actual relocations. */ + /* Each entry represents exactly three actual relocations. */ - used_sym = false; - used_ssym = false; + used_sym = FALSE; + used_ssym = FALSE; for (ir = 0; ir < 3; ir++) { enum elf_mips_reloc_type type; @@ -2094,27 +2081,6 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) break; } - if (type == R_MIPS_NONE) - { - /* There are no more relocations in this entry. If this - is the first entry, we need to generate a dummy - relocation so that the generic linker knows that - there has been a break in the sequence of relocations - applying to a particular address. */ - if (ir == 0) - { - relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; - if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) - relent->address = rela.r_offset; - else - relent->address = rela.r_offset - asect->vma; - relent->addend = 0; - relent->howto = &howto_table[(int) R_MIPS_NONE]; - ++relent; - } - break; - } - /* Some types require symbols, whereas some do not. */ switch (type) { @@ -2143,7 +2109,7 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) relent->sym_ptr_ptr = s->section->symbol_ptr_ptr; } - used_sym = true; + used_sym = TRUE; } else if (! used_ssym) { @@ -2167,7 +2133,7 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) break; } - used_ssym = true; + used_ssym = TRUE; } else relent->sym_ptr_ptr = bfd_abs_section_ptr->symbol_ptr_ptr; @@ -2179,87 +2145,117 @@ mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, rel_hdr) object file, and absolute for an executable file or shared library. The address of a BFD reloc is always section relative. */ - if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) + if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 || dynamic) relent->address = rela.r_offset; else relent->address = rela.r_offset - asect->vma; relent->addend = rela.r_addend; - relent->howto = &howto_table[(int) type]; + relent->howto = mips_elf64_rtype_to_howto (type, rela_p); ++relent; } } - asect->reloc_count += relent - relents; + asect->reloc_count += (relent - relents) / 3; if (allocated != NULL) free (allocated); - return true; + return TRUE; error_return: if (allocated != NULL) free (allocated); - return false; + return FALSE; } /* Read the relocations. On Irix 6, there can be two reloc sections - associated with a single data section. */ - -static boolean -mips_elf64_slurp_reloc_table (abfd, asect, symbols, dynamic) - bfd *abfd; - asection *asect; - asymbol **symbols; - boolean dynamic; + associated with a single data section. This is copied from + elfcode.h as well, with changes as small as accounting for 3 + internal relocs per external reloc and resetting reloc_count to + zero before processing the relocs of a section. */ + +static bfd_boolean +mips_elf64_slurp_reloc_table (bfd *abfd, asection *asect, + asymbol **symbols, bfd_boolean dynamic) { - bfd_size_type amt; struct bfd_elf_section_data * const d = elf_section_data (asect); + Elf_Internal_Shdr *rel_hdr; + Elf_Internal_Shdr *rel_hdr2; + bfd_size_type reloc_count; + bfd_size_type reloc_count2; + arelent *relents; + bfd_size_type amt; + + if (asect->relocation != NULL) + return TRUE; - if (dynamic) + if (! dynamic) { - bfd_set_error (bfd_error_invalid_operation); - return false; - } + if ((asect->flags & SEC_RELOC) == 0 + || asect->reloc_count == 0) + return TRUE; + + rel_hdr = &d->rel_hdr; + reloc_count = NUM_SHDR_ENTRIES (rel_hdr); + rel_hdr2 = d->rel_hdr2; + reloc_count2 = (rel_hdr2 ? NUM_SHDR_ENTRIES (rel_hdr2) : 0); + + BFD_ASSERT (asect->reloc_count == reloc_count + reloc_count2); + BFD_ASSERT (asect->rel_filepos == rel_hdr->sh_offset + || (rel_hdr2 && asect->rel_filepos == rel_hdr2->sh_offset)); - if (asect->relocation != NULL - || (asect->flags & SEC_RELOC) == 0 - || asect->reloc_count == 0) - return true; + } + else + { + /* Note that ASECT->RELOC_COUNT tends not to be accurate in this + case because relocations against this section may use the + dynamic symbol table, and in that case bfd_section_from_shdr + in elf.c does not update the RELOC_COUNT. */ + if (asect->size == 0) + return TRUE; + + rel_hdr = &d->this_hdr; + reloc_count = NUM_SHDR_ENTRIES (rel_hdr); + rel_hdr2 = NULL; + reloc_count2 = 0; + } /* Allocate space for 3 arelent structures for each Rel structure. */ - amt = asect->reloc_count; - amt *= 3 * sizeof (arelent); - asect->relocation = (arelent *) bfd_alloc (abfd, amt); - if (asect->relocation == NULL) - return false; + amt = (reloc_count + reloc_count2) * 3 * sizeof (arelent); + relents = bfd_alloc (abfd, amt); + if (relents == NULL) + return FALSE; /* The slurp_one_reloc_table routine increments reloc_count. */ asect->reloc_count = 0; - if (! mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, &d->rel_hdr)) - return false; + if (! mips_elf64_slurp_one_reloc_table (abfd, asect, + rel_hdr, reloc_count, + relents, + symbols, dynamic)) + return FALSE; if (d->rel_hdr2 != NULL) { - if (! mips_elf64_slurp_one_reloc_table (abfd, asect, symbols, - d->rel_hdr2)) - return false; + if (! mips_elf64_slurp_one_reloc_table (abfd, asect, + rel_hdr2, reloc_count2, + relents + reloc_count * 3, + symbols, dynamic)) + return FALSE; } - return true; + asect->relocation = relents; + return TRUE; } /* Write out the relocations. */ static void -mips_elf64_write_relocs (abfd, sec, data) - bfd *abfd; - asection *sec; - PTR data; +mips_elf64_write_relocs (bfd *abfd, asection *sec, void *data) { - boolean *failedp = (boolean *) data; + bfd_boolean *failedp = data; int count; Elf_Internal_Shdr *rel_hdr; unsigned int idx; @@ -2320,24 +2316,21 @@ mips_elf64_write_relocs (abfd, sec, data) } static void -mips_elf64_write_rel (abfd, sec, rel_hdr, count, data) - bfd *abfd; - asection *sec; - Elf_Internal_Shdr *rel_hdr; - int *count; - PTR data; +mips_elf64_write_rel (bfd *abfd, asection *sec, + Elf_Internal_Shdr *rel_hdr, + int *count, void *data) { - boolean *failedp = (boolean *) data; + bfd_boolean *failedp = data; Elf64_Mips_External_Rel *ext_rel; unsigned int idx; asymbol *last_sym = 0; int last_sym_idx = 0; - rel_hdr->sh_size = (bfd_vma)(rel_hdr->sh_entsize * *count); - rel_hdr->contents = (PTR) bfd_alloc (abfd, rel_hdr->sh_size); + rel_hdr->sh_size = rel_hdr->sh_entsize * *count; + rel_hdr->contents = bfd_alloc (abfd, rel_hdr->sh_size); if (rel_hdr->contents == NULL) { - *failedp = true; + *failedp = TRUE; return; } @@ -2345,7 +2338,7 @@ mips_elf64_write_rel (abfd, sec, rel_hdr, count, data) for (idx = 0; idx < sec->reloc_count; idx++, ext_rel++) { arelent *ptr; - Elf64_Mips_Internal_Rel int_rel; + Elf64_Mips_Internal_Rela int_rel; asymbol *sym; int n; unsigned int i; @@ -2369,7 +2362,7 @@ mips_elf64_write_rel (abfd, sec, rel_hdr, count, data) n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym); if (n < 0) { - *failedp = true; + *failedp = TRUE; return; } last_sym_idx = n; @@ -2381,7 +2374,7 @@ mips_elf64_write_rel (abfd, sec, rel_hdr, count, data) if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec && ! _bfd_elf_validate_reloc (abfd, ptr)) { - *failedp = true; + *failedp = TRUE; return; } @@ -2419,24 +2412,21 @@ mips_elf64_write_rel (abfd, sec, rel_hdr, count, data) } static void -mips_elf64_write_rela (abfd, sec, rela_hdr, count, data) - bfd *abfd; - asection *sec; - Elf_Internal_Shdr *rela_hdr; - int *count; - PTR data; +mips_elf64_write_rela (bfd *abfd, asection *sec, + Elf_Internal_Shdr *rela_hdr, + int *count, void *data) { - boolean *failedp = (boolean *) data; + bfd_boolean *failedp = data; Elf64_Mips_External_Rela *ext_rela; unsigned int idx; asymbol *last_sym = 0; int last_sym_idx = 0; - rela_hdr->sh_size = (bfd_vma)(rela_hdr->sh_entsize * *count); - rela_hdr->contents = (PTR) bfd_alloc (abfd, rela_hdr->sh_size); + rela_hdr->sh_size = rela_hdr->sh_entsize * *count; + rela_hdr->contents = bfd_alloc (abfd, rela_hdr->sh_size); if (rela_hdr->contents == NULL) { - *failedp = true; + *failedp = TRUE; return; } @@ -2468,7 +2458,7 @@ mips_elf64_write_rela (abfd, sec, rela_hdr, count, data) n = _bfd_elf_symbol_from_bfd_symbol (abfd, &sym); if (n < 0) { - *failedp = true; + *failedp = TRUE; return; } last_sym_idx = n; @@ -2481,7 +2471,7 @@ mips_elf64_write_rela (abfd, sec, rela_hdr, count, data) if ((*ptr->sym_ptr_ptr)->the_bfd->xvec != abfd->xvec && ! _bfd_elf_validate_reloc (abfd, ptr)) { - *failedp = true; + *failedp = TRUE; return; } @@ -2520,9 +2510,8 @@ mips_elf64_write_rela (abfd, sec, rela_hdr, count, data) /* Set the right machine number for a MIPS ELF file. */ -static boolean -mips_elf64_object_p (abfd) - bfd *abfd; +static bfd_boolean +mips_elf64_object_p (bfd *abfd) { unsigned long mach; @@ -2530,18 +2519,17 @@ mips_elf64_object_p (abfd) sorted correctly such that local symbols precede global symbols, and the sh_info field in the symbol table is not always right. */ if (elf64_mips_irix_compat (abfd) != ict_none) - elf_bad_symtab (abfd) = true; + elf_bad_symtab (abfd) = TRUE; mach = _bfd_elf_mips_mach (elf_elfheader (abfd)->e_flags); bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach); - return true; + return TRUE; } /* Depending on the target vector we generate some version of Irix executables or "normal" MIPS ELF ABI executables. */ static irix_compat_t -elf64_mips_irix_compat (abfd) - bfd *abfd; +elf64_mips_irix_compat (bfd *abfd) { if ((abfd->xvec == &bfd_elf64_bigmips_vec) || (abfd->xvec == &bfd_elf64_littlemips_vec)) @@ -2550,6 +2538,67 @@ elf64_mips_irix_compat (abfd) return ict_none; } +/* Support for core dump NOTE sections. */ +static bfd_boolean +elf64_mips_grok_prstatus (bfd *abfd, Elf_Internal_Note *note) +{ + int offset; + unsigned int size; + + switch (note->descsz) + { + default: + return FALSE; + + case 480: /* Linux/MIPS - N64 kernel */ + /* pr_cursig */ + elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); + + /* pr_pid */ + elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 32); + + /* pr_reg */ + offset = 112; + size = 360; + + break; + } + + /* Make a ".reg/999" section. */ + return _bfd_elfcore_make_pseudosection (abfd, ".reg", + size, note->descpos + offset); +} + +static bfd_boolean +elf64_mips_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) +{ + switch (note->descsz) + { + default: + return FALSE; + + case 136: /* Linux/MIPS - N64 kernel elf_prpsinfo */ + elf_tdata (abfd)->core_program + = _bfd_elfcore_strndup (abfd, note->descdata + 40, 16); + elf_tdata (abfd)->core_command + = _bfd_elfcore_strndup (abfd, note->descdata + 56, 80); + } + + /* Note that for some reason, a spurious space is tacked + onto the end of the args in some (at least one anyway) + implementations, so strip it off if it exists. */ + + { + char *command = elf_tdata (abfd)->core_command; + int n = strlen (command); + + if (0 < n && command[n - 1] == ' ') + command[n - 1] = '\0'; + } + + return TRUE; +} + /* ECOFF swapping routines. These are used when dealing with the .mdebug section, which is in the ECOFF debugging format. */ static const struct ecoff_debug_swap mips_elf64_ecoff_debug_swap = @@ -2610,7 +2659,7 @@ const struct elf_size_info mips_elf64_size_info = 4, /* hash-table entry size */ 3, /* internal relocations per external relocations */ 64, /* arch_size */ - 8, /* file_align */ + 3, /* log_file_align */ ELFCLASS64, EV_CURRENT, bfd_elf64_write_out_phdrs, @@ -2631,14 +2680,9 @@ const struct elf_size_info mips_elf64_size_info = #define ELF_ARCH bfd_arch_mips #define ELF_MACHINE_CODE EM_MIPS -/* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses - a value of 0x1000, and we are compatible. - FIXME: How does this affect NewABI? */ -#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_collect TRUE +#define elf_backend_type_change_ok TRUE +#define elf_backend_can_gc_sections TRUE #define elf_info_to_howto mips_elf64_info_to_howto_rela #define elf_info_to_howto_rel mips_elf64_info_to_howto_rel #define elf_backend_object_p mips_elf64_object_p @@ -2672,6 +2716,8 @@ const struct elf_size_info mips_elf64_size_info = #define elf_backend_modify_segment_map _bfd_mips_elf_modify_segment_map #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_copy_indirect_symbol \ + _bfd_mips_elf_copy_indirect_symbol #define elf_backend_hide_symbol _bfd_mips_elf_hide_symbol #define elf_backend_ignore_discarded_relocs \ _bfd_mips_elf_ignore_discarded_relocs @@ -2680,8 +2726,10 @@ const struct elf_size_info mips_elf64_size_info = #define elf_backend_ecoff_debug_swap &mips_elf64_ecoff_debug_swap #define elf_backend_size_info mips_elf64_size_info +#define elf_backend_grok_prstatus elf64_mips_grok_prstatus +#define elf_backend_grok_psinfo elf64_mips_grok_psinfo + #define elf_backend_got_header_size (4 * MIPS_RESERVED_GOTNO) -#define elf_backend_plt_header_size 0 /* MIPS ELF64 can use a mixture of REL and RELA, but some Relocations work better/work only in RELA, so we default to this. */ @@ -2689,14 +2737,13 @@ const struct elf_size_info mips_elf64_size_info = #define elf_backend_may_use_rela_p 1 #define elf_backend_default_use_rela_p 1 -#define elf_backend_ignore_discarded_relocs \ - _bfd_mips_elf_ignore_discarded_relocs #define elf_backend_write_section _bfd_mips_elf_write_section /* 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_new_section_hook _bfd_mips_elf_new_section_hook #define bfd_elf64_set_section_contents _bfd_mips_elf_set_section_contents #define bfd_elf64_bfd_get_relocated_section_contents \ _bfd_elf_mips_get_relocated_section_contents @@ -2710,13 +2757,17 @@ const struct elf_size_info mips_elf64_size_info = _bfd_mips_elf_print_private_bfd_data #define bfd_elf64_get_reloc_upper_bound mips_elf64_get_reloc_upper_bound +#define bfd_elf64_canonicalize_reloc mips_elf64_canonicalize_reloc +#define bfd_elf64_get_dynamic_reloc_upper_bound mips_elf64_get_dynamic_reloc_upper_bound +#define bfd_elf64_canonicalize_dynamic_reloc mips_elf64_canonicalize_dynamic_reloc +#define bfd_elf64_bfd_relax_section _bfd_mips_relax_section /* MIPS ELF64 archive functions. */ #define bfd_elf64_archive_functions -extern boolean bfd_elf64_archive_slurp_armap - PARAMS((bfd *)); -extern boolean bfd_elf64_archive_write_armap - PARAMS((bfd *, unsigned int, struct orl *, unsigned int, int)); +extern bfd_boolean bfd_elf64_archive_slurp_armap + (bfd *); +extern bfd_boolean bfd_elf64_archive_write_armap + (bfd *, unsigned int, struct orl *, unsigned int, int); #define bfd_elf64_archive_slurp_extended_name_table \ _bfd_archive_coff_slurp_extended_name_table #define bfd_elf64_archive_construct_extended_name_table \ @@ -2739,9 +2790,12 @@ extern boolean bfd_elf64_archive_write_armap #define TARGET_BIG_SYM bfd_elf64_bigmips_vec #define TARGET_BIG_NAME "elf64-bigmips" -#include "elf64-target.h" +/* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses + a value of 0x1000, and we are compatible. + FIXME: How does this affect NewABI? */ +#define ELF_MAXPAGESIZE 0x1000 -#define INCLUDED_TARGET_FILE /* More a type of flag. */ +#include "elf64-target.h" /* The SYSV-style 'traditional' (n)64 NewABI. */ #undef TARGET_LITTLE_SYM @@ -2749,10 +2803,17 @@ extern boolean bfd_elf64_archive_write_armap #undef TARGET_BIG_SYM #undef TARGET_BIG_NAME +#undef ELF_MAXPAGESIZE + #define TARGET_LITTLE_SYM bfd_elf64_tradlittlemips_vec #define TARGET_LITTLE_NAME "elf64-tradlittlemips" #define TARGET_BIG_SYM bfd_elf64_tradbigmips_vec #define TARGET_BIG_NAME "elf64-tradbigmips" +/* The SVR4 MIPS ABI says that this should be 0x10000, and Linux uses + page sizes of up to that limit, so we need to respect it. */ +#define ELF_MAXPAGESIZE 0x10000 +#define elf64_bed elf64_tradbed + /* Include the target file again for this target. */ #include "elf64-target.h"