X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=bfd%2Felf32-v850.c;h=ae0a0c4e88b195bd1a8f77d5f04fed96979541d1;hb=f617d2b61f0dc2c2367f27d5497b4ea1c58d87f8;hp=518073644e61c0c1cd9b730b214e97d08e5fb7b9;hpb=917583ad772872d4be81820c56aff7828ae4819b;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 518073644e..ae0a0c4e88 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "libiberty.h" /* Sign-extend a 24-bit number. */ -#define SEXT24(x) ((((x) & 0xffffff) ^ (~ 0x7fffff)) + 0x800000) +#define SEXT24(x) ((((x) & 0xffffff) ^ 0x800000) - 0x800000) static reloc_howto_type *v850_elf_reloc_type_lookup PARAMS ((bfd *abfd, bfd_reloc_code_real_type code)); @@ -46,7 +46,7 @@ static boolean v850_elf_relocate_section PARAMS((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); static bfd_reloc_status_type v850_elf_perform_relocation - PARAMS ((bfd *, int, bfd_vma, bfd_byte *)); + PARAMS ((bfd *, unsigned int, bfd_vma, bfd_byte *)); static boolean v850_elf_check_relocs PARAMS ((bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *)); static void remember_hi16s_reloc @@ -64,14 +64,12 @@ static void v850_elf_final_write_processing PARAMS ((bfd *, boolean)); static boolean v850_elf_set_private_flags PARAMS ((bfd *, flagword)); -static boolean v850_elf_copy_private_bfd_data - PARAMS ((bfd *, bfd *)); static boolean v850_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); static boolean v850_elf_print_private_bfd_data PARAMS ((bfd *, PTR)); static boolean v850_elf_section_from_bfd_section - PARAMS ((bfd *, Elf32_Internal_Shdr *, asection *, int *)); + PARAMS ((bfd *, asection *, int *)); static void v850_elf_symbol_processing PARAMS ((bfd *, asymbol *)); static boolean v850_elf_add_symbol_hook @@ -524,7 +522,7 @@ v850_elf_reloc_type_lookup (abfd, code) if (v850_elf_reloc_map[i].bfd_reloc_val == code) { unsigned int elf_reloc_val = v850_elf_reloc_map[i].elf_reloc_val; - + BFD_ASSERT (v850_elf_howto_table[elf_reloc_val].type == elf_reloc_val); return v850_elf_howto_table + elf_reloc_val; @@ -590,7 +588,7 @@ v850_elf_check_relocs (abfd, info, sec, relocs) #ifdef DEBUG fprintf (stderr, "v850_elf_check_relocs called for section %s in %s\n", bfd_get_section_name (abfd, sec), - bfd_get_filename (abfd)); + bfd_archive_filename (abfd)); #endif dynobj = elf_hash_table (info)->dynobj; @@ -699,7 +697,8 @@ v850_elf_check_relocs (abfd, info, sec, relocs) sprintf (buff, msg, h->root.root.string); info->callbacks->warning (info, buff, h->root.root.string, - abfd, h->root.u.def.section, 0); + abfd, h->root.u.def.section, + (bfd_vma) 0); bfd_set_error (bfd_error_bad_value); h->other |= V850_OTHER_ERROR; @@ -764,10 +763,11 @@ remember_hi16s_reloc (abfd, addend, address) bfd_byte * address; { hi16s_location * entry = NULL; + bfd_size_type amt = sizeof (* free_hi16s); /* Find a free structure. */ if (free_hi16s == NULL) - free_hi16s = (hi16s_location *) bfd_zalloc (abfd, sizeof (* free_hi16s)); + free_hi16s = (hi16s_location *) bfd_zalloc (abfd, amt); entry = free_hi16s; free_hi16s = free_hi16s->next; @@ -837,10 +837,10 @@ find_remembered_hi16s_reloc (addend, already_found) static bfd_reloc_status_type v850_elf_perform_relocation (abfd, r_type, addend, address) - bfd * abfd; - int r_type; - bfd_vma addend; - bfd_byte * address; + bfd *abfd; + unsigned int r_type; + bfd_vma addend; + bfd_byte *address; { unsigned long insn; bfd_signed_vma saddend = (bfd_signed_vma) addend; @@ -865,7 +865,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) insn = bfd_get_32 (abfd, address); insn &= ~0xfffe003f; insn |= (((addend & 0xfffe) << 16) | ((addend & 0x3f0000) >> 16)); - bfd_put_32 (abfd, insn, address); + bfd_put_32 (abfd, (bfd_vma) insn, address); return bfd_reloc_ok; case R_V850_9_PCREL: @@ -1064,7 +1064,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) { insn = bfd_get_16 (abfd, hi16s_address); insn += 1; - bfd_put_16 (abfd, insn, hi16s_address); + bfd_put_16 (abfd, (bfd_vma) insn, hi16s_address); } } else @@ -1130,7 +1130,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) if (addend & 1) return bfd_reloc_dangerous; - insn = (addend & ~1) | (insn & 1); + insn = (addend &~ (bfd_vma) 1) | (insn & 1); break; case R_V850_TDA_6_8_OFFSET: @@ -1219,9 +1219,9 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) insn &= 0x0001ffdf; insn |= (addend & 1) << 5; - insn |= (addend & ~1) << 16; + insn |= (addend &~ (bfd_vma) 1) << 16; - bfd_put_32 (abfd, insn, address); + bfd_put_32 (abfd, (bfd_vma) insn, address); return bfd_reloc_ok; case R_V850_CALLT_6_7_OFFSET: @@ -1246,7 +1246,7 @@ v850_elf_perform_relocation (abfd, r_type, addend, address) } - bfd_put_16 (abfd, insn, address); + bfd_put_16 (abfd, (bfd_vma) insn, address); return bfd_reloc_ok; } @@ -1315,7 +1315,7 @@ v850_elf_reloc (abfd, reloc, symbol, data, isection, obfd, err) .text .globl _start nop - _start: + _start: jr foo .section ".foo","ax" @@ -1363,7 +1363,7 @@ v850_elf_final_link_relocate (howto, input_bfd, output_bfd, asection * sym_sec; int is_local ATTRIBUTE_UNUSED; { - unsigned long r_type = howto->type; + unsigned int r_type = howto->type; bfd_byte * hit_data = contents + offset; /* Adjust the value according to the relocation. */ @@ -1535,7 +1535,8 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section, if (sym_hashes == NULL) { info->callbacks->warning - (info, "no hash table available", NULL, input_bfd, input_section, 0); + (info, "no hash table available", + NULL, input_bfd, input_section, (bfd_vma) 0); return false; } @@ -1594,9 +1595,7 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section, { sym = local_syms + r_symndx; sec = local_sections[r_symndx]; - relocation = (sec->output_section->vma - + sec->output_offset - + sym->st_value); + relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); #if 0 { char * name; @@ -1773,14 +1772,9 @@ v850_elf_gc_mark_hook (abfd, info, rel, h, sym) } else { - if (!(elf_bad_symtab (abfd) - && ELF_ST_BIND (sym->st_info) != STB_LOCAL) - && ! ((sym->st_shndx <= 0 || sym->st_shndx >= SHN_LORESERVE) - && sym->st_shndx != SHN_COMMON)) - { - return bfd_section_from_elf_index (abfd, sym->st_shndx); - } - } + return bfd_section_from_elf_index (abfd, sym->st_shndx); + } + return NULL; } @@ -1836,28 +1830,6 @@ v850_elf_set_private_flags (abfd, flags) return true; } -/* Copy backend specific data from one object module to another. */ - -static boolean -v850_elf_copy_private_bfd_data (ibfd, obfd) - bfd * ibfd; - bfd * obfd; -{ - if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour - || bfd_get_flavour (obfd) != bfd_target_elf_flavour) - return true; - - BFD_ASSERT (!elf_flags_init (obfd) - || (elf_elfheader (obfd)->e_flags - == elf_elfheader (ibfd)->e_flags)); - - elf_gp (obfd) = elf_gp (ibfd); - elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; - elf_flags_init (obfd) = true; - - return true; -} - /* Merge backend specific data from an object file to the output object file when linking. */ static boolean @@ -1903,7 +1875,7 @@ v850_elf_merge_private_bfd_data (ibfd, obfd) if ((in_flags & EF_V850_ARCH) != (out_flags & EF_V850_ARCH) && (in_flags & EF_V850_ARCH) != E_V850_ARCH) _bfd_error_handler (_("%s: Architecture mismatch with previous modules"), - bfd_get_filename (ibfd)); + bfd_archive_filename (ibfd)); return true; } @@ -1958,9 +1930,8 @@ static asymbol * v850_elf_zcom_symbol_ptr; corresponding ELF section index. */ static boolean -v850_elf_section_from_bfd_section (abfd, hdr, sec, retval) +v850_elf_section_from_bfd_section (abfd, sec, retval) bfd * abfd ATTRIBUTE_UNUSED; - Elf32_Internal_Shdr * hdr ATTRIBUTE_UNUSED; asection * sec; int * retval; { @@ -1984,9 +1955,9 @@ v850_elf_symbol_processing (abfd, asym) asymbol * asym; { elf_symbol_type * elfsym = (elf_symbol_type *) asym; - unsigned short index; + unsigned int indx; - index = elfsym->internal_elf_sym.st_shndx; + indx = elfsym->internal_elf_sym.st_shndx; /* If the section index is an "ordinary" index, then it may refer to a v850 specific section created by the assembler. @@ -1994,26 +1965,26 @@ v850_elf_symbol_processing (abfd, asym) FIXME: Should we alter the st_shndx field as well ? */ - if (index < elf_elfheader(abfd)[0].e_shnum) - switch (elf_elfsections(abfd)[index]->sh_type) + if (indx < elf_numsections (abfd)) + switch (elf_elfsections(abfd)[indx]->sh_type) { case SHT_V850_SCOMMON: - index = SHN_V850_SCOMMON; + indx = SHN_V850_SCOMMON; break; case SHT_V850_TCOMMON: - index = SHN_V850_TCOMMON; + indx = SHN_V850_TCOMMON; break; case SHT_V850_ZCOMMON: - index = SHN_V850_ZCOMMON; + indx = SHN_V850_ZCOMMON; break; default: break; } - switch (index) + switch (indx) { case SHN_V850_SCOMMON: if (v850_elf_scom_section.name == NULL) @@ -2084,7 +2055,7 @@ v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) asection ** secp; bfd_vma * valp; { - int index = sym->st_shndx; + unsigned int indx = sym->st_shndx; /* If the section index is an "ordinary" index, then it may refer to a v850 specific section created by the assembler. @@ -2092,26 +2063,26 @@ v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) FIXME: Should we alter the st_shndx field as well ? */ - if (index < elf_elfheader(abfd)[0].e_shnum) - switch (elf_elfsections(abfd)[index]->sh_type) + if (indx < elf_numsections (abfd)) + switch (elf_elfsections(abfd)[indx]->sh_type) { case SHT_V850_SCOMMON: - index = SHN_V850_SCOMMON; + indx = SHN_V850_SCOMMON; break; case SHT_V850_TCOMMON: - index = SHN_V850_TCOMMON; + indx = SHN_V850_TCOMMON; break; case SHT_V850_ZCOMMON: - index = SHN_V850_ZCOMMON; + indx = SHN_V850_ZCOMMON; break; default: break; } - switch (index) + switch (indx) { case SHN_V850_SCOMMON: *secp = bfd_make_section_old_way (abfd, ".scommon"); @@ -2218,7 +2189,8 @@ v850_elf_fake_sections (abfd, hdr, sec) #define TARGET_LITTLE_SYM bfd_elf32_v850_vec #define TARGET_LITTLE_NAME "elf32-v850" #define ELF_ARCH bfd_arch_v850 -#define ELF_MACHINE_CODE EM_CYGNUS_V850 +#define ELF_MACHINE_CODE EM_V850 +#define ELF_MACHINE_ALT1 EM_CYGNUS_V850 #define ELF_MAXPAGESIZE 0x1000 #define elf_info_to_howto v850_elf_info_to_howto_rela @@ -2241,7 +2213,6 @@ v850_elf_fake_sections (abfd, hdr, sec) #define bfd_elf32_bfd_is_local_label_name v850_elf_is_local_label_name #define bfd_elf32_bfd_reloc_type_lookup v850_elf_reloc_type_lookup -#define bfd_elf32_bfd_copy_private_bfd_data v850_elf_copy_private_bfd_data #define bfd_elf32_bfd_merge_private_bfd_data v850_elf_merge_private_bfd_data #define bfd_elf32_bfd_set_private_flags v850_elf_set_private_flags #define bfd_elf32_bfd_print_private_bfd_data v850_elf_print_private_bfd_data