X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-pj.c;h=99f43ec09389b856261566e48c51c5ec08db50b9;hb=f1f28025c3ea75d5368ddd3046461648145b89b3;hp=bd0a5b49ffa88948c590e76980d2fdf2af3f54a7;hpb=47b0e7ad8c60ea4b45b22ad5cb376f068991bc88;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c index bd0a5b49ff..99f43ec093 100644 --- a/bfd/elf32-pj.c +++ b/bfd/elf32-pj.c @@ -1,12 +1,12 @@ /* picoJava specific support for 32-bit ELF - Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc. + Copyright (C) 1999-2020 Free Software Foundation, Inc. Contributed by Steve Chamberlan of Transmeta (sac@pobox.com). This file is part of BFD, the Binary File Descriptor library. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -16,10 +16,11 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ + Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, + MA 02110-1301, USA. */ -#include "bfd.h" #include "sysdep.h" +#include "bfd.h" #include "bfdlink.h" #include "libbfd.h" #include "elf-bfd.h" @@ -53,6 +54,7 @@ pj_elf_reloc (bfd *abfd, } if (symbol_in != NULL + && (symbol_in->flags & BSF_WEAK) == 0 && bfd_is_und_section (symbol_in->section)) return bfd_reloc_undefined; @@ -83,8 +85,8 @@ pj_elf_reloc (bfd *abfd, case R_PJ_CODE_REL16: insn = bfd_getb16 (hit_data); insn += sym_value + reloc_entry->addend - - (input_section->output_section->vma - + input_section->output_offset); + - (input_section->output_section->vma + + input_section->output_offset); bfd_putb16 ((bfd_vma) insn, hit_data); break; case R_PJ_CODE_LO16: @@ -112,7 +114,7 @@ static reloc_howto_type pj_elf_howto_table[] = /* No relocation. */ HOWTO (R_PJ_NONE, /* type */ 0, /* rightshift */ - 0, /* size (0 = byte, 1 = short, 2 = long) */ + 3, /* size (0 = byte, 1 = short, 2 = long) */ 0, /* bitsize */ FALSE, /* pc_relative */ 0, /* bitpos */ @@ -221,34 +223,34 @@ static reloc_howto_type pj_elf_howto_table[] = TRUE), /* pcrel_offset */ /* GNU extension to record C++ vtable hierarchy. */ - HOWTO (R_PJ_GNU_VTINHERIT, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - NULL, /* special_function */ - "R_PJ_GNU_VTINHERIT", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + HOWTO (R_PJ_GNU_VTINHERIT, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + NULL, /* special_function */ + "R_PJ_GNU_VTINHERIT", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ /* GNU extension to record C++ vtable member usage. */ HOWTO (R_PJ_GNU_VTENTRY, /* type */ - 0, /* rightshift */ - 2, /* size (0 = byte, 1 = short, 2 = long) */ - 0, /* bitsize */ - FALSE, /* pc_relative */ - 0, /* bitpos */ - complain_overflow_dont, /* complain_on_overflow */ - _bfd_elf_rel_vtable_reloc_fn, /* special_function */ - "R_PJ_GNU_VTENTRY", /* name */ - FALSE, /* partial_inplace */ - 0, /* src_mask */ - 0, /* dst_mask */ - FALSE), /* pcrel_offset */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_elf_rel_vtable_reloc_fn, /* special_function */ + "R_PJ_GNU_VTENTRY", /* name */ + FALSE, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + FALSE), /* pcrel_offset */ }; /* This structure is used to map BFD reloc codes to PJ ELF relocs. */ @@ -263,14 +265,14 @@ struct elf_reloc_map static const struct elf_reloc_map pj_reloc_map[] = { - { BFD_RELOC_NONE, R_PJ_NONE }, - { BFD_RELOC_32, R_PJ_DATA_DIR32 }, - { BFD_RELOC_PJ_CODE_DIR16, R_PJ_CODE_DIR16 }, - { BFD_RELOC_PJ_CODE_DIR32, R_PJ_CODE_DIR32 }, - { BFD_RELOC_PJ_CODE_LO16, R_PJ_CODE_LO16 }, - { BFD_RELOC_PJ_CODE_HI16, R_PJ_CODE_HI16 }, - { BFD_RELOC_PJ_CODE_REL32, R_PJ_CODE_REL32 }, - { BFD_RELOC_PJ_CODE_REL16, R_PJ_CODE_REL16 }, + { BFD_RELOC_NONE, R_PJ_NONE }, + { BFD_RELOC_32, R_PJ_DATA_DIR32 }, + { BFD_RELOC_PJ_CODE_DIR16, R_PJ_CODE_DIR16 }, + { BFD_RELOC_PJ_CODE_DIR32, R_PJ_CODE_DIR32 }, + { BFD_RELOC_PJ_CODE_LO16, R_PJ_CODE_LO16 }, + { BFD_RELOC_PJ_CODE_HI16, R_PJ_CODE_HI16 }, + { BFD_RELOC_PJ_CODE_REL32, R_PJ_CODE_REL32 }, + { BFD_RELOC_PJ_CODE_REL16, R_PJ_CODE_REL16 }, { BFD_RELOC_VTABLE_INHERIT, R_PJ_GNU_VTINHERIT }, { BFD_RELOC_VTABLE_ENTRY, R_PJ_GNU_VTENTRY }, }; @@ -291,10 +293,26 @@ pj_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, return NULL; } +static reloc_howto_type * +pj_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, + const char *r_name) +{ + unsigned int i; + + for (i = 0; + i < sizeof (pj_elf_howto_table) / sizeof (pj_elf_howto_table[0]); + i++) + if (pj_elf_howto_table[i].name != NULL + && strcasecmp (pj_elf_howto_table[i].name, r_name) == 0) + return &pj_elf_howto_table[i]; + + return NULL; +} + /* Given an ELF reloc, fill in the howto field of a relent. */ -static void -pj_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, +static bfd_boolean +pj_elf_info_to_howto (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { @@ -302,32 +320,42 @@ pj_elf_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, r = ELF32_R_TYPE (dst->r_info); - BFD_ASSERT (r < (unsigned int) R_PJ_max); + if (r >= R_PJ_max) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: unsupported relocation type %#x"), + abfd, r); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } cache_ptr->howto = &pj_elf_howto_table[r]; + return TRUE; } /* Take this moment to fill in the special picoJava bits in the e_flags field. */ -static void -pj_elf_final_write_processing (bfd *abfd, - bfd_boolean linker ATTRIBUTE_UNUSED) +static bfd_boolean +pj_elf_final_write_processing (bfd *abfd) { elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_ARCH; elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_GNUCALLS; + return _bfd_elf_final_write_processing (abfd); } -#define TARGET_BIG_SYM bfd_elf32_pj_vec +#define TARGET_BIG_SYM pj_elf32_vec #define TARGET_BIG_NAME "elf32-pj" -#define TARGET_LITTLE_SYM bfd_elf32_pjl_vec +#define TARGET_LITTLE_SYM pj_elf32_le_vec #define TARGET_LITTLE_NAME "elf32-pjl" #define ELF_ARCH bfd_arch_pj #define ELF_MACHINE_CODE EM_PJ #define ELF_MACHINE_ALT1 EM_PJ_OLD #define ELF_MAXPAGESIZE 0x1000 -#define bfd_elf32_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents -#define bfd_elf32_bfd_reloc_type_lookup pj_elf_reloc_type_lookup -#define elf_backend_final_write_processing pj_elf_final_write_processing -#define elf_info_to_howto pj_elf_info_to_howto +#define bfd_elf32_bfd_get_relocated_section_contents \ + bfd_generic_get_relocated_section_contents +#define bfd_elf32_bfd_reloc_type_lookup pj_elf_reloc_type_lookup +#define bfd_elf32_bfd_reloc_name_lookup pj_elf_reloc_name_lookup +#define elf_backend_final_write_processing pj_elf_final_write_processing +#define elf_info_to_howto pj_elf_info_to_howto #include "elf32-target.h"