X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Felf32-m32r.c;h=eb2237f19aad26ebce0cd1334c6b8da66e3d1924;hb=08da05b004779169c90558b82fe2050d2da5342f;hp=307bdc7a740e69c65105060829f97856c004c04d;hpb=c3668558c94afd8baf4024f29baa10332b7f1f0f;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index 307bdc7a74..eb2237f19a 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1,5 +1,6 @@ /* M32R-specific support for 32-bit ELF. - Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -57,7 +58,6 @@ static boolean m32r_elf_relocate_section static boolean m32r_elf_relax_delete_bytes PARAMS ((bfd *, asection *, bfd_vma, int)); #endif - static bfd_reloc_status_type m32r_elf_final_sda_base PARAMS ((bfd *, struct bfd_link_info *, const char **, bfd_vma *)); static boolean m32r_elf_object_p @@ -72,6 +72,16 @@ static boolean m32r_elf_merge_private_bfd_data PARAMS ((bfd *, bfd *)); static boolean m32r_elf_print_private_bfd_data PARAMS ((bfd *, PTR)); +static boolean m32r_elf_gc_sweep_hook + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); +static boolean m32r_elf_check_relocs + PARAMS ((bfd *, struct bfd_link_info *, asection *, + const Elf_Internal_Rela *)); + +asection * m32r_elf_gc_mark_hook + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Rela *, + struct elf_link_hash_entry *, Elf_Internal_Sym *)); #define NOP_INSN 0x7000 #define MAKE_PARALLEL(insn) ((insn) | 0x8000) @@ -359,7 +369,7 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset, + input_section->output_offset); /* These jumps mask off the lower two bits of the current address before doing pcrel calculations. */ - relocation -= (offset & -4L); + relocation -= (offset & -(bfd_vma) 4); if (relocation < -0x200 || relocation > 0x1ff) status = bfd_reloc_overflow; @@ -370,7 +380,7 @@ m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset, relocation >>= howto->rightshift; relocation <<= howto->bitpos; x = (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & howto->dst_mask); - bfd_put_16 (abfd, x, data + offset); + bfd_put_16 (abfd, (bfd_vma) x, data + offset); return status; } @@ -447,7 +457,7 @@ m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data, relocation += reloc_entry->addend; /* Save the information, and let LO16 do the actual relocation. */ - n = (struct m32r_hi16 *) bfd_malloc (sizeof *n); + n = (struct m32r_hi16 *) bfd_malloc ((bfd_size_type) sizeof *n); if (n == NULL) return bfd_reloc_outofrange; n->addr = (bfd_byte *) data + reloc_entry->address; @@ -546,8 +556,8 @@ m32r_elf_lo16_reloc (input_bfd, reloc_entry, symbol, data, if ((val & 0x8000) != 0) val += 0x10000; - insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); - bfd_put_32 (input_bfd, insn, l->addr); + insn = (insn &~ (bfd_vma) 0xffff) | ((val >> 16) & 0xffff); + bfd_put_32 (input_bfd, (bfd_vma) insn, l->addr); next = l->next; free (l); @@ -578,7 +588,7 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, PTR data; asection *input_section; bfd *output_bfd; - char **error_message; + char **error_message ATTRIBUTE_UNUSED; { bfd_reloc_status_type ret; bfd_vma relocation; @@ -595,7 +605,7 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, return bfd_reloc_ok; } - /* Now do the the reloc in the usual way. + /* Now do the reloc in the usual way. ??? It would be nice to call bfd_elf_generic_reloc here, but we have partial_inplace == TRUE. bfd_elf_generic_reloc will pass the handling back to bfd_install_relocation which will install @@ -624,7 +634,7 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, } relocation += reloc_entry->addend; - inplace_address = data + reloc_entry->address; + inplace_address = (bfd_byte *) data + reloc_entry->address; #define DOIT(x) \ x = ( (x & ~reloc_entry->howto->dst_mask) | \ @@ -637,14 +647,14 @@ m32r_elf_generic_reloc (input_bfd, reloc_entry, symbol, data, { short x = bfd_get_16 (input_bfd, inplace_address); DOIT (x); - bfd_put_16 (input_bfd, x, inplace_address); + bfd_put_16 (input_bfd, (bfd_vma) x, inplace_address); } break; case 2: { unsigned long x = bfd_get_32 (input_bfd, inplace_address); DOIT (x); - bfd_put_32 (input_bfd, x, inplace_address); + bfd_put_32 (input_bfd, (bfd_vma)x , inplace_address); } break; default: @@ -845,8 +855,8 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) if (s == NULL) { - int flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS - | SEC_IN_MEMORY | SEC_LINKER_CREATED); + flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_IN_MEMORY | SEC_LINKER_CREATED); s = bfd_make_section_anyway (abfd, ".sdata"); if (s == NULL) @@ -864,7 +874,7 @@ m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) "_SDA_BASE_", BSF_GLOBAL, s, - 32768, + (bfd_vma) 32768, (const char *) NULL, false, get_elf_backend_data (abfd)->collect, @@ -998,7 +1008,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, if (r_type < 0 || r_type >= (int) R_M32R_max) { (*_bfd_error_handler) (_("%s: unknown relocation type %d"), - bfd_get_filename (input_bfd), + bfd_archive_filename (input_bfd), (int) r_type); bfd_set_error (bfd_error_bad_value); ret = false; @@ -1205,11 +1215,12 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section, } else { - (*_bfd_error_handler) (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"), - bfd_get_filename (input_bfd), - sym_name, - m32r_elf_howto_table[(int) r_type].name, - bfd_get_section_name (abfd, sec)); + (*_bfd_error_handler) + (_("%s: The target (%s) of an %s relocation is in the wrong section (%s)"), + bfd_archive_filename (input_bfd), + sym_name, + m32r_elf_howto_table[(int) r_type].name, + bfd_get_section_name (abfd, sec)); /*bfd_set_error (bfd_error_bad_value); ??? why? */ ret = false; continue; @@ -1400,15 +1411,14 @@ m32r_elf_relax_section (abfd, sec, link_info, again) extsyms = (Elf32_External_Sym *) symtab_hdr->contents; else { + bfd_size_type amt = symtab_hdr->sh_size; /* Go get them off disk. */ - extsyms = ((Elf32_External_Sym *) - bfd_malloc (symtab_hdr->sh_size)); + extsyms = (Elf32_External_Sym *) bfd_malloc (amt); if (extsyms == NULL) goto error_return; free_extsyms = extsyms; if (bfd_seek (abfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_read (extsyms, 1, symtab_hdr->sh_size, abfd) - != symtab_hdr->sh_size)) + || bfd_bread (extsyms, amt, abfd) != amt) goto error_return; } } @@ -1772,6 +1782,7 @@ m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order, Elf_Internal_Rela *internal_relocs = NULL; Elf32_External_Sym *external_syms = NULL; Elf_Internal_Sym *internal_syms = NULL; + bfd_size_type amt; /* We only need to handle the case of relaxing, or of having a particular set of section contents, specially. */ @@ -1798,15 +1809,13 @@ m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order, external_syms = (Elf32_External_Sym *) symtab_hdr->contents; else { - external_syms = ((Elf32_External_Sym *) - bfd_malloc (symtab_hdr->sh_info - * sizeof (Elf32_External_Sym))); + amt = symtab_hdr->sh_info; + amt *= sizeof (Elf32_External_Sym); + external_syms = (Elf32_External_Sym *) bfd_malloc (amt); if (external_syms == NULL && symtab_hdr->sh_info > 0) goto error_return; if (bfd_seek (input_bfd, symtab_hdr->sh_offset, SEEK_SET) != 0 - || (bfd_read (external_syms, sizeof (Elf32_External_Sym), - symtab_hdr->sh_info, input_bfd) - != (symtab_hdr->sh_info * sizeof (Elf32_External_Sym)))) + || bfd_bread (external_syms, amt, input_bfd) != amt) goto error_return; } @@ -1816,14 +1825,15 @@ m32r_elf_get_relocated_section_contents (output_bfd, link_info, link_order, if (internal_relocs == NULL) goto error_return; - internal_syms = ((Elf_Internal_Sym *) - bfd_malloc (symtab_hdr->sh_info - * sizeof (Elf_Internal_Sym))); + amt = symtab_hdr->sh_info; + amt *= sizeof (Elf_Internal_Sym); + internal_syms = (Elf_Internal_Sym *) bfd_malloc (amt); if (internal_syms == NULL && symtab_hdr->sh_info > 0) goto error_return; - sections = (asection **) bfd_malloc (symtab_hdr->sh_info - * sizeof (asection *)); + amt = symtab_hdr->sh_info; + amt *= sizeof (asection *); + sections = (asection **) bfd_malloc (amt); if (sections == NULL && symtab_hdr->sh_info > 0) goto error_return; @@ -2007,8 +2017,9 @@ m32r_elf_merge_private_bfd_data (ibfd, obfd) { if ((in_flags & EF_M32R_ARCH) != E_M32R_ARCH) { - _bfd_error_handler (_("%s: Instruction set mismatch with previous modules"), - bfd_get_filename (ibfd)); + (*_bfd_error_handler) + (_("%s: Instruction set mismatch with previous modules"), + bfd_archive_filename (ibfd)); bfd_set_error (bfd_error_bad_value); return false; @@ -2156,11 +2167,10 @@ m32r_elf_check_relocs (abfd, info, sec, relocs) return true; } - - #define ELF_ARCH bfd_arch_m32r -#define ELF_MACHINE_CODE EM_CYGNUS_M32R +#define ELF_MACHINE_CODE EM_M32R +#define ELF_MACHINE_ALT1 EM_CYGNUS_M32R #define ELF_MAXPAGESIZE 0x1 /* Explicitly requested by Mitsubishi. */ #define TARGET_BIG_SYM bfd_elf32_m32r_vec