From 848b76598f233467a312def5689a0de40b0f5ff1 Mon Sep 17 00:00:00 2001 From: nobody <> Date: Mar 31 2006 19:47:12 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'msnyder- reverse-20060331-branch'. Sprout from gdb-csl-available-20060303-branch 2006-03-03 15:57:44 UTC nobody 'This commit was manufactured by cvs2svn to create branch 'gdb-csl-' Cherrypick from master 2006-03-30 00:22:20 UTC Ben Elliston ' PR ld/2267': ChangeLog Makefile.in Makefile.tpl bfd/ChangeLog bfd/Makefile.am bfd/Makefile.in bfd/aoutx.h bfd/archures.c bfd/bfd-in.h bfd/bfd-in2.h bfd/bfd.c bfd/coff-arm.c bfd/coff-h8300.c bfd/coff-ppc.c bfd/cofflink.c bfd/config.bfd bfd/configure bfd/configure.in bfd/cpu-arm.c bfd/cpu-m68k.c bfd/dwarf2.c bfd/ecoff.c bfd/ecofflink.c bfd/elf-bfd.h bfd/elf-m10300.c bfd/elf-strtab.c bfd/elf.c bfd/elf32-arm.c bfd/elf32-bfin.c bfd/elf32-cris.c bfd/elf32-frv.c bfd/elf32-hppa.c bfd/elf32-i386.c bfd/elf32-m32r.c bfd/elf32-m68hc1x.c bfd/elf32-m68k.c bfd/elf32-mips.c bfd/elf32-ppc.c bfd/elf32-s390.c bfd/elf32-sh.c bfd/elf32-vax.c bfd/elf32-xtensa.c bfd/elf64-alpha.c bfd/elf64-hppa.c bfd/elf64-ppc.c bfd/elf64-s390.c bfd/elf64-sh64.c bfd/elf64-x86-64.c bfd/elflink.c bfd/elfxx-ia64.c bfd/elfxx-mips.c bfd/elfxx-mips.h bfd/elfxx-sparc.c bfd/hash.c bfd/i386linux.c bfd/ieee.c bfd/libaout.h bfd/libbfd-in.h bfd/libbfd.h bfd/libcoff-in.h bfd/libcoff.h bfd/linker.c bfd/m68klinux.c bfd/merge.c bfd/opncls.c bfd/pdp11.c bfd/reloc.c bfd/section.c bfd/sparclinux.c bfd/stabs.c bfd/sunos.c bfd/targets.c bfd/version.h bfd/vms.c bfd/xcofflink.c configure configure.in cpu/ChangeLog cpu/m32c.cpu cpu/m32c.opc gdb/ChangeLog gdb/MAINTAINERS gdb/Makefile.in gdb/NEWS gdb/alpha-linux-nat.c gdb/amd64-linux-nat.c gdb/arm-linux-nat.c gdb/arm-tdep.c gdb/cli/cli-script.c gdb/config/frv/frv.mt gdb/config/pa/hppa64.mt gdb/config/s390/s390.mh gdb/configure gdb/configure.ac gdb/configure.tgt gdb/doc/gdbint.texinfo gdb/frv-linux-tdep.c gdb/gdbserver/ChangeLog gdb/gdbserver/Makefile.in gdb/gdbserver/config.in gdb/gdbserver/configure gdb/gdbserver/configure.ac gdb/gdbserver/gdb_proc_service.h gdb/gdbserver/linux-i386-low.c gdb/gdbserver/linux-mips-low.c gdb/gdbserver/linux-x86-64-low.c gdb/gdbserver/proc-service.c gdb/gdbserver/thread-db.c gdb/hppa-linux-nat.c gdb/i386-linux-nat.c gdb/i386-tdep.c gdb/ia64-linux-nat.c gdb/ia64-tdep.c gdb/libunwind-frame.c gdb/libunwind-frame.h gdb/linux-fork.c gdb/linux-nat.c gdb/linux-nat.h gdb/m32r-linux-nat.c gdb/m68klinux-nat.c gdb/mi/gdb-mi.el gdb/mips-linux-nat.c gdb/mips-linux-tdep.c gdb/mips-linux-tdep.h gdb/mips-mdebug-tdep.c gdb/mips-tdep.c gdb/ppc-linux-nat.c gdb/prologue-value.c gdb/prologue-value.h gdb/remote-rdp.c gdb/remote.c gdb/s390-nat.c gdb/sh-tdep.c gdb/solib-frv.c gdb/solib-som.c gdb/solib-svr4.c gdb/sparc-linux-nat.c gdb/sparc64-linux-nat.c gdb/symtab.h gdb/target.c gdb/testsuite/ChangeLog gdb/testsuite/gdb.arch/altivec-abi.exp gdb/testsuite/gdb.arch/altivec-regs.exp gdb/testsuite/gdb.arch/e500-abi.exp gdb/testsuite/gdb.arch/e500-regs.exp gdb/testsuite/gdb.base/all-bin.exp gdb/testsuite/gdb.base/annota1.exp gdb/testsuite/gdb.base/annota3.exp gdb/testsuite/gdb.base/args.exp gdb/testsuite/gdb.base/arithmet.exp gdb/testsuite/gdb.base/assign.exp gdb/testsuite/gdb.base/async.exp gdb/testsuite/gdb.base/bang.exp gdb/testsuite/gdb.base/break.exp gdb/testsuite/gdb.base/call-rt-st.exp gdb/testsuite/gdb.base/completion.exp gdb/testsuite/gdb.base/cond-expr.exp gdb/testsuite/gdb.base/condbreak.exp gdb/testsuite/gdb.base/consecutive.exp gdb/testsuite/gdb.base/define.exp gdb/testsuite/gdb.base/display.exp gdb/testsuite/gdb.base/ena-dis-br.exp gdb/testsuite/gdb.base/environ.exp gdb/testsuite/gdb.base/eval-skip.exp gdb/testsuite/gdb.base/info-proc.exp gdb/testsuite/gdb.base/jump.exp gdb/testsuite/gdb.base/logical.exp gdb/testsuite/gdb.base/long_long.exp gdb/testsuite/gdb.base/maint.exp gdb/testsuite/gdb.base/miscexprs.exp gdb/testsuite/gdb.base/pc-fp.exp gdb/testsuite/gdb.base/pointers.exp gdb/testsuite/gdb.base/prelink-lib.c gdb/testsuite/gdb.base/prelink.c gdb/testsuite/gdb.base/prelink.exp gdb/testsuite/gdb.base/relational.exp gdb/testsuite/gdb.base/reread.exp gdb/testsuite/gdb.base/sect-cmd.exp gdb/testsuite/gdb.base/sep.exp gdb/testsuite/gdb.base/sepdebug.exp gdb/testsuite/gdb.base/until.exp gdb/testsuite/gdb.base/whatis-exp.exp gdb/testsuite/gdb.cp/annota2.exp gdb/testsuite/gdb.cp/annota3.exp gdb/testsuite/gdb.mi/array.f gdb/testsuite/gdb.mi/mi-var-child-f.exp gdb/testsuite/gdb.trace/actions.exp gdb/testsuite/gdb.trace/backtrace.exp gdb/testsuite/gdb.trace/circ.exp gdb/testsuite/gdb.trace/collection.exp gdb/testsuite/gdb.trace/deltrace.exp gdb/testsuite/gdb.trace/infotrace.exp gdb/testsuite/gdb.trace/limits.exp gdb/testsuite/gdb.trace/packetlen.exp gdb/testsuite/gdb.trace/passc-dyn.exp gdb/testsuite/gdb.trace/passcount.exp gdb/testsuite/gdb.trace/report.exp gdb/testsuite/gdb.trace/save-trace.exp gdb/testsuite/gdb.trace/tfind.exp gdb/testsuite/gdb.trace/tracecmd.exp gdb/testsuite/gdb.trace/while-dyn.exp gdb/testsuite/gdb.trace/while-stepping.exp gdb/testsuite/lib/compiler.c gdb/testsuite/lib/compiler.cc gdb/testsuite/lib/gdb.exp gdb/top.c gdb/top.h gdb/tracepoint.c gdb/tui/tui-hooks.c gdb/utils.c gdb/varobj.c gdb/version.in gdb/xstormy16-tdep.c include/ChangeLog include/elf/ChangeLog include/elf/arm.h include/elf/bfin.h include/elf/hppa.h include/elf/m68k.h include/elf/mips.h include/elf/x86-64.h include/opcode/ChangeLog include/opcode/arm.h include/opcode/hppa.h include/opcode/m68k.h libiberty/ChangeLog libiberty/functions.texi libiberty/pex-common.c libiberty/pex-common.h opcodes/ChangeLog opcodes/arm-dis.c opcodes/bfin-dis.c opcodes/cgen-ibld.in opcodes/fr30-ibld.c opcodes/frv-ibld.c opcodes/i386-dis.c opcodes/ip2k-ibld.c opcodes/iq2000-asm.c opcodes/iq2000-ibld.c opcodes/m32c-asm.c opcodes/m32c-desc.c opcodes/m32c-desc.h opcodes/m32c-dis.c opcodes/m32c-ibld.c opcodes/m32c-opc.c opcodes/m32c-opc.h opcodes/m32r-ibld.c opcodes/openrisc-ibld.c opcodes/po/sv.po opcodes/xc16x-ibld.c opcodes/xstormy16-ibld.c readline/ChangeLog.gdb readline/histfile.c sim/ChangeLog sim/MAINTAINERS sim/arm/ChangeLog sim/arm/armos.c sim/common/ChangeLog sim/common/aclocal.m4 sim/m32c/ChangeLog sim/m32c/mem.c sim/m32c/r8c.opc sim/m32c/reg.c sim/m32c/syscall.h sim/m32c/syscalls.c sim/m68hc11/ChangeLog sim/m68hc11/configure sim/mips/ChangeLog sim/mips/configure sim/mn10300/ChangeLog sim/mn10300/configure Cherrypick from master 2006-03-31 19:47:11 UTC Michael Snyder '2006-03-31 Michael Snyder ': gdb/doc/ChangeLog gdb/doc/gdb.texinfo Delete: gdb/nlm/Makefile.in gdb/nlm/configure gdb/nlm/configure.in gdb/nlm/gdbserve.c gdb/nlm/gdbserve.def gdb/nlm/i386.c gdb/nlm/i386.h gdb/nlm/ppc.c gdb/nlm/ppc.h gdb/nlm/prelude.c --- diff --git a/ChangeLog b/ChangeLog index 2a680ac..c0126cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2006-03-14 Paolo Bonzini + + * Makefile.in: Regenerate. + +2006-03-14 Paolo Bonzini + + Sync with gcc: + 2006-03-10 Aldy Hernandez + + * configure.in: Handle --disable- generically. + * configure: Regenerate. + + 2006-02-21 Rafael Avila de Espindola + + * Makefile.tpl (BUILD_CONFIGDIRS): Remove. + (TARGET_CONFIGDIRS): Remove. + * configure.in: Remove AC_SUBST(target_configdirs). + * Makefile.in, configure: Regenerated. + + 2006-03-01 H.J. Lu PR libgcj/17311 diff --git a/Makefile.in b/Makefile.in index 37d5510..eae74a7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -84,8 +84,6 @@ GDB_NLM_DEPS = # the libraries. RPATH_ENVVAR = @RPATH_ENVVAR@ -# This is the list of directories to be built for the build system. -BUILD_CONFIGDIRS = libiberty # Build programs are put under this directory. BUILD_SUBDIR = @build_subdir@ # This is set by the configure script to the arguments to use when configuring @@ -178,9 +176,6 @@ POSTSTAGE1_HOST_EXPORTS = \ -B$$r/$(HOST_SUBDIR)/prev-gcc/ \ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; -# This is set by the configure script to the list of directories which -# should be built using the target tools. -TARGET_CONFIGDIRS = @target_configdirs@ # Target libraries are put under this directory: TARGET_SUBDIR = @target_subdir@ # This is set by the configure script to the arguments to use when configuring diff --git a/Makefile.tpl b/Makefile.tpl index 41c50c4..274474a 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -87,8 +87,6 @@ GDB_NLM_DEPS = # the libraries. RPATH_ENVVAR = @RPATH_ENVVAR@ -# This is the list of directories to be built for the build system. -BUILD_CONFIGDIRS = libiberty # Build programs are put under this directory. BUILD_SUBDIR = @build_subdir@ # This is set by the configure script to the arguments to use when configuring @@ -181,9 +179,6 @@ POSTSTAGE1_HOST_EXPORTS = \ -B$$r/$(HOST_SUBDIR)/prev-gcc/ \ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; -# This is set by the configure script to the list of directories which -# should be built using the target tools. -TARGET_CONFIGDIRS = @target_configdirs@ # Target libraries are put under this directory: TARGET_SUBDIR = @target_subdir@ # This is set by the configure script to the arguments to use when configuring diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e52fdfb..51157c0 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,540 @@ +2006-03-30 Ben Elliston + + PR ld/2267 + * elflink.c (elf_fixup_link_order): Ensure `elfsec' is not a + special section number that exceeds the number of ELF sections + (eg. SHN_MIPS_SCOMMON). + +2006-03-27 Richard Sandiford + + * elfxx-mips.c (mips_got_entry): Add more commentary. + (mips_elf_local_got_index): Use the hash table entry to record + the GOT index of forced-local symbols. + (mips_elf_initialize_tls_index): Rearrange code. Store the index + in either the hash table entry or the mips_got_entry, not both. + Add more commentary. + (mips_elf_multi_got): Make sure the g->next is nonnull when calling + mips_elf_initialize_tls_index. + +2006-03-25 Bernd Schmidt + + * elf32-bfin.c (bfd_const_reloc, bfd_oper_reloc, bfin_push_reloc, + RELOC_STACK_SIZE, reloc_stack, reloc_stack_tos, is_reloc_stack_empty, + reloc_stack_push, reloc_stack_pop, reloc_stack_operate, + bfin_areloc_howto_table): Delete. All + uses deleted as well. + (bfin_reloc_map): Delete all stack relocs. + (bfin_info_to_howto, bfin_bfd_reloc_type_lookup, + bfin_reloc_type_lookup): Don't support them. + (bfin_relocate_section): Don't try to handle them. + + * config.bfd (bfin-*-*): Add bfd_elf32_bfinfdpic_vec. + * configure.in: Likewise. + * configure: Regenerate. + * elf32-bfin.c: Include "elf/dwarf2.h" and "hashtab.h". + (BFIN_RELOC_MAX): Now 0x21. + (bfin_howto_table, bfin_reloc_map): Add FD-PIC relocs. + (bfd_elf32_bfinfdpic_vec): Declare. + (IS_FDPIC): New macro. + (struct bfinfdpic_elf_link_hash_table): New struct. + (bfinfdpic_hash_table, bfinfdpic_got_section, + bfinfdpic_gotrel_section, bfinfdpic_gotfixup_section, + bfinfdpic_plt_setion, bfinfdpic_pltrel_section, + bfinfdpic_relocs_info, bfinfdpic_got_initial_offset, + bfinfdpic_plt_initial_offset): Accessor macros for it. + (BFINFDPIC_SYM_LOCAL, BFINFDPIC_FUNCDESC_LOCAL): New macros. + (struct bfinfdpic_relocs_info): New struct. + (LZPLT_RESOLVER_EXTRA, LZPLT_NORMAL_SIZE, LZPLT_ENTRIES, + BFINFDPIC_LZPLT_BLOCK_SIZE, BFINFDPIC_LZPLT_RESOLV_LOC, + DEFAULT_STACK_SIZE): New macros. + (bfinfdpic_elf_link_hash_table_create, bfinfdpic_relocs_info_hash, + bfinfdpic_relocs_info_eq, bfinfdpics_relocs_info_find, + bfinfdpic_relocs_info_for_global, bfinfdpic_relocs_info_for_local, + bfinfdpic_pic_merge_early_relocs_info, _bfinfdpic_add_dyn_reloc, + _bfinfdpic_add_rofixup, _bfinfdpic_osec_to_segment, + _bfinfdpic_osec_readonly_p, bfinfdpic_relocate_section, + bfinfdpic_check_relocs, bfinfdpic_gc_sweep_hook, + _bfinfdpic_link_omit_section_dynsym, _bfin_create_got_section, + elf32_bfinfdpic_create_dynamic_sections, _bfinfdpic_get_fd_entry, + _bfinfdpic_compute_got_alloc_data, _bfinfdpic_get_got_entry, + _bfinfdpic_assign_got_entries, _bfinfdpic_assign_plt_entries, + _bfinfdpic_resolve_final_relocs_info, + elf32_bfinfdpic_size_dynamic_sections, + elf32_bfinfdpic_always_size_sections, + elf32_bfinfdpic_modify_segment_map, + _bfinfdpic_count_got_plt_entries, + elf32_bfinfdpic_finish_dynamic_sections, + elf32_bfinfdpic_adjust_dynamic_symbol, + elf32_bfinfdpic_finish_dynamic_symbol, + elf32_bfinfdpic_elf_use_relative_eh_frame, + elf32_bfinfdpic_elf_encode_eh_address, + elf32_bfin_object_p, bfin_elf_copy_private_bfd_data, + elf32_bfinfdpic_copy_private_bfd_data, + (struct _bfinfdpic_dynamic_got_info, + struct _bfinfdpic_dynamic_got_plt_info): New structs. + (elf32_bfin_print_private_bfd_data): Print PIC flags. + (elf32_bfin_merge_private_bfd_data): Extend to support FD-PIC. + (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME, elf32_bed, + elf_backend_got_header_size, bfd_elf32_bfd_link_hash_table_create, + elf_backend_always_size_sectinos, elf_backend_modify_segment_map, + bfd_elf32_bfd_copy_private_bfd_data, + elf_backend_create_dynamic_sections, elf_backend_adjust_dynamic_symbol, + elf_backend_size_dynamic_sections, elf_backend_finish_dynamic_symbol, + elf_backend_finish_dynamic_sections, elf_backend_relocate_section, + elf_backend_can_make_relative_eh_frame, elf_backend_check_relocs, + elf_backend_can_make_ldsa_relative_eh_frame, elf_backend_may_use_rel_p, + elf_backend_may_use_rela_p, elf_backend_default_use_rela_p, + elf_backend_omit_section_dynsym): Redefine these macros and include + "elf32-target.h" again to create the elf32-bfinfdpic target. + * reloc.c (BFD_RELOC_BFIN_GOT17M4, BFD_RELOC_BFIN_GOTHI, + BFD_RELOC_BFIN_GOTLO, BFD_RELOC_BFIN_FUNCDESC, + BFD_RELOC_BFIN_FUNCDESC_GOT17M4, BFD_RELOC_BFIN_FUNCDESC_GOTHI, + BFD_RELOC_BFIN_FUNCDESC_GOTLO, BFD_RELOC_BFIN_FUNCDESC_VALUE, + BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4, BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO, BFD_RELOC_BFIN_GOTOFFHI, + BFD_RELOC_BFIN_GOTOFFLO): New. + * targets.c (bfd_elf32_bfinfdpic_vec): New bfd_target. + (_bfd_target_vector): Add it. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + +2006-03-25 Richard Sandiford + + * cpu-m68k.c (bfd_m68k_compatible): Treat ISA A+ and ISA B code as + incompatible. Likewise MAC and EMAC code. + * elf32-m68k.c (elf32_m68k_merge_private_bfd_data): Use + bfd_get_compatible to set the new bfd architecture. Rely on it + to detect incompatibilities. + +2006-03-22 Bob Wilson + + * elf32-xtensa.c (xtensa_read_table_entries): Remove assertion that + rel->r_addend is zero. + +2006-03-22 Richard Sandiford + + * elfxx-mips.c (_bfd_mips_vxworks_finish_dynamic_symbol): Fix type + of "loc". + +2006-03-22 Richard Sandiford + Daniel Jacobowitz + Phil Edwards + Zack Weinberg + Mark Mitchell + Nathan Sidwell + + * bfd-in2.h: Regenerate. + * config.bfd (mips*-*-vxworks*, mips*el-*-vxworks*): New stanzas. + * configure.in (bfd_elf32_bigmips_vxworks_vec): New stanza. + (bfd_elf32_littlemips_vxworks_vec): Likewise. + (bfd_elf32_bigmips_vec): Add elf-vxworks.lo. + (bfd_elf32_littlemips_vec): Likewise. + (bfd_elf32_nbigmips_vec): Likewise. + (bfd_elf32_nlittlemips_vec): Likewise. + (bfd_elf32_ntradbigmips_vec): Likewise. + (bfd_elf32_ntradlittlemips_vec): Likewise. + (bfd_elf32_tradbigmips_vec): Likewise. + (bfd_elf32_tradlittlemips_vec): Likewise. + (bfd_elf64_bigmips_vec): Likewise. + (bfd_elf64_littlemips_vec): Likewise. + (bfd_elf64_tradbigmips_vec): Likewise. + (bfd_elf64_tradlittlemips_vec): Likewise. + * elf32-mips.c: Include elf-vxworks.h. + (mips_info_to_howto_rel): Use elf_backend_mips_rtype_to_howto + instead of calling mips_elf32_rtype_to_howto directly. + (mips_vxworks_copy_howto_rela): New reloc howto. + (mips_vxworks_jump_slot_howto_rela): Likewise. + (mips_vxworks_bfd_reloc_type_lookup): New function. + (mips_vxworks_rtype_to_howto): Likewise. + (mips_vxworks_final_write_processing): Likewise. + (TARGET_LITTLE_SYM, TARGET_LITTLE_NAME): Override for VxWorks. + (TARGET_BIG_SYM, TARGET_BIG_NAME, elf_bed, ELF_MAXPAGESIZE): Likewise. + (elf_backend_want_got_plt): Likewise. + (elf_backend_want_plt_sym): Likewise. + (elf_backend_got_symbol_offset): Likewise. + (elf_backend_want_dynbss): Likewise. + (elf_backend_may_use_rel_p): Likewise. + (elf_backend_may_use_rela_p): Likewise. + (elf_backend_default_use_rela_p): Likewise. + (elf_backend_got_header_size: Likewise. + (elf_backend_plt_readonly): Likewise. + (bfd_elf32_bfd_reloc_type_lookup): Likewise. + (elf_backend_mips_rtype_to_howto): Likewise. + (elf_backend_adjust_dynamic_symbol): Likewise. + (elf_backend_finish_dynamic_symbol): Likewise. + (bfd_elf32_bfd_link_hash_table_create): Likewise. + (elf_backend_add_symbol_hook): Likewise. + (elf_backend_link_output_symbol_hook): Likewise. + (elf_backend_emit_relocs): Likewise. + (elf_backend_final_write_processing: Likewise. + (elf_backend_additional_program_headers): Likewise. + (elf_backend_modify_segment_map): Likewise. + (elf_backend_symbol_processing): Likewise. + * elfxx-mips.c: Include elf-vxworks.h. + (mips_elf_link_hash_entry): Add is_relocation_target and + is_branch_target fields. + (mips_elf_link_hash_table): Add is_vxworks, srelbss, sdynbss, srelplt, + srelplt2, sgotplt, splt, plt_header_size and plt_entry_size fields. + (MIPS_ELF_RELA_SIZE, MIPS_ELF_REL_DYN_NAME): New macros. + (MIPS_RESERVED_GOTNO): Take a mips_elf_link_hash_table argument. + Return 3 for VxWorks. + (ELF_MIPS_GP_OFFSET): Change the argument from a bfd to a + mips_elf_link_hash_table. Return 0 for VxWorks. + (MIPS_ELF_GOT_MAX_SIZE): Change the argument from a bfd to a + mips_elf_link_hash_table. Update the call to ELF_MIPS_GP_OFFSET. + (mips_vxworks_exec_plt0_entry): New variable. + (mips_vxworks_exec_plt_entry): Likewise. + (mips_vxworks_shared_plt0_entry): Likewise. + (mips_vxworks_shared_plt_entry): Likewise. + (mips_elf_link_hash_newfunc): Initialize the new hash_entry fields. + (mips_elf_rel_dyn_section): Change the bfd argument to a + mips_elf_link_hash_table. Use MIPS_ELF_REL_DYN_NAME to get + the name of the section. + (mips_elf_initialize_tls_slots): Update the call to + mips_elf_rel_dyn_section. + (mips_elf_gotplt_index): New function. + (mips_elf_local_got_index): Add an input_section argument. + Update the call to mips_elf_create_local_got_entry. + (mips_elf_got_page): Likewise. + (mips_elf_got16_entry): Likewise. + (mips_elf_create_local_got_entry): Add bfd_link_info and input_section + arguments. Create dynamic relocations for each entry on VxWorks. + (mips_elf_merge_gots): Update the use of MIPS_ELF_GOT_MAX_SIZE. + (mips_elf_multi_got): Update the uses of MIPS_ELF_GOT_MAX_SIZE + and MIPS_RESERVED_GOTNO. + (mips_elf_create_got_section): Update the uses of + MIPS_ELF_GOT_MAX_SIZE. Create .got.plt on VxWorks. + (is_gott_symbol): New function. + (mips_elf_calculate_relocation): Use a dynobj local variable. + Update the calls to mips_elf_local_got_index, mips_elf_got16_entry and + mips_elf_got_page_entry. Set G to the .got.plt entry when calculating + VxWorks R_MIPS_CALL* relocations. Calculate and use G for all GOT + relocations on VxWorks. Add dynamic relocations for references + to the VxWorks __GOTT_BASE__ and __GOTT_INDEX__ symbols. Don't + create dynamic relocations for R_MIPS_32, R_MIPS_REL32 or R_MIPS_64 + in VxWorks executables. + (mips_elf_allocate_dynamic_relocations): Add a bfd_link_info argument. + Use MIPS_ELF_RELA_SIZE to calculate the size of a VxWorks entry. + Don't allocate a null entry on VxWorks. + (mips_elf_create_dynamic_relocation): Update the call to + mips_elf_rel_dyn_section. Use absolute rather than relative + relocations for VxWorks, and make them RELA rather than REL. + (_bfd_mips_elf_create_dynamic_sections): Don't make .dynamic + read-only on VxWorks. Update the call to mips_elf_rel_dyn_section. + Create the .plt, .rela.plt, .dynbss and .rela.bss sections on + VxWorks. Likewise create the _PROCEDURE_LINKAGE_TABLE symbol. + Call elf_vxworks_create_dynamic_sections for VxWorks and + initialize the plt_header_size and plt_entry_size fields. + (_bfd_mips_elf_check_relocs): Don't allow GOT relocations to be + used in VxWorks executables. Don't allocate dynamic relocations + for R_MIPS_32, R_MIPS_REL32 or R_MIPS_64 in VxWorks executables. + Set is_relocation_target for each symbol referenced by a relocation. + Allocate .rela.dyn entries for relocations against the special + VxWorks __GOTT_BASE__ and __GOTT_INDEX__ symbols. Create GOT + entries for all VxWorks R_MIPS_GOT16 relocations. Don't allocate + a global GOT entry for symbols mentioned in VxWorks R_MIPS_CALL*, + R_MIPS_32, R_MIPS_REL32 or R_MIPS_64 relocations. Update the calls + to mips_elf_rel_dyn_section and mips_elf_allocate_dynamic_relocations. + Set is_branch_target for symbols mentioned in R_MIPS_PC16 or R_MIPS_26 + relocations. Don't set no_fn_stub on VxWorks. + (_bfd_mips_elf_adjust_dynamic_symbol): Update the call to + mips_elf_allocate_dynamic_relocations. + (_bfd_mips_vxworks_adjust_dynamic_symbol): New function. + (_bfd_mips_elf_always_size_sections): Do not allocate GOT page + entries for VxWorks, and do not create multiple GOTs. + (_bfd_mips_elf_size_dynamic_sections): Use MIPS_ELF_REL_DYN_NAME. + Handle .got specially for VxWorks. Update the uses of + MIPS_RESERVED_GOTNO and mips_elf_allocate_dynamic_relocations. + Check for sgotplt and splt. Allocate the .rel(a).dyn contents last, + once its final size is known. Set DF_TEXTREL for VxWorks. Add + DT_RELA, DT_RELASZ, DT_RELAENT, DT_PLTREL, DT_PLTRELSZ and DT_JMPREL + tags on VxWorks. Do not add the MIPS-specific tags for VxWorks. + (_bfd_mips_vxworks_finish_dynamic_symbol): New function. + (mips_vxworks_finish_exec_plt): Likewise. + (mips_vxworks_finish_shared_plt): Likewise. + (_bfd_mips_elf_finish_dynamic_sections): Remove an unncessary call + to mips_elf_rel_dyn_section. Use a VxWorks-specific value of + DT_PLTGOT. Handle DT_RELA, DT_RELASZ, DT_RELAENT, DT_PLTREL, + DT_PLTRELSZ and DT_JMPREL. Update the uses of MIPS_RESERVED_GOTNO + and mips_elf_rel_dyn_section. Use a different GOT header for + VxWorks. Don't sort .rela.dyn on VxWorks. Finish the PLT on VxWorks. + (_bfd_mips_elf_link_hash_table_create): Initialize the new + mips_elf_link_hash_table fields. + (_bfd_mips_vxworks_link_hash_table_create): New function. + (_bfd_mips_elf_final_link): Set the GP value to _GLOBAL_OFFSET_TABLE_ + on VxWorks. Update the call to ELF_MIPS_GP_OFFSET. + * elfxx-mips.h (_bfd_mips_vxworks_adjust_dynamic_symbol): Declare. + (_bfd_mips_vxworks_finish_dynamic_symbol): Likewise. + (_bfd_mips_vxworks_link_hash_table_create): Likewise. + * libbfd.h: Regenerate. + * Makefile.am (elfxx-mips.lo): Depend on elf-vxworks.h. + (elf32-mips.lo): Likewise. + * Makefile.in: Regenerate. + * reloc.c (BFD_RELOC_MIPS_COPY, BFD_RELOC_MIPS_JUMP_SLOT): Declare. + * targets.c (bfd_elf32_bigmips_vxworks_vec): Declare. + (bfd_elf32_littlemips_vxworks_vec): Likewise. + (_bfd_target_vector): Add entries for them. + +2006-03-19 John David Anglin + + * elf64-hppa.c (elf64_hppa_special_sections): Change flags for .tbss + section from SHF_PARISC_WEAKORDER to SHF_HP_TLS. + (elf_backend_special_sections): Remove #undef. + +2006-03-18 John David Anglin + + * elf64-hppa.c (allocate_global_data_opd): Don't create an OPD entry + for undefined weak symbols. + +2006-03-17 Daniel Jacobowitz + + PR ld/2462 + * elflink.c (bfd_elf_final_link): Remove + bed->elf_backend_emit_relocs from emit_relocs. + +2006-03-17 Alexandre Oliva + + * elf32-ppc.c (ppc_elf_relocate_section): Copy addend from + first relocation to the second when relaxing TLS GD to LE; + zero it out when relaxing to IE. + +2006-03-17 Alan Modra + + PR 2434 + * elflink.c (elf_link_add_object_symbols): Save and restore + warning sym's linked sym. + +2006-03-16 Alan Modra + + PR 2434 + * elflink.c (struct elf_smash_syms_data, elf_smash_syms): Delete. + (elf_link_add_object_symbols): Delete unnecessary locals. Rename + hash_table -> htab. Formatting. Save entire symbol table + before loading as-needed syms, and restore afterwards if lib not + needed. Use bfd_hash_allocate rather than bfd_alloc for sym + name. Free some buffers earlier. + * bfd-in.h (struct bfd_hash_table): Add entsize. + (bfd_hash_table_init, bfd_hash_table_init_n): Adjust prototype. + * elf-bfd.h (_bfd_elf_link_hash_table_init): Likewise + * hash.c (bfd_hash_table_init_n): Add entsize param, save to + hash table. + (bfd_hash_table_init): Add param, adjust calls. + * aoutx.h: Adjust all hash_table_init functions and calls. + * bfd.c: Likewise. + * coff-arm.c: Likewise. + * coff-h8300.c: Likewise. + * coff-ppc.c: Likewise. + * cofflink.c: Likewise. + * ecoff.c: Likewise. + * ecofflink.c: Likewise. + * elf-m10300.c: Likewise. + * elf-strtab.c: Likewise. + * elf.c: Likewise. + * elf32-arm.c: Likewise. + * elf32-bfin.c: Likewise. + * elf32-cris.c: Likewise. + * elf32-frv.c: Likewise. + * elf32-hppa.c: Likewise. + * elf32-i386.c: Likewise. + * elf32-m32r.c: Likewise. + * elf32-m68hc1x.c: Likewise. + * elf32-m68k.c: Likewise. + * elf32-ppc.c: Likewise. + * elf32-s390.c: Likewise. + * elf32-sh.c: Likewise. + * elf32-vax.c: Likewise. + * elf64-alpha.c: Likewise. + * elf64-hppa.c: Likewise. + * elf64-ppc.c: Likewise. + * elf64-s390.c: Likewise. + * elf64-sh64.c: Likewise. + * elf64-x86-64.c: Likewise. + * elfxx-ia64.c: Likewise. + * elfxx-mips.c: Likewise. + * elfxx-sparc.c: Likewise. + * i386linux.c: Likewise. + * libaout.h: Likewise. + * libbfd-in.h: Likewise. + * libcoff-in.h: Likewise. + * linker.c: Likewise. + * m68klinux.c: Likewise. + * merge.c: Likewise. + * opncls.c: Likewise. + * pdp11.c: Likewise. + * sparclinux.c: Likewise. + * stabs.c: Likewise. + * sunos.c: Likewise. + * vms.c: Likewise. + * xcofflink.c: Likewise. + * section.c (struct section_hash_entry): Move to.. + * libbfd-in.h: ..here. + * Makefile.am: Run "make dep-am" + * Makefile.in: Regenerate. + * bfd-in2.h: Regenerate. + * libbfd.h: Regenerate. + * libcoff.h: Regenerate. + +2006-03-16 Alan Modra + + * elf32-ppc.c (ppc_elf_check_relocs): REL24 and REL14 relocs + against __GLOBAL_OFFSET_TABLE__ need never be dynamic. Tweak + last change to REL32 relocs so that they are counted as + possibly dynamic as per REL24 and REL14. + +2006-03-16 Alan Modra + + * elf32-ppc.c (ppc_elf_check_relocs): Don't fall into REL24 + checks from REL32. + +2006-03-15 Ben Elliston + + * elf32-arm.c (elf32_arm_merge_eabi_attributes): Iterate over all + in_list elements, not just the first. + +2006-03-14 Richard Sandiford + + * elf32-mips.c (mips_elf_adjust_addend): New function, mostly split + out from... + (_bfd_mips_elf_relocate_section): ...here. Use it to adjust r_addend + for final links too. + +2006-03-13 Richard Sandiford + + * elfxx-mips.c (mips_elf_create_got_section): Initialize hgot. + +2006-03-11 H.J. Lu + + PR ld/2443 + * dwarf2.c (concat_filename): Don't issue an error if file is + 0. + +2006-03-10 Paul Brook + + * elf32-arm.c (INTERWORK_FLAG): Handle EABIv5. + (elf32_arm_print_private_bfd_data): Ditto. + +2006-03-09 Paul Brook + + * cpu-arm.c (bfd_is_arm_mapping_symbol_name): Recognise additional + mapping symbols. + +2006-03-09 Khem Raj + + * elf32-arm.c(elf32_arm_finish_dynamic_sections): Use unsigned + char type. + +2006-03-08 H.J. Lu + + * elfxx-ia64.c (elfNN_ia64_choose_gp): Properly choose gp. + +2006-03-07 Richard Sandiford + Daniel Jacobowitz + Zack Weinberg + Nathan Sidwell + Paul Brook + Ricardo Anguiano + Phil Edwards + + * configure.in (bfd_elf32_bigarm_vec): Include elf-vxworks.lo. + (bfd_elf32_bigarm_symbian_vec): Likewise. + (bfd_elf32_bigarm_vxworks_vec): Likewise. + (bfd_elf32_littlearm_vec): Likewise. + (bfd_elf32_littlearm_symbian_vec): Likewise. + (bfd_elf32_littlearm_vxworks_vec): Likewise. + * configure: Regenerate. + * elf32-arm.c: Include libiberty.h and elf-vxworks.h. + (RELOC_SECTION, RELOC_SIZE, SWAP_RELOC_IN, SWAP_RELOC_OUT): New macros. + (elf32_arm_vxworks_bed): Add forward declaration. + (elf32_arm_howto_table_1): Fix the masks for R_ASM_ABS12. + (elf32_arm_vxworks_exec_plt0_entry): New table. + (elf32_arm_vxworks_exec_plt_entry): Likewise. + (elf32_arm_vxworks_shared_plt_entry): Likewise. + (elf32_arm_link_hash_table): Add vxworks_p and srelplt2 fields. + (reloc_section_p): New function. + (create_got_section): Use RELOC_SECTION. + (elf32_arm_create_dynamic_sections): Likewise. Call + elf_vxworks_create_dynamic_sections for VxWorks targets. + Choose between the two possible values of plt_header_size + and plt_entry_size. + (elf32_arm_link_hash_table_create): Initialize vxworks_p and srelplt2. + (elf32_arm_abs12_reloc): New function. + (elf32_arm_final_link_relocate): Call it. Allow the creation of + dynamic R_ARM_ABS12 relocs on VxWorks. Use reloc_section_p, + RELOC_SIZE, SWAP_RELOC_OUT and RELOC_SECTION. Initialize the + r_addend fields of relocs. On rela targets, skip any code that + adjusts in-place addends. When using _bfd_link_final_relocate + to perform a final relocation, pass rel->r_addend as the addend + argument. + (elf32_arm_merge_private_bfd_data): If one of the bfds is a VxWorks + object, ignore flags that are not standard on VxWorks. + (elf32_arm_check_relocs): Allow the creation of dynamic R_ARM_ABS12 + relocs on VxWorks. Use reloc_section_p. + (elf32_arm_adjust_dynamic_symbol): Use RELOC_SECTION and RELOC_SIZE. + (allocate_dynrelocs): Use RELOC_SIZE. Account for the size of + .rela.plt.unloaded relocs on VxWorks targets. + (elf32_arm_size_dynamic_sections): Use RELOC_SIZE. Check for + .rela.plt.unloaded as well as .rel(a).plt. Add DT_RELA* tags + instead of DT_REL* tags on RELA targets. + (elf32_arm_finish_dynamic_symbol): Use RELOC_SECTION, RELOC_SIZE + and SWAP_RELOC_OUT. Initialize r_addend fields. Handle VxWorks + PLT entries. Do not make _GLOBAL_OFFSET_TABLE_ absolute on VxWorks. + (elf32_arm_finish_dynamic_sections): Use RELOC_SECTION, RELOC_SIZE + and SWAP_RELOC_OUT. Initialize r_addend fields. Handle DT_RELASZ + like DT_RELSZ. Handle the VxWorks form of initial PLT entry. + Correct the .rela.plt.unreloaded symbol indexes. + (elf32_arm_output_symbol_hook): Call the VxWorks version of this + hook on VxWorks targets. + (elf32_arm_vxworks_link_hash_table_create): Set vxworks_p to true. + Minor formatting tweak. + (elf32_arm_vxworks_final_write_processing): New function. + (elf_backend_add_symbol_hook): Override for VxWorks and reset + for Symbian. + (elf_backend_final_write_processing): Likewise. + (elf_backend_emit_relocs): Likewise. + (elf_backend_want_plt_sym): Likewise. + (ELF_MAXPAGESIZE): Likewise. + (elf_backend_may_use_rel_p): Minor formatting tweak. + (elf_backend_may_use_rela_p): Likewise. + (elf_backend_default_use_rela_p): Likewise. + (elf_backend_rela_normal): Likewise. + * Makefile.in (elf32-arm.lo): Depend on elf-vxworks.h. + +2006-03-06 Nathan Sidwell + + * archures.c (bfd_mach_mcf_isa_a_nodiv, bfd_mach_mcf_isa_b_nousp): + New. Adjust other variants. + (bfd_default_scan): Update. + * bfd-in2.h: Rebuilt. + * cpu-m68k.c: Adjust. + (bfd_m68k_compatible): New. Use it for architectures. + * elf32-m68k.c (elf32_m68k_object_p): Adjust. + (elf32_m68k_merge_private_bfd_data): Adjust. Correct isa-a/b + mismatch. + (elf32_m68k_print_private_bfd_data): Adjust. + * ieee.c (ieee_write_processor): Adjust. + +2006-03-06 Alan Modra + + * dwarf2.c: Formatting. + (add_line_info): Remove outer loop. + +2006-03-05 H.J. Lu + Alan Modra + + PR binutils/2338 + * dwarf2.c (loadable_section): New struct. + (dwarf2_debug): Add loadable_section_count and + loadable_sections. + (new_line_sorts_after): New. + (add_line_info): Use new_line_sorts_after to compare line + addresses. + (check_function_name): Removed. + (unset_sections): New. + (place_sections): New. + (_bfd_dwarf2_find_nearest_line): Updated. Call place_sections + and unset_sections on relocatable files. + (_bfd_dwarf2_find_line): Likewise. + 2006-03-03 Nick Clifton * cpu-avr.c: Update to ISO-C90 formatting. diff --git a/bfd/Makefile.am b/bfd/Makefile.am index f793c9a..a0d5edf 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -1000,7 +1000,8 @@ cpu-m68hc11.lo: cpu-m68hc11.c $(INCDIR)/filenames.h \ $(INCDIR)/hashtab.h cpu-m68hc12.lo: cpu-m68hc12.c $(INCDIR)/filenames.h \ $(INCDIR)/hashtab.h -cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h +cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ + $(INCDIR)/opcode/m68k.h cpu-m88k.lo: cpu-m88k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h cpu-m10200.lo: cpu-m10200.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h @@ -1218,10 +1219,11 @@ elf32-arc.lo: elf32-arc.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h \ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \ elf32-target.h -elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arm.h \ - $(INCDIR)/elf/reloc-macros.h elf32-target.h +elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ + $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + elf-vxworks.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-avr.lo: elf32-avr.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/avr.h \ @@ -1312,7 +1314,8 @@ elf32-m32r.lo: elf32-m32r.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf32-m68k.lo: elf32-m68k.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/m68k.h \ - $(INCDIR)/elf/reloc-macros.h elf32-target.h + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/opcode/m68k.h \ + elf32-target.h elf32-m68hc11.lo: elf32-m68hc11.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elf32-m68hc1x.h \ @@ -1347,14 +1350,14 @@ elfxx-mips.lo: elfxx-mips.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ elfxx-mips.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ - $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h + $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h elf-vxworks.h elf32-mips.lo: elf32-mips.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/bfdlink.h genlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfxx-mips.h \ $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h \ $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h \ - ecoffswap.h elf32-target.h + ecoffswap.h elf32-target.h elf-vxworks.h elf32-mt.lo: elf32-mt.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/mt.h \ @@ -1439,17 +1442,17 @@ elf32-xtensa.lo: elf32-xtensa.c $(INCDIR)/filenames.h \ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/xtensa-isa.h \ $(INCDIR)/xtensa-config.h elf32-target.h elf32-xc16x.lo: elf32-xc16x.c $(INCDIR)/filenames.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/xc16x.h \ - $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \ - elf32-target.h + $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/xc16x.h $(INCDIR)/elf/reloc-macros.h \ + $(INCDIR)/elf/dwarf2.h $(INCDIR)/libiberty.h elf32-target.h elf32.lo: elf32.c elfcode.h $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfcore.h elflink.lo: elflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/safe-ctype.h \ - $(INCDIR)/libiberty.h + $(INCDIR)/libiberty.h $(INCDIR)/objalloc.h elf-strtab.lo: elf-strtab.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h diff --git a/bfd/Makefile.in b/bfd/Makefile.in index bd496aa..6b78333 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -2,7 +2,7 @@ # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. +# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -1567,7 +1567,8 @@ cpu-m68hc11.lo: cpu-m68hc11.c $(INCDIR)/filenames.h \ $(INCDIR)/hashtab.h cpu-m68hc12.lo: cpu-m68hc12.c $(INCDIR)/filenames.h \ $(INCDIR)/hashtab.h -cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h +cpu-m68k.lo: cpu-m68k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ + $(INCDIR)/opcode/m68k.h cpu-m88k.lo: cpu-m88k.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h cpu-m10200.lo: cpu-m10200.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h cpu-m10300.lo: cpu-m10300.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h @@ -1785,10 +1786,11 @@ elf32-arc.lo: elf32-arc.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arc.h \ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \ elf32-target.h -elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/arm.h \ - $(INCDIR)/elf/reloc-macros.h elf32-target.h +elf32-arm.lo: elf32-arm.c $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ + $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + elf-vxworks.h $(INCDIR)/elf/arm.h $(INCDIR)/elf/reloc-macros.h \ + elf32-target.h elf32-avr.lo: elf32-avr.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/avr.h \ @@ -1879,7 +1881,8 @@ elf32-m32r.lo: elf32-m32r.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf32-m68k.lo: elf32-m68k.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/elf/m68k.h \ - $(INCDIR)/elf/reloc-macros.h elf32-target.h + $(INCDIR)/elf/reloc-macros.h $(INCDIR)/opcode/m68k.h \ + elf32-target.h elf32-m68hc11.lo: elf32-m68hc11.c $(INCDIR)/filenames.h \ $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elf32-m68hc1x.h \ @@ -1914,14 +1917,14 @@ elfxx-mips.lo: elfxx-mips.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ elfxx-mips.h $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/ecoff.h \ - $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h + $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h elf-vxworks.h elf32-mips.lo: elf32-mips.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ $(INCDIR)/bfdlink.h genlink.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfxx-mips.h \ $(INCDIR)/elf/mips.h $(INCDIR)/elf/reloc-macros.h $(INCDIR)/coff/sym.h \ $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h $(INCDIR)/coff/external.h \ - ecoffswap.h elf32-target.h + ecoffswap.h elf32-target.h elf-vxworks.h elf32-mt.lo: elf32-mt.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/mt.h \ @@ -2006,17 +2009,17 @@ elf32-xtensa.lo: elf32-xtensa.c $(INCDIR)/filenames.h \ $(INCDIR)/elf/reloc-macros.h $(INCDIR)/xtensa-isa.h \ $(INCDIR)/xtensa-config.h elf32-target.h elf32-xc16x.lo: elf32-xc16x.c $(INCDIR)/filenames.h \ - elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ - $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/elf/xc16x.h \ - $(INCDIR)/elf/reloc-macros.h $(INCDIR)/libiberty.h \ - elf32-target.h + $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ + $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \ + $(INCDIR)/elf/xc16x.h $(INCDIR)/elf/reloc-macros.h \ + $(INCDIR)/elf/dwarf2.h $(INCDIR)/libiberty.h elf32-target.h elf32.lo: elf32.c elfcode.h $(INCDIR)/filenames.h $(INCDIR)/libiberty.h \ $(INCDIR)/bfdlink.h $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h elfcore.h elflink.lo: elflink.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \ $(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \ $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/safe-ctype.h \ - $(INCDIR)/libiberty.h + $(INCDIR)/libiberty.h $(INCDIR)/objalloc.h elf-strtab.lo: elf-strtab.c $(INCDIR)/filenames.h $(INCDIR)/hashtab.h \ elf-bfd.h $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h \ $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h $(INCDIR)/libiberty.h diff --git a/bfd/aoutx.h b/bfd/aoutx.h index 9c44605..7dce072 100644 --- a/bfd/aoutx.h +++ b/bfd/aoutx.h @@ -1,6 +1,6 @@ /* BFD semi-generic back-end for a.out binaries. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -2859,9 +2859,10 @@ NAME (aout, link_hash_table_init) (struct aout_link_hash_table *table, bfd *abfd, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { - return _bfd_link_hash_table_init (&table->root, abfd, newfunc); + return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize); } /* Create an a.out link hash table. */ @@ -2876,8 +2877,9 @@ NAME (aout, link_hash_table_create) (bfd *abfd) if (ret == NULL) return NULL; - if (! NAME (aout, link_hash_table_init) (ret, abfd, - NAME (aout, link_hash_newfunc))) + if (!NAME (aout, link_hash_table_init) (ret, abfd, + NAME (aout, link_hash_newfunc), + sizeof (struct aout_link_hash_entry))) { free (ret); return NULL; @@ -5252,9 +5254,10 @@ NAME (aout, final_link) (bfd *abfd, aout_info.symbol_map = NULL; aout_info.output_syms = NULL; - if (! bfd_hash_table_init_n (&aout_info.includes.root, - aout_link_includes_newfunc, - 251)) + if (!bfd_hash_table_init_n (&aout_info.includes.root, + aout_link_includes_newfunc, + sizeof (struct aout_link_includes_entry), + 251)) goto error_return; includes_hash_initialized = TRUE; diff --git a/bfd/archures.c b/bfd/archures.c index fc2f85b..f4080a6 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -80,22 +80,22 @@ DESCRIPTION .#define bfd_mach_m68040 6 .#define bfd_mach_m68060 7 .#define bfd_mach_cpu32 8 -.#define bfd_mach_mcf_isa_a 9 -.#define bfd_mach_mcf_isa_a_div 10 -.#define bfd_mach_mcf_isa_a_div_mac 11 -.#define bfd_mach_mcf_isa_a_div_emac 12 +.#define bfd_mach_mcf_isa_a_nodiv 9 +.#define bfd_mach_mcf_isa_a 10 +.#define bfd_mach_mcf_isa_a_mac 11 +.#define bfd_mach_mcf_isa_a_emac 12 .#define bfd_mach_mcf_isa_aplus 13 .#define bfd_mach_mcf_isa_aplus_mac 14 .#define bfd_mach_mcf_isa_aplus_emac 15 -.#define bfd_mach_mcf_isa_aplus_usp 16 -.#define bfd_mach_mcf_isa_aplus_usp_mac 17 -.#define bfd_mach_mcf_isa_aplus_usp_emac 18 +.#define bfd_mach_mcf_isa_b_nousp 16 +.#define bfd_mach_mcf_isa_b_nousp_mac 17 +.#define bfd_mach_mcf_isa_b_nousp_emac 18 .#define bfd_mach_mcf_isa_b 19 .#define bfd_mach_mcf_isa_b_mac 20 .#define bfd_mach_mcf_isa_b_emac 21 -.#define bfd_mach_mcf_isa_b_usp_float 22 -.#define bfd_mach_mcf_isa_b_usp_float_mac 23 -.#define bfd_mach_mcf_isa_b_usp_float_emac 24 +.#define bfd_mach_mcf_isa_b_float 22 +.#define bfd_mach_mcf_isa_b_float_mac 23 +.#define bfd_mach_mcf_isa_b_float_emac 24 . bfd_arch_vax, {* DEC Vax *} . bfd_arch_i960, {* Intel 960 *} . {* The order of the following is important. @@ -1016,23 +1016,23 @@ bfd_default_scan (const bfd_arch_info_type *info, const char *string) break; case 5200: arch = bfd_arch_m68k; - number = bfd_mach_mcf_isa_a; + number = bfd_mach_mcf_isa_a_nodiv; break; case 5206: arch = bfd_arch_m68k; - number = bfd_mach_mcf_isa_a_div_mac; + number = bfd_mach_mcf_isa_a_mac; break; case 5307: arch = bfd_arch_m68k; - number = bfd_mach_mcf_isa_a_div_mac; + number = bfd_mach_mcf_isa_a_mac; break; case 5407: arch = bfd_arch_m68k; - number = bfd_mach_mcf_isa_b_mac; + number = bfd_mach_mcf_isa_b_nousp_mac; break; case 5282: arch = bfd_arch_m68k; - number = bfd_mach_mcf_isa_b_usp_float_emac; + number = bfd_mach_mcf_isa_aplus_emac; break; case 32000: diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 25ae6a4..9daa578 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -376,6 +376,8 @@ struct bfd_hash_table struct bfd_hash_entry **table; /* The number of slots in the hash table. */ unsigned int size; + /* The size of elements. */ + unsigned int entsize; /* A function used to create new elements in the hash table. The first entry is itself a pointer to an element. When this function is first invoked, this pointer will be NULL. However, @@ -395,7 +397,8 @@ extern bfd_boolean bfd_hash_table_init (struct bfd_hash_table *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); /* Initialize a hash table specifying a size. */ extern bfd_boolean bfd_hash_table_init_n @@ -403,7 +406,7 @@ extern bfd_boolean bfd_hash_table_init_n struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), - unsigned int size); + unsigned int, unsigned int); /* Free up a hash table. */ extern void bfd_hash_table_free diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index cc9eb24..63fb521 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -383,6 +383,8 @@ struct bfd_hash_table struct bfd_hash_entry **table; /* The number of slots in the hash table. */ unsigned int size; + /* The size of elements. */ + unsigned int entsize; /* A function used to create new elements in the hash table. The first entry is itself a pointer to an element. When this function is first invoked, this pointer will be NULL. However, @@ -402,7 +404,8 @@ extern bfd_boolean bfd_hash_table_init (struct bfd_hash_table *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); /* Initialize a hash table specifying a size. */ extern bfd_boolean bfd_hash_table_init_n @@ -410,7 +413,7 @@ extern bfd_boolean bfd_hash_table_init_n struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), - unsigned int size); + unsigned int, unsigned int); /* Free up a hash table. */ extern void bfd_hash_table_free @@ -1674,22 +1677,22 @@ enum bfd_architecture #define bfd_mach_m68040 6 #define bfd_mach_m68060 7 #define bfd_mach_cpu32 8 -#define bfd_mach_mcf_isa_a 9 -#define bfd_mach_mcf_isa_a_div 10 -#define bfd_mach_mcf_isa_a_div_mac 11 -#define bfd_mach_mcf_isa_a_div_emac 12 +#define bfd_mach_mcf_isa_a_nodiv 9 +#define bfd_mach_mcf_isa_a 10 +#define bfd_mach_mcf_isa_a_mac 11 +#define bfd_mach_mcf_isa_a_emac 12 #define bfd_mach_mcf_isa_aplus 13 #define bfd_mach_mcf_isa_aplus_mac 14 #define bfd_mach_mcf_isa_aplus_emac 15 -#define bfd_mach_mcf_isa_aplus_usp 16 -#define bfd_mach_mcf_isa_aplus_usp_mac 17 -#define bfd_mach_mcf_isa_aplus_usp_emac 18 +#define bfd_mach_mcf_isa_b_nousp 16 +#define bfd_mach_mcf_isa_b_nousp_mac 17 +#define bfd_mach_mcf_isa_b_nousp_emac 18 #define bfd_mach_mcf_isa_b 19 #define bfd_mach_mcf_isa_b_mac 20 #define bfd_mach_mcf_isa_b_emac 21 -#define bfd_mach_mcf_isa_b_usp_float 22 -#define bfd_mach_mcf_isa_b_usp_float_mac 23 -#define bfd_mach_mcf_isa_b_usp_float_emac 24 +#define bfd_mach_mcf_isa_b_float 22 +#define bfd_mach_mcf_isa_b_float_mac 23 +#define bfd_mach_mcf_isa_b_float_emac 24 bfd_arch_vax, /* DEC Vax */ bfd_arch_i960, /* Intel 960 */ /* The order of the following is important. @@ -2585,6 +2588,11 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_MIPS_TLS_TPREL_LO16, +/* MIPS ELF relocations (VxWorks extensions). */ + BFD_RELOC_MIPS_COPY, + BFD_RELOC_MIPS_JUMP_SLOT, + + /* Fujitsu Frv Relocations. */ BFD_RELOC_FRV_LABEL16, BFD_RELOC_FRV_LABEL24, @@ -2699,6 +2707,11 @@ in the instruction. */ BFD_RELOC_X86_64_TPOFF32, BFD_RELOC_X86_64_GOTOFF64, BFD_RELOC_X86_64_GOTPC32, + BFD_RELOC_X86_64_GOT64, + BFD_RELOC_X86_64_GOTPCREL64, + BFD_RELOC_X86_64_GOTPC64, + BFD_RELOC_X86_64_GOTPLT64, + BFD_RELOC_X86_64_PLTOFF64, BFD_RELOC_X86_64_GOTPC32_TLSDESC, BFD_RELOC_X86_64_TLSDESC_CALL, BFD_RELOC_X86_64_TLSDESC, @@ -3072,6 +3085,22 @@ through 0. */ /* ADI Blackfin Long Jump pcrel. */ BFD_RELOC_BFIN_24_PCREL_JUMP_L, +/* ADI Blackfin FD-PIC relocations. */ + BFD_RELOC_BFIN_GOT17M4, + BFD_RELOC_BFIN_GOTHI, + BFD_RELOC_BFIN_GOTLO, + BFD_RELOC_BFIN_FUNCDESC, + BFD_RELOC_BFIN_FUNCDESC_GOT17M4, + BFD_RELOC_BFIN_FUNCDESC_GOTHI, + BFD_RELOC_BFIN_FUNCDESC_GOTLO, + BFD_RELOC_BFIN_FUNCDESC_VALUE, + BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI, + BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO, + BFD_RELOC_BFIN_GOTOFF17M4, + BFD_RELOC_BFIN_GOTOFFHI, + BFD_RELOC_BFIN_GOTOFFLO, + /* ADI Blackfin GOT relocation. */ BFD_RELOC_BFIN_GOT, diff --git a/bfd/bfd.c b/bfd/bfd.c index c4b18e9..733f6ee 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -1440,7 +1440,8 @@ bfd_preserve_save (bfd *abfd, struct bfd_preserve *preserve) preserve->section_count = abfd->section_count; preserve->section_htab = abfd->section_htab; - if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc)) + if (! bfd_hash_table_init (&abfd->section_htab, bfd_section_hash_newfunc, + sizeof (struct section_hash_entry))) return FALSE; abfd->tdata.any = NULL; diff --git a/bfd/coff-arm.c b/bfd/coff-arm.c index 4ae195c..6b83dc7 100644 --- a/bfd/coff-arm.c +++ b/bfd/coff-arm.c @@ -1,6 +1,6 @@ /* BFD back-end for ARM COFF files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -879,8 +879,10 @@ coff_arm_link_hash_table_create (bfd * abfd) if (ret == NULL) return NULL; - if (! _bfd_coff_link_hash_table_init - (& ret->root, abfd, _bfd_coff_link_hash_newfunc)) + if (!_bfd_coff_link_hash_table_init (&ret->root, + abfd, + _bfd_coff_link_hash_newfunc, + sizeof (struct coff_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c index ef29664..9c858e1 100644 --- a/bfd/coff-h8300.c +++ b/bfd/coff-h8300.c @@ -1,6 +1,6 @@ /* BFD back-end for Renesas H8/300 COFF binaries. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Steve Chamberlain, . @@ -63,13 +63,6 @@ static struct bfd_hash_entry * funcvec_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *); -static bfd_boolean -funcvec_hash_table_init - (struct funcvec_hash_table *, bfd *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *)); - static bfd_reloc_status_type special (bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **); static int select_reloc @@ -181,13 +174,14 @@ funcvec_hash_table_init (struct funcvec_hash_table *table, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { /* Initialize our local fields, then call the generic initialization routine. */ table->offset = 0; table->abfd = abfd; - return (bfd_hash_table_init (&table->root, newfunc)); + return (bfd_hash_table_init (&table->root, newfunc, entsize)); } /* Create the derived linker hash table. We use a derived hash table @@ -204,7 +198,8 @@ h8300_coff_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; if (!_bfd_link_hash_table_init (&ret->root.root, abfd, - _bfd_generic_link_hash_newfunc)) + _bfd_generic_link_hash_newfunc, + sizeof (struct generic_link_hash_entry))) { free (ret); return NULL; @@ -1298,7 +1293,8 @@ h8300_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info) /* And initialize the funcvec hash table. */ if (!funcvec_hash_table_init (funcvec_hash_table, abfd, - funcvec_hash_newfunc)) + funcvec_hash_newfunc, + sizeof (struct funcvec_hash_entry))) { bfd_release (abfd, funcvec_hash_table); return FALSE; diff --git a/bfd/coff-ppc.c b/bfd/coff-ppc.c index 55f5f62..b442793 100644 --- a/bfd/coff-ppc.c +++ b/bfd/coff-ppc.c @@ -1,6 +1,6 @@ /* BFD back-end for PowerPC Microsoft Portable Executable files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Original version pieced together by Kim Knuttila (krk@cygnus.com) @@ -127,11 +127,6 @@ struct ppc_coff_link_hash_table static struct bfd_hash_entry *ppc_coff_link_hash_newfunc PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); -static bfd_boolean ppc_coff_link_hash_table_init - PARAMS ((struct ppc_coff_link_hash_table *, bfd *, - struct bfd_hash_entry *(*) (struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *))); static struct bfd_link_hash_table *ppc_coff_link_hash_table_create PARAMS ((bfd *)); static bfd_boolean coff_ppc_relocate_section @@ -184,14 +179,14 @@ ppc_coff_link_hash_newfunc (entry, table, string) /* Initialize a PE linker hash table. */ static bfd_boolean -ppc_coff_link_hash_table_init (table, abfd, newfunc) - struct ppc_coff_link_hash_table *table; - bfd *abfd; - struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *, - struct bfd_hash_table *, - const char *)); +ppc_coff_link_hash_table_init (struct ppc_coff_link_hash_table *table, + bfd *abfd, + struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, + struct bfd_hash_table *, + const char *), + unsigned int entsize) { - return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc); + return _bfd_coff_link_hash_table_init (&table->root, abfd, newfunc, entsize); } /* Create a PE linker hash table. */ @@ -206,8 +201,9 @@ ppc_coff_link_hash_table_create (abfd) ret = (struct ppc_coff_link_hash_table *) bfd_malloc (amt); if (ret == NULL) return NULL; - if (! ppc_coff_link_hash_table_init (ret, abfd, - ppc_coff_link_hash_newfunc)) + if (!ppc_coff_link_hash_table_init (ret, abfd, + ppc_coff_link_hash_newfunc, + sizeof (struct ppc_coff_link_hash_entry))) { free (ret); return (struct bfd_link_hash_table *) NULL; diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 151b1ff..a1f6684 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -1,6 +1,6 @@ /* COFF specific linker code. Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + 2004, 2005, 2006 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -94,10 +94,11 @@ _bfd_coff_link_hash_table_init (struct coff_link_hash_table *table, bfd *abfd, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { memset (&table->stab_info, 0, sizeof (table->stab_info)); - return _bfd_link_hash_table_init (&table->root, abfd, newfunc); + return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize); } /* Create a COFF linker hash table. */ @@ -113,7 +114,8 @@ _bfd_coff_link_hash_table_create (bfd *abfd) return NULL; if (! _bfd_coff_link_hash_table_init (ret, abfd, - _bfd_coff_link_hash_newfunc)) + _bfd_coff_link_hash_newfunc, + sizeof (struct coff_link_hash_entry))) { free (ret); return (struct bfd_link_hash_table *) NULL; diff --git a/bfd/config.bfd b/bfd/config.bfd index 37dd03c..ccd0de8 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -313,7 +313,8 @@ case "${targ}" in bfin-*-*) targ_defvec=bfd_elf32_bfin_vec - tar_underscore=yes + targ_selvecs=bfd_elf32_bfinfdpic_vec + targ_underscore=yes ;; c30-*-*aout* | tic30-*-*aout*) @@ -868,6 +869,16 @@ case "${targ}" in targ_defvec=ecoff_big_vec targ_selvecs=ecoff_little_vec ;; +#ifdef BFD64 + mips*el-*-vxworks*) + targ_defvec=bfd_elf32_littlemips_vxworks_vec + targ_selvecs="bfd_elf32_littlemips_vec bfd_elf32_bigmips_vxworks_vec bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" + ;; + mips*-*-vxworks*) + targ_defvec=bfd_elf32_bigmips_vxworks_vec + targ_selvecs="bfd_elf32_bigmips_vec bfd_elf32_littlemips_vxworks_vec bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" + ;; +#endif mips*el-*-elf* | mips*el-*-vxworks* | mips*-*-chorus*) targ_defvec=bfd_elf32_littlemips_vec targ_selvecs="bfd_elf32_bigmips_vec bfd_elf64_bigmips_vec bfd_elf64_littlemips_vec" diff --git a/bfd/configure b/bfd/configure index b79f0da..5ad2bc4 100755 --- a/bfd/configure +++ b/bfd/configure @@ -13071,14 +13071,17 @@ do bfd_elf32_am33lin_vec) tb="$tb elf32-am33lin.lo elf32.lo $elf" ;; bfd_elf32_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;; bfd_elf32_bfin_vec) tb="$tb elf32-bfin.lo elf32.lo $elf" ;; + bfd_elf32_bfinfdpic_vec) tb="$tb elf32-bfin.lo elf32.lo $elf" ;; bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;; bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; - bfd_elf32_bigarm_vec) tb="$tb elf32-arm.lo elf32.lo $elf" ;; + bfd_elf32_bigarm_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; bfd_elf32_bigarm_symbian_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; bfd_elf32_bigarm_vxworks_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; - bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_bigmips_vxworks_vec) + tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_cr16c_vec) tb="$tb elf32-cr16c.lo elf32.lo $elf" ;; bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_crx_vec) tb="$tb elf32-crx.lo elf32.lo $elf" ;; @@ -13106,11 +13109,13 @@ do bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;; bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; bfd_elf32_littlearm_symbian_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; bfd_elf32_littlearm_vxworks_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; - bfd_elf32_littlearm_vec) tb="$tb elf32-arm.lo elf32.lo $elf" ;; - bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + bfd_elf32_littlearm_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_littlemips_vxworks_vec) + tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_m32c_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;; bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;; bfd_elf32_m32rle_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;; @@ -13126,10 +13131,10 @@ do bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;; bfd_elf32_mt_vec) tb="$tb elf32-mt.lo elf32.lo $elf" ;; bfd_elf32_msp430_vec) tb="$tb elf32-msp430.lo elf32.lo $elf" ;; - bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_ntradbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_ntradbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf32_openrisc_vec) tb="$tb elf32-openrisc.lo elf32.lo $elf" ;; bfd_elf32_or32_big_vec) tb="$tb elf32-or32.lo elf32.lo $elf" ;; bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; @@ -13155,8 +13160,8 @@ do bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elfxx-sparc.lo elf32.lo $elf" ;; - bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; - bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;; bfd_elf32_vax_vec) tb="$tb elf32-vax.lo elf32.lo $elf" ;; @@ -13167,14 +13172,14 @@ do bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; @@ -13186,8 +13191,8 @@ do bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; diff --git a/bfd/configure.in b/bfd/configure.in index b90e1fa..bc8dabb 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -584,14 +584,17 @@ do bfd_elf32_am33lin_vec) tb="$tb elf32-am33lin.lo elf32.lo $elf" ;; bfd_elf32_avr_vec) tb="$tb elf32-avr.lo elf32.lo $elf" ;; bfd_elf32_bfin_vec) tb="$tb elf32-bfin.lo elf32.lo $elf" ;; + bfd_elf32_bfinfdpic_vec) tb="$tb elf32-bfin.lo elf32.lo $elf" ;; bfd_elf32_big_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;; bfd_elf32_bigarc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; - bfd_elf32_bigarm_vec) tb="$tb elf32-arm.lo elf32.lo $elf" ;; + bfd_elf32_bigarm_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; bfd_elf32_bigarm_symbian_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; bfd_elf32_bigarm_vxworks_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; - bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + bfd_elf32_bigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_bigmips_vxworks_vec) + tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_cr16c_vec) tb="$tb elf32-cr16c.lo elf32.lo $elf" ;; bfd_elf32_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_crx_vec) tb="$tb elf32-crx.lo elf32.lo $elf" ;; @@ -619,11 +622,13 @@ do bfd_elf32_little_generic_vec) tb="$tb elf32-gen.lo elf32.lo $elf" ;; bfd_elf32_littlearc_vec) tb="$tb elf32-arc.lo elf32.lo $elf" ;; bfd_elf32_littlearm_symbian_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; bfd_elf32_littlearm_vxworks_vec) - tb="$tb elf32-arm.lo elf32.lo $elf" ;; - bfd_elf32_littlearm_vec) tb="$tb elf32-arm.lo elf32.lo $elf" ;; - bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + bfd_elf32_littlearm_vec) tb="$tb elf32-arm.lo elf32.lo elf-vxworks.lo $elf" ;; + bfd_elf32_littlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_littlemips_vxworks_vec) + tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_m32c_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;; bfd_elf32_m32r_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;; bfd_elf32_m32rle_vec) tb="$tb elf32-m32r.lo elf32.lo $elf" ;; @@ -639,10 +644,10 @@ do bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;; bfd_elf32_mt_vec) tb="$tb elf32-mt.lo elf32.lo $elf" ;; bfd_elf32_msp430_vec) tb="$tb elf32-msp430.lo elf32.lo $elf" ;; - bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_ntradbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_nbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_nlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_ntradbigmips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf32_ntradlittlemips_vec) tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf32_openrisc_vec) tb="$tb elf32-openrisc.lo elf32.lo $elf" ;; bfd_elf32_or32_big_vec) tb="$tb elf32-or32.lo elf32.lo $elf" ;; bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; @@ -668,8 +673,8 @@ do bfd_elf32_shlnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_shnbsd_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo cofflink.lo" ;; bfd_elf32_sparc_vec) tb="$tb elf32-sparc.lo elfxx-sparc.lo elf32.lo $elf" ;; - bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; - bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradbigmips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; + bfd_elf32_tradlittlemips_vec) tb="$tb elf32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo" ;; bfd_elf32_us_cris_vec) tb="$tb elf32-cris.lo elf32.lo $elf" ;; bfd_elf32_v850_vec) tb="$tb elf32-v850.lo elf32.lo $elf" ;; bfd_elf32_vax_vec) tb="$tb elf32-vax.lo elf32.lo $elf" ;; @@ -680,14 +685,14 @@ do bfd_elf64_alpha_freebsd_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_alpha_vec) tb="$tb elf64-alpha.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_hpux_big_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_ia64_little_vec) tb="$tb elf64-ia64.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;; bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; @@ -699,8 +704,8 @@ do bfd_elf64_sh64lnbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sh64nbsd_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; bfd_elf64_sparc_vec) tb="$tb elf64-sparc.lo elfxx-sparc.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradbigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; + bfd_elf64_tradlittlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; bfd_elf64_x86_64_vec) tb="$tb elf64-x86-64.lo elf64.lo $elf"; target_size=64 ;; bfd_mmo_vec) tb="$tb mmo.lo" target_size=64 ;; bfd_powerpc_pe_vec) tb="$tb pe-ppc.lo peigen.lo cofflink.lo" ;; diff --git a/bfd/cpu-arm.c b/bfd/cpu-arm.c index 3f56e8f..a28a1f9 100644 --- a/bfd/cpu-arm.c +++ b/bfd/cpu-arm.c @@ -404,9 +404,12 @@ bfd_arm_get_mach_from_notes (bfd *abfd, const char *note_section) bfd_boolean bfd_is_arm_mapping_symbol_name (const char * name) { + /* The ARM compiler outputs several obsolete forms. Recognize them + in addition to the standard $a, $t and $d. */ return (name != NULL) && (name[0] == '$') - && ((name[1] == 'a') || (name[1] == 't') || (name[1] == 'd')) - && (name[2] == 0); + && ((name[1] == 'a') || (name[1] == 't') || (name[1] == 'd') + || (name[1] == 'm') || (name[1] == 'f') || (name[1] == 'p')) + && (name[2] == 0 || name[2] == '.'); } diff --git a/bfd/cpu-m68k.c b/bfd/cpu-m68k.c index 93b60f9..3662789 100644 --- a/bfd/cpu-m68k.c +++ b/bfd/cpu-m68k.c @@ -24,8 +24,12 @@ #include "libbfd.h" #include "opcode/m68k.h" +static const bfd_arch_info_type * +bfd_m68k_compatible (const bfd_arch_info_type *a, + const bfd_arch_info_type *b); + #define N(name, print,d,next) \ -{ 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_default_compatible,bfd_default_scan, next, } +{ 32, 32, 8, bfd_arch_m68k, name, "m68k",print,2,d,bfd_m68k_compatible,bfd_default_scan, next, } static const bfd_arch_info_type arch_info_struct[] = { @@ -39,25 +43,25 @@ static const bfd_arch_info_type arch_info_struct[] = N(bfd_mach_cpu32, "m68k:cpu32", FALSE, &arch_info_struct[8]), /* Various combinations of CF architecture features */ - N(bfd_mach_mcf_isa_a, "m68k:isa-a", + N(bfd_mach_mcf_isa_a_nodiv, "m68k:isa-a:nodiv", FALSE, &arch_info_struct[9]), - N(bfd_mach_mcf_isa_a_div, "m68k:isa-a:div", + N(bfd_mach_mcf_isa_a, "m68k:isa-a", FALSE, &arch_info_struct[10]), - N(bfd_mach_mcf_isa_a_div_mac, "m68k:isa-a:div:mac", + N(bfd_mach_mcf_isa_a_mac, "m68k:isa-a:mac", FALSE, &arch_info_struct[11]), - N(bfd_mach_mcf_isa_a_div_emac, "m68k:isa-a:div:emac", + N(bfd_mach_mcf_isa_a_emac, "m68k:isa-a:emac", FALSE, &arch_info_struct[12]), - N(bfd_mach_mcf_isa_aplus, "m68k:isa-a+", + N(bfd_mach_mcf_isa_aplus, "m68k:isa-aplus", FALSE, &arch_info_struct[13]), - N(bfd_mach_mcf_isa_aplus_mac, "m68k:isa-a+:mac", + N(bfd_mach_mcf_isa_aplus_mac, "m68k:isa-aplus:mac", FALSE, &arch_info_struct[14]), - N(bfd_mach_mcf_isa_aplus_emac, "m68k:isa-a+:emac", + N(bfd_mach_mcf_isa_aplus_emac, "m68k:isa-aplus:emac", FALSE, &arch_info_struct[15]), - N(bfd_mach_mcf_isa_aplus_usp, "m68k:isa-a+:usp", + N(bfd_mach_mcf_isa_b_nousp, "m68k:isa-b:nousp", FALSE, &arch_info_struct[16]), - N(bfd_mach_mcf_isa_aplus_usp_mac, "m68k:isa-a+:usp:mac", + N(bfd_mach_mcf_isa_b_nousp_mac, "m68k:isa-b:nousp:mac", FALSE, &arch_info_struct[17]), - N(bfd_mach_mcf_isa_aplus_usp_emac, "m68k:isa-a+:usp:emac", + N(bfd_mach_mcf_isa_b_nousp_emac, "m68k:isa-b:nousp:emac", FALSE, &arch_info_struct[18]), N(bfd_mach_mcf_isa_b, "m68k:isa-b", FALSE, &arch_info_struct[19]), @@ -65,28 +69,26 @@ static const bfd_arch_info_type arch_info_struct[] = FALSE, &arch_info_struct[20]), N(bfd_mach_mcf_isa_b_emac, "m68k:isa-b:emac", FALSE, &arch_info_struct[21]), - N(bfd_mach_mcf_isa_b_usp_float, "m68k:isa-b:usp:float", + N(bfd_mach_mcf_isa_b_float, "m68k:isa-b:float", FALSE, &arch_info_struct[22]), - N(bfd_mach_mcf_isa_b_usp_float_mac, "m68k:isa-b:usp:float:mac", + N(bfd_mach_mcf_isa_b_float_mac, "m68k:isa-b:float:mac", FALSE, &arch_info_struct[23]), - N(bfd_mach_mcf_isa_b_usp_float_emac, "m68k:isa-b:usp:float:emac", + N(bfd_mach_mcf_isa_b_float_emac, "m68k:isa-b:float:emac", FALSE, &arch_info_struct[24]), /* Legacy names for CF architectures */ - N(bfd_mach_mcf_isa_a, "m68k:5200", FALSE, &arch_info_struct[25]), - N(bfd_mach_mcf_isa_a_div_mac,"m68k:5206e", FALSE, &arch_info_struct[26]), - N(bfd_mach_mcf_isa_a_div_mac, "m68k:5307", FALSE, &arch_info_struct[27]), - N(bfd_mach_mcf_isa_b_mac, "m68k:5407", FALSE, &arch_info_struct[28]), - N(bfd_mach_mcf_isa_aplus_usp_emac, "m68k:528x", - FALSE, &arch_info_struct[29]), - N(bfd_mach_mcf_isa_aplus_usp_emac, "m68k:521x", - FALSE, &arch_info_struct[30]), - N(bfd_mach_mcf_isa_a_div_emac, "m68k:5249", FALSE, &arch_info_struct[31]), - N(bfd_mach_mcf_isa_b_usp_float_emac, "m68k:547x", + N(bfd_mach_mcf_isa_a_nodiv, "m68k:5200", FALSE, &arch_info_struct[25]), + N(bfd_mach_mcf_isa_a_mac,"m68k:5206e", FALSE, &arch_info_struct[26]), + N(bfd_mach_mcf_isa_a_mac, "m68k:5307", FALSE, &arch_info_struct[27]), + N(bfd_mach_mcf_isa_b_nousp_mac, "m68k:5407", FALSE, &arch_info_struct[28]), + N(bfd_mach_mcf_isa_aplus_emac, "m68k:528x", FALSE, &arch_info_struct[29]), + N(bfd_mach_mcf_isa_aplus_emac, "m68k:521x", FALSE, &arch_info_struct[30]), + N(bfd_mach_mcf_isa_a_emac, "m68k:5249", FALSE, &arch_info_struct[31]), + N(bfd_mach_mcf_isa_b_float_emac, "m68k:547x", FALSE, &arch_info_struct[32]), - N(bfd_mach_mcf_isa_b_usp_float_emac, "m68k:548x", + N(bfd_mach_mcf_isa_b_float_emac, "m68k:548x", FALSE, &arch_info_struct[33]), - N(bfd_mach_mcf_isa_b_usp_float_emac, "m68k:cfv4e", FALSE, 0), + N(bfd_mach_mcf_isa_b_float_emac, "m68k:cfv4e", FALSE, 0), }; const bfd_arch_info_type bfd_m68k_arch = @@ -109,15 +111,15 @@ static const unsigned m68k_arch_features[] = mcfisa_a|mcfhwdiv, mcfisa_a|mcfhwdiv|mcfmac, mcfisa_a|mcfhwdiv|mcfemac, - mcfisa_a|mcfisa_aa|mcfhwdiv, - mcfisa_a|mcfisa_aa|mcfhwdiv|mcfmac, - mcfisa_a|mcfisa_aa|mcfhwdiv|mcfemac, mcfisa_a|mcfisa_aa|mcfhwdiv|mcfusp, mcfisa_a|mcfisa_aa|mcfhwdiv|mcfusp|mcfmac, mcfisa_a|mcfisa_aa|mcfhwdiv|mcfusp|mcfemac, mcfisa_a|mcfhwdiv|mcfisa_b, mcfisa_a|mcfhwdiv|mcfisa_b|mcfmac, mcfisa_a|mcfhwdiv|mcfisa_b|mcfemac, + mcfisa_a|mcfhwdiv|mcfisa_b|mcfusp, + mcfisa_a|mcfhwdiv|mcfisa_b|mcfusp|mcfmac, + mcfisa_a|mcfhwdiv|mcfisa_b|mcfusp|mcfemac, mcfisa_a|mcfhwdiv|mcfisa_b|mcfusp|cfloat, mcfisa_a|mcfhwdiv|mcfisa_b|mcfusp|cfloat|mcfmac, mcfisa_a|mcfhwdiv|mcfisa_b|mcfusp|cfloat|mcfemac, @@ -181,3 +183,43 @@ int bfd_m68k_features_to_mach (unsigned features) } return superset ? superset : subset; } + +static const bfd_arch_info_type * +bfd_m68k_compatible (const bfd_arch_info_type *a, + const bfd_arch_info_type *b) +{ + if (a->arch != b->arch) + return NULL; + + if (a->bits_per_word != b->bits_per_word) + return NULL; + + if (!a->mach) + return b; + if (!b->mach) + return a; + + if (a->mach <= bfd_mach_m68060 && b->mach <= bfd_mach_m68060) + /* Merge m68k machine. */ + return a->mach > b->mach ? a : b; + else if (a->mach >= bfd_mach_mcf_isa_a_nodiv + && b->mach >= bfd_mach_mcf_isa_a_nodiv) + { + /* Merge cf machine. */ + unsigned features = (bfd_m68k_mach_to_features (a->mach) + | bfd_m68k_mach_to_features (b->mach)); + + /* ISA A+ and ISA B are incompatible. */ + if ((~features & (mcfisa_aa | mcfisa_b)) == 0) + return NULL; + + /* MAC and EMAC code cannot be merged. */ + if ((~features & (mcfmac | mcfemac)) == 0) + return NULL; + + return bfd_lookup_arch (a->arch, bfd_m68k_features_to_mach (features)); + } + else + /* They are incompatible. */ + return NULL; +} diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c index f9cff9b..ae68d18 100644 --- a/bfd/dwarf2.c +++ b/bfd/dwarf2.c @@ -1,6 +1,6 @@ /* DWARF 2 support. Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + 2004, 2005, 2006 Free Software Foundation, Inc. Adapted from gdb/dwarf2read.c by Gavin Koch of Cygnus Solutions (gavin@cygnus.com). @@ -74,6 +74,12 @@ struct dwarf_block bfd_byte *data; }; +struct loadable_section +{ + asection *section; + bfd_vma adj_vma; +}; + struct dwarf2_debug { /* A list of all previously read comp_units. */ @@ -124,6 +130,12 @@ struct dwarf2_debug calling chain for subsequent calls to bfd_find_inliner_info to use. */ struct funcinfo *inliner_chain; + + /* Number of loadable sections. */ + unsigned int loadable_section_count; + + /* Array of loadable sections. */ + struct loadable_section *loadable_sections; }; struct arange @@ -481,21 +493,21 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash) amt *= sizeof (struct attr_abbrev); tmp = bfd_realloc (cur_abbrev->attrs, amt); if (tmp == NULL) - { - size_t i; - - for (i = 0; i < ABBREV_HASH_SIZE; i++) - { - struct abbrev_info *abbrev = abbrevs[i]; - - while (abbrev) - { - free (abbrev->attrs); - abbrev = abbrev->next; - } - } - return NULL; - } + { + size_t i; + + for (i = 0; i < ABBREV_HASH_SIZE; i++) + { + struct abbrev_info *abbrev = abbrevs[i]; + + while (abbrev) + { + free (abbrev->attrs); + abbrev = abbrev->next; + } + } + return NULL; + } cur_abbrev->attrs = tmp; } @@ -521,7 +533,7 @@ read_abbrevs (bfd *abfd, bfd_uint64_t offset, struct dwarf2_debug *stash) for the next compile unit) or if the end of the abbreviation table is reached. */ if ((unsigned int) (abbrev_ptr - stash->dwarf_abbrev_buffer) - >= stash->dwarf_abbrev_size) + >= stash->dwarf_abbrev_size) break; abbrev_number = read_unsigned_leb128 (abfd, abbrev_ptr, &bytes_read); abbrev_ptr += bytes_read; @@ -744,6 +756,17 @@ struct varinfo unsigned int stack: 1; }; +/* Return TRUE if NEW_LINE should sort after LINE. */ + +static inline bfd_boolean +new_line_sorts_after (struct line_info *new_line, struct line_info *line) +{ + return (new_line->address > line->address + || (new_line->address == line->address + && new_line->end_sequence < line->end_sequence)); +} + + /* Adds a new entry to the line_info list in the line_info_table, ensuring that the list is sorted. Note that the line_info list is sorted from highest to lowest VMA (with possible duplicates); that is, @@ -760,6 +783,21 @@ add_line_info (struct line_info_table *table, bfd_size_type amt = sizeof (struct line_info); struct line_info* info = bfd_alloc (table->abfd, amt); + /* Set member data of 'info'. */ + info->address = address; + info->line = line; + info->column = column; + info->end_sequence = end_sequence; + + if (filename && filename[0]) + { + info->filename = bfd_alloc (table->abfd, strlen (filename) + 1); + if (info->filename) + strcpy (info->filename, filename); + } + else + info->filename = NULL; + /* Find the correct location for 'info'. Normally we will receive new line_info data 1) in order and 2) with increasing VMAs. However some compilers break the rules (cf. decode_line_info) and @@ -775,70 +813,45 @@ add_line_info (struct line_info_table *table, Note: we may receive duplicate entries from 'decode_line_info'. */ - while (1) - if (!table->last_line - || address >= table->last_line->address) - { - /* Normal case: add 'info' to the beginning of the list */ - info->prev_line = table->last_line; - table->last_line = info; - - /* lcl_head: initialize to head a *possible* sequence at the end. */ - if (!table->lcl_head) - table->lcl_head = info; - break; - } - else if (!table->lcl_head->prev_line - && table->lcl_head->address > address) - { - /* Abnormal but easy: lcl_head is 1) at the *end* of the line - list and 2) the head of 'info'. */ - info->prev_line = NULL; - table->lcl_head->prev_line = info; - break; - } - else if (table->lcl_head->prev_line - && table->lcl_head->address > address - && address >= table->lcl_head->prev_line->address) - { - /* Abnormal but easy: lcl_head is 1) in the *middle* of the line - list and 2) the head of 'info'. */ - info->prev_line = table->lcl_head->prev_line; - table->lcl_head->prev_line = info; - break; - } - else - { - /* Abnormal and hard: Neither 'last_line' nor 'lcl_head' are valid - heads for 'info'. Reset 'lcl_head' and repeat. */ - struct line_info* li2 = table->last_line; /* always non-NULL */ - struct line_info* li1 = li2->prev_line; - - while (li1) - { - if (li2->address > address && address >= li1->address) - break; - - li2 = li1; /* always non-NULL */ - li1 = li1->prev_line; - } - table->lcl_head = li2; - } - - /* Set member data of 'info'. */ - info->address = address; - info->line = line; - info->column = column; - info->end_sequence = end_sequence; + if (!table->last_line + || new_line_sorts_after (info, table->last_line)) + { + /* Normal case: add 'info' to the beginning of the list */ + info->prev_line = table->last_line; + table->last_line = info; - if (filename && filename[0]) + /* lcl_head: initialize to head a *possible* sequence at the end. */ + if (!table->lcl_head) + table->lcl_head = info; + } + else if (!new_line_sorts_after (info, table->lcl_head) + && (!table->lcl_head->prev_line + || new_line_sorts_after (info, table->lcl_head->prev_line))) { - info->filename = bfd_alloc (table->abfd, strlen (filename) + 1); - if (info->filename) - strcpy (info->filename, filename); + /* Abnormal but easy: lcl_head is the head of 'info'. */ + info->prev_line = table->lcl_head->prev_line; + table->lcl_head->prev_line = info; } else - info->filename = NULL; + { + /* Abnormal and hard: Neither 'last_line' nor 'lcl_head' are valid + heads for 'info'. Reset 'lcl_head'. */ + struct line_info* li2 = table->last_line; /* always non-NULL */ + struct line_info* li1 = li2->prev_line; + + while (li1) + { + if (!new_line_sorts_after (info, li2) + && new_line_sorts_after (info, li1)) + break; + + li2 = li1; /* always non-NULL */ + li1 = li1->prev_line; + } + table->lcl_head = li2; + info->prev_line = table->lcl_head->prev_line; + table->lcl_head->prev_line = info; + } } /* Extract a fully qualified filename from a line info table. @@ -852,8 +865,10 @@ concat_filename (struct line_info_table *table, unsigned int file) if (file - 1 >= table->num_files) { - (*_bfd_error_handler) - (_("Dwarf Error: mangled line number section (bad file number).")); + /* FILE == 0 means unknown. */ + if (file) + (*_bfd_error_handler) + (_("Dwarf Error: mangled line number section (bad file number).")); return strdup (""); } @@ -1168,12 +1183,12 @@ decode_line_info (struct comp_unit *unit, struct dwarf2_debug *stash) amt *= sizeof (struct fileinfo); tmp = bfd_realloc (table->files, amt); if (tmp == NULL) - { + { free (table->files); free (table->dirs); free (filename); return NULL; - } + } table->files = tmp; } table->files[table->num_files].name = cur_file; @@ -1585,7 +1600,7 @@ read_rangelist (struct comp_unit *unit, struct arange *arange, bfd_uint64_t offs return; } ranges_ptr = unit->stash->dwarf_ranges_buffer + offset; - + for (;;) { bfd_vma low_pc; @@ -1802,7 +1817,7 @@ scan_unit_for_symbols (struct comp_unit *unit) attr.u.blk->data + 1); } break; - + default: break; } @@ -2179,28 +2194,91 @@ find_debug_info (bfd *abfd, asection *after_sec) return NULL; } -/* Return TRUE if there is no mismatch bewteen function FUNC and - section SECTION from symbol table SYMBOLS in ABFD. */ +/* Unset vmas for loadable sections in STASH. */ + +static void +unset_sections (struct dwarf2_debug *stash) +{ + unsigned int i; + struct loadable_section *p; + + i = stash->loadable_section_count; + p = stash->loadable_sections; + for (; i > 0; i--, p++) + p->section->vma = 0; +} + +/* Set unique vmas for loadable sections in ABFD and save vmas in + STASH for unset_sections. */ static bfd_boolean -check_function_name (bfd *abfd, asection *section, asymbol **symbols, - const char *func) +place_sections (bfd *abfd, struct dwarf2_debug *stash) { - /* Mismatch can only happen when we have 2 functions with the same - address. It can only occur in a relocatable file. */ - if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0 - && func != NULL - && section != NULL - && symbols != NULL) + struct loadable_section *p; + unsigned int i; + + if (stash->loadable_section_count != 0) { - asymbol **p; + i = stash->loadable_section_count; + p = stash->loadable_sections; + for (; i > 0; i--, p++) + p->section->vma = p->adj_vma; + } + else + { + asection *sect; + bfd_vma last_vma = 0; + bfd_size_type amt; + struct loadable_section *p; - for (p = symbols; *p != NULL; p++) + i = 0; + for (sect = abfd->sections; sect != NULL; sect = sect->next) { - if (((*p)->flags & BSF_FUNCTION) != 0 - && (*p)->name != NULL - && strcmp ((*p)->name, func) == 0) - return (*p)->section == section; + bfd_size_type sz; + + if (sect->vma != 0 || (sect->flags & SEC_LOAD) == 0) + continue; + + sz = sect->rawsize ? sect->rawsize : sect->size; + if (sz == 0) + continue; + + i++; + } + + amt = i * sizeof (struct loadable_section); + p = (struct loadable_section *) bfd_zalloc (abfd, amt); + if (! p) + return FALSE; + + stash->loadable_sections = p; + stash->loadable_section_count = i; + + for (sect = abfd->sections; sect != NULL; sect = sect->next) + { + bfd_size_type sz; + + if (sect->vma != 0 || (sect->flags & SEC_LOAD) == 0) + continue; + + sz = sect->rawsize ? sect->rawsize : sect->size; + if (sz == 0) + continue; + + p->section = sect; + if (last_vma != 0) + { + /* Align the new address to the current section + alignment. */ + last_vma = ((last_vma + + ~((bfd_vma) -1 << sect->alignment_power)) + & ((bfd_vma) -1 << sect->alignment_power)); + sect->vma = last_vma; + } + p->adj_vma = sect->vma; + last_vma += sect->vma + sz; + + p++; } } @@ -2239,7 +2317,27 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, struct comp_unit* each; + bfd_vma found = FALSE; + stash = *pinfo; + + if (! stash) + { + bfd_size_type amt = sizeof (struct dwarf2_debug); + + stash = bfd_zalloc (abfd, amt); + if (! stash) + return FALSE; + } + + /* In a relocatable file, 2 functions may have the same address. + We change the section vma so that they won't overlap. */ + if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) + { + if (! place_sections (abfd, stash)) + return FALSE; + } + addr = offset; if (section->output_section) addr += section->output_section->vma + section->output_offset; @@ -2256,15 +2354,10 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, addr_size = 4; BFD_ASSERT (addr_size == 4 || addr_size == 8); - if (! stash) + if (! *pinfo) { bfd_size_type total_size; asection *msec; - bfd_size_type amt = sizeof (struct dwarf2_debug); - - stash = bfd_zalloc (abfd, amt); - if (! stash) - return FALSE; *pinfo = stash; @@ -2273,7 +2366,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, /* No dwarf2 info. Note that at this point the stash has been allocated, but contains zeros, this lets future calls to this function fail quicker. */ - return FALSE; + goto done; /* There can be more than one DWARF2 info section in a BFD these days. Read them all in and produce one large stash. We do this in two @@ -2285,7 +2378,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, stash->info_ptr = bfd_alloc (abfd, total_size); if (stash->info_ptr == NULL) - return FALSE; + goto done; stash->info_ptr_end = stash->info_ptr; @@ -2319,7 +2412,7 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, /* A null info_ptr indicates that there is no dwarf2 info (or that an error occured while setting up the stash). */ if (! stash->info_ptr) - return FALSE; + goto done; stash->inliner_chain = NULL; @@ -2328,10 +2421,11 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, if (comp_unit_contains_address (each, addr) && comp_unit_find_nearest_line (each, addr, filename_ptr, functionname_ptr, - linenumber_ptr, stash) - && check_function_name (abfd, section, symbols, - *functionname_ptr)) - return TRUE; + linenumber_ptr, stash)) + { + found = TRUE; + goto done; + } /* Read each remaining comp. units checking each as they are read. */ while (stash->info_ptr < stash->info_ptr_end) @@ -2398,15 +2492,20 @@ _bfd_dwarf2_find_nearest_line (bfd *abfd, filename_ptr, functionname_ptr, linenumber_ptr, - stash) - && check_function_name (abfd, section, symbols, - *functionname_ptr)) - return TRUE; + stash)) + { + found = TRUE; + goto done; + } } } } - return FALSE; +done: + if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) + unset_sections (stash); + + return found; } /* The DWARF2 version of find_line. Return TRUE if the line is found @@ -2438,10 +2537,29 @@ _bfd_dwarf2_find_line (bfd *abfd, asection *section; - bfd_boolean found; + bfd_boolean found = FALSE; section = bfd_get_section (symbol); + stash = *pinfo; + + if (! stash) + { + bfd_size_type amt = sizeof (struct dwarf2_debug); + + stash = bfd_zalloc (abfd, amt); + if (! stash) + return FALSE; + } + + /* In a relocatable file, 2 functions may have the same address. + We change the section vma so that they won't overlap. */ + if (!stash && (abfd->flags & (EXEC_P | DYNAMIC)) == 0) + { + if (! place_sections (abfd, stash)) + return FALSE; + } + addr = symbol->value; if (section->output_section) addr += section->output_section->vma + section->output_offset; @@ -2449,19 +2567,13 @@ _bfd_dwarf2_find_line (bfd *abfd, addr += section->vma; *filename_ptr = NULL; - stash = *pinfo; *filename_ptr = NULL; *linenumber_ptr = 0; - if (! stash) + if (! *pinfo) { bfd_size_type total_size; asection *msec; - bfd_size_type amt = sizeof (struct dwarf2_debug); - - stash = bfd_zalloc (abfd, amt); - if (! stash) - return FALSE; *pinfo = stash; @@ -2470,7 +2582,7 @@ _bfd_dwarf2_find_line (bfd *abfd, /* No dwarf2 info. Note that at this point the stash has been allocated, but contains zeros, this lets future calls to this function fail quicker. */ - return FALSE; + goto done; /* There can be more than one DWARF2 info section in a BFD these days. Read them all in and produce one large stash. We do this in two @@ -2482,7 +2594,7 @@ _bfd_dwarf2_find_line (bfd *abfd, stash->info_ptr = bfd_alloc (abfd, total_size); if (stash->info_ptr == NULL) - return FALSE; + goto done; stash->info_ptr_end = stash->info_ptr; @@ -2516,7 +2628,7 @@ _bfd_dwarf2_find_line (bfd *abfd, /* A null info_ptr indicates that there is no dwarf2 info (or that an error occured while setting up the stash). */ if (! stash->info_ptr) - return FALSE; + goto done; stash->inliner_chain = NULL; @@ -2528,7 +2640,7 @@ _bfd_dwarf2_find_line (bfd *abfd, found = comp_unit_find_line (each, symbol, addr, filename_ptr, linenumber_ptr, stash); if (found) - return found; + goto done; } /* The DWARF2 spec says that the initial length field, and the @@ -2605,12 +2717,16 @@ _bfd_dwarf2_find_line (bfd *abfd, linenumber_ptr, stash)); if (found) - return TRUE; + goto done; } } } - return FALSE; +done: + if ((abfd->flags & (EXEC_P | DYNAMIC)) == 0) + unset_sections (stash); + + return found; } bfd_boolean @@ -2659,21 +2775,21 @@ _bfd_dwarf2_cleanup_debug_info (bfd *abfd) size_t i; for (i = 0; i < ABBREV_HASH_SIZE; i++) - { - struct abbrev_info *abbrev = abbrevs[i]; + { + struct abbrev_info *abbrev = abbrevs[i]; - while (abbrev) - { - free (abbrev->attrs); - abbrev = abbrev->next; - } - } + while (abbrev) + { + free (abbrev->attrs); + abbrev = abbrev->next; + } + } if (each->line_table) - { - free (each->line_table->dirs); - free (each->line_table->files); - } + { + free (each->line_table->dirs); + free (each->line_table->files); + } } free (stash->dwarf_abbrev_buffer); diff --git a/bfd/ecoff.c b/bfd/ecoff.c index 8c855b3..75e1cc2 100644 --- a/bfd/ecoff.c +++ b/bfd/ecoff.c @@ -1,6 +1,6 @@ /* Generic ECOFF (Extended-COFF) routines. Copyright 1990, 1991, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Original version by Per Bothner. Full support added by Ian Lance Taylor, ian@cygnus.com. @@ -3285,8 +3285,9 @@ _bfd_ecoff_bfd_link_hash_table_create (bfd *abfd) ret = bfd_malloc (amt); if (ret == NULL) return NULL; - if (! _bfd_link_hash_table_init (&ret->root, abfd, - ecoff_link_hash_newfunc)) + if (!_bfd_link_hash_table_init (&ret->root, abfd, + ecoff_link_hash_newfunc, + sizeof (struct ecoff_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/ecofflink.c b/bfd/ecofflink.c index d7bb817..4246e94 100644 --- a/bfd/ecofflink.c +++ b/bfd/ecofflink.c @@ -1,6 +1,6 @@ /* Routines to link ECOFF debugging information. Copyright 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + 2004, 2005, 2006 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support, . This file is part of BFD, the Binary File Descriptor library. @@ -501,8 +501,8 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info) ainfo = (struct accumulate *) bfd_malloc (amt); if (!ainfo) return NULL; - if (! bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc, - 1021)) + if (!bfd_hash_table_init_n (&ainfo->fdr_hash.table, string_hash_newfunc, + sizeof (struct string_hash_entry), 1021)) return NULL; ainfo->line = NULL; @@ -528,7 +528,8 @@ bfd_ecoff_debug_init (output_bfd, output_debug, output_swap, info) if (! info->relocatable) { - if (! bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc)) + if (!bfd_hash_table_init (&ainfo->str_hash.table, string_hash_newfunc, + sizeof (struct string_hash_entry))) return NULL; /* The first entry in the string table is the empty string. */ diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 76be811..3fba1c2 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -1489,7 +1489,8 @@ extern bfd_boolean _bfd_elf_link_hash_fixup_symbol extern bfd_boolean _bfd_elf_link_hash_table_init (struct elf_link_hash_table *, bfd *, struct bfd_hash_entry *(*) - (struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); + (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), + unsigned int); extern bfd_boolean _bfd_elf_slurp_version_tables (bfd *, bfd_boolean); extern bfd_boolean _bfd_elf_merge_sections diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index 81c5db0..509f2a1 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -1,6 +1,6 @@ /* Matsushita 10300 specific support for 32-bit ELF - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -3695,8 +3695,9 @@ elf32_mn10300_link_hash_table_create (abfd) if (ret == (struct elf32_mn10300_link_hash_table *) NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - elf32_mn10300_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + elf32_mn10300_link_hash_newfunc, + sizeof (struct elf32_mn10300_link_hash_entry))) { free (ret); return NULL; @@ -3712,8 +3713,9 @@ elf32_mn10300_link_hash_table_create (abfd) return NULL; } - if (! _bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd, - elf32_mn10300_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->static_hash_table->root, abfd, + elf32_mn10300_link_hash_newfunc, + sizeof (struct elf32_mn10300_link_hash_entry))) { free (ret->static_hash_table); free (ret); diff --git a/bfd/elf-strtab.c b/bfd/elf-strtab.c index ac17b15..a0ce1d7 100644 --- a/bfd/elf-strtab.c +++ b/bfd/elf-strtab.c @@ -1,5 +1,5 @@ /* ELF strtab with GC and suffix merging support. - Copyright 2001, 2002, 2003, 2005 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc. Written by Jakub Jelinek . This file is part of BFD, the Binary File Descriptor library. @@ -99,7 +99,8 @@ _bfd_elf_strtab_init (void) if (table == NULL) return NULL; - if (! bfd_hash_table_init (&table->table, elf_strtab_hash_newfunc)) + if (!bfd_hash_table_init (&table->table, elf_strtab_hash_newfunc, + sizeof (struct elf_strtab_hash_entry))) { free (table); return NULL; diff --git a/bfd/elf.c b/bfd/elf.c index 365c3a0..9e48f66 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -1561,7 +1561,8 @@ _bfd_elf_link_hash_table_init bfd *abfd, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { bfd_boolean ret; int can_refcount = get_elf_backend_data (abfd)->can_refcount; @@ -1588,7 +1589,7 @@ _bfd_elf_link_hash_table_init table->loaded = NULL; table->is_relocatable_executable = FALSE; - ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc); + ret = _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize); table->root.type = bfd_link_elf_hash_table; return ret; @@ -1606,7 +1607,8 @@ _bfd_elf_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc)) + if (! _bfd_elf_link_hash_table_init (ret, abfd, _bfd_elf_link_hash_newfunc, + sizeof (struct elf_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index ef19e6e..ca33121 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -20,20 +20,50 @@ #include "bfd.h" #include "sysdep.h" +#include "libiberty.h" #include "libbfd.h" #include "elf-bfd.h" +#include "elf-vxworks.h" #include "elf/arm.h" #ifndef NUM_ELEM #define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0])) #endif +/* Return the relocation section associated with NAME. HTAB is the + bfd's elf32_arm_link_hash_entry. */ +#define RELOC_SECTION(HTAB, NAME) \ + ((HTAB)->use_rel ? ".rel" NAME : ".rela" NAME) + +/* Return size of a relocation entry. HTAB is the bfd's + elf32_arm_link_hash_entry. */ +#define RELOC_SIZE(HTAB) \ + ((HTAB)->use_rel \ + ? sizeof (Elf32_External_Rel) \ + : sizeof (Elf32_External_Rela)) + +/* Return function to swap relocations in. HTAB is the bfd's + elf32_arm_link_hash_entry. */ +#define SWAP_RELOC_IN(HTAB) \ + ((HTAB)->use_rel \ + ? bfd_elf32_swap_reloc_in \ + : bfd_elf32_swap_reloca_in) + +/* Return function to swap relocations out. HTAB is the bfd's + elf32_arm_link_hash_entry. */ +#define SWAP_RELOC_OUT(HTAB) \ + ((HTAB)->use_rel \ + ? bfd_elf32_swap_reloc_out \ + : bfd_elf32_swap_reloca_out) + #define elf_info_to_howto 0 #define elf_info_to_howto_rel elf32_arm_info_to_howto #define ARM_ELF_ABI_VERSION 0 #define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM +static const struct elf_backend_data elf32_arm_vxworks_bed; + /* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g. R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO in that slot. */ @@ -140,8 +170,8 @@ static reloc_howto_type elf32_arm_howto_table_1[] = bfd_elf_generic_reloc, /* special_function */ "R_ARM_ABS12", /* name */ FALSE, /* partial_inplace */ - 0x000008ff, /* src_mask */ - 0x000008ff, /* dst_mask */ + 0x00000fff, /* src_mask */ + 0x00000fff, /* dst_mask */ FALSE), /* pcrel_offset */ HOWTO (R_ARM_THM_ABS5, /* type */ @@ -1422,9 +1452,10 @@ elf32_arm_nabi_grok_psinfo (bfd *abfd, Elf_Internal_Note *note) typedef unsigned long int insn32; typedef unsigned short int insn16; -/* In lieu of proper flags, assume all EABIv4 objects are interworkable. */ +/* In lieu of proper flags, assume all EABIv4 or later objects are + interworkable. */ #define INTERWORK_FLAG(abfd) \ - (EF_ARM_EABI_VERSION (elf_elfheader (abfd)->e_flags) == EF_ARM_EABI_VER4 \ + (EF_ARM_EABI_VERSION (elf_elfheader (abfd)->e_flags) >= EF_ARM_EABI_VER4 \ || (elf_elfheader (abfd)->e_flags & EF_ARM_INTERWORK)) /* The linker script knows the section names for placement. @@ -1491,6 +1522,38 @@ static const bfd_vma elf32_arm_plt_entry [] = #endif +/* The format of the first entry in the procedure linkage table + for a VxWorks executable. */ +static const bfd_vma elf32_arm_vxworks_exec_plt0_entry[] = + { + 0xe52dc008, /* str ip,[sp,#-8]! */ + 0xe59fc000, /* ldr ip,[pc] */ + 0xe59cf008, /* ldr pc,[ip,#8] */ + 0x00000000, /* .long _GLOBAL_OFFSET_TABLE_ */ + }; + +/* The format of subsequent entries in a VxWorks executable. */ +static const bfd_vma elf32_arm_vxworks_exec_plt_entry[] = + { + 0xe59fc000, /* ldr ip,[pc] */ + 0xe59cf000, /* ldr pc,[ip] */ + 0x00000000, /* .long @got */ + 0xe59fc000, /* ldr ip,[pc] */ + 0xea000000, /* b _PLT */ + 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */ + }; + +/* The format of entries in a VxWorks shared library. */ +static const bfd_vma elf32_arm_vxworks_shared_plt_entry[] = + { + 0xe59fc000, /* ldr ip,[pc] */ + 0xe79cf009, /* ldr pc,[ip,r9] */ + 0x00000000, /* .long @got */ + 0xe59fc000, /* ldr ip,[pc] */ + 0xe599f008, /* ldr pc,[r9,#8] */ + 0x00000000, /* .long @pltindex*sizeof(Elf32_Rela) */ + }; + /* An initial stub used if the PLT entry is referenced from Thumb code. */ #define PLT_THUMB_STUB_SIZE 4 static const bfd_vma elf32_arm_plt_thumb_stub [] = @@ -1668,6 +1731,9 @@ struct elf32_arm_link_hash_table /* The number of bytes in the subsequent PLT etries. */ bfd_size_type plt_entry_size; + /* True if the target system is VxWorks. */ + int vxworks_p; + /* True if the target system is Symbian OS. */ int symbian_p; @@ -1683,6 +1749,9 @@ struct elf32_arm_link_hash_table asection *sdynbss; asection *srelbss; + /* The (unloaded but important) VxWorks .rela.plt.unloaded section. */ + asection *srelplt2; + /* Data for R_ARM_TLS_LDM32 relocations. */ union { bfd_signed_vma refcount; @@ -1728,7 +1797,20 @@ elf32_arm_link_hash_newfunc (struct bfd_hash_entry * entry, return (struct bfd_hash_entry *) ret; } -/* Create .got, .gotplt, and .rel.got sections in DYNOBJ, and set up +/* Return true if NAME is the name of the relocation section associated + with S. */ + +static bfd_boolean +reloc_section_p (struct elf32_arm_link_hash_table *htab, + const char *name, asection *s) +{ + if (htab->use_rel) + return strncmp (name, ".rel", 4) == 0 && strcmp (s->name, name + 4) == 0; + else + return strncmp (name, ".rela", 5) == 0 && strcmp (s->name, name + 5) == 0; +} + +/* Create .got, .gotplt, and .rel(a).got sections in DYNOBJ, and set up shortcuts to them in our hash table. */ static bfd_boolean @@ -1749,7 +1831,8 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) if (!htab->sgot || !htab->sgotplt) abort (); - htab->srelgot = bfd_make_section_with_flags (dynobj, ".rel.got", + htab->srelgot = bfd_make_section_with_flags (dynobj, + RELOC_SECTION (htab, ".got"), (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY @@ -1761,8 +1844,8 @@ create_got_section (bfd *dynobj, struct bfd_link_info *info) return TRUE; } -/* Create .plt, .rel.plt, .got, .got.plt, .rel.got, .dynbss, and - .rel.bss sections in DYNOBJ, and set up shortcuts to them in our +/* Create .plt, .rel(a).plt, .got, .got.plt, .rel(a).got, .dynbss, and + .rel(a).bss sections in DYNOBJ, and set up shortcuts to them in our hash table. */ static bfd_boolean @@ -1778,10 +1861,32 @@ elf32_arm_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) return FALSE; htab->splt = bfd_get_section_by_name (dynobj, ".plt"); - htab->srelplt = bfd_get_section_by_name (dynobj, ".rel.plt"); + htab->srelplt = bfd_get_section_by_name (dynobj, + RELOC_SECTION (htab, ".plt")); htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); if (!info->shared) - htab->srelbss = bfd_get_section_by_name (dynobj, ".rel.bss"); + htab->srelbss = bfd_get_section_by_name (dynobj, + RELOC_SECTION (htab, ".bss")); + + if (htab->vxworks_p) + { + if (!elf_vxworks_create_dynamic_sections (dynobj, info, &htab->srelplt2)) + return FALSE; + + if (info->shared) + { + htab->plt_header_size = 0; + htab->plt_entry_size + = 4 * ARRAY_SIZE (elf32_arm_vxworks_shared_plt_entry); + } + else + { + htab->plt_header_size + = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt0_entry); + htab->plt_entry_size + = 4 * ARRAY_SIZE (elf32_arm_vxworks_exec_plt_entry); + } + } if (!htab->splt || !htab->srelplt @@ -1862,7 +1967,8 @@ elf32_arm_link_hash_table_create (bfd *abfd) return NULL; if (!_bfd_elf_link_hash_table_init (& ret->root, abfd, - elf32_arm_link_hash_newfunc)) + elf32_arm_link_hash_newfunc, + sizeof (struct elf32_arm_link_hash_entry))) { free (ret); return NULL; @@ -1875,6 +1981,7 @@ elf32_arm_link_hash_table_create (bfd *abfd) ret->srelplt = NULL; ret->sdynbss = NULL; ret->srelbss = NULL; + ret->srelplt2 = NULL; ret->thumb_glue_size = 0; ret->arm_glue_size = 0; ret->bfd_of_glue_owner = NULL; @@ -1890,6 +1997,7 @@ elf32_arm_link_hash_table_create (bfd *abfd) #endif ret->fix_v4bx = 0; ret->use_blx = 0; + ret->vxworks_p = 0; ret->symbian_p = 0; ret->use_rel = 1; ret->sym_sec.abfd = NULL; @@ -2805,6 +2913,20 @@ tpoff (struct bfd_link_info *info, bfd_vma address) return address - htab->tls_sec->vma + base; } +/* Perform an R_ARM_ABS12 relocation on the field pointed to by DATA. + VALUE is the relocation value. */ + +static bfd_reloc_status_type +elf32_arm_abs12_reloc (bfd *abfd, void *data, bfd_vma value) +{ + if (value > 0xfff) + return bfd_reloc_overflow; + + value |= bfd_get_32 (abfd, data) & 0xfffff000; + bfd_put_32 (abfd, value, data); + return bfd_reloc_ok; +} + /* Perform a relocation as part of a final link. */ static bfd_reloc_status_type @@ -2891,6 +3013,10 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, *unresolved_reloc_p = FALSE; return bfd_reloc_ok; + case R_ARM_ABS12: + if (!globals->vxworks_p) + return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); + case R_ARM_PC24: case R_ARM_ABS32: case R_ARM_REL32: @@ -2925,7 +3051,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, *unresolved_reloc_p = FALSE; return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, - (bfd_vma) 0); + rel->r_addend); } /* When generating a shared object or relocatable executable, these @@ -2961,10 +3087,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, if (name == NULL) return bfd_reloc_notsupported; - BFD_ASSERT (strncmp (name, ".rel", 4) == 0 - && strcmp (bfd_get_section_name (input_bfd, - input_section), - name + 4) == 0); + BFD_ASSERT (reloc_section_p (globals, name, input_section)); sreloc = bfd_get_section_by_name (dynobj, name); BFD_ASSERT (sreloc != NULL); @@ -2973,6 +3096,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, skip = FALSE; relocate = FALSE; + outrel.r_addend = addend; outrel.r_offset = _bfd_elf_section_offset (output_bfd, info, input_section, rel->r_offset); @@ -2996,7 +3120,6 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, int symbol; /* This symbol is local, or marked to become local. */ - relocate = TRUE; if (sym_flags == STT_ARM_TFUNC) value |= 1; if (globals->symbian_p) @@ -3021,11 +3144,15 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, so the symbol does not matter. */ symbol = 0; outrel.r_info = ELF32_R_INFO (symbol, R_ARM_RELATIVE); + if (globals->use_rel) + relocate = TRUE; + else + outrel.r_addend += value; } loc = sreloc->contents; - loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + loc += sreloc->reloc_count++ * RELOC_SIZE (globals); + SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); /* If this reloc is against an external symbol, we do not want to fiddle with the addend. Otherwise, we need to include the symbol @@ -3039,6 +3166,9 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, } else switch (r_type) { + case R_ARM_ABS12: + return elf32_arm_abs12_reloc (input_bfd, hit_data, value + addend); + case R_ARM_XPC25: /* Arm BLX instruction. */ case R_ARM_CALL: case R_ARM_JUMP24: @@ -3186,18 +3316,6 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, bfd_put_16 (input_bfd, value, hit_data); return bfd_reloc_ok; - case R_ARM_ABS12: - /* Support ldr and str instruction for the arm */ - /* Also thumb b (unconditional branch). ??? Really? */ - value += addend; - - if ((long) value > 0x7ff || (long) value < -0x800) - return bfd_reloc_overflow; - - value |= (bfd_get_32 (input_bfd, hit_data) & 0xfffff000); - bfd_put_32 (input_bfd, value, hit_data); - return bfd_reloc_ok; - case R_ARM_THM_ABS5: /* Support ldr and str instructions for the thumb. */ if (globals->use_rel) @@ -3589,7 +3707,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, value -= sgot->output_section->vma; return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, - (bfd_vma) 0); + rel->r_addend); case R_ARM_GOTPC: /* Use global offset table as symbol value. */ @@ -3602,7 +3720,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, value = sgot->output_section->vma; return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, - (bfd_vma) 0); + rel->r_addend); case R_ARM_GOT32: case R_ARM_GOT_PREL: @@ -3632,7 +3750,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, always be a multiple of 4, we use the least significant bit to record whether we have initialized it already. - When doing a dynamic link, we create a .rel.got relocation + When doing a dynamic link, we create a .rel(a).got relocation entry to initialize the value. This is done in the finish_dynamic_symbol routine. */ if ((off & 1) != 0) @@ -3678,7 +3796,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, if (sym_flags == STT_ARM_TFUNC) value |= 1; - bfd_put_32 (output_bfd, value, sgot->contents + off); + if (globals->use_rel) + bfd_put_32 (output_bfd, value, sgot->contents + off); if (info->shared) { @@ -3686,16 +3805,18 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, Elf_Internal_Rela outrel; bfd_byte *loc; - srelgot = bfd_get_section_by_name (dynobj, ".rel.got"); + srelgot = (bfd_get_section_by_name + (dynobj, RELOC_SECTION (globals, ".got"))); BFD_ASSERT (srelgot != NULL); + outrel.r_addend = addend + value; outrel.r_offset = (sgot->output_section->vma + sgot->output_offset + off); outrel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); loc = srelgot->contents; - loc += srelgot->reloc_count++ * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + loc += srelgot->reloc_count++ * RELOC_SIZE (globals); + SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); } local_got_offsets[r_symndx] |= 1; @@ -3708,13 +3829,14 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, - (bfd_vma) 0); + rel->r_addend); case R_ARM_TLS_LDO32: value = value - dtpoff_base (info); return _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, value, (bfd_vma) 0); + contents, rel->r_offset, value, + rel->r_addend); case R_ARM_TLS_LDM32: { @@ -3739,15 +3861,18 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, if (globals->srelgot == NULL) abort (); + outrel.r_addend = 0; outrel.r_offset = (globals->sgot->output_section->vma + globals->sgot->output_offset + off); outrel.r_info = ELF32_R_INFO (0, R_ARM_TLS_DTPMOD32); - bfd_put_32 (output_bfd, 0, globals->sgot->contents + off); + if (globals->use_rel) + bfd_put_32 (output_bfd, outrel.r_addend, + globals->sgot->contents + off); loc = globals->srelgot->contents; - loc += globals->srelgot->reloc_count++ * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + loc += globals->srelgot->reloc_count++ * RELOC_SIZE (globals); + SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); } else bfd_put_32 (output_bfd, 1, globals->sgot->contents + off); @@ -3760,7 +3885,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, - (bfd_vma) 0); + rel->r_addend); } case R_ARM_TLS_GD32: @@ -3821,36 +3946,45 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, if (globals->srelgot == NULL) abort (); loc = globals->srelgot->contents; - loc += globals->srelgot->reloc_count * sizeof (Elf32_External_Rel); + loc += globals->srelgot->reloc_count * RELOC_SIZE (globals); } if (tls_type & GOT_TLS_GD) { if (need_relocs) { + outrel.r_addend = 0; outrel.r_offset = (globals->sgot->output_section->vma - + globals->sgot->output_offset + cur_off); + + globals->sgot->output_offset + + cur_off); outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_DTPMOD32); - bfd_put_32 (output_bfd, 0, globals->sgot->contents + cur_off); - bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + if (globals->use_rel) + bfd_put_32 (output_bfd, outrel.r_addend, + globals->sgot->contents + cur_off); + + SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); globals->srelgot->reloc_count++; - loc += sizeof (Elf32_External_Rel); + loc += RELOC_SIZE (globals); if (indx == 0) bfd_put_32 (output_bfd, value - dtpoff_base (info), globals->sgot->contents + cur_off + 4); else { - bfd_put_32 (output_bfd, 0, - globals->sgot->contents + cur_off + 4); - + outrel.r_addend = 0; outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_DTPOFF32); outrel.r_offset += 4; - bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + + if (globals->use_rel) + bfd_put_32 (output_bfd, outrel.r_addend, + globals->sgot->contents + cur_off + 4); + + + SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); globals->srelgot->reloc_count++; - loc += sizeof (Elf32_External_Rel); + loc += RELOC_SIZE (globals); } } else @@ -3873,21 +4007,22 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, { if (need_relocs) { + if (indx == 0) + outrel.r_addend = value - dtpoff_base (info); + else + outrel.r_addend = 0; outrel.r_offset = (globals->sgot->output_section->vma + globals->sgot->output_offset + cur_off); outrel.r_info = ELF32_R_INFO (indx, R_ARM_TLS_TPOFF32); - if (indx == 0) - bfd_put_32 (output_bfd, value - dtpoff_base (info), - globals->sgot->contents + cur_off); - else - bfd_put_32 (output_bfd, 0, + if (globals->use_rel) + bfd_put_32 (output_bfd, outrel.r_addend, globals->sgot->contents + cur_off); - bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); + SWAP_RELOC_OUT (globals) (output_bfd, &outrel, loc); globals->srelgot->reloc_count++; - loc += sizeof (Elf32_External_Rel); + loc += RELOC_SIZE (globals); } else bfd_put_32 (output_bfd, tpoff (info, value), @@ -3908,7 +4043,7 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, return _bfd_final_link_relocate (howto, input_bfd, input_section, contents, rel->r_offset, value, - (bfd_vma) 0); + rel->r_addend); } case R_ARM_TLS_LE32: @@ -3924,7 +4059,8 @@ elf32_arm_final_link_relocate (reloc_howto_type * howto, value = tpoff (info, value); return _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, rel->r_offset, value, (bfd_vma) 0); + contents, rel->r_offset, value, + rel->r_addend); case R_ARM_V4BX: if (globals->fix_v4bx) @@ -5011,14 +5147,31 @@ elf32_arm_merge_eabi_attributes (bfd *ibfd, bfd *obfd) for (; in_list; in_list = in_list->next) { if ((in_list->tag & 128) < 64) - _bfd_error_handler - (_("Warning: %B: Unknown EABI object attribute %d"), - ibfd, in_list->tag); - break; + { + _bfd_error_handler + (_("Warning: %B: Unknown EABI object attribute %d"), + ibfd, in_list->tag); + break; + } } return TRUE; } + +/* Return TRUE if the two EABI versions are incompatible. */ + +static bfd_boolean +elf32_arm_versions_compatible (unsigned iver, unsigned over) +{ + /* v4 and v5 are the same spec before and after it was released, + so allow mixing them. */ + if ((iver == EF_ARM_EABI_VER4 && over == EF_ARM_EABI_VER5) + || (iver == EF_ARM_EABI_VER5 && over == EF_ARM_EABI_VER4)) + return TRUE; + + return (iver == over); +} + /* Merge backend specific data from an object file to the output object file when linking. */ @@ -5117,7 +5270,8 @@ elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd) } /* Complain about various flag mismatches. */ - if (EF_ARM_EABI_VERSION (in_flags) != EF_ARM_EABI_VERSION (out_flags)) + if (!elf32_arm_versions_compatible (EF_ARM_EABI_VERSION (in_flags), + EF_ARM_EABI_VERSION (out_flags))) { _bfd_error_handler (_("ERROR: Source object %B has EABI version %d, but target %B has EABI version %d"), @@ -5128,7 +5282,10 @@ elf32_arm_merge_private_bfd_data (bfd * ibfd, bfd * obfd) } /* Not sure what needs to be checked for EABI versions >= 1. */ - if (EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN) + /* VxWorks libraries do not use these flags. */ + if (get_elf_backend_data (obfd) != &elf32_arm_vxworks_bed + && get_elf_backend_data (ibfd) != &elf32_arm_vxworks_bed + && EF_ARM_EABI_VERSION (in_flags) == EF_ARM_EABI_UNKNOWN) { if ((in_flags & EF_ARM_APCS_26) != (out_flags & EF_ARM_APCS_26)) { @@ -5325,7 +5482,11 @@ elf32_arm_print_private_bfd_data (bfd *abfd, void * ptr) case EF_ARM_EABI_VER4: fprintf (file, _(" [Version4 EABI]")); + goto eabi; + case EF_ARM_EABI_VER5: + fprintf (file, _(" [Version5 EABI]")); + eabi: if (flags & EF_ARM_BE8) fprintf (file, _(" [BE8]")); @@ -5683,6 +5844,13 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, } break; + case R_ARM_ABS12: + /* VxWorks uses dynamic R_ARM_ABS12 relocations for + ldr __GOTT_INDEX__ offsets. */ + if (!htab->vxworks_p) + break; + /* Fall through */ + case R_ARM_ABS32: case R_ARM_REL32: case R_ARM_PC24: @@ -5757,9 +5925,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, if (name == NULL) return FALSE; - BFD_ASSERT (strncmp (name, ".rel", 4) == 0 - && strcmp (bfd_get_section_name (abfd, sec), - name + 4) == 0); + BFD_ASSERT (reloc_section_p (htab, name, sec)); sreloc = bfd_get_section_by_name (dynobj, name); if (sreloc == NULL) @@ -6094,14 +6260,14 @@ elf32_arm_adjust_dynamic_symbol (struct bfd_link_info * info, /* We must generate a R_ARM_COPY reloc to tell the dynamic linker to copy the initial value out of the dynamic object and into the runtime process image. We need to remember the offset into the - .rel.bss section we are going to use. */ + .rel(a).bss section we are going to use. */ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) { asection *srel; - srel = bfd_get_section_by_name (dynobj, ".rel.bss"); + srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (globals, ".bss")); BFD_ASSERT (srel != NULL); - srel->size += sizeof (Elf32_External_Rel); + srel->size += RELOC_SIZE (globals); h->needs_copy = 1; } @@ -6215,8 +6381,24 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) htab->sgotplt->size += 4; } - /* We also need to make an entry in the .rel.plt section. */ - htab->srelplt->size += sizeof (Elf32_External_Rel); + /* We also need to make an entry in the .rel(a).plt section. */ + htab->srelplt->size += RELOC_SIZE (htab); + + /* VxWorks executables have a second set of relocations for + each PLT entry. They go in a separate relocation section, + which is processed by the kernel loader. */ + if (htab->vxworks_p && !info->shared) + { + /* There is a relocation for the initial PLT entry: + an R_ARM_32 relocation for _GLOBAL_OFFSET_TABLE_. */ + if (h->plt.offset == htab->plt_header_size) + htab->srelplt2->size += RELOC_SIZE (htab); + + /* There are two extra relocations for each subsequent + PLT entry: an R_ARM_32 relocation for the GOT entry, + and an R_ARM_32 relocation for the PLT entry. */ + htab->srelplt2->size += RELOC_SIZE (htab) * 2; + } } else { @@ -6281,19 +6463,19 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) || h->root.type != bfd_link_hash_undefweak)) { if (tls_type & GOT_TLS_IE) - htab->srelgot->size += sizeof (Elf32_External_Rel); + htab->srelgot->size += RELOC_SIZE (htab); if (tls_type & GOT_TLS_GD) - htab->srelgot->size += sizeof (Elf32_External_Rel); + htab->srelgot->size += RELOC_SIZE (htab); if ((tls_type & GOT_TLS_GD) && indx != 0) - htab->srelgot->size += sizeof (Elf32_External_Rel); + htab->srelgot->size += RELOC_SIZE (htab); } else if ((ELF_ST_VISIBILITY (h->other) == STV_DEFAULT || h->root.type != bfd_link_hash_undefweak) && (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) - htab->srelgot->size += sizeof (Elf32_External_Rel); + htab->srelgot->size += RELOC_SIZE (htab); } } else @@ -6397,7 +6579,7 @@ allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) for (p = eh->relocs_copied; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->section)->sreloc; - sreloc->size += p->count * sizeof (Elf32_External_Rel); + sreloc->size += p->count * RELOC_SIZE (htab); } return TRUE; @@ -6493,7 +6675,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, else if (p->count != 0) { srel = elf_section_data (p->section)->sreloc; - srel->size += p->count * sizeof (Elf32_External_Rel); + srel->size += p->count * RELOC_SIZE (htab); if ((p->section->output_section->flags & SEC_READONLY) != 0) info->flags |= DF_TEXTREL; } @@ -6524,7 +6706,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, s->size += 4; if (info->shared || *local_tls_type == GOT_TLS_GD) - srel->size += sizeof (Elf32_External_Rel); + srel->size += RELOC_SIZE (htab); } else *local_got = (bfd_vma) -1; @@ -6538,7 +6720,7 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, htab->tls_ldm_got.offset = htab->sgot->size; htab->sgot->size += 8; if (info->shared) - htab->srelgot->size += sizeof (Elf32_External_Rel); + htab->srelgot->size += RELOC_SIZE (htab); } else htab->tls_ldm_got.offset = -1; @@ -6573,8 +6755,8 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, if (s->size != 0) { /* Remember whether there are any reloc sections other - than .rel.plt. */ - if (strcmp (name, ".rel.plt") != 0) + than .rel(a).plt and .rela.plt.unloaded. */ + if (s != htab->srelplt && s != htab->srelplt2) relocs = TRUE; /* We use the reloc_count field as a counter if we need @@ -6592,8 +6774,8 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, if (s->size == 0) { /* If we don't need this section, strip it from the - output file. This is mostly to handle .rel.bss and - .rel.plt. We must create both sections in + output file. This is mostly to handle .rel(a).bss and + .rel(a).plt. We must create both sections in create_dynamic_sections, because they must be created before the linker maps input sections to output sections. The linker does that before @@ -6633,17 +6815,28 @@ elf32_arm_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, { if ( !add_dynamic_entry (DT_PLTGOT, 0) || !add_dynamic_entry (DT_PLTRELSZ, 0) - || !add_dynamic_entry (DT_PLTREL, DT_REL) + || !add_dynamic_entry (DT_PLTREL, + htab->use_rel ? DT_REL : DT_RELA) || !add_dynamic_entry (DT_JMPREL, 0)) return FALSE; } if (relocs) { - if ( !add_dynamic_entry (DT_REL, 0) - || !add_dynamic_entry (DT_RELSZ, 0) - || !add_dynamic_entry (DT_RELENT, sizeof (Elf32_External_Rel))) - return FALSE; + if (htab->use_rel) + { + if (!add_dynamic_entry (DT_REL, 0) + || !add_dynamic_entry (DT_RELSZ, 0) + || !add_dynamic_entry (DT_RELENT, RELOC_SIZE (htab))) + return FALSE; + } + else + { + if (!add_dynamic_entry (DT_RELA, 0) + || !add_dynamic_entry (DT_RELASZ, 0) + || !add_dynamic_entry (DT_RELAENT, RELOC_SIZE (htab))) + return FALSE; + } } /* If any dynamic relocs apply to a read-only section, @@ -6692,7 +6885,7 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, BFD_ASSERT (h->dynindx != -1); splt = bfd_get_section_by_name (dynobj, ".plt"); - srel = bfd_get_section_by_name (dynobj, ".rel.plt"); + srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".plt")); BFD_ASSERT (splt != NULL && srel != NULL); /* Fill in the entry in the procedure linkage table. */ @@ -6719,7 +6912,7 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, } else { - bfd_vma got_offset; + bfd_vma got_offset, got_address, plt_address; bfd_vma got_displacement; asection * sgot; @@ -6737,38 +6930,103 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, symbols appear in the same order as in .plt. */ plt_index = (got_offset - 12) / 4; - /* Calculate the displacement between the PLT slot and the - entry in the GOT. The eight-byte offset accounts for the - value produced by adding to pc in the first instruction - of the PLT stub. */ - got_displacement = (sgot->output_section->vma - + sgot->output_offset - + got_offset - - splt->output_section->vma - - splt->output_offset - - h->plt.offset - - 8); + /* Calculate the address of the GOT entry. */ + got_address = (sgot->output_section->vma + + sgot->output_offset + + got_offset); - BFD_ASSERT ((got_displacement & 0xf0000000) == 0); + /* ...and the address of the PLT entry. */ + plt_address = (splt->output_section->vma + + splt->output_offset + + h->plt.offset); - if (!htab->use_blx && eh->plt_thumb_refcount > 0) + if (htab->vxworks_p && info->shared) { - bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[0], - splt->contents + h->plt.offset - 4); - bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[1], - splt->contents + h->plt.offset - 2); + unsigned int i; + bfd_vma val; + + for (i = 0; i != htab->plt_entry_size / 4; i++) + { + val = elf32_arm_vxworks_shared_plt_entry[i]; + if (i == 2) + val |= got_address - sgot->output_section->vma; + if (i == 5) + val |= plt_index * RELOC_SIZE (htab); + bfd_put_32 (output_bfd, val, + htab->splt->contents + h->plt.offset + i * 4); + } } + else if (htab->vxworks_p) + { + unsigned int i; + bfd_vma val; - bfd_put_32 (output_bfd, elf32_arm_plt_entry[0] | ((got_displacement & 0x0ff00000) >> 20), - splt->contents + h->plt.offset + 0); - bfd_put_32 (output_bfd, elf32_arm_plt_entry[1] | ((got_displacement & 0x000ff000) >> 12), - splt->contents + h->plt.offset + 4); - bfd_put_32 (output_bfd, elf32_arm_plt_entry[2] | (got_displacement & 0x00000fff), - splt->contents + h->plt.offset + 8); + for (i = 0; i != htab->plt_entry_size / 4; i++) + { + val = elf32_arm_vxworks_exec_plt_entry[i]; + if (i == 2) + val |= got_address; + if (i == 4) + val |= 0xffffff & -((h->plt.offset + i * 4 + 8) >> 2); + if (i == 5) + val |= plt_index * RELOC_SIZE (htab); + bfd_put_32 (output_bfd, val, + htab->splt->contents + h->plt.offset + i * 4); + } + + loc = (htab->srelplt2->contents + + (plt_index * 2 + 1) * RELOC_SIZE (htab)); + + /* Create the .rela.plt.unloaded R_ARM_ABS32 relocation + referencing the GOT for this PLT entry. */ + rel.r_offset = plt_address + 8; + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); + rel.r_addend = got_offset; + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); + loc += RELOC_SIZE (htab); + + /* Create the R_ARM_ABS32 relocation referencing the + beginning of the PLT for this GOT entry. */ + rel.r_offset = got_address; + rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_ARM_ABS32); + rel.r_addend = 0; + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); + } + else + { + /* Calculate the displacement between the PLT slot and the + entry in the GOT. The eight-byte offset accounts for the + value produced by adding to pc in the first instruction + of the PLT stub. */ + got_displacement = got_address - (plt_address + 8); + + BFD_ASSERT ((got_displacement & 0xf0000000) == 0); + + if (!htab->use_blx && eh->plt_thumb_refcount > 0) + { + bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[0], + splt->contents + h->plt.offset - 4); + bfd_put_16 (output_bfd, elf32_arm_plt_thumb_stub[1], + splt->contents + h->plt.offset - 2); + } + + bfd_put_32 (output_bfd, + elf32_arm_plt_entry[0] + | ((got_displacement & 0x0ff00000) >> 20), + splt->contents + h->plt.offset + 0); + bfd_put_32 (output_bfd, + elf32_arm_plt_entry[1] + | ((got_displacement & 0x000ff000) >> 12), + splt->contents + h->plt.offset + 4); + bfd_put_32 (output_bfd, + elf32_arm_plt_entry[2] + | (got_displacement & 0x00000fff), + splt->contents + h->plt.offset + 8); #ifdef FOUR_WORD_PLT - bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], - splt->contents + h->plt.offset + 12); + bfd_put_32 (output_bfd, elf32_arm_plt_entry[3], + splt->contents + h->plt.offset + 12); #endif + } /* Fill in the entry in the global offset table. */ bfd_put_32 (output_bfd, @@ -6776,15 +7034,14 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, + splt->output_offset), sgot->contents + got_offset); - /* Fill in the entry in the .rel.plt section. */ - rel.r_offset = (sgot->output_section->vma - + sgot->output_offset - + got_offset); + /* Fill in the entry in the .rel(a).plt section. */ + rel.r_addend = 0; + rel.r_offset = got_address; rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_JUMP_SLOT); } - loc = srel->contents + plt_index * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_out (output_bfd, &rel, loc); + loc = srel->contents + plt_index * RELOC_SIZE (htab); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); if (!h->def_regular) { @@ -6808,16 +7065,19 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, asection * srel; Elf_Internal_Rela rel; bfd_byte *loc; + bfd_vma offset; /* This symbol has an entry in the global offset table. Set it up. */ sgot = bfd_get_section_by_name (dynobj, ".got"); - srel = bfd_get_section_by_name (dynobj, ".rel.got"); + srel = bfd_get_section_by_name (dynobj, RELOC_SECTION (htab, ".got")); BFD_ASSERT (sgot != NULL && srel != NULL); + offset = (h->got.offset & ~(bfd_vma) 1); + rel.r_addend = 0; rel.r_offset = (sgot->output_section->vma + sgot->output_offset - + (h->got.offset &~ (bfd_vma) 1)); + + offset); /* If this is a static link, or it is a -Bsymbolic link and the symbol is defined locally or was forced to be local because @@ -6829,16 +7089,21 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, { BFD_ASSERT((h->got.offset & 1) != 0); rel.r_info = ELF32_R_INFO (0, R_ARM_RELATIVE); + if (!htab->use_rel) + { + rel.r_addend = bfd_get_32 (output_bfd, sgot->contents + offset); + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset); + } } else { BFD_ASSERT((h->got.offset & 1) == 0); - bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + offset); rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_GLOB_DAT); } - loc = srel->contents + srel->reloc_count++ * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_out (output_bfd, &rel, loc); + loc = srel->contents + srel->reloc_count++ * RELOC_SIZE (htab); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); } if (h->needs_copy) @@ -6853,20 +7118,23 @@ elf32_arm_finish_dynamic_symbol (bfd * output_bfd, struct bfd_link_info * info, || h->root.type == bfd_link_hash_defweak)); s = bfd_get_section_by_name (h->root.u.def.section->owner, - ".rel.bss"); + RELOC_SECTION (htab, ".bss")); BFD_ASSERT (s != NULL); + rel.r_addend = 0; rel.r_offset = (h->root.u.def.value + h->root.u.def.section->output_section->vma + h->root.u.def.section->output_offset); rel.r_info = ELF32_R_INFO (h->dynindx, R_ARM_COPY); - loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rel); - bfd_elf32_swap_reloc_out (output_bfd, &rel, loc); + loc = s->contents + s->reloc_count++ * RELOC_SIZE (htab); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, loc); } - /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */ + /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. On VxWorks, + the _GLOBAL_OFFSET_TABLE_ symbol is not absolute: it is relative + to the ".got" section. */ if (strcmp (h->root.root.string, "_DYNAMIC") == 0 - || h == htab->root.hgot) + || (!htab->vxworks_p && h == htab->root.hgot)) sym->st_shndx = SHN_ABS; return TRUE; @@ -6938,7 +7206,7 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info name = ".got"; goto get_vma; case DT_JMPREL: - name = ".rel.plt"; + name = RELOC_SECTION (htab, ".plt"); get_vma: s = bfd_get_section_by_name (output_bfd, name); BFD_ASSERT (s != NULL); @@ -6958,13 +7226,15 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info break; case DT_PLTRELSZ: - s = bfd_get_section_by_name (output_bfd, ".rel.plt"); + s = bfd_get_section_by_name (output_bfd, + RELOC_SECTION (htab, ".plt")); BFD_ASSERT (s != NULL); dyn.d_un.d_val = s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); break; case DT_RELSZ: + case DT_RELASZ: if (!htab->symbian_p) { /* My reading of the SVR4 ABI indicates that the @@ -6973,10 +7243,11 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info what Solaris does. However, UnixWare can not handle that case. Therefore, we override the DT_RELSZ entry here to make it not include the JMPREL relocs. Since - the linker script arranges for .rel.plt to follow all + the linker script arranges for .rel(a).plt to follow all other relocation sections, we don't have to worry about changing the DT_REL entry. */ - s = bfd_get_section_by_name (output_bfd, ".rel.plt"); + s = bfd_get_section_by_name (output_bfd, + RELOC_SECTION (htab, ".plt")); if (s != NULL) dyn.d_un.d_val -= s->size; bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); @@ -6986,7 +7257,6 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info case DT_REL: case DT_RELA: - case DT_RELASZ: /* In the BPABI, the DT_REL tag must point at the file offset, not the VMA, of the first relocation section. So, we use code similar to that in @@ -7049,31 +7319,83 @@ elf32_arm_finish_dynamic_sections (bfd * output_bfd, struct bfd_link_info * info /* Fill in the first entry in the procedure linkage table. */ if (splt->size > 0 && elf32_arm_hash_table (info)->plt_header_size) { - bfd_vma got_displacement; + const bfd_vma *plt0_entry; + bfd_vma got_address, plt_address, got_displacement; + + /* Calculate the addresses of the GOT and PLT. */ + got_address = sgot->output_section->vma + sgot->output_offset; + plt_address = splt->output_section->vma + splt->output_offset; + + if (htab->vxworks_p) + { + /* The VxWorks GOT is relocated by the dynamic linker. + Therefore, we must emit relocations rather than simply + computing the values now. */ + Elf_Internal_Rela rel; + + plt0_entry = elf32_arm_vxworks_exec_plt0_entry; + bfd_put_32 (output_bfd, plt0_entry[0], splt->contents + 0); + bfd_put_32 (output_bfd, plt0_entry[1], splt->contents + 4); + bfd_put_32 (output_bfd, plt0_entry[2], splt->contents + 8); + bfd_put_32 (output_bfd, got_address, splt->contents + 12); + + /* Generate a relocation for _GLOBAL_OFFSET_TABLE_. */ + rel.r_offset = plt_address + 12; + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); + rel.r_addend = 0; + SWAP_RELOC_OUT (htab) (output_bfd, &rel, + htab->srelplt2->contents); + } + else + { + got_displacement = got_address - (plt_address + 16); + + plt0_entry = elf32_arm_plt0_entry; + bfd_put_32 (output_bfd, plt0_entry[0], splt->contents + 0); + bfd_put_32 (output_bfd, plt0_entry[1], splt->contents + 4); + bfd_put_32 (output_bfd, plt0_entry[2], splt->contents + 8); + bfd_put_32 (output_bfd, plt0_entry[3], splt->contents + 12); - /* Calculate the displacement between the PLT slot and &GOT[0]. */ - got_displacement = (sgot->output_section->vma - + sgot->output_offset - - splt->output_section->vma - - splt->output_offset - - 16); - - bfd_put_32 (output_bfd, elf32_arm_plt0_entry[0], splt->contents + 0); - bfd_put_32 (output_bfd, elf32_arm_plt0_entry[1], splt->contents + 4); - bfd_put_32 (output_bfd, elf32_arm_plt0_entry[2], splt->contents + 8); - bfd_put_32 (output_bfd, elf32_arm_plt0_entry[3], splt->contents + 12); #ifdef FOUR_WORD_PLT - /* The displacement value goes in the otherwise-unused last word of - the second entry. */ - bfd_put_32 (output_bfd, got_displacement, splt->contents + 28); + /* The displacement value goes in the otherwise-unused + last word of the second entry. */ + bfd_put_32 (output_bfd, got_displacement, splt->contents + 28); #else - bfd_put_32 (output_bfd, got_displacement, splt->contents + 16); + bfd_put_32 (output_bfd, got_displacement, splt->contents + 16); #endif + } } /* UnixWare sets the entsize of .plt to 4, although that doesn't really seem like the right value. */ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; + + if (htab->vxworks_p && !info->shared && htab->splt->size > 0) + { + /* Correct the .rel(a).plt.unloaded relocations. They will have + incorrect symbol indexes. */ + int num_plts; + unsigned char *p; + + num_plts = ((htab->splt->size - htab->plt_header_size) + / htab->plt_entry_size); + p = htab->srelplt2->contents + RELOC_SIZE (htab); + + for (; num_plts; num_plts--) + { + Elf_Internal_Rela rel; + + SWAP_RELOC_IN (htab) (output_bfd, p, &rel); + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_ARM_ABS32); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, p); + p += RELOC_SIZE (htab); + + SWAP_RELOC_IN (htab) (output_bfd, p, &rel); + rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_ARM_ABS32); + SWAP_RELOC_OUT (htab) (output_bfd, &rel, p); + p += RELOC_SIZE (htab); + } + } } /* Fill in the first three entries in the global offset table. */ @@ -7443,7 +7765,7 @@ elf32_arm_output_symbol_hook (struct bfd_link_info *info, const char *name, Elf_Internal_Sym *elfsym, asection *input_sec, - struct elf_link_hash_entry *h ATTRIBUTE_UNUSED) + struct elf_link_hash_entry *h) { int mapcount; elf32_arm_section_map *map; @@ -7451,12 +7773,17 @@ elf32_arm_output_symbol_hook (struct bfd_link_info *info, _arm_elf_section_data *arm_data; struct elf32_arm_link_hash_table *globals; + globals = elf32_arm_hash_table (info); + if (globals->vxworks_p + && !elf_vxworks_link_output_symbol_hook (info, name, elfsym, + input_sec, h)) + return FALSE; + /* Only do this on final link. */ if (info->relocatable) return TRUE; /* Only build a map if we need to byteswap code. */ - globals = elf32_arm_hash_table (info); if (!globals->byteswap_code) return TRUE; @@ -7837,27 +8164,48 @@ elf32_arm_vxworks_link_hash_table_create (bfd *abfd) if (ret) { struct elf32_arm_link_hash_table *htab - = (struct elf32_arm_link_hash_table *)ret; + = (struct elf32_arm_link_hash_table *) ret; htab->use_rel = 0; + htab->vxworks_p = 1; } return ret; } +static void +elf32_arm_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) +{ + elf32_arm_final_write_processing (abfd, linker); + elf_vxworks_final_write_processing (abfd, linker); +} + #undef elf32_bed #define elf32_bed elf32_arm_vxworks_bed #undef bfd_elf32_bfd_link_hash_table_create #define bfd_elf32_bfd_link_hash_table_create \ elf32_arm_vxworks_link_hash_table_create +#undef elf_backend_add_symbol_hook +#define elf_backend_add_symbol_hook \ + elf_vxworks_add_symbol_hook +#undef elf_backend_final_write_processing +#define elf_backend_final_write_processing \ + elf32_arm_vxworks_final_write_processing +#undef elf_backend_emit_relocs +#define elf_backend_emit_relocs \ + elf_vxworks_emit_relocs #undef elf_backend_may_use_rel_p -#define elf_backend_may_use_rel_p 0 +#define elf_backend_may_use_rel_p 0 #undef elf_backend_may_use_rela_p -#define elf_backend_may_use_rela_p 1 +#define elf_backend_may_use_rela_p 1 #undef elf_backend_default_use_rela_p -#define elf_backend_default_use_rela_p 1 +#define elf_backend_default_use_rela_p 1 #undef elf_backend_rela_normal -#define elf_backend_rela_normal 1 +#define elf_backend_rela_normal 1 +#undef elf_backend_want_plt_sym +#define elf_backend_want_plt_sym 1 +#undef ELF_MAXPAGESIZE +#define ELF_MAXPAGESIZE 0x1000 #include "elf32-target.h" @@ -7969,6 +8317,7 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd, #undef bfd_elf32_bfd_link_hash_table_create #define bfd_elf32_bfd_link_hash_table_create \ elf32_arm_symbian_link_hash_table_create +#undef elf_backend_add_symbol_hook #undef elf_backend_special_sections #define elf_backend_special_sections elf32_arm_symbian_special_sections @@ -7976,6 +8325,10 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd, #undef elf_backend_begin_write_processing #define elf_backend_begin_write_processing \ elf32_arm_symbian_begin_write_processing +#undef elf_backend_final_write_processing +#define elf_backend_final_write_processing \ + elf32_arm_final_write_processing +#undef elf_backend_emit_relocs #undef elf_backend_modify_segment_map #define elf_backend_modify_segment_map elf32_arm_symbian_modify_segment_map @@ -7989,12 +8342,16 @@ elf32_arm_symbian_modify_segment_map (bfd *abfd, #define elf_backend_want_got_plt 0 #undef elf_backend_may_use_rel_p -#define elf_backend_may_use_rel_p 1 +#define elf_backend_may_use_rel_p 1 #undef elf_backend_may_use_rela_p -#define elf_backend_may_use_rela_p 0 +#define elf_backend_may_use_rela_p 0 #undef elf_backend_default_use_rela_p -#define elf_backend_default_use_rela_p 0 +#define elf_backend_default_use_rela_p 0 #undef elf_backend_rela_normal -#define elf_backend_rela_normal 0 +#define elf_backend_rela_normal 0 +#undef elf_backend_want_plt_sym +#define elf_backend_want_plt_sym 0 +#undef ELF_MAXPAGESIZE +#define ELF_MAXPAGESIZE 0x8000 #include "elf32-target.h" diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index c97cbb2..219a834 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -1,5 +1,5 @@ -/* ADI Blackfin BFD support for 32-bit ELF. - Copyright 2005 Free Software Foundation, Inc. +/* ADI Blackfin BFD support for 32-bit ELF. + Copyright 2005, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -23,167 +23,8 @@ #include "libbfd.h" #include "elf-bfd.h" #include "elf/bfin.h" - -/* Handling expression relocations for blackfin. Blackfin - will generate relocations in an expression form with a stack. - A relocation such as P1.H = _typenames-4000000; - will generate the following relocs at offset 4: -00000004 R_expst_push _typenames -00000004 R_expst_const .__constant -00000004 R_expst_sub .__operator -00000006 R_huimm16 .__operator - - The .__constant and .__operator symbol names are fake. - Special case is a single relocation - P1.L = _typenames; generates -00000002 R_luimm16 _typenames - - Thus, if you get a R_luimm16, R_huimm16, R_imm16, - if the stack is not empty, pop the stack and - put the value, else do the normal thing - We will currently assume that the max the stack - would grow to is 100. . */ - -#define RELOC_STACK_SIZE 100 -static bfd_vma reloc_stack[RELOC_STACK_SIZE]; -static unsigned int reloc_stack_tos = 0; - -#define is_reloc_stack_empty() ((reloc_stack_tos > 0) ? 0 : 1) - -static void -reloc_stack_push (bfd_vma value) -{ - reloc_stack[reloc_stack_tos++] = value; -} - -static bfd_vma -reloc_stack_pop (void) -{ - return reloc_stack[--reloc_stack_tos]; -} - -static bfd_vma -reloc_stack_operate (unsigned int oper) -{ - bfd_vma value; - switch (oper) - { - case R_add: - { - value = - reloc_stack[reloc_stack_tos - 2] + reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_sub: - { - value = - reloc_stack[reloc_stack_tos - 2] - reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_mult: - { - value = - reloc_stack[reloc_stack_tos - 2] * reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_div: - { - if (reloc_stack[reloc_stack_tos - 1] == 0) - { - _bfd_abort (__FILE__, __LINE__, _("Division by zero. ")); - } - else - { - value = - reloc_stack[reloc_stack_tos - 2] / reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - } - break; - } - case R_mod: - { - value = - reloc_stack[reloc_stack_tos - 2] % reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_lshift: - { - value = - reloc_stack[reloc_stack_tos - 2] << reloc_stack[reloc_stack_tos - - 1]; - reloc_stack_tos -= 2; - break; - } - case R_rshift: - { - value = - reloc_stack[reloc_stack_tos - 2] >> reloc_stack[reloc_stack_tos - - 1]; - reloc_stack_tos -= 2; - break; - } - case R_and: - { - value = - reloc_stack[reloc_stack_tos - 2] & reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_or: - { - value = - reloc_stack[reloc_stack_tos - 2] | reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_xor: - { - value = - reloc_stack[reloc_stack_tos - 2] ^ reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_land: - { - value = reloc_stack[reloc_stack_tos - 2] - && reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_lor: - { - value = reloc_stack[reloc_stack_tos - 2] - || reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 2; - break; - } - case R_neg: - { - value = -reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos--; - break; - } - case R_comp: - { - value = ~reloc_stack[reloc_stack_tos - 1]; - reloc_stack_tos -= 1; - break; - } - default: - { - fprintf (stderr, "bfin relocation : Internal bug\n"); - return 0; - } - } - - reloc_stack_push (value); - - return value; -} +#include "elf/dwarf2.h" +#include "hashtab.h" /* FUNCTION : bfin_pltpc_reloc ABSTRACT : TODO : figure out how to handle pltpc relocs. */ @@ -195,10 +36,10 @@ bfin_pltpc_reloc ( PTR data ATTRIBUTE_UNUSED, asection *input_section ATTRIBUTE_UNUSED, bfd *output_bfd ATTRIBUTE_UNUSED, - char **error_message ATTRIBUTE_UNUSED) + char **error_message ATTRIBUTE_UNUSED) { bfd_reloc_status_type flag = bfd_reloc_ok; - return flag; + return flag; } @@ -221,49 +62,44 @@ bfin_pcrel24_reloc (bfd *abfd, if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) return bfd_reloc_outofrange; - if (!is_reloc_stack_empty ()) - relocation = reloc_stack_pop(); + if (bfd_is_und_section (symbol->section) + && (symbol->flags & BSF_WEAK) == 0 + && !relocatable) + return bfd_reloc_undefined; + + if (bfd_is_com_section (symbol->section)) + relocation = 0; else - { - if (bfd_is_und_section (symbol->section) - && (symbol->flags & BSF_WEAK) == 0 - && !relocatable) - return bfd_reloc_undefined; + relocation = symbol->value; - if (bfd_is_com_section (symbol->section)) - relocation = 0; - else - relocation = symbol->value; + output_section = symbol->section->output_section; + + if (relocatable) + output_base = 0; + else + output_base = output_section->vma; + + if (!relocatable || !strcmp (symbol->name, symbol->section->name)) + relocation += output_base + symbol->section->output_offset; - output_section = symbol->section->output_section; + if (!relocatable && !strcmp (symbol->name, symbol->section->name)) + relocation += reloc_entry->addend; - if (relocatable) - output_base = 0; - else - output_base = output_section->vma; - - if (!relocatable || !strcmp (symbol->name, symbol->section->name)) - relocation += output_base + symbol->section->output_offset; - - if (!relocatable && !strcmp (symbol->name, symbol->section->name)) - relocation += reloc_entry->addend; - } - relocation -= input_section->output_section->vma + input_section->output_offset; relocation -= reloc_entry->address; if (howto->complain_on_overflow != complain_overflow_dont) { bfd_reloc_status_type status; - status= bfd_check_overflow (howto->complain_on_overflow, - howto->bitsize, - howto->rightshift, - bfd_arch_bits_per_address(abfd), - relocation); + status = bfd_check_overflow (howto->complain_on_overflow, + howto->bitsize, + howto->rightshift, + bfd_arch_bits_per_address(abfd), + relocation); if (status != bfd_reloc_ok) return status; } - + /* if rightshift is 1 and the number odd, return error. */ if (howto->rightshift && (relocation & 0x01)) { @@ -286,11 +122,11 @@ bfin_pcrel24_reloc (bfd *abfd, short x; /* We are getting reloc_entry->address 2 byte off from - the start of instruction. Assuming absolute postion - of the reloc data. But, following code had been written assuming - reloc address is starting at begining of instruction. - To compensate that I have increased the value of - relocation by 1 (effectively 2) and used the addr -2 instead of addr. */ + the start of instruction. Assuming absolute postion + of the reloc data. But, following code had been written assuming + reloc address is starting at begining of instruction. + To compensate that I have increased the value of + relocation by 1 (effectively 2) and used the addr -2 instead of addr. */ relocation += 1; x = bfd_get_16 (abfd, (bfd_byte *) data + addr - 2); @@ -305,30 +141,32 @@ bfin_pcrel24_reloc (bfd *abfd, } static bfd_reloc_status_type -bfin_push_reloc (bfd *abfd ATTRIBUTE_UNUSED, - arelent *reloc_entry, - asymbol *symbol, - PTR data ATTRIBUTE_UNUSED, - asection *input_section, - bfd *output_bfd, - char **error_message ATTRIBUTE_UNUSED) +bfin_imm16_reloc (bfd *abfd, + arelent *reloc_entry, + asymbol *symbol, + PTR data, + asection *input_section, + bfd *output_bfd, + char **error_message ATTRIBUTE_UNUSED) { - bfd_vma relocation; + bfd_vma relocation, x; + bfd_size_type reloc_addr = reloc_entry->address; bfd_vma output_base = 0; + reloc_howto_type *howto = reloc_entry->howto; asection *output_section; bfd_boolean relocatable = (output_bfd != NULL); + /* Is the address of the relocation really within the section? */ + if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) + return bfd_reloc_outofrange; + if (bfd_is_und_section (symbol->section) && (symbol->flags & BSF_WEAK) == 0 && !relocatable) return bfd_reloc_undefined; - /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > bfd_get_section_limit(abfd, input_section)) - return bfd_reloc_outofrange; - output_section = symbol->section->output_section; - relocation = symbol->value; + relocation = symbol->value; /* Convert input-section-relative symbol value to absolute. */ if (relocatable) @@ -336,7 +174,7 @@ bfin_push_reloc (bfd *abfd ATTRIBUTE_UNUSED, else output_base = output_section->vma; - if (!relocatable || !strcmp(symbol->name, symbol->section->name)) + if (!relocatable || !strcmp (symbol->name, symbol->section->name)) relocation += output_base + symbol->section->output_offset; /* Add in supplied addend. */ @@ -347,105 +185,6 @@ bfin_push_reloc (bfd *abfd ATTRIBUTE_UNUSED, reloc_entry->address += input_section->output_offset; reloc_entry->addend += symbol->section->output_offset; } - - /* Now that we have the value, push it. */ - reloc_stack_push (relocation); - - return bfd_reloc_ok; -} - -static bfd_reloc_status_type -bfin_oper_reloc (bfd *abfd ATTRIBUTE_UNUSED, - arelent *reloc_entry, - asymbol *symbol ATTRIBUTE_UNUSED, - PTR data ATTRIBUTE_UNUSED, - asection *input_section, - bfd *output_bfd, - char **error_message ATTRIBUTE_UNUSED) -{ - bfd_boolean relocatable = (output_bfd != NULL); - - /* Just call the operation based on the reloc_type. */ - reloc_stack_operate (reloc_entry->howto->type); - - if (relocatable) - reloc_entry->address += input_section->output_offset; - - return bfd_reloc_ok; -} - -static bfd_reloc_status_type -bfin_const_reloc (bfd *abfd ATTRIBUTE_UNUSED, - arelent *reloc_entry, - asymbol *symbol ATTRIBUTE_UNUSED, - PTR data ATTRIBUTE_UNUSED, - asection *input_section, - bfd *output_bfd, - char **error_message ATTRIBUTE_UNUSED) -{ - bfd_boolean relocatable = (output_bfd != NULL); - - /* Push the addend portion of the relocation. */ - reloc_stack_push (reloc_entry->addend); - - if (relocatable) - reloc_entry->address += input_section->output_offset; - - return bfd_reloc_ok; -} - -static bfd_reloc_status_type -bfin_imm16_reloc (bfd *abfd, - arelent *reloc_entry, - asymbol *symbol, - PTR data, - asection *input_section, - bfd *output_bfd, - char **error_message ATTRIBUTE_UNUSED) -{ - bfd_vma relocation, x; - bfd_size_type reloc_addr = reloc_entry->address; - bfd_vma output_base = 0; - reloc_howto_type *howto = reloc_entry->howto; - asection *output_section; - bfd_boolean relocatable = (output_bfd != NULL); - - /* Is the address of the relocation really within the section? */ - if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) - return bfd_reloc_outofrange; - - if (is_reloc_stack_empty ()) - { - if (bfd_is_und_section (symbol->section) - && (symbol->flags & BSF_WEAK) == 0 - && !relocatable) - return bfd_reloc_undefined; - - output_section = symbol->section->output_section; - relocation = symbol->value; - - /* Convert input-section-relative symbol value to absolute. */ - if (relocatable) - output_base = 0; - else - output_base = output_section->vma; - - if (!relocatable || !strcmp (symbol->name, symbol->section->name)) - relocation += output_base + symbol->section->output_offset; - - /* Add in supplied addend. */ - relocation += reloc_entry->addend; - } - else - { - relocation = reloc_stack_pop (); - } - - if (relocatable) - { - reloc_entry->address += input_section->output_offset; - reloc_entry->addend += symbol->section->output_offset; - } else { reloc_entry->addend = 0; @@ -455,15 +194,14 @@ bfin_imm16_reloc (bfd *abfd, { bfd_reloc_status_type flag; flag = bfd_check_overflow (howto->complain_on_overflow, - howto->bitsize, - howto->rightshift, - bfd_arch_bits_per_address(abfd), - relocation); + howto->bitsize, + howto->rightshift, + bfd_arch_bits_per_address(abfd), + relocation); if (flag != bfd_reloc_ok) - return flag; + return flag; } - /* Here the variable relocation holds the final address of the symbol we are relocating against, plus any addend. */ @@ -481,7 +219,7 @@ bfin_byte4_reloc (bfd *abfd, PTR data, asection *input_section, bfd *output_bfd, - char **error_message ATTRIBUTE_UNUSED) + char **error_message ATTRIBUTE_UNUSED) { bfd_vma relocation, x; bfd_size_type addr = reloc_entry->address; @@ -493,39 +231,31 @@ bfin_byte4_reloc (bfd *abfd, if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) return bfd_reloc_outofrange; - if (is_reloc_stack_empty ()) - { - if (bfd_is_und_section (symbol->section) - && (symbol->flags & BSF_WEAK) == 0 - && !relocatable) - return bfd_reloc_undefined; - - output_section = symbol->section->output_section; - relocation = symbol->value; - /* Convert input-section-relative symbol value to absolute. */ - if (relocatable) - output_base = 0; - else - output_base = output_section->vma; - - if ((symbol->name - && symbol->section->name - && !strcmp (symbol->name, symbol->section->name)) - || !relocatable) - { - relocation += output_base + symbol->section->output_offset; - } + if (bfd_is_und_section (symbol->section) + && (symbol->flags & BSF_WEAK) == 0 + && !relocatable) + return bfd_reloc_undefined; - relocation += reloc_entry->addend; - } + output_section = symbol->section->output_section; + relocation = symbol->value; + /* Convert input-section-relative symbol value to absolute. */ + if (relocatable) + output_base = 0; else + output_base = output_section->vma; + + if ((symbol->name + && symbol->section->name + && !strcmp (symbol->name, symbol->section->name)) + || !relocatable) { - relocation = reloc_stack_pop(); - relocation += reloc_entry->addend; + relocation += output_base + symbol->section->output_offset; } + relocation += reloc_entry->addend; + if (relocatable) - { + { /* This output will be relocatable ... like ld -r. */ reloc_entry->address += input_section->output_offset; reloc_entry->addend += symbol->section->output_offset; @@ -540,7 +270,7 @@ bfin_byte4_reloc (bfd *abfd, x = relocation & 0xFFFF0000; x >>=16; bfd_put_16 (abfd, x, (unsigned char *) data + addr + 2); - + x = relocation & 0x0000FFFF; bfd_put_16 (abfd, x, (unsigned char *) data + addr); return bfd_reloc_ok; @@ -568,42 +298,34 @@ bfin_bfd_reloc (bfd *abfd, if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) return bfd_reloc_outofrange; - if (is_reloc_stack_empty()) - { - if (bfd_is_und_section (symbol->section) - && (symbol->flags & BSF_WEAK) == 0 - && !relocatable) - return bfd_reloc_undefined; + if (bfd_is_und_section (symbol->section) + && (symbol->flags & BSF_WEAK) == 0 + && !relocatable) + return bfd_reloc_undefined; - /* Get symbol value. (Common symbols are special.) */ - if (bfd_is_com_section (symbol->section)) - relocation = 0; - else - relocation = symbol->value; - - output_section = symbol->section->output_section; - - /* Convert input-section-relative symbol value to absolute. */ - if (relocatable) - output_base = 0; - else - output_base = output_section->vma; - - if (!relocatable || !strcmp (symbol->name, symbol->section->name)) - relocation += output_base + symbol->section->output_offset; - - if (!relocatable && !strcmp (symbol->name, symbol->section->name)) - { - /* Add in supplied addend. */ - relocation += reloc_entry->addend; - } - - } + /* Get symbol value. (Common symbols are special.) */ + if (bfd_is_com_section (symbol->section)) + relocation = 0; + else + relocation = symbol->value; + + output_section = symbol->section->output_section; + + /* Convert input-section-relative symbol value to absolute. */ + if (relocatable) + output_base = 0; else + output_base = output_section->vma; + + if (!relocatable || !strcmp (symbol->name, symbol->section->name)) + relocation += output_base + symbol->section->output_offset; + + if (!relocatable && !strcmp (symbol->name, symbol->section->name)) { - relocation = reloc_stack_pop(); + /* Add in supplied addend. */ + relocation += reloc_entry->addend; } - + /* Here the variable relocation holds the final address of the symbol we are relocating against, plus any addend. */ @@ -625,15 +347,15 @@ bfin_bfd_reloc (bfd *abfd, { bfd_reloc_status_type status; - status = bfd_check_overflow (howto->complain_on_overflow, + status = bfd_check_overflow (howto->complain_on_overflow, howto->bitsize, - howto->rightshift, + howto->rightshift, bfd_arch_bits_per_address(abfd), relocation); if (status != bfd_reloc_ok) return status; } - + /* If rightshift is 1 and the number odd, return error. */ if (howto->rightshift && (relocation & 0x01)) { @@ -647,7 +369,7 @@ bfin_bfd_reloc (bfd *abfd, relocation <<= (bfd_vma) howto->bitpos; -#define DOIT(x) \ +#define DOIT(x) \ x = ( (x & ~howto->dst_mask) | (relocation & howto->dst_mask)) /* handle 8 and 16 bit relocations here. */ @@ -673,41 +395,9 @@ bfin_bfd_reloc (bfd *abfd, return bfd_reloc_other; } - return bfd_reloc_ok; + return bfd_reloc_ok; } -#if 0 -static bfd_reloc_status_type bfin_bfd_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_imm16_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_pcrel24_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_pltpc_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_const_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_oper_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_byte4_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_reloc_status_type bfin_push_reloc - PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); - -static bfd_boolean bfin_is_local_label_name - PARAMS ((bfd *, const char *)); -#endif -bfd_boolean bfd_bfin_elf32_create_embedded_relocs - PARAMS ((bfd *, struct bfd_link_info *, asection *, asection *, char **)); - - /* HOWTO Table for blackfin. Blackfin relocations are fairly complicated. Some of the salient features are @@ -722,7 +412,7 @@ bfd_boolean bfd_bfin_elf32_create_embedded_relocs the relocation stack. . */ #define BFIN_RELOC_MIN 0 -#define BFIN_RELOC_MAX 0x13 +#define BFIN_RELOC_MAX 0x21 #define BFIN_GNUEXT_RELOC_MIN 0x40 #define BFIN_GNUEXT_RELOC_MAX 0x43 #define BFIN_ARELOC_MIN 0xE0 @@ -786,7 +476,7 @@ static reloc_howto_type bfin_howto_table [] = 0, /* src_mask. */ 0x000003FF, /* dst_mask. */ TRUE), /* pcrel_offset. */ - + HOWTO (R_pcrel12_jump, /* type. */ 1, /* rightshift. */ /* the offset is actually 13 bit @@ -832,7 +522,7 @@ static reloc_howto_type bfin_howto_table [] = 0, /* src_mask. */ 0x0000FFFF, /* dst_mask. */ TRUE), /* pcrel_offset. */ - + HOWTO (R_huimm16, /* type. */ 16, /* rightshift. */ 1, /* size (0 = byte, 1 = short, 2 = long). */ @@ -1014,319 +704,259 @@ static reloc_howto_type bfin_howto_table [] = 0, /* src_mask. */ 0x000003FF, /* dst_mask. */ FALSE), /* pcrel_offset. */ + + + /* A 18-bit signed operand with the GOT offset for the address of + the symbol. */ + HOWTO (R_BFIN_GOT17M4, /* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_GOT12", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The upper 16 bits of the GOT offset for the address of the + symbol. */ + HOWTO (R_BFIN_GOTHI, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_GOTHI", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The lower 16 bits of the GOT offset for the address of the + symbol. */ + HOWTO (R_BFIN_GOTLO, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_GOTLO", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The 32-bit address of the canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A 12-bit signed operand with the GOT offset for the address of + canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_GOT17M4, /* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_GOT17M4", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The upper 16 bits of the GOT offset for the address of the + canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_GOTHI, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_GOTHI", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The lower 16 bits of the GOT offset for the address of the + canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_GOTLO, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_GOTLO", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The 32-bit address of the canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_VALUE, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 64, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_VALUE", /* name */ + FALSE, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A 12-bit signed operand with the GOT offset for the address of + canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_GOTOFF17M4, /* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_GOTOFF17M4", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The upper 16 bits of the GOT offset for the address of the + canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_GOTOFFHI, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_GOTOFFHI", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The lower 16 bits of the GOT offset for the address of the + canonical descriptor of a function. */ + HOWTO (R_BFIN_FUNCDESC_GOTOFFLO, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_FUNCDESC_GOTOFFLO", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* A 12-bit signed operand with the GOT offset for the address of + the symbol. */ + HOWTO (R_BFIN_GOTOFF17M4, /* type */ + 2, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_GOTOFF17M4", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The upper 16 bits of the GOT offset for the address of the + symbol. */ + HOWTO (R_BFIN_GOTOFFHI, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_GOTOFFHI", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ + + /* The lower 16 bits of the GOT offset for the address of the + symbol. */ + HOWTO (R_BFIN_GOTOFFLO, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_BFIN_GOTOFFLO", /* name */ + FALSE, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + FALSE), /* pcrel_offset */ }; -static reloc_howto_type bfin_areloc_howto_table [] = -{ - HOWTO (R_push, - 0, - 2, - 0, - FALSE, - 0, - complain_overflow_dont, - bfin_push_reloc, - "R_expst_push", - FALSE, - 0, - 0, - FALSE), - - HOWTO (R_const, - 0, - 2, - 0, - FALSE, - 0, - complain_overflow_dont, - bfin_const_reloc, - "R_expst_const", - FALSE, - 0, - 0, - FALSE), - - HOWTO (R_add, - 0, - 0, - 0, - FALSE, - 0, - complain_overflow_dont, - bfin_oper_reloc, - "R_expst_add", - FALSE, - 0, - 0, - FALSE), - - HOWTO (R_sub, - 0, - 0, - 0, - FALSE, - 0, - complain_overflow_dont, - bfin_oper_reloc, - "R_expst_sub", - FALSE, - 0, - 0, - FALSE), - - HOWTO (R_mult, - 0, - 0, - 0, - FALSE, - 0, - complain_overflow_dont, - bfin_oper_reloc, - "R_expst_mult", - FALSE, - 0, - 0, - FALSE), - - HOWTO (R_div, /* type. */ +static reloc_howto_type bfin_gnuext_howto_table [] = +{ + HOWTO (R_pltpc, /* type. */ 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ + 1, /* size (0 = byte, 1 = short, 2 = long). */ + 16, /* bitsize. */ FALSE, /* pc_relative. */ 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_div", /* name. */ + complain_overflow_bitfield, /* complain_on_overflow. */ + bfin_pltpc_reloc, /* special_function. */ + "R_pltpc", /* name. */ FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ + 0xffff, /* src_mask. */ + 0xffff, /* dst_mask. */ FALSE), /* pcrel_offset. */ - HOWTO (R_mod, /* type. */ + HOWTO (R_got, /* type. */ 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ + 1, /* size (0 = byte, 1 = short, 2 = long). */ + 16, /* bitsize. */ FALSE, /* pc_relative. */ 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_mod", /* name. */ + complain_overflow_bitfield, /* complain_on_overflow. */ + bfd_elf_generic_reloc, /* special_function. */ + "R_got", /* name. */ FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_lshift, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_lshift", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_rshift, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_rshift", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_and, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_and", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_or, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_or", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_xor, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_xor", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_land, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_land", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_lor, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_lor", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_len, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_len", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_neg, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_neg", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_comp, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_comp", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_page, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_page", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_hwpage, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_hwpage", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_addr, /* type. */ - 0, /* rightshift. */ - 0, /* size (0 = byte, 1 = short, 2 = long). */ - 0, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_dont, /* complain_on_overflow. */ - bfin_oper_reloc, /* special_function. */ - "R_expst_addr", /* name. */ - FALSE, /* partial_inplace. */ - 0, /* src_mask. */ - 0, /* dst_mask. */ - FALSE), /* pcrel_offset. */ -}; - -static reloc_howto_type bfin_gnuext_howto_table [] = -{ - HOWTO (R_pltpc, /* type. */ - 0, /* rightshift. */ - 1, /* size (0 = byte, 1 = short, 2 = long). */ - 16, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_bitfield, /* complain_on_overflow. */ - bfin_pltpc_reloc, /* special_function. */ - "R_pltpc", /* name. */ - FALSE, /* partial_inplace. */ - 0xffff, /* src_mask. */ - 0xffff, /* dst_mask. */ - FALSE), /* pcrel_offset. */ - - HOWTO (R_got, /* type. */ - 0, /* rightshift. */ - 1, /* size (0 = byte, 1 = short, 2 = long). */ - 16, /* bitsize. */ - FALSE, /* pc_relative. */ - 0, /* bitpos. */ - complain_overflow_bitfield, /* complain_on_overflow. */ - bfd_elf_generic_reloc, /* special_function. */ - "R_got", /* name. */ - FALSE, /* partial_inplace. */ - 0x7fff, /* src_mask. */ - 0x7fff, /* dst_mask. */ + 0x7fff, /* src_mask. */ + 0x7fff, /* dst_mask. */ FALSE), /* pcrel_offset. */ /* GNU extension to record C++ vtable hierarchy. */ @@ -1389,29 +1019,24 @@ static const struct bfin_reloc_map bfin_reloc_map [] = { BFD_RELOC_BFIN_11_PCREL, R_pcrel11 }, { BFD_RELOC_BFIN_GOT, R_got }, { BFD_RELOC_BFIN_PLTPC, R_pltpc }, + + { BFD_RELOC_BFIN_GOT17M4, R_BFIN_GOT17M4 }, + { BFD_RELOC_BFIN_GOTHI, R_BFIN_GOTHI }, + { BFD_RELOC_BFIN_GOTLO, R_BFIN_GOTLO }, + { BFD_RELOC_BFIN_FUNCDESC, R_BFIN_FUNCDESC }, + { BFD_RELOC_BFIN_FUNCDESC_GOT17M4, R_BFIN_FUNCDESC_GOT17M4 }, + { BFD_RELOC_BFIN_FUNCDESC_GOTHI, R_BFIN_FUNCDESC_GOTHI }, + { BFD_RELOC_BFIN_FUNCDESC_GOTLO, R_BFIN_FUNCDESC_GOTLO }, + { BFD_RELOC_BFIN_FUNCDESC_VALUE, R_BFIN_FUNCDESC_VALUE }, + { BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4, R_BFIN_FUNCDESC_GOTOFF17M4 }, + { BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI, R_BFIN_FUNCDESC_GOTOFFHI }, + { BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO, R_BFIN_FUNCDESC_GOTOFFLO }, + { BFD_RELOC_BFIN_GOTOFF17M4, R_BFIN_GOTOFF17M4 }, + { BFD_RELOC_BFIN_GOTOFFHI, R_BFIN_GOTOFFHI }, + { BFD_RELOC_BFIN_GOTOFFLO, R_BFIN_GOTOFFLO }, + { BFD_RELOC_VTABLE_INHERIT, R_BFIN_GNU_VTINHERIT }, { BFD_RELOC_VTABLE_ENTRY, R_BFIN_GNU_VTENTRY }, - { BFD_ARELOC_BFIN_PUSH, R_push }, - { BFD_ARELOC_BFIN_CONST, R_const }, - { BFD_ARELOC_BFIN_ADD, R_add }, - { BFD_ARELOC_BFIN_SUB, R_sub }, - { BFD_ARELOC_BFIN_MULT, R_mult }, - { BFD_ARELOC_BFIN_DIV, R_div }, - { BFD_ARELOC_BFIN_MOD, R_mod }, - { BFD_ARELOC_BFIN_LSHIFT, R_lshift }, - { BFD_ARELOC_BFIN_RSHIFT, R_rshift }, - { BFD_ARELOC_BFIN_AND, R_and }, - { BFD_ARELOC_BFIN_OR, R_or }, - { BFD_ARELOC_BFIN_XOR, R_xor }, - { BFD_ARELOC_BFIN_LAND, R_land }, - { BFD_ARELOC_BFIN_LOR, R_lor }, - { BFD_ARELOC_BFIN_LEN, R_len }, - { BFD_ARELOC_BFIN_NEG, R_neg }, - { BFD_ARELOC_BFIN_COMP, R_comp }, - { BFD_ARELOC_BFIN_PAGE, R_page }, - { BFD_ARELOC_BFIN_HWPAGE, R_hwpage }, - { BFD_ARELOC_BFIN_ADDR, R_addr } - }; @@ -1427,9 +1052,6 @@ bfin_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED, if (r_type <= BFIN_RELOC_MAX) cache_ptr->howto = &bfin_howto_table [r_type]; - else if (r_type >= BFIN_ARELOC_MIN && r_type <= BFIN_ARELOC_MAX) - cache_ptr->howto = &bfin_areloc_howto_table [r_type - BFIN_ARELOC_MIN]; - else if (r_type >= BFIN_GNUEXT_RELOC_MIN && r_type <= BFIN_GNUEXT_RELOC_MAX) cache_ptr->howto = &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN]; @@ -1452,9 +1074,6 @@ bfin_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, if (r_type <= BFIN_RELOC_MAX && r_type > BFIN_RELOC_MIN) return &bfin_howto_table [r_type]; - else if (r_type >= BFIN_ARELOC_MIN && r_type <= BFIN_ARELOC_MAX) - return &bfin_areloc_howto_table [r_type - BFIN_ARELOC_MIN]; - else if (r_type >= BFIN_GNUEXT_RELOC_MIN && r_type <= BFIN_GNUEXT_RELOC_MAX) return &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN]; @@ -1469,9 +1088,6 @@ bfin_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, if (r_type <= BFIN_RELOC_MAX) return &bfin_howto_table [r_type]; - else if (r_type >= BFIN_ARELOC_MIN && r_type <= BFIN_ARELOC_MAX) - return &bfin_areloc_howto_table [r_type - BFIN_ARELOC_MIN]; - else if (r_type >= BFIN_GNUEXT_RELOC_MIN && r_type <= BFIN_GNUEXT_RELOC_MAX) return &bfin_gnuext_howto_table [r_type - BFIN_GNUEXT_RELOC_MIN]; @@ -1492,96 +1108,887 @@ bfin_is_local_label_name ( return _bfd_elf_is_local_label_name (abfd, label); } +extern const bfd_target bfd_elf32_bfinfdpic_vec; +#define IS_FDPIC(bfd) ((bfd)->xvec == &bfd_elf32_bfinfdpic_vec) -/* Look through the relocs for a section during the first phase, and - allocate space in the global offset table or procedure linkage - table. */ - -static bfd_boolean -bfin_check_relocs (bfd * abfd, - struct bfd_link_info *info, - asection *sec, - const Elf_Internal_Rela *relocs) +/* An extension of the elf hash table data structure, containing some + additional Blackfin-specific data. */ +struct bfinfdpic_elf_link_hash_table { - bfd *dynobj; - Elf_Internal_Shdr *symtab_hdr; - struct elf_link_hash_entry **sym_hashes; - bfd_signed_vma *local_got_refcounts; - const Elf_Internal_Rela *rel; - const Elf_Internal_Rela *rel_end; + struct elf_link_hash_table elf; + + /* A pointer to the .got section. */ asection *sgot; - asection *srelgot; - asection *sreloc; - if (info->relocatable) - return TRUE; + /* A pointer to the .rel.got section. */ + asection *sgotrel; + /* A pointer to the .rofixup section. */ + asection *sgotfixup; + /* A pointer to the .plt section. */ + asection *splt; + /* A pointer to the .rel.plt section. */ + asection *spltrel; + /* GOT base offset. */ + bfd_vma got0; + /* Location of the first non-lazy PLT entry, i.e., the number of + bytes taken by lazy PLT entries. */ + bfd_vma plt0; + /* A hash table holding information about which symbols were + referenced with which PIC-related relocations. */ + struct htab *relocs_info; +}; - dynobj = elf_hash_table (info)->dynobj; - symtab_hdr = &elf_tdata (abfd)->symtab_hdr; - sym_hashes = elf_sym_hashes (abfd); - local_got_refcounts = elf_local_got_refcounts (abfd); +/* Get the Blackfin ELF linker hash table from a link_info structure. */ + +#define bfinfdpic_hash_table(info) \ + ((struct bfinfdpic_elf_link_hash_table *) ((info)->hash)) + +#define bfinfdpic_got_section(info) \ + (bfinfdpic_hash_table (info)->sgot) +#define bfinfdpic_gotrel_section(info) \ + (bfinfdpic_hash_table (info)->sgotrel) +#define bfinfdpic_gotfixup_section(info) \ + (bfinfdpic_hash_table (info)->sgotfixup) +#define bfinfdpic_plt_section(info) \ + (bfinfdpic_hash_table (info)->splt) +#define bfinfdpic_pltrel_section(info) \ + (bfinfdpic_hash_table (info)->spltrel) +#define bfinfdpic_relocs_info(info) \ + (bfinfdpic_hash_table (info)->relocs_info) +#define bfinfdpic_got_initial_offset(info) \ + (bfinfdpic_hash_table (info)->got0) +#define bfinfdpic_plt_initial_offset(info) \ + (bfinfdpic_hash_table (info)->plt0) + +/* Create a Blackfin ELF linker hash table. */ - sgot = NULL; - srelgot = NULL; - sreloc = NULL; +static struct bfd_link_hash_table * +bfinfdpic_elf_link_hash_table_create (bfd *abfd) +{ + struct bfinfdpic_elf_link_hash_table *ret; + bfd_size_type amt = sizeof (struct bfinfdpic_elf_link_hash_table); - rel_end = relocs + sec->reloc_count; - for (rel = relocs; rel < rel_end; rel++) + ret = bfd_zalloc (abfd, amt); + if (ret == NULL) + return NULL; + + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, + _bfd_elf_link_hash_newfunc, + sizeof (struct elf_link_hash_entry))) { - unsigned long r_symndx; - struct elf_link_hash_entry *h; + free (ret); + return NULL; + } - r_symndx = ELF32_R_SYM (rel->r_info); - if (r_symndx < symtab_hdr->sh_info) - h = NULL; - else - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + return &ret->elf.root; +} - switch (ELF32_R_TYPE (rel->r_info)) - { - /* This relocation describes the C++ object vtable hierarchy. - Reconstruct it for later use during GC. */ - case R_BFIN_GNU_VTINHERIT: - if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) - return FALSE; - break; +/* Decide whether a reference to a symbol can be resolved locally or + not. If the symbol is protected, we want the local address, but + its function descriptor must be assigned by the dynamic linker. */ +#define BFINFDPIC_SYM_LOCAL(INFO, H) \ + (_bfd_elf_symbol_refs_local_p ((H), (INFO), 1) \ + || ! elf_hash_table (INFO)->dynamic_sections_created) +#define BFINFDPIC_FUNCDESC_LOCAL(INFO, H) \ + ((H)->dynindx == -1 || ! elf_hash_table (INFO)->dynamic_sections_created) + +/* This structure collects information on what kind of GOT, PLT or + function descriptors are required by relocations that reference a + certain symbol. */ +struct bfinfdpic_relocs_info +{ + /* The index of the symbol, as stored in the relocation r_info, if + we have a local symbol; -1 otherwise. */ + long symndx; + union + { + /* The input bfd in which the symbol is defined, if it's a local + symbol. */ + bfd *abfd; + /* If symndx == -1, the hash table entry corresponding to a global + symbol (even if it turns out to bind locally, in which case it + should ideally be replaced with section's symndx + addend). */ + struct elf_link_hash_entry *h; + } d; + /* The addend of the relocation that references the symbol. */ + bfd_vma addend; + + /* The fields above are used to identify an entry. The fields below + contain information on how an entry is used and, later on, which + locations it was assigned. */ + /* The following 2 fields record whether the symbol+addend above was + ever referenced with a GOT relocation. The 17M4 suffix indicates a + GOT17M4 relocation; hilo is used for GOTLO/GOTHI pairs. */ + unsigned got17m4:1; + unsigned gothilo:1; + /* Whether a FUNCDESC relocation references symbol+addend. */ + unsigned fd:1; + /* Whether a FUNCDESC_GOT relocation references symbol+addend. */ + unsigned fdgot17m4:1; + unsigned fdgothilo:1; + /* Whether a FUNCDESC_GOTOFF relocation references symbol+addend. */ + unsigned fdgoff17m4:1; + unsigned fdgoffhilo:1; + /* Whether symbol+addend is referenced with GOTOFF17M4, GOTOFFLO or + GOTOFFHI relocations. The addend doesn't really matter, since we + envision that this will only be used to check whether the symbol + is mapped to the same segment as the got. */ + unsigned gotoff:1; + /* Whether symbol+addend is referenced by a LABEL24 relocation. */ + unsigned call:1; + /* Whether symbol+addend is referenced by a 32 or FUNCDESC_VALUE + relocation. */ + unsigned sym:1; + /* Whether we need a PLT entry for a symbol. Should be implied by + something like: + (call && symndx == -1 && ! BFINFDPIC_SYM_LOCAL (info, d.h)) */ + unsigned plt:1; + /* Whether a function descriptor should be created in this link unit + for symbol+addend. Should be implied by something like: + (plt || fdgotoff17m4 || fdgotofflohi + || ((fd || fdgot17m4 || fdgothilo) + && (symndx != -1 || BFINFDPIC_FUNCDESC_LOCAL (info, d.h)))) */ + unsigned privfd:1; + /* Whether a lazy PLT entry is needed for this symbol+addend. + Should be implied by something like: + (privfd && symndx == -1 && ! BFINFDPIC_SYM_LOCAL (info, d.h) + && ! (info->flags & DF_BIND_NOW)) */ + unsigned lazyplt:1; + /* Whether we've already emitted GOT relocations and PLT entries as + needed for this symbol. */ + unsigned done:1; + + /* The number of R_byte4_data, R_BFIN_FUNCDESC and R_BFIN_FUNCDESC_VALUE + relocations referencing the symbol. */ + unsigned relocs32, relocsfd, relocsfdv; + + /* The number of .rofixups entries and dynamic relocations allocated + for this symbol, minus any that might have already been used. */ + unsigned fixups, dynrelocs; + + /* The offsets of the GOT entries assigned to symbol+addend, to the + function descriptor's address, and to a function descriptor, + respectively. Should be zero if unassigned. The offsets are + counted from the value that will be assigned to the PIC register, + not from the beginning of the .got section. */ + bfd_signed_vma got_entry, fdgot_entry, fd_entry; + /* The offsets of the PLT entries assigned to symbol+addend, + non-lazy and lazy, respectively. If unassigned, should be + (bfd_vma)-1. */ + bfd_vma plt_entry, lzplt_entry; +}; - /* This relocation describes which C++ vtable entries - are actually used. Record for later use during GC. */ - case R_BFIN_GNU_VTENTRY: - if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) - return FALSE; - break; +/* Compute a hash with the key fields of an bfinfdpic_relocs_info entry. */ +static hashval_t +bfinfdpic_relocs_info_hash (const void *entry_) +{ + const struct bfinfdpic_relocs_info *entry = entry_; - case R_got: - if (h != NULL - && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) - break; - /* Fall through. */ + return (entry->symndx == -1 + ? entry->d.h->root.root.hash + : entry->symndx + entry->d.abfd->id * 257) + entry->addend; +} - if (dynobj == NULL) - { - /* Create the .got section. */ - elf_hash_table (info)->dynobj = dynobj = abfd; - if (!_bfd_elf_create_got_section (dynobj, info)) - return FALSE; - } +/* Test whether the key fields of two bfinfdpic_relocs_info entries are + identical. */ +static int +bfinfdpic_relocs_info_eq (const void *entry1, const void *entry2) +{ + const struct bfinfdpic_relocs_info *e1 = entry1; + const struct bfinfdpic_relocs_info *e2 = entry2; - if (sgot == NULL) - { - sgot = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (sgot != NULL); - } + return e1->symndx == e2->symndx && e1->addend == e2->addend + && (e1->symndx == -1 ? e1->d.h == e2->d.h : e1->d.abfd == e2->d.abfd); +} - if (srelgot == NULL && (h != NULL || info->shared)) - { - srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); - if (srelgot == NULL) - { - srelgot = bfd_make_section (dynobj, ".rela.got"); - if (srelgot == NULL - || !bfd_set_section_flags (dynobj, srelgot, - (SEC_ALLOC - | SEC_LOAD +/* Find or create an entry in a hash table HT that matches the key + fields of the given ENTRY. If it's not found, memory for a new + entry is allocated in ABFD's obstack. */ +static struct bfinfdpic_relocs_info * +bfinfdpic_relocs_info_find (struct htab *ht, + bfd *abfd, + const struct bfinfdpic_relocs_info *entry, + enum insert_option insert) +{ + struct bfinfdpic_relocs_info **loc = + (struct bfinfdpic_relocs_info **) htab_find_slot (ht, entry, insert); + + if (! loc) + return NULL; + + if (*loc) + return *loc; + + *loc = bfd_zalloc (abfd, sizeof (**loc)); + + if (! *loc) + return *loc; + + (*loc)->symndx = entry->symndx; + (*loc)->d = entry->d; + (*loc)->addend = entry->addend; + (*loc)->plt_entry = (bfd_vma)-1; + (*loc)->lzplt_entry = (bfd_vma)-1; + + return *loc; +} + +/* Obtain the address of the entry in HT associated with H's symbol + + addend, creating a new entry if none existed. ABFD is only used + for memory allocation purposes. */ +inline static struct bfinfdpic_relocs_info * +bfinfdpic_relocs_info_for_global (struct htab *ht, + bfd *abfd, + struct elf_link_hash_entry *h, + bfd_vma addend, + enum insert_option insert) +{ + struct bfinfdpic_relocs_info entry; + + entry.symndx = -1; + entry.d.h = h; + entry.addend = addend; + + return bfinfdpic_relocs_info_find (ht, abfd, &entry, insert); +} + +/* Obtain the address of the entry in HT associated with the SYMNDXth + local symbol of the input bfd ABFD, plus the addend, creating a new + entry if none existed. */ +inline static struct bfinfdpic_relocs_info * +bfinfdpic_relocs_info_for_local (struct htab *ht, + bfd *abfd, + long symndx, + bfd_vma addend, + enum insert_option insert) +{ + struct bfinfdpic_relocs_info entry; + + entry.symndx = symndx; + entry.d.abfd = abfd; + entry.addend = addend; + + return bfinfdpic_relocs_info_find (ht, abfd, &entry, insert); +} + +/* Merge fields set by check_relocs() of two entries that end up being + mapped to the same (presumably global) symbol. */ + +inline static void +bfinfdpic_pic_merge_early_relocs_info (struct bfinfdpic_relocs_info *e2, + struct bfinfdpic_relocs_info const *e1) +{ + e2->got17m4 |= e1->got17m4; + e2->gothilo |= e1->gothilo; + e2->fd |= e1->fd; + e2->fdgot17m4 |= e1->fdgot17m4; + e2->fdgothilo |= e1->fdgothilo; + e2->fdgoff17m4 |= e1->fdgoff17m4; + e2->fdgoffhilo |= e1->fdgoffhilo; + e2->gotoff |= e1->gotoff; + e2->call |= e1->call; + e2->sym |= e1->sym; +} + +/* Every block of 65535 lazy PLT entries shares a single call to the + resolver, inserted in the 32768th lazy PLT entry (i.e., entry # + 32767, counting from 0). All other lazy PLT entries branch to it + in a single instruction. */ + +#define LZPLT_RESOLVER_EXTRA 10 +#define LZPLT_NORMAL_SIZE 6 +#define LZPLT_ENTRIES 1362 + +#define BFINFDPIC_LZPLT_BLOCK_SIZE ((bfd_vma) LZPLT_NORMAL_SIZE * LZPLT_ENTRIES + LZPLT_RESOLVER_EXTRA) +#define BFINFDPIC_LZPLT_RESOLV_LOC (LZPLT_NORMAL_SIZE * LZPLT_ENTRIES / 2) + +/* Add a dynamic relocation to the SRELOC section. */ + +inline static bfd_vma +_bfinfdpic_add_dyn_reloc (bfd *output_bfd, asection *sreloc, bfd_vma offset, + int reloc_type, long dynindx, bfd_vma addend, + struct bfinfdpic_relocs_info *entry) +{ + Elf_Internal_Rela outrel; + bfd_vma reloc_offset; + + outrel.r_offset = offset; + outrel.r_info = ELF32_R_INFO (dynindx, reloc_type); + outrel.r_addend = addend; + + reloc_offset = sreloc->reloc_count * sizeof (Elf32_External_Rel); + BFD_ASSERT (reloc_offset < sreloc->size); + bfd_elf32_swap_reloc_out (output_bfd, &outrel, + sreloc->contents + reloc_offset); + sreloc->reloc_count++; + + /* If the entry's index is zero, this relocation was probably to a + linkonce section that got discarded. We reserved a dynamic + relocation, but it was for another entry than the one we got at + the time of emitting the relocation. Unfortunately there's no + simple way for us to catch this situation, since the relocation + is cleared right before calling relocate_section, at which point + we no longer know what the relocation used to point to. */ + if (entry->symndx) + { + BFD_ASSERT (entry->dynrelocs > 0); + entry->dynrelocs--; + } + + return reloc_offset; +} + +/* Add a fixup to the ROFIXUP section. */ + +static bfd_vma +_bfinfdpic_add_rofixup (bfd *output_bfd, asection *rofixup, bfd_vma offset, + struct bfinfdpic_relocs_info *entry) +{ + bfd_vma fixup_offset; + + if (rofixup->flags & SEC_EXCLUDE) + return -1; + + fixup_offset = rofixup->reloc_count * 4; + if (rofixup->contents) + { + BFD_ASSERT (fixup_offset < rofixup->size); + bfd_put_32 (output_bfd, offset, rofixup->contents + fixup_offset); + } + rofixup->reloc_count++; + + if (entry && entry->symndx) + { + /* See discussion about symndx == 0 in _bfinfdpic_add_dyn_reloc + above. */ + BFD_ASSERT (entry->fixups > 0); + entry->fixups--; + } + + return fixup_offset; +} + +/* Find the segment number in which OSEC, and output section, is + located. */ + +static unsigned +_bfinfdpic_osec_to_segment (bfd *output_bfd, asection *osec) +{ + struct elf_segment_map *m; + Elf_Internal_Phdr *p; + + /* Find the segment that contains the output_section. */ + for (m = elf_tdata (output_bfd)->segment_map, + p = elf_tdata (output_bfd)->phdr; + m != NULL; + m = m->next, p++) + { + int i; + + for (i = m->count - 1; i >= 0; i--) + if (m->sections[i] == osec) + break; + + if (i >= 0) + break; + } + + return p - elf_tdata (output_bfd)->phdr; +} + +inline static bfd_boolean +_bfinfdpic_osec_readonly_p (bfd *output_bfd, asection *osec) +{ + unsigned seg = _bfinfdpic_osec_to_segment (output_bfd, osec); + + return ! (elf_tdata (output_bfd)->phdr[seg].p_flags & PF_W); +} + +/* Generate relocations for GOT entries, function descriptors, and + code for PLT and lazy PLT entries. */ + +inline static bfd_boolean +_bfinfdpic_emit_got_relocs_plt_entries (struct bfinfdpic_relocs_info *entry, + bfd *output_bfd, + struct bfd_link_info *info, + asection *sec, + Elf_Internal_Sym *sym, + bfd_vma addend) + +{ + bfd_vma fd_lazy_rel_offset = (bfd_vma)-1; + int dynindx = -1; + + if (entry->done) + return TRUE; + entry->done = 1; + + if (entry->got_entry || entry->fdgot_entry || entry->fd_entry) + { + /* If the symbol is dynamic, consider it for dynamic + relocations, otherwise decay to section + offset. */ + if (entry->symndx == -1 && entry->d.h->dynindx != -1) + dynindx = entry->d.h->dynindx; + else + { + if (sec->output_section + && ! bfd_is_abs_section (sec->output_section) + && ! bfd_is_und_section (sec->output_section)) + dynindx = elf_section_data (sec->output_section)->dynindx; + else + dynindx = 0; + } + } + + /* Generate relocation for GOT entry pointing to the symbol. */ + if (entry->got_entry) + { + int idx = dynindx; + bfd_vma ad = addend; + + /* If the symbol is dynamic but binds locally, use + section+offset. */ + if (sec && (entry->symndx != -1 + || BFINFDPIC_SYM_LOCAL (info, entry->d.h))) + { + if (entry->symndx == -1) + ad += entry->d.h->root.u.def.value; + else + ad += sym->st_value; + ad += sec->output_offset; + if (sec->output_section && elf_section_data (sec->output_section)) + idx = elf_section_data (sec->output_section)->dynindx; + else + idx = 0; + } + + /* If we're linking an executable at a fixed address, we can + omit the dynamic relocation as long as the symbol is local to + this module. */ + if (info->executable && !info->pie + && (entry->symndx != -1 + || BFINFDPIC_SYM_LOCAL (info, entry->d.h))) + { + if (sec) + ad += sec->output_section->vma; + if (entry->symndx != -1 + || entry->d.h->root.type != bfd_link_hash_undefweak) + _bfinfdpic_add_rofixup (output_bfd, + bfinfdpic_gotfixup_section (info), + bfinfdpic_got_section (info)->output_section + ->vma + + bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info) + + entry->got_entry, entry); + } + else + _bfinfdpic_add_dyn_reloc (output_bfd, bfinfdpic_gotrel_section (info), + _bfd_elf_section_offset + (output_bfd, info, + bfinfdpic_got_section (info), + bfinfdpic_got_initial_offset (info) + + entry->got_entry) + + bfinfdpic_got_section (info) + ->output_section->vma + + bfinfdpic_got_section (info)->output_offset, + R_byte4_data, idx, ad, entry); + + bfd_put_32 (output_bfd, ad, + bfinfdpic_got_section (info)->contents + + bfinfdpic_got_initial_offset (info) + + entry->got_entry); + } + + /* Generate relocation for GOT entry pointing to a canonical + function descriptor. */ + if (entry->fdgot_entry) + { + int reloc, idx; + bfd_vma ad = 0; + + if (! (entry->symndx == -1 + && entry->d.h->root.type == bfd_link_hash_undefweak + && BFINFDPIC_SYM_LOCAL (info, entry->d.h))) + { + /* If the symbol is dynamic and there may be dynamic symbol + resolution because we are, or are linked with, a shared + library, emit a FUNCDESC relocation such that the dynamic + linker will allocate the function descriptor. If the + symbol needs a non-local function descriptor but binds + locally (e.g., its visibility is protected, emit a + dynamic relocation decayed to section+offset. */ + if (entry->symndx == -1 + && ! BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h) + && BFINFDPIC_SYM_LOCAL (info, entry->d.h) + && !(info->executable && !info->pie)) + { + reloc = R_BFIN_FUNCDESC; + idx = elf_section_data (entry->d.h->root.u.def.section + ->output_section)->dynindx; + ad = entry->d.h->root.u.def.section->output_offset + + entry->d.h->root.u.def.value; + } + else if (entry->symndx == -1 + && ! BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h)) + { + reloc = R_BFIN_FUNCDESC; + idx = dynindx; + ad = addend; + if (ad) + return FALSE; + } + else + { + /* Otherwise, we know we have a private function descriptor, + so reference it directly. */ + if (elf_hash_table (info)->dynamic_sections_created) + BFD_ASSERT (entry->privfd); + reloc = R_byte4_data; + idx = elf_section_data (bfinfdpic_got_section (info) + ->output_section)->dynindx; + ad = bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info) + entry->fd_entry; + } + + /* If there is room for dynamic symbol resolution, emit the + dynamic relocation. However, if we're linking an + executable at a fixed location, we won't have emitted a + dynamic symbol entry for the got section, so idx will be + zero, which means we can and should compute the address + of the private descriptor ourselves. */ + if (info->executable && !info->pie + && (entry->symndx != -1 + || BFINFDPIC_FUNCDESC_LOCAL (info, entry->d.h))) + { + ad += bfinfdpic_got_section (info)->output_section->vma; + _bfinfdpic_add_rofixup (output_bfd, + bfinfdpic_gotfixup_section (info), + bfinfdpic_got_section (info) + ->output_section->vma + + bfinfdpic_got_section (info) + ->output_offset + + bfinfdpic_got_initial_offset (info) + + entry->fdgot_entry, entry); + } + else + _bfinfdpic_add_dyn_reloc (output_bfd, + bfinfdpic_gotrel_section (info), + _bfd_elf_section_offset + (output_bfd, info, + bfinfdpic_got_section (info), + bfinfdpic_got_initial_offset (info) + + entry->fdgot_entry) + + bfinfdpic_got_section (info) + ->output_section->vma + + bfinfdpic_got_section (info) + ->output_offset, + reloc, idx, ad, entry); + } + + bfd_put_32 (output_bfd, ad, + bfinfdpic_got_section (info)->contents + + bfinfdpic_got_initial_offset (info) + + entry->fdgot_entry); + } + + /* Generate relocation to fill in a private function descriptor in + the GOT. */ + if (entry->fd_entry) + { + int idx = dynindx; + bfd_vma ad = addend; + bfd_vma ofst; + long lowword, highword; + + /* If the symbol is dynamic but binds locally, use + section+offset. */ + if (sec && (entry->symndx != -1 + || BFINFDPIC_SYM_LOCAL (info, entry->d.h))) + { + if (entry->symndx == -1) + ad += entry->d.h->root.u.def.value; + else + ad += sym->st_value; + ad += sec->output_offset; + if (sec->output_section && elf_section_data (sec->output_section)) + idx = elf_section_data (sec->output_section)->dynindx; + else + idx = 0; + } + + /* If we're linking an executable at a fixed address, we can + omit the dynamic relocation as long as the symbol is local to + this module. */ + if (info->executable && !info->pie + && (entry->symndx != -1 || BFINFDPIC_SYM_LOCAL (info, entry->d.h))) + { + if (sec) + ad += sec->output_section->vma; + ofst = 0; + if (entry->symndx != -1 + || entry->d.h->root.type != bfd_link_hash_undefweak) + { + _bfinfdpic_add_rofixup (output_bfd, + bfinfdpic_gotfixup_section (info), + bfinfdpic_got_section (info) + ->output_section->vma + + bfinfdpic_got_section (info) + ->output_offset + + bfinfdpic_got_initial_offset (info) + + entry->fd_entry, entry); + _bfinfdpic_add_rofixup (output_bfd, + bfinfdpic_gotfixup_section (info), + bfinfdpic_got_section (info) + ->output_section->vma + + bfinfdpic_got_section (info) + ->output_offset + + bfinfdpic_got_initial_offset (info) + + entry->fd_entry + 4, entry); + } + } + else + { + ofst + = _bfinfdpic_add_dyn_reloc (output_bfd, + entry->lazyplt + ? bfinfdpic_pltrel_section (info) + : bfinfdpic_gotrel_section (info), + _bfd_elf_section_offset + (output_bfd, info, + bfinfdpic_got_section (info), + bfinfdpic_got_initial_offset (info) + + entry->fd_entry) + + bfinfdpic_got_section (info) + ->output_section->vma + + bfinfdpic_got_section (info) + ->output_offset, + R_BFIN_FUNCDESC_VALUE, idx, ad, entry); + } + + /* If we've omitted the dynamic relocation, just emit the fixed + addresses of the symbol and of the local GOT base offset. */ + if (info->executable && !info->pie && sec && sec->output_section) + { + lowword = ad; + highword = bfinfdpic_got_section (info)->output_section->vma + + bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info); + } + else if (entry->lazyplt) + { + if (ad) + return FALSE; + + fd_lazy_rel_offset = ofst; + + /* A function descriptor used for lazy or local resolving is + initialized such that its high word contains the output + section index in which the PLT entries are located, and + the low word contains the address of the lazy PLT entry + entry point, that must be within the memory region + assigned to that section. */ + lowword = entry->lzplt_entry + 4 + + bfinfdpic_plt_section (info)->output_offset + + bfinfdpic_plt_section (info)->output_section->vma; + highword = _bfinfdpic_osec_to_segment + (output_bfd, bfinfdpic_plt_section (info)->output_section); + } + else + { + /* A function descriptor for a local function gets the index + of the section. For a non-local function, it's + disregarded. */ + lowword = ad; + if (entry->symndx == -1 && entry->d.h->dynindx != -1 + && entry->d.h->dynindx == idx) + highword = 0; + else + highword = _bfinfdpic_osec_to_segment + (output_bfd, sec->output_section); + } + + bfd_put_32 (output_bfd, lowword, + bfinfdpic_got_section (info)->contents + + bfinfdpic_got_initial_offset (info) + + entry->fd_entry); + bfd_put_32 (output_bfd, highword, + bfinfdpic_got_section (info)->contents + + bfinfdpic_got_initial_offset (info) + + entry->fd_entry + 4); + } + + /* Generate code for the PLT entry. */ + if (entry->plt_entry != (bfd_vma) -1) + { + bfd_byte *plt_code = bfinfdpic_plt_section (info)->contents + + entry->plt_entry; + + BFD_ASSERT (entry->fd_entry); + + /* Figure out what kind of PLT entry we need, depending on the + location of the function descriptor within the GOT. */ + if (entry->fd_entry >= -(1 << (18 - 1)) + && entry->fd_entry + 4 < (1 << (18 - 1))) + { + /* P1 = [P3 + fd_entry]; P3 = [P3 + fd_entry + 4] */ + bfd_put_32 (output_bfd, + 0xe519 | ((entry->fd_entry << 14) & 0xFFFF0000), + plt_code); + bfd_put_32 (output_bfd, + 0xe51b | (((entry->fd_entry + 4) << 14) & 0xFFFF0000), + plt_code + 4); + plt_code += 8; + } + else + { + /* P1.L = fd_entry; P1.H = fd_entry; + P3 = P3 + P1; + P1 = [P3]; + P3 = [P3 + 4]; */ + bfd_put_32 (output_bfd, + 0xe109 | (entry->fd_entry << 16), + plt_code); + bfd_put_32 (output_bfd, + 0xe149 | (entry->fd_entry & 0xFFFF0000), + plt_code + 4); + bfd_put_16 (output_bfd, 0x5ad9, plt_code + 8); + bfd_put_16 (output_bfd, 0x9159, plt_code + 10); + bfd_put_16 (output_bfd, 0xac5b, plt_code + 12); + plt_code += 14; + } + /* JUMP (P1) */ + bfd_put_16 (output_bfd, 0x0051, plt_code); + } + + /* Generate code for the lazy PLT entry. */ + if (entry->lzplt_entry != (bfd_vma) -1) + { + bfd_byte *lzplt_code = bfinfdpic_plt_section (info)->contents + + entry->lzplt_entry; + bfd_vma resolverStub_addr; + + bfd_put_32 (output_bfd, fd_lazy_rel_offset, lzplt_code); + lzplt_code += 4; + + resolverStub_addr = entry->lzplt_entry / BFINFDPIC_LZPLT_BLOCK_SIZE + * BFINFDPIC_LZPLT_BLOCK_SIZE + BFINFDPIC_LZPLT_RESOLV_LOC; + if (resolverStub_addr >= bfinfdpic_plt_initial_offset (info)) + resolverStub_addr = bfinfdpic_plt_initial_offset (info) - LZPLT_NORMAL_SIZE - LZPLT_RESOLVER_EXTRA; + + if (entry->lzplt_entry == resolverStub_addr) + { + /* This is a lazy PLT entry that includes a resolver call. + P2 = [P3]; + R3 = [P3 + 4]; + JUMP (P2); */ + bfd_put_32 (output_bfd, + 0xa05b915a, + lzplt_code); + bfd_put_16 (output_bfd, 0x0052, lzplt_code + 4); + } + else + { + /* JUMP.S resolverStub */ + bfd_put_16 (output_bfd, + 0x2000 + | (((resolverStub_addr - entry->lzplt_entry) + / 2) & (((bfd_vma)1 << 12) - 1)), + lzplt_code); + } + } + + return TRUE; +} + + +/* Look through the relocs for a section during the first phase, and + allocate space in the global offset table or procedure linkage + table. */ + +static bfd_boolean +bfin_check_relocs (bfd * abfd, + struct bfd_link_info *info, + asection *sec, + const Elf_Internal_Rela *relocs) +{ + bfd *dynobj; + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + bfd_signed_vma *local_got_refcounts; + const Elf_Internal_Rela *rel; + const Elf_Internal_Rela *rel_end; + asection *sgot; + asection *srelgot; + asection *sreloc; + if (info->relocatable) + return TRUE; + + dynobj = elf_hash_table (info)->dynobj; + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (abfd); + local_got_refcounts = elf_local_got_refcounts (abfd); + + sgot = NULL; + srelgot = NULL; + sreloc = NULL; + + rel_end = relocs + sec->reloc_count; + for (rel = relocs; rel < rel_end; rel++) + { + unsigned long r_symndx; + struct elf_link_hash_entry *h; + + r_symndx = ELF32_R_SYM (rel->r_info); + if (r_symndx < symtab_hdr->sh_info) + h = NULL; + else + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + + switch (ELF32_R_TYPE (rel->r_info)) + { + /* This relocation describes the C++ object vtable hierarchy. + Reconstruct it for later use during GC. */ + case R_BFIN_GNU_VTINHERIT: + if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) + return FALSE; + break; + + /* This relocation describes which C++ vtable entries + are actually used. Record for later use during GC. */ + case R_BFIN_GNU_VTENTRY: + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + return FALSE; + break; + + case R_got: + if (h != NULL + && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) + break; + /* Fall through. */ + + if (dynobj == NULL) + { + /* Create the .got section. */ + elf_hash_table (info)->dynobj = dynobj = abfd; + if (!_bfd_elf_create_got_section (dynobj, info)) + return FALSE; + } + + if (sgot == NULL) + { + sgot = bfd_get_section_by_name (dynobj, ".got"); + BFD_ASSERT (sgot != NULL); + } + + if (srelgot == NULL && (h != NULL || info->shared)) + { + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + if (srelgot == NULL) + { + srelgot = bfd_make_section (dynobj, ".rela.got"); + if (srelgot == NULL + || !bfd_set_section_flags (dynobj, srelgot, + (SEC_ALLOC + | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED @@ -1656,492 +2063,2747 @@ elf32_bfin_reloc_type_class (const Elf_Internal_Rela * rela) return reloc_class_normal; } } + +/* Relocate an Blackfin ELF section. + + The RELOCATE_SECTION function is called by the new ELF backend linker + to handle the relocations for a section. + + The relocs are always passed as Rela structures; if the section + actually uses Rel structures, the r_addend field will always be + zero. + + This function is responsible for adjusting the section contents as + necessary, and (if using Rela relocs and generating a relocatable + output file) adjusting the reloc addend as necessary. + + This function does not have to worry about setting the reloc + address or the reloc symbol index. + + LOCAL_SYMS is a pointer to the swapped in local symbols. + + LOCAL_SECTIONS is an array giving the section in the input file + corresponding to the st_shndx field of each local symbol. + + The global hash table entry for the global symbols can be found + via elf_sym_hashes (input_bfd). + + When generating relocatable output, this function must handle + STB_LOCAL/STT_SECTION symbols specially. The output symbol is + going to be the section symbol corresponding to the output + section, which means that the addend must be adjusted + accordingly. */ static bfd_boolean -bfin_relocate_section (bfd * output_bfd, - struct bfd_link_info *info, - bfd * input_bfd, - asection * input_section, - bfd_byte * contents, - Elf_Internal_Rela * relocs, - Elf_Internal_Sym * local_syms, - asection ** local_sections) +bfinfdpic_relocate_section (bfd * output_bfd, + struct bfd_link_info *info, + bfd * input_bfd, + asection * input_section, + bfd_byte * contents, + Elf_Internal_Rela * relocs, + Elf_Internal_Sym * local_syms, + asection ** local_sections) { - bfd *dynobj; Elf_Internal_Shdr *symtab_hdr; struct elf_link_hash_entry **sym_hashes; - bfd_vma *local_got_offsets; - asection *sgot; - asection *sreloc; Elf_Internal_Rela *rel; Elf_Internal_Rela *relend; - int i = 0; + unsigned isec_segment, got_segment, plt_segment, + check_segment[2]; + int silence_segment_error = !(info->shared || info->pie); if (info->relocatable) return TRUE; - dynobj = elf_hash_table (info)->dynobj; - symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + symtab_hdr = & elf_tdata (input_bfd)->symtab_hdr; sym_hashes = elf_sym_hashes (input_bfd); - local_got_offsets = elf_local_got_offsets (input_bfd); - - sgot = NULL; - sreloc = NULL; + relend = relocs + input_section->reloc_count; + + isec_segment = _bfinfdpic_osec_to_segment (output_bfd, + input_section->output_section); + if (IS_FDPIC (output_bfd) && bfinfdpic_got_section (info)) + got_segment = _bfinfdpic_osec_to_segment (output_bfd, + bfinfdpic_got_section (info) + ->output_section); + else + got_segment = -1; + if (IS_FDPIC (output_bfd) && elf_hash_table (info)->dynamic_sections_created) + plt_segment = _bfinfdpic_osec_to_segment (output_bfd, + bfinfdpic_plt_section (info) + ->output_section); + else + plt_segment = -1; - rel = relocs; - relend = relocs + input_section->reloc_count; - for (; rel < relend; rel++, i++) + for (rel = relocs; rel < relend; rel ++) { - int r_type; reloc_howto_type *howto; unsigned long r_symndx; - struct elf_link_hash_entry *h; Elf_Internal_Sym *sym; asection *sec; - bfd_vma relocation = 0; - bfd_boolean unresolved_reloc; + struct elf_link_hash_entry *h; + bfd_vma relocation; bfd_reloc_status_type r; - bfd_vma address; + const char * name = NULL; + int r_type; + asection *osec; + struct bfinfdpic_relocs_info *picrel; + bfd_vma orig_addend = rel->r_addend; r_type = ELF32_R_TYPE (rel->r_info); - if (r_type < 0 || r_type >= 243) - { - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - if (r_type == R_BFIN_GNU_VTENTRY - || r_type == R_BFIN_GNU_VTINHERIT) + if (r_type == R_BFIN_GNU_VTINHERIT + || r_type == R_BFIN_GNU_VTENTRY) continue; + /* This is a final link. */ + r_symndx = ELF32_R_SYM (rel->r_info); howto = bfin_reloc_type_lookup (input_bfd, r_type); if (howto == NULL) { bfd_set_error (bfd_error_bad_value); return FALSE; } - r_symndx = ELF32_R_SYM (rel->r_info); - h = NULL; - sym = NULL; - sec = NULL; - unresolved_reloc = FALSE; + h = NULL; + sym = NULL; + sec = NULL; if (r_symndx < symtab_hdr->sh_info) { sym = local_syms + r_symndx; - sec = local_sections[r_symndx]; + osec = sec = local_sections [r_symndx]; relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); + + name = bfd_elf_string_from_elf_section + (input_bfd, symtab_hdr->sh_link, sym->st_name); + name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name; } else { - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + h = sym_hashes [r_symndx - symtab_hdr->sh_info]; while (h->root.type == bfd_link_hash_indirect || h->root.type == bfd_link_hash_warning) h = (struct elf_link_hash_entry *) h->root.u.i.link; - if (! - (!strcmp (h->root.root.string, ".__constant") - || !strcmp (h->root.root.string, ".__operator"))) - { - bfd_boolean warned; - h = NULL; - RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, - r_symndx, symtab_hdr, sym_hashes, - h, sec, relocation, - unresolved_reloc, warned); + name = h->root.root.string; + if ((h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + && ! BFINFDPIC_SYM_LOCAL (info, h)) + { + sec = NULL; + relocation = 0; } + else + if (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak) + { + sec = h->root.u.def.section; + relocation = (h->root.u.def.value + + sec->output_section->vma + + sec->output_offset); + } + else if (h->root.type == bfd_link_hash_undefweak) + { + relocation = 0; + } + else if (info->unresolved_syms_in_objects == RM_IGNORE + && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) + relocation = 0; + else + { + if (! ((*info->callbacks->undefined_symbol) + (info, h->root.root.string, input_bfd, + input_section, rel->r_offset, + (info->unresolved_syms_in_objects == RM_GENERATE_ERROR + || ELF_ST_VISIBILITY (h->other))))) + return FALSE; + relocation = 0; + } + osec = sec; } - address = rel->r_offset; - /* First, get stack relocs out of the way. */ switch (r_type) { - case R_push: - reloc_stack_push (relocation + rel->r_addend); - r = bfd_reloc_ok; - goto done_reloc; - case R_const: - reloc_stack_push (rel->r_addend); - r = bfd_reloc_ok; - goto done_reloc; - case R_add: - case R_sub: - case R_mult: - case R_div: - case R_mod: - case R_lshift: - case R_rshift: - case R_neg: - case R_and: - case R_or: - case R_xor: - case R_land: - case R_lor: - case R_comp: - case R_page: - case R_hwpage: - reloc_stack_operate (r_type); - r = bfd_reloc_ok; - goto done_reloc; + case R_pcrel24: + case R_pcrel24_jump_l: + case R_byte4_data: + if (! IS_FDPIC (output_bfd)) + goto non_fdpic; + + case R_BFIN_GOT17M4: + case R_BFIN_GOTHI: + case R_BFIN_GOTLO: + case R_BFIN_FUNCDESC_GOT17M4: + case R_BFIN_FUNCDESC_GOTHI: + case R_BFIN_FUNCDESC_GOTLO: + case R_BFIN_GOTOFF17M4: + case R_BFIN_GOTOFFHI: + case R_BFIN_GOTOFFLO: + case R_BFIN_FUNCDESC_GOTOFF17M4: + case R_BFIN_FUNCDESC_GOTOFFHI: + case R_BFIN_FUNCDESC_GOTOFFLO: + case R_BFIN_FUNCDESC: + case R_BFIN_FUNCDESC_VALUE: + if (h != NULL) + picrel = bfinfdpic_relocs_info_for_global (bfinfdpic_relocs_info + (info), input_bfd, h, + orig_addend, INSERT); + else + /* In order to find the entry we created before, we must + use the original addend, not the one that may have been + modified by _bfd_elf_rela_local_sym(). */ + picrel = bfinfdpic_relocs_info_for_local (bfinfdpic_relocs_info + (info), input_bfd, r_symndx, + orig_addend, INSERT); + if (! picrel) + return FALSE; + + if (!_bfinfdpic_emit_got_relocs_plt_entries (picrel, output_bfd, info, + osec, sym, + rel->r_addend)) + { + (*_bfd_error_handler) + (_("%B: relocation at `%A+0x%x' references symbol `%s' with nonzero addend"), + input_bfd, input_section, rel->r_offset, name); + return FALSE; + + } + + break; default: - if (!is_reloc_stack_empty()) - relocation = reloc_stack_pop (); + non_fdpic: + picrel = NULL; + if (h && ! BFINFDPIC_SYM_LOCAL (info, h)) + { + info->callbacks->warning + (info, _("relocation references symbol not defined in the module"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; + } break; } - /* Then, process normally. */ switch (r_type) { - case R_BFIN_GNU_VTINHERIT: - case R_BFIN_GNU_VTENTRY: - return bfd_reloc_ok; + case R_pcrel24: + case R_pcrel24_jump_l: + check_segment[0] = isec_segment; + if (! IS_FDPIC (output_bfd)) + check_segment[1] = isec_segment; + else if (picrel->plt) + { + relocation = bfinfdpic_plt_section (info)->output_section->vma + + bfinfdpic_plt_section (info)->output_offset + + picrel->plt_entry; + check_segment[1] = plt_segment; + } + /* We don't want to warn on calls to undefined weak symbols, + as calls to them must be protected by non-NULL tests + anyway, and unprotected calls would invoke undefined + behavior. */ + else if (picrel->symndx == -1 + && picrel->d.h->root.type == bfd_link_hash_undefweak) + check_segment[1] = check_segment[0]; + else + check_segment[1] = sec + ? _bfinfdpic_osec_to_segment (output_bfd, sec->output_section) + : (unsigned)-1; + break; - case R_got: - /* Relocation is to the address of the entry for this symbol - in the global offset table. */ - if (h != NULL - && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) - goto do_default; - /* Fall through. */ - /* Relocation is the offset of the entry for this symbol in - the global offset table. */ + case R_BFIN_GOT17M4: + case R_BFIN_GOTHI: + case R_BFIN_GOTLO: + relocation = picrel->got_entry; + check_segment[0] = check_segment[1] = got_segment; + break; - { - bfd_vma off; + case R_BFIN_FUNCDESC_GOT17M4: + case R_BFIN_FUNCDESC_GOTHI: + case R_BFIN_FUNCDESC_GOTLO: + relocation = picrel->fdgot_entry; + check_segment[0] = check_segment[1] = got_segment; + break; - if (sgot == NULL) - { - sgot = bfd_get_section_by_name (dynobj, ".got"); - BFD_ASSERT (sgot != NULL); - } + case R_BFIN_GOTOFFHI: + case R_BFIN_GOTOFF17M4: + case R_BFIN_GOTOFFLO: + relocation -= bfinfdpic_got_section (info)->output_section->vma + + bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info); + check_segment[0] = got_segment; + check_segment[1] = sec + ? _bfinfdpic_osec_to_segment (output_bfd, sec->output_section) + : (unsigned)-1; + break; - if (h != NULL) - { - bfd_boolean dyn; + case R_BFIN_FUNCDESC_GOTOFF17M4: + case R_BFIN_FUNCDESC_GOTOFFHI: + case R_BFIN_FUNCDESC_GOTOFFLO: + relocation = picrel->fd_entry; + check_segment[0] = check_segment[1] = got_segment; + break; - off = h->got.offset; - BFD_ASSERT (off != (bfd_vma) - 1); - dyn = elf_hash_table (info)->dynamic_sections_created; + case R_BFIN_FUNCDESC: + { + int dynindx; + bfd_vma addend = rel->r_addend; - if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) - || (info->shared - && (info->symbolic - || h->dynindx == -1 - || h->forced_local) - && h->def_regular)) + if (! (h && h->root.type == bfd_link_hash_undefweak + && BFINFDPIC_SYM_LOCAL (info, h))) + { + /* If the symbol is dynamic and there may be dynamic + symbol resolution because we are or are linked with a + shared library, emit a FUNCDESC relocation such that + the dynamic linker will allocate the function + descriptor. If the symbol needs a non-local function + descriptor but binds locally (e.g., its visibility is + protected, emit a dynamic relocation decayed to + section+offset. */ + if (h && ! BFINFDPIC_FUNCDESC_LOCAL (info, h) + && BFINFDPIC_SYM_LOCAL (info, h) + && !(info->executable && !info->pie)) { - /* This is actually a static link, or it is a - -Bsymbolic link and the symbol is defined - locally, or the symbol was forced to be local - because of a version file.. We must initialize - this entry in the global offset table. Since - the offset must always be a multiple of 4, we - use the least significant bit to record whether - we have initialized it already. - - When doing a dynamic link, we create a .rela.got - relocation entry to initialize the value. This - is done in the finish_dynamic_symbol routine. */ - if ((off & 1) != 0) - off &= ~1; - else + dynindx = elf_section_data (h->root.u.def.section + ->output_section)->dynindx; + addend += h->root.u.def.section->output_offset + + h->root.u.def.value; + } + else if (h && ! BFINFDPIC_FUNCDESC_LOCAL (info, h)) + { + if (addend) { - bfd_put_32 (output_bfd, relocation, - sgot->contents + off); - h->got.offset |= 1; + info->callbacks->warning + (info, _("R_BFIN_FUNCDESC references dynamic symbol with nonzero addend"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; } + dynindx = h->dynindx; } else - unresolved_reloc = FALSE; - } - else - { - BFD_ASSERT (local_got_offsets != NULL); - off = local_got_offsets[r_symndx]; - BFD_ASSERT (off != (bfd_vma) - 1); - - /* The offset must always be a multiple of 4. We use - the least significant bit to record whether we have - already generated the necessary reloc. */ - if ((off & 1) != 0) - off &= ~1; - else { - bfd_put_32 (output_bfd, relocation, sgot->contents + off); + /* Otherwise, we know we have a private function + descriptor, so reference it directly. */ + BFD_ASSERT (picrel->privfd); + r_type = R_byte4_data; + dynindx = elf_section_data (bfinfdpic_got_section (info) + ->output_section)->dynindx; + addend = bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info) + + picrel->fd_entry; + } - if (info->shared) + /* If there is room for dynamic symbol resolution, emit + the dynamic relocation. However, if we're linking an + executable at a fixed location, we won't have emitted a + dynamic symbol entry for the got section, so idx will + be zero, which means we can and should compute the + address of the private descriptor ourselves. */ + if (info->executable && !info->pie + && (!h || BFINFDPIC_FUNCDESC_LOCAL (info, h))) + { + addend += bfinfdpic_got_section (info)->output_section->vma; + if ((bfd_get_section_flags (output_bfd, + input_section->output_section) + & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) { - asection *s; - Elf_Internal_Rela outrel; - bfd_byte *loc; - - s = bfd_get_section_by_name (dynobj, ".rela.got"); - BFD_ASSERT (s != NULL); - - outrel.r_offset = (sgot->output_section->vma - + sgot->output_offset + off); - outrel.r_info = - ELF32_R_INFO (0, R_pcrel24); - outrel.r_addend = relocation; - loc = s->contents; - loc += - s->reloc_count++ * sizeof (Elf32_External_Rela); - bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); + if (_bfinfdpic_osec_readonly_p (output_bfd, + input_section + ->output_section)) + { + info->callbacks->warning + (info, + _("cannot emit fixups in read-only section"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; + } + _bfinfdpic_add_rofixup (output_bfd, + bfinfdpic_gotfixup_section + (info), + _bfd_elf_section_offset + (output_bfd, info, + input_section, rel->r_offset) + + input_section + ->output_section->vma + + input_section->output_offset, + picrel); } - - local_got_offsets[r_symndx] |= 1; } + else if ((bfd_get_section_flags (output_bfd, + input_section->output_section) + & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) + { + if (_bfinfdpic_osec_readonly_p (output_bfd, + input_section + ->output_section)) + { + info->callbacks->warning + (info, + _("cannot emit dynamic relocations in read-only section"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; + } + _bfinfdpic_add_dyn_reloc (output_bfd, + bfinfdpic_gotrel_section (info), + _bfd_elf_section_offset + (output_bfd, info, + input_section, rel->r_offset) + + input_section + ->output_section->vma + + input_section->output_offset, + r_type, dynindx, addend, picrel); + } + else + addend += bfinfdpic_got_section (info)->output_section->vma; } - relocation = sgot->output_offset + off; - rel->r_addend = 0; - /* bfin : preg = [preg + 17bitdiv4offset] relocation is div by 4. */ - relocation /= 4; + /* We want the addend in-place because dynamic + relocations are REL. Setting relocation to it should + arrange for it to be installed. */ + relocation = addend - rel->r_addend; } - goto do_default; + check_segment[0] = check_segment[1] = got_segment; + break; - case R_pcrel24: - case R_pcrel24_jump_l: + case R_byte4_data: + if (! IS_FDPIC (output_bfd)) + { + check_segment[0] = check_segment[1] = -1; + break; + } + /* Fall through. */ + case R_BFIN_FUNCDESC_VALUE: { - bfd_vma x; - - relocation += rel->r_addend; - - /* Perform usual pc-relative correction. */ - relocation -= input_section->output_section->vma + input_section->output_offset; - relocation -= address; - - /* We are getting reloc_entry->address 2 byte off from - the start of instruction. Assuming absolute postion - of the reloc data. But, following code had been written assuming - reloc address is starting at begining of instruction. - To compensate that I have increased the value of - relocation by 1 (effectively 2) and used the addr -2 instead of addr. */ - - relocation += 2; - address -= 2; + int dynindx; + bfd_vma addend = rel->r_addend; - relocation >>= 1; + /* If the symbol is dynamic but binds locally, use + section+offset. */ + if (h && ! BFINFDPIC_SYM_LOCAL (info, h)) + { + if (addend && r_type == R_BFIN_FUNCDESC_VALUE) + { + info->callbacks->warning + (info, _("R_BFIN_FUNCDESC_VALUE references dynamic symbol with nonzero addend"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; + } + dynindx = h->dynindx; + } + else + { + if (h) + addend += h->root.u.def.value; + else + addend += sym->st_value; + if (osec) + addend += osec->output_offset; + if (osec && osec->output_section + && ! bfd_is_abs_section (osec->output_section) + && ! bfd_is_und_section (osec->output_section)) + dynindx = elf_section_data (osec->output_section)->dynindx; + else + dynindx = 0; + } - x = bfd_get_16 (input_bfd, contents + address); - x = (x & 0xff00) | ((relocation >> 16) & 0xff); - bfd_put_16 (input_bfd, x, contents + address); + /* If we're linking an executable at a fixed address, we + can omit the dynamic relocation as long as the symbol + is defined in the current link unit (which is implied + by its output section not being NULL). */ + if (info->executable && !info->pie + && (!h || BFINFDPIC_SYM_LOCAL (info, h))) + { + if (osec) + addend += osec->output_section->vma; + if (IS_FDPIC (input_bfd) + && (bfd_get_section_flags (output_bfd, + input_section->output_section) + & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) + { + if (_bfinfdpic_osec_readonly_p (output_bfd, + input_section + ->output_section)) + { + info->callbacks->warning + (info, + _("cannot emit fixups in read-only section"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; + } + if (!h || h->root.type != bfd_link_hash_undefweak) + { + _bfinfdpic_add_rofixup (output_bfd, + bfinfdpic_gotfixup_section + (info), + _bfd_elf_section_offset + (output_bfd, info, + input_section, rel->r_offset) + + input_section + ->output_section->vma + + input_section->output_offset, + picrel); + if (r_type == R_BFIN_FUNCDESC_VALUE) + _bfinfdpic_add_rofixup + (output_bfd, + bfinfdpic_gotfixup_section (info), + _bfd_elf_section_offset + (output_bfd, info, + input_section, rel->r_offset) + + input_section->output_section->vma + + input_section->output_offset + 4, picrel); + } + } + } + else + { + if ((bfd_get_section_flags (output_bfd, + input_section->output_section) + & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD)) + { + if (_bfinfdpic_osec_readonly_p (output_bfd, + input_section + ->output_section)) + { + info->callbacks->warning + (info, + _("cannot emit dynamic relocations in read-only section"), + name, input_bfd, input_section, rel->r_offset); + return FALSE; + } + _bfinfdpic_add_dyn_reloc (output_bfd, + bfinfdpic_gotrel_section (info), + _bfd_elf_section_offset + (output_bfd, info, + input_section, rel->r_offset) + + input_section + ->output_section->vma + + input_section->output_offset, + r_type, dynindx, addend, picrel); + } + else if (osec) + addend += osec->output_section->vma; + /* We want the addend in-place because dynamic + relocations are REL. Setting relocation to it + should arrange for it to be installed. */ + relocation = addend - rel->r_addend; + } - x = bfd_get_16 (input_bfd, contents + address + 2); - x = relocation & 0xFFFF; - bfd_put_16 (input_bfd, x, contents + address + 2); - r = bfd_reloc_ok; + if (r_type == R_BFIN_FUNCDESC_VALUE) + { + /* If we've omitted the dynamic relocation, just emit + the fixed addresses of the symbol and of the local + GOT base offset. */ + if (info->executable && !info->pie + && (!h || BFINFDPIC_SYM_LOCAL (info, h))) + bfd_put_32 (output_bfd, + bfinfdpic_got_section (info)->output_section->vma + + bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info), + contents + rel->r_offset + 4); + else + /* A function descriptor used for lazy or local + resolving is initialized such that its high word + contains the output section index in which the + PLT entries are located, and the low word + contains the offset of the lazy PLT entry entry + point into that section. */ + bfd_put_32 (output_bfd, + h && ! BFINFDPIC_SYM_LOCAL (info, h) + ? 0 + : _bfinfdpic_osec_to_segment (output_bfd, + sec + ->output_section), + contents + rel->r_offset + 4); + } } + check_segment[0] = check_segment[1] = got_segment; break; default: - do_default: - r = _bfd_final_link_relocate (howto, input_bfd, input_section, - contents, address, - relocation, rel->r_addend); - + check_segment[0] = isec_segment; + check_segment[1] = sec + ? _bfinfdpic_osec_to_segment (output_bfd, sec->output_section) + : (unsigned)-1; break; } - done_reloc: - /* Dynamic relocs are not propagated for SEC_DEBUGGING sections - because such sections are not SEC_ALLOC and thus ld.so will - not process them. */ - if (unresolved_reloc + if (check_segment[0] != check_segment[1] && IS_FDPIC (output_bfd)) + { +#if 1 /* If you take this out, remove the #error from fdpic-static-6.d + in the ld testsuite. */ + /* This helps catch problems in GCC while we can't do more + than static linking. The idea is to test whether the + input file basename is crt0.o only once. */ + if (silence_segment_error == 1) + silence_segment_error = + (strlen (input_bfd->filename) == 6 + && strcmp (input_bfd->filename, "crt0.o") == 0) + || (strlen (input_bfd->filename) > 6 + && strcmp (input_bfd->filename + + strlen (input_bfd->filename) - 7, + "/crt0.o") == 0) + ? -1 : 0; +#endif + if (!silence_segment_error + /* We don't want duplicate errors for undefined + symbols. */ + && !(picrel && picrel->symndx == -1 + && picrel->d.h->root.type == bfd_link_hash_undefined)) + info->callbacks->warning + (info, + (info->shared || info->pie) + ? _("relocations between different segments are not supported") + : _("warning: relocation references a different segment"), + name, input_bfd, input_section, rel->r_offset); + if (!silence_segment_error && (info->shared || info->pie)) + return FALSE; + elf_elfheader (output_bfd)->e_flags |= EF_BFIN_PIC; + } + + switch (r_type) + { + case R_BFIN_GOTOFFHI: + /* We need the addend to be applied before we shift the + value right. */ + relocation += rel->r_addend; + /* Fall through. */ + case R_BFIN_GOTHI: + case R_BFIN_FUNCDESC_GOTHI: + case R_BFIN_FUNCDESC_GOTOFFHI: + relocation >>= 16; + /* Fall through. */ + + case R_BFIN_GOTLO: + case R_BFIN_FUNCDESC_GOTLO: + case R_BFIN_GOTOFFLO: + case R_BFIN_FUNCDESC_GOTOFFLO: + relocation &= 0xffff; + break; + + default: + break; + } + + switch (r_type) + { + case R_pcrel24: + case R_pcrel24_jump_l: + if (! IS_FDPIC (output_bfd) || ! picrel->plt) + break; + /* Fall through. */ + + /* When referencing a GOT entry, a function descriptor or a + PLT, we don't want the addend to apply to the reference, + but rather to the referenced symbol. The actual entry + will have already been created taking the addend into + account, so cancel it out here. */ + case R_BFIN_GOT17M4: + case R_BFIN_GOTHI: + case R_BFIN_GOTLO: + case R_BFIN_FUNCDESC_GOT17M4: + case R_BFIN_FUNCDESC_GOTHI: + case R_BFIN_FUNCDESC_GOTLO: + case R_BFIN_FUNCDESC_GOTOFF17M4: + case R_BFIN_FUNCDESC_GOTOFFHI: + case R_BFIN_FUNCDESC_GOTOFFLO: + /* Note that we only want GOTOFFHI, not GOTOFFLO or GOTOFF17M4 + here, since we do want to apply the addend to the others. + Note that we've applied the addend to GOTOFFHI before we + shifted it right. */ + case R_BFIN_GOTOFFHI: + relocation -= rel->r_addend; + break; + + default: + break; + } + + if (r_type == R_pcrel24 + || r_type == R_pcrel24_jump_l) + { + bfd_vma x; + bfd_vma address = rel->r_offset; + + relocation += rel->r_addend; + + /* Perform usual pc-relative correction. */ + relocation -= input_section->output_section->vma + input_section->output_offset; + relocation -= address; + + /* We are getting reloc_entry->address 2 byte off from + the start of instruction. Assuming absolute postion + of the reloc data. But, following code had been written assuming + reloc address is starting at begining of instruction. + To compensate that I have increased the value of + relocation by 1 (effectively 2) and used the addr -2 instead of addr. */ + + relocation += 2; + address -= 2; + + relocation >>= 1; + + x = bfd_get_16 (input_bfd, contents + address); + x = (x & 0xff00) | ((relocation >> 16) & 0xff); + bfd_put_16 (input_bfd, x, contents + address); + + x = bfd_get_16 (input_bfd, contents + address + 2); + x = relocation & 0xFFFF; + bfd_put_16 (input_bfd, x, contents + address + 2); + r = bfd_reloc_ok; + } + else + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, rel->r_addend); + + if (r != bfd_reloc_ok) + { + const char * msg = (const char *) NULL; + + switch (r) + { + case bfd_reloc_overflow: + r = info->callbacks->reloc_overflow + (info, (h ? &h->root : NULL), name, howto->name, + (bfd_vma) 0, input_bfd, input_section, rel->r_offset); + break; + + case bfd_reloc_undefined: + r = info->callbacks->undefined_symbol + (info, name, input_bfd, input_section, rel->r_offset, TRUE); + break; + + case bfd_reloc_outofrange: + msg = _("internal error: out of range error"); + break; + + case bfd_reloc_notsupported: + msg = _("internal error: unsupported relocation error"); + break; + + case bfd_reloc_dangerous: + msg = _("internal error: dangerous relocation"); + break; + + default: + msg = _("internal error: unknown error"); + break; + } + + if (msg) + r = info->callbacks->warning + (info, msg, name, input_bfd, input_section, rel->r_offset); + + if (! r) + return FALSE; + } + } + + return TRUE; +} + +static bfd_boolean +bfin_relocate_section (bfd * output_bfd, + struct bfd_link_info *info, + bfd * input_bfd, + asection * input_section, + bfd_byte * contents, + Elf_Internal_Rela * relocs, + Elf_Internal_Sym * local_syms, + asection ** local_sections) +{ + bfd *dynobj; + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + bfd_vma *local_got_offsets; + asection *sgot; + asection *sreloc; + Elf_Internal_Rela *rel; + Elf_Internal_Rela *relend; + int i = 0; + + if (info->relocatable) + return TRUE; + + dynobj = elf_hash_table (info)->dynobj; + symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (input_bfd); + local_got_offsets = elf_local_got_offsets (input_bfd); + + sgot = NULL; + sreloc = NULL; + + rel = relocs; + relend = relocs + input_section->reloc_count; + for (; rel < relend; rel++, i++) + { + int r_type; + reloc_howto_type *howto; + unsigned long r_symndx; + struct elf_link_hash_entry *h; + Elf_Internal_Sym *sym; + asection *sec; + bfd_vma relocation = 0; + bfd_boolean unresolved_reloc; + bfd_reloc_status_type r; + bfd_vma address; + + r_type = ELF32_R_TYPE (rel->r_info); + if (r_type < 0 || r_type >= 243) + { + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + + if (r_type == R_BFIN_GNU_VTENTRY + || r_type == R_BFIN_GNU_VTINHERIT) + continue; + + howto = bfin_reloc_type_lookup (input_bfd, r_type); + if (howto == NULL) + { + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + r_symndx = ELF32_R_SYM (rel->r_info); + + h = NULL; + sym = NULL; + sec = NULL; + unresolved_reloc = FALSE; + + if (r_symndx < symtab_hdr->sh_info) + { + sym = local_syms + r_symndx; + sec = local_sections[r_symndx]; + relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); + } + else + { + bfd_boolean warned; + h = NULL; + RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, + r_symndx, symtab_hdr, sym_hashes, + h, sec, relocation, + unresolved_reloc, warned); + } + + address = rel->r_offset; + + /* Then, process normally. */ + switch (r_type) + { + case R_BFIN_GNU_VTINHERIT: + case R_BFIN_GNU_VTENTRY: + return bfd_reloc_ok; + + case R_got: + /* Relocation is to the address of the entry for this symbol + in the global offset table. */ + if (h != NULL + && strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") == 0) + goto do_default; + /* Fall through. */ + /* Relocation is the offset of the entry for this symbol in + the global offset table. */ + + { + bfd_vma off; + + if (sgot == NULL) + { + sgot = bfd_get_section_by_name (dynobj, ".got"); + BFD_ASSERT (sgot != NULL); + } + + if (h != NULL) + { + bfd_boolean dyn; + + off = h->got.offset; + BFD_ASSERT (off != (bfd_vma) - 1); + dyn = elf_hash_table (info)->dynamic_sections_created; + + if (!WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) + || (info->shared + && (info->symbolic + || h->dynindx == -1 + || h->forced_local) + && h->def_regular)) + { + /* This is actually a static link, or it is a + -Bsymbolic link and the symbol is defined + locally, or the symbol was forced to be local + because of a version file.. We must initialize + this entry in the global offset table. Since + the offset must always be a multiple of 4, we + use the least significant bit to record whether + we have initialized it already. + + When doing a dynamic link, we create a .rela.got + relocation entry to initialize the value. This + is done in the finish_dynamic_symbol routine. */ + if ((off & 1) != 0) + off &= ~1; + else + { + bfd_put_32 (output_bfd, relocation, + sgot->contents + off); + h->got.offset |= 1; + } + } + else + unresolved_reloc = FALSE; + } + else + { + BFD_ASSERT (local_got_offsets != NULL); + off = local_got_offsets[r_symndx]; + BFD_ASSERT (off != (bfd_vma) - 1); + + /* The offset must always be a multiple of 4. We use + the least significant bit to record whether we have + already generated the necessary reloc. */ + if ((off & 1) != 0) + off &= ~1; + else + { + bfd_put_32 (output_bfd, relocation, sgot->contents + off); + + if (info->shared) + { + asection *s; + Elf_Internal_Rela outrel; + bfd_byte *loc; + + s = bfd_get_section_by_name (dynobj, ".rela.got"); + BFD_ASSERT (s != NULL); + + outrel.r_offset = (sgot->output_section->vma + + sgot->output_offset + off); + outrel.r_info = + ELF32_R_INFO (0, R_pcrel24); + outrel.r_addend = relocation; + loc = s->contents; + loc += + s->reloc_count++ * sizeof (Elf32_External_Rela); + bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); + } + + local_got_offsets[r_symndx] |= 1; + } + } + + relocation = sgot->output_offset + off; + rel->r_addend = 0; + /* bfin : preg = [preg + 17bitdiv4offset] relocation is div by 4. */ + relocation /= 4; + } + goto do_default; + + case R_pcrel24: + case R_pcrel24_jump_l: + { + bfd_vma x; + + relocation += rel->r_addend; + + /* Perform usual pc-relative correction. */ + relocation -= input_section->output_section->vma + input_section->output_offset; + relocation -= address; + + /* We are getting reloc_entry->address 2 byte off from + the start of instruction. Assuming absolute postion + of the reloc data. But, following code had been written assuming + reloc address is starting at begining of instruction. + To compensate that I have increased the value of + relocation by 1 (effectively 2) and used the addr -2 instead of addr. */ + + relocation += 2; + address -= 2; + + relocation >>= 1; + + x = bfd_get_16 (input_bfd, contents + address); + x = (x & 0xff00) | ((relocation >> 16) & 0xff); + bfd_put_16 (input_bfd, x, contents + address); + + x = bfd_get_16 (input_bfd, contents + address + 2); + x = relocation & 0xFFFF; + bfd_put_16 (input_bfd, x, contents + address + 2); + r = bfd_reloc_ok; + } + break; + + default: + do_default: + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, address, + relocation, rel->r_addend); + + break; + } + + /* Dynamic relocs are not propagated for SEC_DEBUGGING sections + because such sections are not SEC_ALLOC and thus ld.so will + not process them. */ + if (unresolved_reloc && !((input_section->flags & SEC_DEBUGGING) != 0 && h->def_dynamic)) { - (*_bfd_error_handler) - (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"), - input_bfd, - input_section, (long) rel->r_offset, h->root.root.string); + (*_bfd_error_handler) + (_("%B(%A+0x%lx): unresolvable relocation against symbol `%s'"), + input_bfd, + input_section, (long) rel->r_offset, h->root.root.string); + return FALSE; + } + + if (r != bfd_reloc_ok) + { + const char *name; + + if (h != NULL) + name = h->root.root.string; + else + { + name = bfd_elf_string_from_elf_section (input_bfd, + symtab_hdr->sh_link, + sym->st_name); + if (name == NULL) + return FALSE; + if (*name == '\0') + name = bfd_section_name (input_bfd, sec); + } + + if (r == bfd_reloc_overflow) + { + if (!(info->callbacks->reloc_overflow + (info, (h ? &h->root : NULL), name, howto->name, + (bfd_vma) 0, input_bfd, input_section, rel->r_offset))) + return FALSE; + } + else + { + (*_bfd_error_handler) + (_("%B(%A+0x%lx): reloc against `%s': error %d"), + input_bfd, input_section, + (long) rel->r_offset, name, (int) r); + return FALSE; + } + } + } + + return TRUE; +} + +static asection * +bfin_gc_mark_hook (asection * sec, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + Elf_Internal_Rela * rel, + struct elf_link_hash_entry *h, + Elf_Internal_Sym * sym) +{ + if (h != NULL) + { + switch (ELF32_R_TYPE (rel->r_info)) + { + + case R_BFIN_GNU_VTINHERIT: + case R_BFIN_GNU_VTENTRY: + break; + + default: + switch (h->root.type) + { + default: + break; + + case bfd_link_hash_defined: + case bfd_link_hash_defweak: + return h->root.u.def.section; + + case bfd_link_hash_common: + return h->root.u.c.p->section; + } + } + } + else + return bfd_section_from_elf_index (sec->owner, sym->st_shndx); + + return NULL; +} + + +/* Update the got entry reference counts for the section being removed. */ + +static bfd_boolean +bfinfdpic_gc_sweep_hook (bfd *abfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + asection *sec ATTRIBUTE_UNUSED, + const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED) +{ + return TRUE; +} + +/* Update the got entry reference counts for the section being removed. */ + +static bfd_boolean +bfin_gc_sweep_hook (bfd * abfd, + struct bfd_link_info *info, + asection * sec, + const Elf_Internal_Rela * relocs) +{ + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes; + bfd_signed_vma *local_got_refcounts; + const Elf_Internal_Rela *rel, *relend; + bfd *dynobj; + asection *sgot; + asection *srelgot; + + dynobj = elf_hash_table (info)->dynobj; + if (dynobj == NULL) + return TRUE; + + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (abfd); + local_got_refcounts = elf_local_got_refcounts (abfd); + + sgot = bfd_get_section_by_name (dynobj, ".got"); + srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + + relend = relocs + sec->reloc_count; + for (rel = relocs; rel < relend; rel++) + { + unsigned long r_symndx; + struct elf_link_hash_entry *h; + + switch (ELF32_R_TYPE (rel->r_info)) + { + case R_got: + r_symndx = ELF32_R_SYM (rel->r_info); + if (r_symndx >= symtab_hdr->sh_info) + { + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + if (h->got.refcount > 0) + { + --h->got.refcount; + if (h->got.refcount == 0) + { + /* We don't need the .got entry any more. */ + sgot->size -= 4; + srelgot->size -= sizeof (Elf32_External_Rela); + } + } + } + else if (local_got_refcounts != NULL) + { + if (local_got_refcounts[r_symndx] > 0) + { + --local_got_refcounts[r_symndx]; + if (local_got_refcounts[r_symndx] == 0) + { + /* We don't need the .got entry any more. */ + sgot->size -= 4; + if (info->shared) + srelgot->size -= sizeof (Elf32_External_Rela); + } + } + } + break; + default: + break; + } + } + return TRUE; +} + +/* We need dynamic symbols for every section, since segments can + relocate independently. */ +static bfd_boolean +_bfinfdpic_link_omit_section_dynsym (bfd *output_bfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info + ATTRIBUTE_UNUSED, + asection *p ATTRIBUTE_UNUSED) +{ + switch (elf_section_data (p)->this_hdr.sh_type) + { + case SHT_PROGBITS: + case SHT_NOBITS: + /* If sh_type is yet undecided, assume it could be + SHT_PROGBITS/SHT_NOBITS. */ + case SHT_NULL: + return FALSE; + + /* There shouldn't be section relative relocations + against any other section. */ + default: + return TRUE; + } +} + +/* Create a .got section, as well as its additional info field. This + is almost entirely copied from + elflink.c:_bfd_elf_create_got_section(). */ + +static bfd_boolean +_bfin_create_got_section (bfd *abfd, struct bfd_link_info *info) +{ + flagword flags, pltflags; + asection *s; + struct elf_link_hash_entry *h; + struct bfd_link_hash_entry *bh; + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + int ptralign; + int offset; + + /* This function may be called more than once. */ + s = bfd_get_section_by_name (abfd, ".got"); + if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0) + return TRUE; + + /* Machine specific: although pointers are 32-bits wide, we want the + GOT to be aligned to a 64-bit boundary, such that function + descriptors in it can be accessed with 64-bit loads and + stores. */ + ptralign = 3; + + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED); + pltflags = flags; + + s = bfd_make_section_with_flags (abfd, ".got", flags); + if (s == NULL + || !bfd_set_section_alignment (abfd, s, ptralign)) + return FALSE; + + if (bed->want_got_plt) + { + s = bfd_make_section_with_flags (abfd, ".got.plt", flags); + if (s == NULL + || !bfd_set_section_alignment (abfd, s, ptralign)) + return FALSE; + } + + if (bed->want_got_sym) + { + /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got + (or .got.plt) section. We don't do this in the linker script + because we don't want to define the symbol if we are not creating + a global offset table. */ + h = _bfd_elf_define_linkage_sym (abfd, info, s, "_GLOBAL_OFFSET_TABLE_"); + elf_hash_table (info)->hgot = h; + if (h == NULL) + return FALSE; + + /* Machine-specific: we want the symbol for executables as + well. */ + if (! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; + } + + /* The first bit of the global offset table is the header. */ + s->size += bed->got_header_size; + + /* This is the machine-specific part. Create and initialize section + data for the got. */ + if (IS_FDPIC (abfd)) + { + bfinfdpic_got_section (info) = s; + bfinfdpic_relocs_info (info) = htab_try_create (1, + bfinfdpic_relocs_info_hash, + bfinfdpic_relocs_info_eq, + (htab_del) NULL); + if (! bfinfdpic_relocs_info (info)) + return FALSE; + + s = bfd_make_section_with_flags (abfd, ".rel.got", + (flags | SEC_READONLY)); + if (s == NULL + || ! bfd_set_section_alignment (abfd, s, 2)) + return FALSE; + + bfinfdpic_gotrel_section (info) = s; + + /* Machine-specific. */ + s = bfd_make_section_with_flags (abfd, ".rofixup", + (flags | SEC_READONLY)); + if (s == NULL + || ! bfd_set_section_alignment (abfd, s, 2)) + return FALSE; + + bfinfdpic_gotfixup_section (info) = s; + offset = -2048; + flags = BSF_GLOBAL; + } + else + { + offset = 2048; + flags = BSF_GLOBAL | BSF_WEAK; + } + + /* Define _gp in .rofixup, for FDPIC, or .got otherwise. If it + turns out that we're linking with a different linker script, the + linker script will override it. */ + bh = NULL; + if (!(_bfd_generic_link_add_one_symbol + (info, abfd, "_gp", flags, s, offset, (const char *) NULL, FALSE, + bed->collect, &bh))) + return FALSE; + h = (struct elf_link_hash_entry *) bh; + h->def_regular = 1; + h->type = STT_OBJECT; + /* h->other = STV_HIDDEN; */ /* Should we? */ + + /* Machine-specific: we want the symbol for executables as well. */ + if (IS_FDPIC (abfd) && ! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; + + return TRUE; +} + +/* Make sure the got and plt sections exist, and that our pointers in + the link hash table point to them. */ + +static bfd_boolean +elf32_bfinfdpic_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) +{ + /* This is mostly copied from + elflink.c:_bfd_elf_create_dynamic_sections(). */ + flagword flags, pltflags; + asection *s; + const struct elf_backend_data *bed = get_elf_backend_data (abfd); + + /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and + .rel[a].bss sections. */ + + flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY + | SEC_LINKER_CREATED); + + pltflags = flags; + pltflags |= SEC_CODE; + if (bed->plt_not_loaded) + pltflags &= ~ (SEC_CODE | SEC_LOAD | SEC_HAS_CONTENTS); + if (bed->plt_readonly) + pltflags |= SEC_READONLY; + + s = bfd_make_section (abfd, ".plt"); + if (s == NULL + || ! bfd_set_section_flags (abfd, s, pltflags) + || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment)) + return FALSE; + /* Blackfin-specific: remember it. */ + bfinfdpic_plt_section (info) = s; + + if (bed->want_plt_sym) + { + /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the + .plt section. */ + struct elf_link_hash_entry *h; + struct bfd_link_hash_entry *bh = NULL; + + if (! (_bfd_generic_link_add_one_symbol + (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s, 0, NULL, + FALSE, get_elf_backend_data (abfd)->collect, &bh))) + return FALSE; + h = (struct elf_link_hash_entry *) bh; + h->def_regular = 1; + h->type = STT_OBJECT; + + if (! info->executable + && ! bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; + } + + /* Blackfin-specific: we want rel relocations for the plt. */ + s = bfd_make_section (abfd, ".rel.plt"); + if (s == NULL + || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) + || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) + return FALSE; + /* Blackfin-specific: remember it. */ + bfinfdpic_pltrel_section (info) = s; + + /* Blackfin-specific: we want to create the GOT in the Blackfin way. */ + if (! _bfin_create_got_section (abfd, info)) + return FALSE; + + /* Blackfin-specific: make sure we created everything we wanted. */ + BFD_ASSERT (bfinfdpic_got_section (info) && bfinfdpic_gotrel_section (info) + /* && bfinfdpic_gotfixup_section (info) */ + && bfinfdpic_plt_section (info) + && bfinfdpic_pltrel_section (info)); + + if (bed->want_dynbss) + { + /* The .dynbss section is a place to put symbols which are defined + by dynamic objects, are referenced by regular objects, and are + not functions. We must allocate space for them in the process + image and use a R_*_COPY reloc to tell the dynamic linker to + initialize them at run time. The linker script puts the .dynbss + section into the .bss section of the final image. */ + s = bfd_make_section (abfd, ".dynbss"); + if (s == NULL + || ! bfd_set_section_flags (abfd, s, SEC_ALLOC | SEC_LINKER_CREATED)) + return FALSE; + + /* The .rel[a].bss section holds copy relocs. This section is not + normally needed. We need to create it here, though, so that the + linker will map it to an output section. We can't just create it + only if we need it, because we will not know whether we need it + until we have seen all the input files, and the first time the + main linker code calls BFD after examining all the input files + (size_dynamic_sections) the input sections have already been + mapped to the output sections. If the section turns out not to + be needed, we can discard it later. We will never need this + section when generating a shared object, since they do not use + copy relocs. */ + if (! info->shared) + { + s = bfd_make_section (abfd, + (bed->default_use_rela_p + ? ".rela.bss" : ".rel.bss")); + if (s == NULL + || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) + || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) + return FALSE; + } + } + + return TRUE; +} + +/* The name of the dynamic interpreter. This is put in the .interp + section. */ + +#define ELF_DYNAMIC_INTERPRETER "/lib/ld.so.1" + +#define DEFAULT_STACK_SIZE 0x20000 + +/* This structure is used to collect the number of entries present in + each addressable range of the got. */ +struct _bfinfdpic_dynamic_got_info +{ + /* Several bits of information about the current link. */ + struct bfd_link_info *info; + /* Total size needed for GOT entries within the 18- or 32-bit + ranges. */ + bfd_vma got17m4, gothilo; + /* Total size needed for function descriptor entries within the 18- + or 32-bit ranges. */ + bfd_vma fd17m4, fdhilo; + /* Total size needed function descriptor entries referenced in PLT + entries, that would be profitable to place in offsets close to + the PIC register. */ + bfd_vma fdplt; + /* Total size needed by lazy PLT entries. */ + bfd_vma lzplt; + /* Number of relocations carried over from input object files. */ + unsigned long relocs; + /* Number of fixups introduced by relocations in input object files. */ + unsigned long fixups; +}; + +/* Compute the total GOT size required by each symbol in each range. + Symbols may require up to 4 words in the GOT: an entry pointing to + the symbol, an entry pointing to its function descriptor, and a + private function descriptors taking two words. */ + +static int +_bfinfdpic_count_got_plt_entries (void **entryp, void *dinfo_) +{ + struct bfinfdpic_relocs_info *entry = *entryp; + struct _bfinfdpic_dynamic_got_info *dinfo = dinfo_; + unsigned relocs = 0, fixups = 0; + + /* Allocate space for a GOT entry pointing to the symbol. */ + if (entry->got17m4) + dinfo->got17m4 += 4; + else if (entry->gothilo) + dinfo->gothilo += 4; + else + entry->relocs32--; + entry->relocs32++; + + /* Allocate space for a GOT entry pointing to the function + descriptor. */ + if (entry->fdgot17m4) + dinfo->got17m4 += 4; + else if (entry->fdgothilo) + dinfo->gothilo += 4; + else + entry->relocsfd--; + entry->relocsfd++; + + /* Decide whether we need a PLT entry, a function descriptor in the + GOT, and a lazy PLT entry for this symbol. */ + entry->plt = entry->call + && entry->symndx == -1 && ! BFINFDPIC_SYM_LOCAL (dinfo->info, entry->d.h) + && elf_hash_table (dinfo->info)->dynamic_sections_created; + entry->privfd = entry->plt + || entry->fdgoff17m4 || entry->fdgoffhilo + || ((entry->fd || entry->fdgot17m4 || entry->fdgothilo) + && (entry->symndx != -1 + || BFINFDPIC_FUNCDESC_LOCAL (dinfo->info, entry->d.h))); + entry->lazyplt = entry->privfd + && entry->symndx == -1 && ! BFINFDPIC_SYM_LOCAL (dinfo->info, entry->d.h) + && ! (dinfo->info->flags & DF_BIND_NOW) + && elf_hash_table (dinfo->info)->dynamic_sections_created; + + /* Allocate space for a function descriptor. */ + if (entry->fdgoff17m4) + dinfo->fd17m4 += 8; + else if (entry->privfd && entry->plt) + dinfo->fdplt += 8; + else if (entry->privfd) + dinfo->fdhilo += 8; + else + entry->relocsfdv--; + entry->relocsfdv++; + + if (entry->lazyplt) + dinfo->lzplt += LZPLT_NORMAL_SIZE; + + if (!dinfo->info->executable || dinfo->info->pie) + relocs = entry->relocs32 + entry->relocsfd + entry->relocsfdv; + else + { + if (entry->symndx != -1 || BFINFDPIC_SYM_LOCAL (dinfo->info, entry->d.h)) + { + if (entry->symndx != -1 + || entry->d.h->root.type != bfd_link_hash_undefweak) + fixups += entry->relocs32 + 2 * entry->relocsfdv; + } + else + relocs += entry->relocs32 + entry->relocsfdv; + + if (entry->symndx != -1 + || BFINFDPIC_FUNCDESC_LOCAL (dinfo->info, entry->d.h)) + { + if (entry->symndx != -1 + || entry->d.h->root.type != bfd_link_hash_undefweak) + fixups += entry->relocsfd; + } + else + relocs += entry->relocsfd; + } + + entry->dynrelocs += relocs; + entry->fixups += fixups; + dinfo->relocs += relocs; + dinfo->fixups += fixups; + + return 1; +} + +/* This structure is used to assign offsets to got entries, function + descriptors, plt entries and lazy plt entries. */ + +struct _bfinfdpic_dynamic_got_plt_info +{ + /* Summary information collected with _bfinfdpic_count_got_plt_entries. */ + struct _bfinfdpic_dynamic_got_info g; + + /* For each addressable range, we record a MAX (positive) and MIN + (negative) value. CUR is used to assign got entries, and it's + incremented from an initial positive value to MAX, then from MIN + to FDCUR (unless FDCUR wraps around first). FDCUR is used to + assign function descriptors, and it's decreased from an initial + non-positive value to MIN, then from MAX down to CUR (unless CUR + wraps around first). All of MIN, MAX, CUR and FDCUR always point + to even words. ODD, if non-zero, indicates an odd word to be + used for the next got entry, otherwise CUR is used and + incremented by a pair of words, wrapping around when it reaches + MAX. FDCUR is decremented (and wrapped) before the next function + descriptor is chosen. FDPLT indicates the number of remaining + slots that can be used for function descriptors used only by PLT + entries. */ + struct _bfinfdpic_dynamic_got_alloc_data + { + bfd_signed_vma max, cur, odd, fdcur, min; + bfd_vma fdplt; + } got17m4, gothilo; +}; + +/* Determine the positive and negative ranges to be used by each + offset range in the GOT. FDCUR and CUR, that must be aligned to a + double-word boundary, are the minimum (negative) and maximum + (positive) GOT offsets already used by previous ranges, except for + an ODD entry that may have been left behind. GOT and FD indicate + the size of GOT entries and function descriptors that must be + placed within the range from -WRAP to WRAP. If there's room left, + up to FDPLT bytes should be reserved for additional function + descriptors. */ + +inline static bfd_signed_vma +_bfinfdpic_compute_got_alloc_data (struct _bfinfdpic_dynamic_got_alloc_data *gad, + bfd_signed_vma fdcur, + bfd_signed_vma odd, + bfd_signed_vma cur, + bfd_vma got, + bfd_vma fd, + bfd_vma fdplt, + bfd_vma wrap) +{ + bfd_signed_vma wrapmin = -wrap; + + /* Start at the given initial points. */ + gad->fdcur = fdcur; + gad->cur = cur; + + /* If we had an incoming odd word and we have any got entries that + are going to use it, consume it, otherwise leave gad->odd at + zero. We might force gad->odd to zero and return the incoming + odd such that it is used by the next range, but then GOT entries + might appear to be out of order and we wouldn't be able to + shorten the GOT by one word if it turns out to end with an + unpaired GOT entry. */ + if (odd && got) + { + gad->odd = odd; + got -= 4; + odd = 0; + } + else + gad->odd = 0; + + /* If we're left with an unpaired GOT entry, compute its location + such that we can return it. Otherwise, if got doesn't require an + odd number of words here, either odd was already zero in the + block above, or it was set to zero because got was non-zero, or + got was already zero. In the latter case, we want the value of + odd to carry over to the return statement, so we don't want to + reset odd unless the condition below is true. */ + if (got & 4) + { + odd = cur + got; + got += 4; + } + + /* Compute the tentative boundaries of this range. */ + gad->max = cur + got; + gad->min = fdcur - fd; + gad->fdplt = 0; + + /* If function descriptors took too much space, wrap some of them + around. */ + if (gad->min < wrapmin) + { + gad->max += wrapmin - gad->min; + gad->min = wrapmin; + } + /* If there is space left and we have function descriptors + referenced in PLT entries that could take advantage of shorter + offsets, place them here. */ + else if (fdplt && gad->min > wrapmin) + { + bfd_vma fds; + if ((bfd_vma) (gad->min - wrapmin) < fdplt) + fds = gad->min - wrapmin; + else + fds = fdplt; + + fdplt -= fds; + gad->min -= fds; + gad->fdplt += fds; + } + + /* If GOT entries took too much space, wrap some of them around. + This may well cause gad->min to become lower than wrapmin. This + will cause a relocation overflow later on, so we don't have to + report it here . */ + if ((bfd_vma) gad->max > wrap) + { + gad->min -= gad->max - wrap; + gad->max = wrap; + } + /* If there is more space left, try to place some more function + descriptors for PLT entries. */ + else if (fdplt && (bfd_vma) gad->max < wrap) + { + bfd_vma fds; + if ((bfd_vma) (wrap - gad->max) < fdplt) + fds = wrap - gad->max; + else + fds = fdplt; + + fdplt -= fds; + gad->max += fds; + gad->fdplt += fds; + } + + /* If odd was initially computed as an offset past the wrap point, + wrap it around. */ + if (odd > gad->max) + odd = gad->min + odd - gad->max; + + /* _bfinfdpic_get_got_entry() below will always wrap gad->cur if needed + before returning, so do it here too. This guarantees that, + should cur and fdcur meet at the wrap point, they'll both be + equal to min. */ + if (gad->cur == gad->max) + gad->cur = gad->min; + + return odd; +} + +/* Compute the location of the next GOT entry, given the allocation + data for a range. */ + +inline static bfd_signed_vma +_bfinfdpic_get_got_entry (struct _bfinfdpic_dynamic_got_alloc_data *gad) +{ + bfd_signed_vma ret; + + if (gad->odd) + { + /* If there was an odd word left behind, use it. */ + ret = gad->odd; + gad->odd = 0; + } + else + { + /* Otherwise, use the word pointed to by cur, reserve the next + as an odd word, and skip to the next pair of words, possibly + wrapping around. */ + ret = gad->cur; + gad->odd = gad->cur + 4; + gad->cur += 8; + if (gad->cur == gad->max) + gad->cur = gad->min; + } + + return ret; +} + +/* Compute the location of the next function descriptor entry in the + GOT, given the allocation data for a range. */ + +inline static bfd_signed_vma +_bfinfdpic_get_fd_entry (struct _bfinfdpic_dynamic_got_alloc_data *gad) +{ + /* If we're at the bottom, wrap around, and only then allocate the + next pair of words. */ + if (gad->fdcur == gad->min) + gad->fdcur = gad->max; + return gad->fdcur -= 8; +} + +/* Assign GOT offsets for every GOT entry and function descriptor. + Doing everything in a single pass is tricky. */ + +static int +_bfinfdpic_assign_got_entries (void **entryp, void *info_) +{ + struct bfinfdpic_relocs_info *entry = *entryp; + struct _bfinfdpic_dynamic_got_plt_info *dinfo = info_; + + if (entry->got17m4) + entry->got_entry = _bfinfdpic_get_got_entry (&dinfo->got17m4); + else if (entry->gothilo) + entry->got_entry = _bfinfdpic_get_got_entry (&dinfo->gothilo); + + if (entry->fdgot17m4) + entry->fdgot_entry = _bfinfdpic_get_got_entry (&dinfo->got17m4); + else if (entry->fdgothilo) + entry->fdgot_entry = _bfinfdpic_get_got_entry (&dinfo->gothilo); + + if (entry->fdgoff17m4) + entry->fd_entry = _bfinfdpic_get_fd_entry (&dinfo->got17m4); + else if (entry->plt && dinfo->got17m4.fdplt) + { + dinfo->got17m4.fdplt -= 8; + entry->fd_entry = _bfinfdpic_get_fd_entry (&dinfo->got17m4); + } + else if (entry->plt) + { + dinfo->gothilo.fdplt -= 8; + entry->fd_entry = _bfinfdpic_get_fd_entry (&dinfo->gothilo); + } + else if (entry->privfd) + entry->fd_entry = _bfinfdpic_get_fd_entry (&dinfo->gothilo); + + return 1; +} + +/* Assign GOT offsets to private function descriptors used by PLT + entries (or referenced by 32-bit offsets), as well as PLT entries + and lazy PLT entries. */ + +static int +_bfinfdpic_assign_plt_entries (void **entryp, void *info_) +{ + struct bfinfdpic_relocs_info *entry = *entryp; + struct _bfinfdpic_dynamic_got_plt_info *dinfo = info_; + + /* If this symbol requires a local function descriptor, allocate + one. */ + if (entry->privfd && entry->fd_entry == 0) + { + if (dinfo->got17m4.fdplt) + { + entry->fd_entry = _bfinfdpic_get_fd_entry (&dinfo->got17m4); + dinfo->got17m4.fdplt -= 8; + } + else + { + BFD_ASSERT (dinfo->gothilo.fdplt); + entry->fd_entry = _bfinfdpic_get_fd_entry (&dinfo->gothilo); + dinfo->gothilo.fdplt -= 8; + } + } + + if (entry->plt) + { + int size; + + /* We use the section's raw size to mark the location of the + next PLT entry. */ + entry->plt_entry = bfinfdpic_plt_section (dinfo->g.info)->size; + + /* Figure out the length of this PLT entry based on the + addressing mode we need to reach the function descriptor. */ + BFD_ASSERT (entry->fd_entry); + if (entry->fd_entry >= -(1 << (18 - 1)) + && entry->fd_entry + 4 < (1 << (18 - 1))) + size = 10; + else + size = 16; + + bfinfdpic_plt_section (dinfo->g.info)->size += size; + } + + if (entry->lazyplt) + { + entry->lzplt_entry = dinfo->g.lzplt; + dinfo->g.lzplt += LZPLT_NORMAL_SIZE; + /* If this entry is the one that gets the resolver stub, account + for the additional instruction. */ + if (entry->lzplt_entry % BFINFDPIC_LZPLT_BLOCK_SIZE + == BFINFDPIC_LZPLT_RESOLV_LOC) + dinfo->g.lzplt += LZPLT_RESOLVER_EXTRA; + } + + return 1; +} + +/* Follow indirect and warning hash entries so that each got entry + points to the final symbol definition. P must point to a pointer + to the hash table we're traversing. Since this traversal may + modify the hash table, we set this pointer to NULL to indicate + we've made a potentially-destructive change to the hash table, so + the traversal must be restarted. */ +static int +_bfinfdpic_resolve_final_relocs_info (void **entryp, void *p) +{ + struct bfinfdpic_relocs_info *entry = *entryp; + htab_t *htab = p; + + if (entry->symndx == -1) + { + struct elf_link_hash_entry *h = entry->d.h; + struct bfinfdpic_relocs_info *oentry; + + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *)h->root.u.i.link; + + if (entry->d.h == h) + return 1; + + oentry = bfinfdpic_relocs_info_for_global (*htab, 0, h, entry->addend, + NO_INSERT); + + if (oentry) + { + /* Merge the two entries. */ + bfinfdpic_pic_merge_early_relocs_info (oentry, entry); + htab_clear_slot (*htab, entryp); + return 1; + } + + entry->d.h = h; + + /* If we can't find this entry with the new bfd hash, re-insert + it, and get the traversal restarted. */ + if (! htab_find (*htab, entry)) + { + htab_clear_slot (*htab, entryp); + entryp = htab_find_slot (*htab, entry, INSERT); + if (! *entryp) + *entryp = entry; + /* Abort the traversal, since the whole table may have + moved, and leave it up to the parent to restart the + process. */ + *(htab_t *)p = NULL; + return 0; + } + } + + return 1; +} + +/* Set the sizes of the dynamic sections. */ + +static bfd_boolean +elf32_bfinfdpic_size_dynamic_sections (bfd *output_bfd, + struct bfd_link_info *info) +{ + bfd *dynobj; + asection *s; + struct _bfinfdpic_dynamic_got_plt_info gpinfo; + bfd_signed_vma odd; + bfd_vma limit; + + dynobj = elf_hash_table (info)->dynobj; + BFD_ASSERT (dynobj != NULL); + + if (elf_hash_table (info)->dynamic_sections_created) + { + /* Set the contents of the .interp section to the interpreter. */ + if (info->executable) + { + s = bfd_get_section_by_name (dynobj, ".interp"); + BFD_ASSERT (s != NULL); + s->size = sizeof ELF_DYNAMIC_INTERPRETER; + s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER; + } + } + + memset (&gpinfo, 0, sizeof (gpinfo)); + gpinfo.g.info = info; + + for (;;) + { + htab_t relocs = bfinfdpic_relocs_info (info); + + htab_traverse (relocs, _bfinfdpic_resolve_final_relocs_info, &relocs); + + if (relocs == bfinfdpic_relocs_info (info)) + break; + } + + htab_traverse (bfinfdpic_relocs_info (info), _bfinfdpic_count_got_plt_entries, + &gpinfo.g); + + odd = 12; + /* Compute the total size taken by entries in the 18-bit range, + to tell how many PLT function descriptors we can bring into it + without causing it to overflow. */ + limit = odd + gpinfo.g.got17m4 + gpinfo.g.fd17m4; + if (limit < (bfd_vma)1 << 18) + limit = ((bfd_vma)1 << 18) - limit; + else + limit = 0; + if (gpinfo.g.fdplt < limit) + limit = gpinfo.g.fdplt; + + /* Determine the ranges of GOT offsets that we can use for each + range of addressing modes. */ + odd = _bfinfdpic_compute_got_alloc_data (&gpinfo.got17m4, + 0, + odd, + 16, + gpinfo.g.got17m4, + gpinfo.g.fd17m4, + limit, + (bfd_vma)1 << (18-1)); + odd = _bfinfdpic_compute_got_alloc_data (&gpinfo.gothilo, + gpinfo.got17m4.min, + odd, + gpinfo.got17m4.max, + gpinfo.g.gothilo, + gpinfo.g.fdhilo, + gpinfo.g.fdplt - gpinfo.got17m4.fdplt, + (bfd_vma)1 << (32-1)); + + /* Now assign (most) GOT offsets. */ + htab_traverse (bfinfdpic_relocs_info (info), _bfinfdpic_assign_got_entries, + &gpinfo); + + bfinfdpic_got_section (info)->size = gpinfo.gothilo.max + - gpinfo.gothilo.min + /* If an odd word is the last word of the GOT, we don't need this + word to be part of the GOT. */ + - (odd + 4 == gpinfo.gothilo.max ? 4 : 0); + if (bfinfdpic_got_section (info)->size == 0) + bfinfdpic_got_section (info)->flags |= SEC_EXCLUDE; + else if (bfinfdpic_got_section (info)->size == 12 + && ! elf_hash_table (info)->dynamic_sections_created) + { + bfinfdpic_got_section (info)->flags |= SEC_EXCLUDE; + bfinfdpic_got_section (info)->size = 0; + } + else + { + bfinfdpic_got_section (info)->contents = + (bfd_byte *) bfd_zalloc (dynobj, + bfinfdpic_got_section (info)->size); + if (bfinfdpic_got_section (info)->contents == NULL) + return FALSE; + } + + if (elf_hash_table (info)->dynamic_sections_created) + /* Subtract the number of lzplt entries, since those will generate + relocations in the pltrel section. */ + bfinfdpic_gotrel_section (info)->size = + (gpinfo.g.relocs - gpinfo.g.lzplt / LZPLT_NORMAL_SIZE) + * get_elf_backend_data (output_bfd)->s->sizeof_rel; + else + BFD_ASSERT (gpinfo.g.relocs == 0); + if (bfinfdpic_gotrel_section (info)->size == 0) + bfinfdpic_gotrel_section (info)->flags |= SEC_EXCLUDE; + else + { + bfinfdpic_gotrel_section (info)->contents = + (bfd_byte *) bfd_zalloc (dynobj, + bfinfdpic_gotrel_section (info)->size); + if (bfinfdpic_gotrel_section (info)->contents == NULL) + return FALSE; + } + + bfinfdpic_gotfixup_section (info)->size = (gpinfo.g.fixups + 1) * 4; + if (bfinfdpic_gotfixup_section (info)->size == 0) + bfinfdpic_gotfixup_section (info)->flags |= SEC_EXCLUDE; + else + { + bfinfdpic_gotfixup_section (info)->contents = + (bfd_byte *) bfd_zalloc (dynobj, + bfinfdpic_gotfixup_section (info)->size); + if (bfinfdpic_gotfixup_section (info)->contents == NULL) + return FALSE; + } + + if (elf_hash_table (info)->dynamic_sections_created) + { + bfinfdpic_pltrel_section (info)->size = + gpinfo.g.lzplt / LZPLT_NORMAL_SIZE * get_elf_backend_data (output_bfd)->s->sizeof_rel; + if (bfinfdpic_pltrel_section (info)->size == 0) + bfinfdpic_pltrel_section (info)->flags |= SEC_EXCLUDE; + else + { + bfinfdpic_pltrel_section (info)->contents = + (bfd_byte *) bfd_zalloc (dynobj, + bfinfdpic_pltrel_section (info)->size); + if (bfinfdpic_pltrel_section (info)->contents == NULL) + return FALSE; + } + } + + /* Add 4 bytes for every block of at most 65535 lazy PLT entries, + such that there's room for the additional instruction needed to + call the resolver. Since _bfinfdpic_assign_got_entries didn't + account for them, our block size is 4 bytes smaller than the real + block size. */ + if (elf_hash_table (info)->dynamic_sections_created) + { + bfinfdpic_plt_section (info)->size = gpinfo.g.lzplt + + ((gpinfo.g.lzplt + (BFINFDPIC_LZPLT_BLOCK_SIZE - 4) - LZPLT_NORMAL_SIZE) + / (BFINFDPIC_LZPLT_BLOCK_SIZE - 4) * LZPLT_RESOLVER_EXTRA); + } + + /* Reset it, such that _bfinfdpic_assign_plt_entries() can use it to + actually assign lazy PLT entries addresses. */ + gpinfo.g.lzplt = 0; + + /* Save information that we're going to need to generate GOT and PLT + entries. */ + bfinfdpic_got_initial_offset (info) = -gpinfo.gothilo.min; + + if (get_elf_backend_data (output_bfd)->want_got_sym) + elf_hash_table (info)->hgot->root.u.def.value + += bfinfdpic_got_initial_offset (info); + + if (elf_hash_table (info)->dynamic_sections_created) + bfinfdpic_plt_initial_offset (info) = + bfinfdpic_plt_section (info)->size; + + htab_traverse (bfinfdpic_relocs_info (info), _bfinfdpic_assign_plt_entries, + &gpinfo); + + /* Allocate the PLT section contents only after + _bfinfdpic_assign_plt_entries has a chance to add the size of the + non-lazy PLT entries. */ + if (elf_hash_table (info)->dynamic_sections_created) + { + if (bfinfdpic_plt_section (info)->size == 0) + bfinfdpic_plt_section (info)->flags |= SEC_EXCLUDE; + else + { + bfinfdpic_plt_section (info)->contents = + (bfd_byte *) bfd_zalloc (dynobj, + bfinfdpic_plt_section (info)->size); + if (bfinfdpic_plt_section (info)->contents == NULL) + return FALSE; + } + } + + if (elf_hash_table (info)->dynamic_sections_created) + { + if (bfinfdpic_got_section (info)->size) + if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0)) + return FALSE; + + if (bfinfdpic_pltrel_section (info)->size) + if (!_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_REL) + || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) + return FALSE; + + if (bfinfdpic_gotrel_section (info)->size) + if (!_bfd_elf_add_dynamic_entry (info, DT_REL, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELSZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELENT, + sizeof (Elf32_External_Rel))) return FALSE; + } + + return TRUE; +} + +static bfd_boolean +elf32_bfinfdpic_always_size_sections (bfd *output_bfd, + struct bfd_link_info *info) +{ + if (!info->relocatable) + { + struct elf_link_hash_entry *h; + asection *sec; + + /* Force a PT_GNU_STACK segment to be created. */ + if (! elf_tdata (output_bfd)->stack_flags) + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; + + /* Define __stacksize if it's not defined yet. */ + h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize", + FALSE, FALSE, FALSE); + if (! h || h->root.type != bfd_link_hash_defined + || h->type != STT_OBJECT + || !h->def_regular) + { + struct bfd_link_hash_entry *bh = NULL; + + if (!(_bfd_generic_link_add_one_symbol + (info, output_bfd, "__stacksize", + BSF_GLOBAL, bfd_abs_section_ptr, DEFAULT_STACK_SIZE, + (const char *) NULL, FALSE, + get_elf_backend_data (output_bfd)->collect, &bh))) + return FALSE; + + h = (struct elf_link_hash_entry *) bh; + h->def_regular = 1; + h->type = STT_OBJECT; } - if (r != bfd_reloc_ok) + /* Create a stack section, and set its alignment. */ + sec = bfd_make_section (output_bfd, ".stack"); + + if (sec == NULL + || ! bfd_set_section_alignment (output_bfd, sec, 3)) + return FALSE; + } + + return TRUE; +} + +static bfd_boolean +elf32_bfinfdpic_modify_segment_map (bfd *output_bfd, + struct bfd_link_info *info) +{ + struct elf_segment_map *m; + + /* objcopy and strip preserve what's already there using + elf32_bfinfdpic_copy_private_bfd_data (). */ + if (! info) + return TRUE; + + for (m = elf_tdata (output_bfd)->segment_map; m != NULL; m = m->next) + if (m->p_type == PT_GNU_STACK) + break; + + if (m) + { + asection *sec = bfd_get_section_by_name (output_bfd, ".stack"); + struct elf_link_hash_entry *h; + + if (sec) { - const char *name; + /* Obtain the pointer to the __stacksize symbol. */ + h = elf_link_hash_lookup (elf_hash_table (info), "__stacksize", + FALSE, FALSE, FALSE); + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *)h->root.u.i.link; + BFD_ASSERT (h->root.type == bfd_link_hash_defined); - if (h != NULL) - name = h->root.root.string; + /* Set the section size from the symbol value. We + intentionally ignore the symbol section. */ + if (h->root.type == bfd_link_hash_defined) + sec->size = h->root.u.def.value; else - { - name = bfd_elf_string_from_elf_section (input_bfd, - symtab_hdr->sh_link, - sym->st_name); - if (name == NULL) - return FALSE; - if (*name == '\0') - name = bfd_section_name (input_bfd, sec); - } + sec->size = DEFAULT_STACK_SIZE; - if (r == bfd_reloc_overflow) - { - if (!(info->callbacks->reloc_overflow - (info, (h ? &h->root : NULL), name, howto->name, - (bfd_vma) 0, input_bfd, input_section, rel->r_offset))) - return FALSE; - } - else + /* Add the stack section to the PT_GNU_STACK segment, + such that its size and alignment requirements make it + to the segment. */ + m->sections[m->count] = sec; + m->count++; + } + } + + return TRUE; +} + +static bfd_boolean +elf32_bfinfdpic_finish_dynamic_sections (bfd *output_bfd, + struct bfd_link_info *info) +{ + bfd *dynobj; + asection *sdyn; + + dynobj = elf_hash_table (info)->dynobj; + + if (bfinfdpic_got_section (info)) + { + BFD_ASSERT (bfinfdpic_gotrel_section (info)->size + == (bfinfdpic_gotrel_section (info)->reloc_count + * sizeof (Elf32_External_Rel))); + + if (bfinfdpic_gotfixup_section (info)) + { + struct elf_link_hash_entry *hgot = elf_hash_table (info)->hgot; + bfd_vma got_value = hgot->root.u.def.value + + hgot->root.u.def.section->output_section->vma + + hgot->root.u.def.section->output_offset; + + _bfinfdpic_add_rofixup (output_bfd, bfinfdpic_gotfixup_section (info), + got_value, 0); + + if (bfinfdpic_gotfixup_section (info)->size + != (bfinfdpic_gotfixup_section (info)->reloc_count * 4)) { (*_bfd_error_handler) - (_("%B(%A+0x%lx): reloc against `%s': error %d"), - input_bfd, input_section, - (long) rel->r_offset, name, (int) r); + ("LINKER BUG: .rofixup section size mismatch"); return FALSE; } } } + if (elf_hash_table (info)->dynamic_sections_created) + { + BFD_ASSERT (bfinfdpic_pltrel_section (info)->size + == (bfinfdpic_pltrel_section (info)->reloc_count + * sizeof (Elf32_External_Rel))); + } + + sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + + if (elf_hash_table (info)->dynamic_sections_created) + { + Elf32_External_Dyn * dyncon; + Elf32_External_Dyn * dynconend; + + BFD_ASSERT (sdyn != NULL); + + dyncon = (Elf32_External_Dyn *) sdyn->contents; + dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); + + for (; dyncon < dynconend; dyncon++) + { + Elf_Internal_Dyn dyn; + + bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); + + switch (dyn.d_tag) + { + default: + break; + + case DT_PLTGOT: + dyn.d_un.d_ptr = bfinfdpic_got_section (info)->output_section->vma + + bfinfdpic_got_section (info)->output_offset + + bfinfdpic_got_initial_offset (info); + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + + case DT_JMPREL: + dyn.d_un.d_ptr = bfinfdpic_pltrel_section (info) + ->output_section->vma + + bfinfdpic_pltrel_section (info)->output_offset; + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + + case DT_PLTRELSZ: + dyn.d_un.d_val = bfinfdpic_pltrel_section (info)->size; + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); + break; + } + } + } + + return TRUE; +} + +/* Adjust a symbol defined by a dynamic object and referenced by a + regular object. */ + +static bfd_boolean +elf32_bfinfdpic_adjust_dynamic_symbol +(struct bfd_link_info *info ATTRIBUTE_UNUSED, + struct elf_link_hash_entry *h ATTRIBUTE_UNUSED) +{ + bfd * dynobj; + + dynobj = elf_hash_table (info)->dynobj; + + /* Make sure we know what is going on here. */ + BFD_ASSERT (dynobj != NULL + && (h->u.weakdef != NULL + || (h->def_dynamic + && h->ref_regular + && !h->def_regular))); + + /* If this is a weak symbol, and there is a real definition, the + processor independent code will have arranged for us to see the + real definition first, and we can just use the same value. */ + if (h->u.weakdef != NULL) + { + BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined + || h->u.weakdef->root.type == bfd_link_hash_defweak); + h->root.u.def.section = h->u.weakdef->root.u.def.section; + h->root.u.def.value = h->u.weakdef->root.u.def.value; + } return TRUE; } -static asection * -bfin_gc_mark_hook (asection * sec, - struct bfd_link_info *info ATTRIBUTE_UNUSED, - Elf_Internal_Rela * rel, - struct elf_link_hash_entry *h, - Elf_Internal_Sym * sym) +/* Perform any actions needed for dynamic symbols. */ + +static bfd_boolean +elf32_bfinfdpic_finish_dynamic_symbol +(bfd *output_bfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + struct elf_link_hash_entry *h ATTRIBUTE_UNUSED, + Elf_Internal_Sym *sym ATTRIBUTE_UNUSED) { - if (h != NULL) - { - switch (ELF32_R_TYPE (rel->r_info)) - { + return TRUE; +} - case R_BFIN_GNU_VTINHERIT: - case R_BFIN_GNU_VTENTRY: - break; +/* Decide whether to attempt to turn absptr or lsda encodings in + shared libraries into pcrel within the given input section. */ - default: - switch (h->root.type) - { - default: - break; +static bfd_boolean +bfinfdpic_elf_use_relative_eh_frame +(bfd *input_bfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + asection *eh_frame_section ATTRIBUTE_UNUSED) +{ + /* We can't use PC-relative encodings in FDPIC binaries, in general. */ + return FALSE; +} - case bfd_link_hash_defined: - case bfd_link_hash_defweak: - return h->root.u.def.section; +/* Adjust the contents of an eh_frame_hdr section before they're output. */ - case bfd_link_hash_common: - return h->root.u.c.p->section; - } - } - } - else - return bfd_section_from_elf_index (sec->owner, sym->st_shndx); +static bfd_byte +bfinfdpic_elf_encode_eh_address (bfd *abfd, + struct bfd_link_info *info, + asection *osec, bfd_vma offset, + asection *loc_sec, bfd_vma loc_offset, + bfd_vma *encoded) +{ + struct elf_link_hash_entry *h; - return NULL; + h = elf_hash_table (info)->hgot; + BFD_ASSERT (h && h->root.type == bfd_link_hash_defined); + + if (! h || (_bfinfdpic_osec_to_segment (abfd, osec) + == _bfinfdpic_osec_to_segment (abfd, loc_sec->output_section))) + return _bfd_elf_encode_eh_address (abfd, info, osec, offset, + loc_sec, loc_offset, encoded); + + BFD_ASSERT (_bfinfdpic_osec_to_segment (abfd, osec) + == (_bfinfdpic_osec_to_segment + (abfd, h->root.u.def.section->output_section))); + + *encoded = osec->vma + offset + - (h->root.u.def.value + + h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset); + + return DW_EH_PE_datarel | DW_EH_PE_sdata4; } -/* Update the got entry reference counts for the section being removed. */ + +/* Look through the relocs for a section during the first phase. + + Besides handling virtual table relocs for gc, we have to deal with + all sorts of PIC-related relocations. We describe below the + general plan on how to handle such relocations, even though we only + collect information at this point, storing them in hash tables for + perusal of later passes. + + 32 relocations are propagated to the linker output when creating + position-independent output. LO16 and HI16 relocations are not + supposed to be encountered in this case. + + LABEL16 should always be resolvable by the linker, since it's only + used by branches. + + LABEL24, on the other hand, is used by calls. If it turns out that + the target of a call is a dynamic symbol, a PLT entry must be + created for it, which triggers the creation of a private function + descriptor and, unless lazy binding is disabled, a lazy PLT entry. + + GPREL relocations require the referenced symbol to be in the same + segment as _gp, but this can only be checked later. + + All GOT, GOTOFF and FUNCDESC relocations require a .got section to + exist. LABEL24 might as well, since it may require a PLT entry, + that will require a got. + + Non-FUNCDESC GOT relocations require a GOT entry to be created + regardless of whether the symbol is dynamic. However, since a + global symbol that turns out to not be exported may have the same + address of a non-dynamic symbol, we don't assign GOT entries at + this point, such that we can share them in this case. A relocation + for the GOT entry always has to be created, be it to offset a + private symbol by the section load address, be it to get the symbol + resolved dynamically. + + FUNCDESC GOT relocations require a GOT entry to be created, and + handled as if a FUNCDESC relocation was applied to the GOT entry in + an object file. + + FUNCDESC relocations referencing a symbol that turns out to NOT be + dynamic cause a private function descriptor to be created. The + FUNCDESC relocation then decays to a 32 relocation that points at + the private descriptor. If the symbol is dynamic, the FUNCDESC + relocation is propagated to the linker output, such that the + dynamic linker creates the canonical descriptor, pointing to the + dynamically-resolved definition of the function. + + Non-FUNCDESC GOTOFF relocations must always refer to non-dynamic + symbols that are assigned to the same segment as the GOT, but we + can only check this later, after we know the complete set of + symbols defined and/or exported. + + FUNCDESC GOTOFF relocations require a function descriptor to be + created and, unless lazy binding is disabled or the symbol is not + dynamic, a lazy PLT entry. Since we can't tell at this point + whether a symbol is going to be dynamic, we have to decide later + whether to create a lazy PLT entry or bind the descriptor directly + to the private function. + + FUNCDESC_VALUE relocations are not supposed to be present in object + files, but they may very well be simply propagated to the linker + output, since they have no side effect. + + + A function descriptor always requires a FUNCDESC_VALUE relocation. + Whether it's in .plt.rel or not depends on whether lazy binding is + enabled and on whether the referenced symbol is dynamic. + + The existence of a lazy PLT requires the resolverStub lazy PLT + entry to be present. + + + As for assignment of GOT, PLT and lazy PLT entries, and private + descriptors, we might do them all sequentially, but we can do + better than that. For example, we can place GOT entries and + private function descriptors referenced using 12-bit operands + closer to the PIC register value, such that these relocations don't + overflow. Those that are only referenced with LO16 relocations + could come next, but we may as well place PLT-required function + descriptors in the 12-bit range to make them shorter. Symbols + referenced with LO16/HI16 may come next, but we may place + additional function descriptors in the 16-bit range if we can + reliably tell that we've already placed entries that are ever + referenced with only LO16. PLT entries are therefore generated as + small as possible, while not introducing relocation overflows in + GOT or FUNCDESC_GOTOFF relocations. Lazy PLT entries could be + generated before or after PLT entries, but not intermingled with + them, such that we can have more lazy PLT entries in range for a + branch to the resolverStub. The resolverStub should be emitted at + the most distant location from the first lazy PLT entry such that + it's still in range for a branch, or closer, if there isn't a need + for so many lazy PLT entries. Additional lazy PLT entries may be + emitted after the resolverStub, as long as branches are still in + range. If the branch goes out of range, longer lazy PLT entries + are emitted. + + We could further optimize PLT and lazy PLT entries by giving them + priority in assignment to closer-to-gr17 locations depending on the + number of occurrences of references to them (assuming a function + that's called more often is more important for performance, so its + PLT entry should be faster), or taking hints from the compiler. + Given infinite time and money... :-) */ static bfd_boolean -bfin_gc_sweep_hook (bfd * abfd, - struct bfd_link_info *info, - asection * sec, - const Elf_Internal_Rela * relocs) +bfinfdpic_check_relocs (bfd *abfd, struct bfd_link_info *info, + asection *sec, const Elf_Internal_Rela *relocs) { Elf_Internal_Shdr *symtab_hdr; - struct elf_link_hash_entry **sym_hashes; - bfd_signed_vma *local_got_refcounts; - const Elf_Internal_Rela *rel, *relend; + struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; + const Elf_Internal_Rela *rel; + const Elf_Internal_Rela *rel_end; bfd *dynobj; - asection *sgot; - asection *srelgot; + struct bfinfdpic_relocs_info *picrel; - dynobj = elf_hash_table (info)->dynobj; - if (dynobj == NULL) + if (info->relocatable) return TRUE; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); - local_got_refcounts = elf_local_got_refcounts (abfd); - - sgot = bfd_get_section_by_name (dynobj, ".got"); - srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); + sym_hashes_end = sym_hashes + symtab_hdr->sh_size/sizeof(Elf32_External_Sym); + if (!elf_bad_symtab (abfd)) + sym_hashes_end -= symtab_hdr->sh_info; - relend = relocs + sec->reloc_count; - for (rel = relocs; rel < relend; rel++) + dynobj = elf_hash_table (info)->dynobj; + rel_end = relocs + sec->reloc_count; + for (rel = relocs; rel < rel_end; rel++) { - unsigned long r_symndx; struct elf_link_hash_entry *h; + unsigned long r_symndx; + + r_symndx = ELF32_R_SYM (rel->r_info); + if (r_symndx < symtab_hdr->sh_info) + h = NULL; + else + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; switch (ELF32_R_TYPE (rel->r_info)) { - case R_got: - r_symndx = ELF32_R_SYM (rel->r_info); - if (r_symndx >= symtab_hdr->sh_info) + case R_BFIN_GOT17M4: + case R_BFIN_GOTHI: + case R_BFIN_GOTLO: + case R_BFIN_FUNCDESC_GOT17M4: + case R_BFIN_FUNCDESC_GOTHI: + case R_BFIN_FUNCDESC_GOTLO: + case R_BFIN_GOTOFF17M4: + case R_BFIN_GOTOFFHI: + case R_BFIN_GOTOFFLO: + case R_BFIN_FUNCDESC_GOTOFF17M4: + case R_BFIN_FUNCDESC_GOTOFFHI: + case R_BFIN_FUNCDESC_GOTOFFLO: + case R_BFIN_FUNCDESC: + case R_BFIN_FUNCDESC_VALUE: + if (! IS_FDPIC (abfd)) + goto bad_reloc; + /* Fall through. */ + case R_pcrel24: + case R_pcrel24_jump_l: + case R_byte4_data: + if (IS_FDPIC (abfd) && ! dynobj) { - h = sym_hashes[r_symndx - symtab_hdr->sh_info]; - if (h->got.refcount > 0) - { - --h->got.refcount; - if (h->got.refcount == 0) - { - /* We don't need the .got entry any more. */ - sgot->size -= 4; - srelgot->size -= sizeof (Elf32_External_Rela); - } - } + elf_hash_table (info)->dynobj = dynobj = abfd; + if (! _bfin_create_got_section (abfd, info)) + return FALSE; } - else if (local_got_refcounts != NULL) + if (! IS_FDPIC (abfd)) { - if (local_got_refcounts[r_symndx] > 0) - { - --local_got_refcounts[r_symndx]; - if (local_got_refcounts[r_symndx] == 0) - { - /* We don't need the .got entry any more. */ - sgot->size -= 4; - if (info->shared) - srelgot->size -= sizeof (Elf32_External_Rela); - } - } + picrel = NULL; + break; + } + if (h != NULL) + { + if (h->dynindx == -1) + switch (ELF_ST_VISIBILITY (h->other)) + { + case STV_INTERNAL: + case STV_HIDDEN: + break; + default: + bfd_elf_link_record_dynamic_symbol (info, h); + break; + } + picrel + = bfinfdpic_relocs_info_for_global (bfinfdpic_relocs_info (info), + abfd, h, + rel->r_addend, INSERT); } + else + picrel = bfinfdpic_relocs_info_for_local (bfinfdpic_relocs_info + (info), abfd, r_symndx, + rel->r_addend, INSERT); + if (! picrel) + return FALSE; break; + default: + picrel = NULL; break; } + + switch (ELF32_R_TYPE (rel->r_info)) + { + case R_pcrel24: + case R_pcrel24_jump_l: + if (IS_FDPIC (abfd)) + picrel->call = 1; + break; + + case R_BFIN_FUNCDESC_VALUE: + picrel->relocsfdv++; + if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC) + picrel->relocs32--; + /* Fall through. */ + + case R_byte4_data: + if (! IS_FDPIC (abfd)) + break; + + picrel->sym = 1; + if (bfd_get_section_flags (abfd, sec) & SEC_ALLOC) + picrel->relocs32++; + break; + + case R_BFIN_GOT17M4: + picrel->got17m4 = 1; + break; + + case R_BFIN_GOTHI: + case R_BFIN_GOTLO: + picrel->gothilo = 1; + break; + + case R_BFIN_FUNCDESC_GOT17M4: + picrel->fdgot17m4 = 1; + break; + + case R_BFIN_FUNCDESC_GOTHI: + case R_BFIN_FUNCDESC_GOTLO: + picrel->fdgothilo = 1; + break; + + case R_BFIN_GOTOFF17M4: + case R_BFIN_GOTOFFHI: + case R_BFIN_GOTOFFLO: + picrel->gotoff = 1; + break; + + case R_BFIN_FUNCDESC_GOTOFF17M4: + picrel->fdgoff17m4 = 1; + break; + + case R_BFIN_FUNCDESC_GOTOFFHI: + case R_BFIN_FUNCDESC_GOTOFFLO: + picrel->fdgoffhilo = 1; + break; + + case R_BFIN_FUNCDESC: + picrel->fd = 1; + picrel->relocsfd++; + break; + + /* This relocation describes the C++ object vtable hierarchy. + Reconstruct it for later use during GC. */ + case R_BFIN_GNU_VTINHERIT: + if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) + return FALSE; + break; + + /* This relocation describes which C++ vtable entries are actually + used. Record for later use during GC. */ + case R_BFIN_GNU_VTENTRY: + if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + return FALSE; + break; + + case R_huimm16: + case R_luimm16: + case R_pcrel12_jump_s: + case R_pcrel10: + break; + + default: + bad_reloc: + (*_bfd_error_handler) + (_("%B: unsupported relocation type %i"), + abfd, ELF32_R_TYPE (rel->r_info)); + return FALSE; + } } return TRUE; } +/* Set the right machine number for a Blackfin ELF file. */ + +static bfd_boolean +elf32_bfin_object_p (bfd *abfd) +{ + bfd_default_set_arch_mach (abfd, bfd_arch_bfin, 0); + return (((elf_elfheader (abfd)->e_flags & EF_BFIN_FDPIC) != 0) + == (IS_FDPIC (abfd))); +} -/* Merge backend specific data from an object file to the output - object file when linking. */ static bfd_boolean -elf32_bfin_merge_private_bfd_data (bfd * ibfd, bfd * obfd) +elf32_bfin_set_private_flags (bfd * abfd, flagword flags) { - flagword out_flags; - flagword in_flags; + elf_elfheader (abfd)->e_flags = flags; + elf_flags_init (abfd) = TRUE; + return TRUE; +} + +/* Copy backend specific data from one object module to another. */ +static bfd_boolean +bfin_elf_copy_private_bfd_data (bfd *ibfd, bfd *obfd) +{ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour || bfd_get_flavour (obfd) != bfd_target_elf_flavour) return TRUE; - in_flags = elf_elfheader (ibfd)->e_flags; - out_flags = elf_elfheader (obfd)->e_flags; - - if (!elf_flags_init (obfd)) - { - elf_flags_init (obfd) = TRUE; - elf_elfheader (obfd)->e_flags = in_flags; - } + BFD_ASSERT (!elf_flags_init (obfd) + || elf_elfheader (obfd)->e_flags == elf_elfheader (ibfd)->e_flags); + elf_elfheader (obfd)->e_flags = elf_elfheader (ibfd)->e_flags; + elf_flags_init (obfd) = TRUE; return TRUE; } - static bfd_boolean -elf32_bfin_set_private_flags (bfd * abfd, flagword flags) +elf32_bfinfdpic_copy_private_bfd_data (bfd *ibfd, bfd *obfd) { - elf_elfheader (abfd)->e_flags = flags; - elf_flags_init (abfd) = TRUE; + unsigned i; + + if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour + || bfd_get_flavour (obfd) != bfd_target_elf_flavour) + return TRUE; + + if (! bfin_elf_copy_private_bfd_data (ibfd, obfd)) + return FALSE; + + if (! elf_tdata (ibfd) || ! elf_tdata (ibfd)->phdr + || ! elf_tdata (obfd) || ! elf_tdata (obfd)->phdr) + return TRUE; + + /* Copy the stack size. */ + for (i = 0; i < elf_elfheader (ibfd)->e_phnum; i++) + if (elf_tdata (ibfd)->phdr[i].p_type == PT_GNU_STACK) + { + Elf_Internal_Phdr *iphdr = &elf_tdata (ibfd)->phdr[i]; + + for (i = 0; i < elf_elfheader (obfd)->e_phnum; i++) + if (elf_tdata (obfd)->phdr[i].p_type == PT_GNU_STACK) + { + memcpy (&elf_tdata (obfd)->phdr[i], iphdr, sizeof (*iphdr)); + + /* Rewrite the phdrs, since we're only called after they + were first written. */ + if (bfd_seek (obfd, (bfd_signed_vma) get_elf_backend_data (obfd) + ->s->sizeof_ehdr, SEEK_SET) != 0 + || get_elf_backend_data (obfd)->s + ->write_out_phdrs (obfd, elf_tdata (obfd)->phdr, + elf_elfheader (obfd)->e_phnum) != 0) + return FALSE; + break; + } + + break; + } + return TRUE; } @@ -2151,23 +4813,103 @@ static bfd_boolean elf32_bfin_print_private_bfd_data (bfd * abfd, PTR ptr) { FILE *file = (FILE *) ptr; + flagword flags; BFD_ASSERT (abfd != NULL && ptr != NULL); /* Print normal ELF private data. */ _bfd_elf_print_private_bfd_data (abfd, ptr); - /* Ignore init flag - it may not be set, despite the flags field - containing valid data. */ + flags = elf_elfheader (abfd)->e_flags; /* xgettext:c-format */ fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags); + if (flags & EF_BFIN_PIC) + fprintf (file, " -fpic"); + + if (flags & EF_BFIN_FDPIC) + fprintf (file, " -mfdpic"); + fputc ('\n', file); return TRUE; } +/* Merge backend specific data from an object file to the output + object file when linking. */ + +static bfd_boolean +elf32_bfin_merge_private_bfd_data (bfd *ibfd, bfd *obfd) +{ + flagword old_flags, old_partial; + flagword new_flags, new_partial; + bfd_boolean error = FALSE; + + new_flags = elf_elfheader (ibfd)->e_flags; + old_flags = elf_elfheader (obfd)->e_flags; + + if (new_flags & EF_BFIN_FDPIC) + new_flags &= ~EF_BFIN_PIC; + +#ifdef DEBUG + (*_bfd_error_handler) ("old_flags = 0x%.8lx, new_flags = 0x%.8lx, init = %s, filename = %s", + old_flags, new_flags, elf_flags_init (obfd) ? "yes" : "no", + bfd_get_filename (ibfd)); +#endif + + if (!elf_flags_init (obfd)) /* First call, no flags set. */ + { + elf_flags_init (obfd) = TRUE; + old_flags = new_flags; + } + + else if (new_flags == old_flags) /* Compatible flags are ok. */ + ; + + else /* Possibly incompatible flags. */ + { + /* We don't have to do anything if the pic flags are the same, or the new + module(s) were compiled with -mlibrary-pic. */ + new_partial = (new_flags & EF_BFIN_PIC_FLAGS); + old_partial = (old_flags & EF_BFIN_PIC_FLAGS); + if (new_partial == old_partial) + ; + + /* If we have mixtures of -fpic and -fPIC, or in both bits. */ + else if (new_partial != 0 && old_partial != 0) + old_flags |= new_partial; + + /* One module was compiled for pic and the other was not, see if we have + had any relocations that are not pic-safe. */ + else + old_flags |= new_partial; + + } + + /* Update the old flags now with changes made above. */ + elf_elfheader (obfd)->e_flags = old_flags; + + if (((new_flags & EF_BFIN_FDPIC) == 0) + != (! IS_FDPIC (ibfd))) + { + error = TRUE; + if (IS_FDPIC (obfd)) + (*_bfd_error_handler) + (_("%s: cannot link non-fdpic object file into fdpic executable"), + bfd_get_filename (ibfd)); + else + (*_bfd_error_handler) + (_("%s: cannot link fdpic object file into non-fdpic executable"), + bfd_get_filename (ibfd)); + } + + if (error) + bfd_set_error (bfd_error_bad_value); + + return !error; +} + /* bfin ELF linker hash entry. */ struct bfin_link_hash_entry @@ -2192,7 +4934,7 @@ struct bfin_link_hash_table static struct bfd_hash_entry * bfin_link_hash_newfunc (struct bfd_hash_entry *entry, - struct bfd_hash_table *table, const char *string) + struct bfd_hash_table *table, const char *string) { struct bfd_hash_entry *ret = entry; @@ -2219,12 +4961,13 @@ bfin_link_hash_table_create (bfd * abfd) struct bfin_link_hash_table *ret; bfd_size_type amt = sizeof (struct bfin_link_hash_table); - ret = (struct bfin_link_hash_table *) bfd_malloc (amt); - if (ret == (struct bfin_link_hash_table *) NULL) + ret = bfd_zalloc (abfd, amt); + if (ret == NULL) return NULL; if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, - bfin_link_hash_newfunc)) + bfin_link_hash_newfunc, + sizeof (struct elf_link_hash_entry))) { free (ret); return NULL; @@ -2511,9 +5254,6 @@ bfin_discard_copies (struct elf_link_hash_entry *h, PTR inf) return TRUE; } -/* Set the sizes of the dynamic sections. */ -#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1" - static bfd_boolean bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, struct bfd_link_info *info) @@ -2659,7 +5399,7 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, return TRUE; } - + /* Given a .data section and a .emreloc in-memory section, store relocation information into the .emreloc section which can be used at runtime to relocate the section. This is called by the @@ -2667,6 +5407,9 @@ bfin_size_dynamic_sections (bfd * output_bfd ATTRIBUTE_UNUSED, after the add_symbols entry point has been called for all the objects, and before the final_link entry point is called. */ +bfd_boolean bfd_bfin_elf32_create_embedded_relocs + PARAMS ((bfd *, struct bfd_link_info *, asection *, asection *, char **)); + bfd_boolean bfd_bfin_elf32_create_embedded_relocs ( bfd *abfd, @@ -2782,17 +5525,18 @@ error_return: free (internal_relocs); return FALSE; } - + #define TARGET_LITTLE_SYM bfd_elf32_bfin_vec #define TARGET_LITTLE_NAME "elf32-bfin" #define ELF_ARCH bfd_arch_bfin -#define ELF_MACHINE_CODE EM_BLACKFIN +#define ELF_MACHINE_CODE EM_BLACKFIN #define ELF_MAXPAGESIZE 0x1000 #define elf_symbol_leading_char '_' #define bfd_elf32_bfd_reloc_type_lookup bfin_bfd_reloc_type_lookup #define elf_info_to_howto bfin_info_to_howto #define elf_info_to_howto_rel 0 +#define elf_backend_object_p elf32_bfin_object_p #define bfd_elf32_bfd_is_local_label_name \ bfin_is_local_label_name @@ -2807,7 +5551,7 @@ error_return: bfin_link_hash_table_create #define bfd_elf32_bfd_final_link bfd_elf_gc_common_final_link -#define elf_backend_check_relocs bfin_check_relocs +#define elf_backend_check_relocs bfin_check_relocs #define elf_backend_adjust_dynamic_symbol \ bfin_adjust_dynamic_symbol #define elf_backend_size_dynamic_sections \ @@ -2834,5 +5578,74 @@ error_return: #define elf_backend_got_header_size 12 #define elf_backend_rela_normal 1 +#include "elf32-target.h" + +#undef TARGET_LITTLE_SYM +#define TARGET_LITTLE_SYM bfd_elf32_bfinfdpic_vec +#undef TARGET_LITTLE_NAME +#define TARGET_LITTLE_NAME "elf32-bfinfdpic" +#undef elf32_bed +#define elf32_bed elf32_bfinfdpic_bed + +#undef elf_backend_gc_sweep_hook +#define elf_backend_gc_sweep_hook bfinfdpic_gc_sweep_hook + +#undef elf_backend_got_header_size +#define elf_backend_got_header_size 0 + +#undef elf_backend_relocate_section +#define elf_backend_relocate_section bfinfdpic_relocate_section +#undef elf_backend_check_relocs +#define elf_backend_check_relocs bfinfdpic_check_relocs + +#undef bfd_elf32_bfd_link_hash_table_create +#define bfd_elf32_bfd_link_hash_table_create \ + bfinfdpic_elf_link_hash_table_create +#undef elf_backend_always_size_sections +#define elf_backend_always_size_sections \ + elf32_bfinfdpic_always_size_sections +#undef elf_backend_modify_segment_map +#define elf_backend_modify_segment_map \ + elf32_bfinfdpic_modify_segment_map +#undef bfd_elf32_bfd_copy_private_bfd_data +#define bfd_elf32_bfd_copy_private_bfd_data \ + elf32_bfinfdpic_copy_private_bfd_data + +#undef elf_backend_create_dynamic_sections +#define elf_backend_create_dynamic_sections \ + elf32_bfinfdpic_create_dynamic_sections +#undef elf_backend_adjust_dynamic_symbol +#define elf_backend_adjust_dynamic_symbol \ + elf32_bfinfdpic_adjust_dynamic_symbol +#undef elf_backend_size_dynamic_sections +#define elf_backend_size_dynamic_sections \ + elf32_bfinfdpic_size_dynamic_sections +#undef elf_backend_finish_dynamic_symbol +#define elf_backend_finish_dynamic_symbol \ + elf32_bfinfdpic_finish_dynamic_symbol +#undef elf_backend_finish_dynamic_sections +#define elf_backend_finish_dynamic_sections \ + elf32_bfinfdpic_finish_dynamic_sections + +#undef elf_backend_can_make_relative_eh_frame +#define elf_backend_can_make_relative_eh_frame \ + bfinfdpic_elf_use_relative_eh_frame +#undef elf_backend_can_make_lsda_relative_eh_frame +#define elf_backend_can_make_lsda_relative_eh_frame \ + bfinfdpic_elf_use_relative_eh_frame +#undef elf_backend_encode_eh_address +#define elf_backend_encode_eh_address \ + bfinfdpic_elf_encode_eh_address + +#undef elf_backend_may_use_rel_p +#define elf_backend_may_use_rel_p 1 +#undef elf_backend_may_use_rela_p +#define elf_backend_may_use_rela_p 1 +/* We use REL for dynamic relocations only. */ +#undef elf_backend_default_use_rela_p +#define elf_backend_default_use_rela_p 1 + +#undef elf_backend_omit_section_dynsym +#define elf_backend_omit_section_dynsym _bfinfdpic_link_omit_section_dynsym #include "elf32-target.h" diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 3edabc7..4019e34 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -1,5 +1,5 @@ /* CRIS-specific support for 32-bit ELF. - Copyright 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Axis Communications AB. Written by Hans-Peter Nilsson, based on elf32-fr30.c @@ -849,8 +849,9 @@ elf_cris_link_hash_table_create (abfd) if (ret == (struct elf_cris_link_hash_table *) NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - elf_cris_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + elf_cris_link_hash_newfunc, + sizeof (struct elf_cris_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index 7126ed4..1758e27 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -1,5 +1,5 @@ /* FRV-specific support for 32-bit ELF. - Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1008,8 +1008,9 @@ frvfdpic_elf_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, - _bfd_elf_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, + _bfd_elf_link_hash_newfunc, + sizeof (struct elf_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index b5d6714..51c210e 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -394,14 +394,16 @@ elf32_hppa_link_hash_table_create (bfd *abfd) if (htab == NULL) return NULL; - if (!_bfd_elf_link_hash_table_init (&htab->etab, abfd, hppa_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&htab->etab, abfd, hppa_link_hash_newfunc, + sizeof (struct elf32_hppa_link_hash_entry))) { free (htab); return NULL; } /* Init the stub hash table too. */ - if (!bfd_hash_table_init (&htab->bstab, stub_hash_newfunc)) + if (!bfd_hash_table_init (&htab->bstab, stub_hash_newfunc, + sizeof (struct elf32_hppa_stub_hash_entry))) return NULL; htab->stub_bfd = NULL; diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index c14fc3b..bc44cba 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -721,7 +721,8 @@ elf_i386_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc, + sizeof (struct elf_i386_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index aecf0fe..6c42c2f 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -1572,8 +1572,9 @@ m32r_elf_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - m32r_elf_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + m32r_elf_link_hash_newfunc, + sizeof (struct elf_m32r_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index bf34694..e7fb944 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -1,5 +1,5 @@ /* Motorola 68HC11/HC12-specific support for 32-bit ELF - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Stephane Carrez (stcarrez@nerim.fr) @@ -70,8 +70,9 @@ m68hc11_elf_hash_table_create (bfd *abfd) return NULL; memset (ret, 0, amt); - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - _bfd_elf_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + _bfd_elf_link_hash_newfunc, + sizeof (struct elf_link_hash_entry))) { free (ret); return NULL; @@ -85,7 +86,8 @@ m68hc11_elf_hash_table_create (bfd *abfd) free (ret); return NULL; } - if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc)) + if (!bfd_hash_table_init (ret->stub_hash_table, stub_hash_newfunc, + sizeof (struct elf32_m68hc11_stub_hash_entry))) return NULL; ret->stub_bfd = NULL; diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 98b0b12..df988a8 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -361,8 +361,9 @@ elf_m68k_link_hash_table_create (abfd) if (ret == (struct elf_m68k_link_hash_table *) NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - elf_m68k_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + elf_m68k_link_hash_newfunc, + sizeof (struct elf_m68k_link_hash_entry))) { free (ret); return NULL; @@ -390,18 +391,22 @@ elf32_m68k_object_p (bfd *abfd) { switch (eflags & EF_M68K_ISA_MASK) { - case EF_M68K_ISA_B: - features |= mcfisa_b; - /* FALLTHROUGH */ - case EF_M68K_ISA_A_PLUS: - features |= mcfisa_aa; - /* FALLTHROUGH */ - case EF_M68K_ISA_A: + case EF_M68K_ISA_A_NODIV: features |= mcfisa_a; break; + case EF_M68K_ISA_A: + features |= mcfisa_a|mcfhwdiv; + break; + case EF_M68K_ISA_A_PLUS: + features |= mcfisa_a|mcfisa_aa|mcfhwdiv|mcfusp; + break; + case EF_M68K_ISA_B_NOUSP: + features |= mcfisa_a|mcfisa_b|mcfhwdiv; + break; + case EF_M68K_ISA_B: + features |= mcfisa_a|mcfisa_b|mcfhwdiv|mcfusp; + break; } - if (eflags & EF_M68K_HW_DIV) - features |= mcfhwdiv; switch (eflags & EF_M68K_MAC_MASK) { case EF_M68K_MAC: @@ -411,8 +416,6 @@ elf32_m68k_object_p (bfd *abfd) features |= mcfemac; break; } - if (eflags & EF_M68K_USP) - features |= mcfusp; if (eflags & EF_M68K_FLOAT) features |= cfloat; } @@ -443,39 +446,24 @@ elf32_m68k_merge_private_bfd_data (ibfd, obfd) { flagword out_flags; flagword in_flags; - unsigned in_mach, out_mach; + flagword out_isa; + flagword in_isa; + const bfd_arch_info_type *arch_info; if ( bfd_get_flavour (ibfd) != bfd_target_elf_flavour || bfd_get_flavour (obfd) != bfd_target_elf_flavour) return FALSE; - in_mach = bfd_get_mach (ibfd); - out_mach = bfd_get_mach (obfd); - if (!out_mach || !in_mach) - /* One is unknown, copy the input machine. */ - out_mach = in_mach; - else if (in_mach != out_mach) - { - if (in_mach <= bfd_mach_m68060 && out_mach <= bfd_mach_m68060) - { - /* Merge m68k machine. */ - if (in_mach > out_mach) - out_mach = in_mach; - } - else if (in_mach >= bfd_mach_mcf_isa_a && out_mach >= bfd_mach_mcf_isa_a) - /* Merge cf machine. */ - out_mach = bfd_m68k_features_to_mach - (bfd_m68k_mach_to_features (in_mach) - | bfd_m68k_mach_to_features (out_mach)); - else - /* They are incompatible. */ - return FALSE; - } - bfd_set_arch_mach (obfd, bfd_arch_m68k, out_mach); - - in_flags = elf_elfheader (ibfd)->e_flags; - out_flags = elf_elfheader (obfd)->e_flags; + /* Get the merged machine. This checks for incompatibility between + Coldfire & non-Coldfire flags, incompability between different + Coldfire ISAs, and incompability between different MAC types. */ + arch_info = bfd_arch_get_compatible (ibfd, obfd, FALSE); + if (!arch_info) + return FALSE; + bfd_set_arch_mach (obfd, bfd_arch_m68k, arch_info->mach); + + in_flags = elf_elfheader (ibfd)->e_flags; if (!elf_flags_init (obfd)) { elf_flags_init (obfd) = TRUE; @@ -483,44 +471,12 @@ elf32_m68k_merge_private_bfd_data (ibfd, obfd) } else { - /* Copy legacy flags. */ - out_flags |= in_flags & (EF_M68K_CPU32 | EF_M68K_M68000 | EF_M68K_CFV4E); - - if (((in_flags | out_flags) & EF_M68K_ISA_MASK) - && ((in_flags | out_flags) & (EF_M68K_CPU32 | EF_M68K_M68000))) - /* Mixing m68k and cf is not allowed */ - return FALSE; - - if (in_flags & EF_M68K_ISA_MASK) - { - if (out_flags & EF_M68K_ISA_MASK) - { - /* Merge cf specific flags */ - if ((in_flags & EF_M68K_ISA_MASK) - > (out_flags & EF_M68K_ISA_MASK)) - { - out_flags ^= out_flags & EF_M68K_ISA_MASK; - out_flags |= in_flags & EF_M68K_ISA_MASK; - } - out_flags |= in_flags - & (EF_M68K_HW_DIV | EF_M68K_USP | EF_M68K_FLOAT); - if (in_flags & EF_M68K_MAC_MASK) - { - if (!(out_flags & EF_M68K_MAC_MASK)) - out_flags |= in_flags & EF_M68K_MAC_MASK; - else if ((out_flags & EF_M68K_MAC_MASK) - != (in_flags & EF_M68K_MAC_MASK)) - /* Cannot mix MACs */ - return FALSE; - } - } - else - { - /* Copy the coldfire bits. */ - out_flags &= ~EF_M68K_CF_MASK; - out_flags |= in_flags & EF_M68K_CF_MASK; - } - } + out_flags = elf_elfheader (obfd)->e_flags; + in_isa = (in_flags & EF_M68K_ISA_MASK); + out_isa = (out_flags & EF_M68K_ISA_MASK); + if (in_isa > out_isa) + out_flags ^= in_isa ^ out_isa; + out_flags |= in_flags ^ in_isa; } elf_elfheader (obfd)->e_flags = out_flags; @@ -559,22 +515,31 @@ elf32_m68k_print_private_bfd_data (abfd, ptr) { char const *isa = _("unknown"); char const *mac = _("unknown"); + char const *additional = ""; switch (eflags & EF_M68K_ISA_MASK) { + case EF_M68K_ISA_A_NODIV: + isa = "A"; + additional = " [nodiv]"; + break; case EF_M68K_ISA_A: isa = "A"; break; case EF_M68K_ISA_A_PLUS: isa = "A+"; break; + case EF_M68K_ISA_B_NOUSP: + isa = "B"; + additional = " [nousp]"; + break; case EF_M68K_ISA_B: isa = "B"; break; } - fprintf (file, " [isa %s]", isa); - if (eflags & EF_M68K_HW_DIV) - fprintf (file, " [hwdiv]"); + fprintf (file, " [isa %s]%s", isa, additional); + if (eflags & EF_M68K_FLOAT) + fprintf (file, " [float]"); switch (eflags & EF_M68K_MAC_MASK) { case 0: @@ -589,10 +554,6 @@ elf32_m68k_print_private_bfd_data (abfd, ptr) } if (mac) fprintf (file, " [%s]", mac); - if (eflags & EF_M68K_USP) - fprintf (file, " [usp"); - if (eflags & EF_M68K_FLOAT) - fprintf (file, " [float]"); } fputc ('\n', file); diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 3cdaeee..6ed4ad3 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. #include "elf-bfd.h" #include "elfxx-mips.h" #include "elf/mips.h" +#include "elf-vxworks.h" /* Get the ECOFF swapping routines. */ #include "coff/sym.h" @@ -1319,10 +1320,12 @@ mips_elf32_rtype_to_howto (unsigned int r_type, static void mips_info_to_howto_rel (bfd *abfd, arelent *cache_ptr, Elf_Internal_Rela *dst) { + const struct elf_backend_data *bed; unsigned int r_type; r_type = ELF32_R_TYPE (dst->r_info); - cache_ptr->howto = mips_elf32_rtype_to_howto (r_type, FALSE); + bed = get_elf_backend_data (abfd); + cache_ptr->howto = bed->elf_backend_mips_rtype_to_howto (r_type, FALSE); /* The addend for a GPREL16 or LITERAL relocation comes from the GP value for the object file. We get the addend now, rather than @@ -1619,3 +1622,147 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = { /* Include the target file again for this target. */ #include "elf32-target.h" + + +/* Specific to VxWorks. */ +static reloc_howto_type mips_vxworks_copy_howto_rela = + HOWTO (R_MIPS_COPY, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_MIPS_COPY", /* name */ + FALSE, /* partial_inplace */ + 0x0, /* src_mask */ + 0x0, /* dst_mask */ + FALSE); /* pcrel_offset */ + +/* Specific to VxWorks. */ +static reloc_howto_type mips_vxworks_jump_slot_howto_rela = + HOWTO (R_MIPS_JUMP_SLOT, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + FALSE, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + bfd_elf_generic_reloc, /* special_function */ + "R_MIPS_JUMP_SLOT", /* name */ + FALSE, /* partial_inplace */ + 0x0, /* src_mask */ + 0x0, /* dst_mask */ + FALSE); /* pcrel_offset */ + +/* Implement elf_backend_bfd_reloc_type_lookup for VxWorks. */ + +static reloc_howto_type * +mips_vxworks_bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code) +{ + switch (code) + { + case BFD_RELOC_MIPS_COPY: + return &mips_vxworks_copy_howto_rela; + case BFD_RELOC_MIPS_JUMP_SLOT: + return &mips_vxworks_jump_slot_howto_rela; + default: + return bfd_elf32_bfd_reloc_type_lookup (abfd, code); + } +} + +/* Implement elf_backend_mips_rtype_to_lookup for VxWorks. */ + +static reloc_howto_type * +mips_vxworks_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p) +{ + switch (r_type) + { + case R_MIPS_COPY: + return &mips_vxworks_copy_howto_rela; + case R_MIPS_JUMP_SLOT: + return &mips_vxworks_jump_slot_howto_rela; + default: + return mips_elf32_rtype_to_howto (r_type, rela_p); + } +} + +/* Implement elf_backend_final_write_processing for VxWorks. */ + +static void +mips_vxworks_final_write_processing (bfd *abfd, bfd_boolean linker) +{ + _bfd_mips_elf_final_write_processing (abfd, linker); + elf_vxworks_final_write_processing (abfd, linker); +} + +#undef TARGET_LITTLE_SYM +#undef TARGET_LITTLE_NAME +#undef TARGET_BIG_SYM +#undef TARGET_BIG_NAME + +#define TARGET_LITTLE_SYM bfd_elf32_littlemips_vxworks_vec +#define TARGET_LITTLE_NAME "elf32-littlemips-vxworks" +#define TARGET_BIG_SYM bfd_elf32_bigmips_vxworks_vec +#define TARGET_BIG_NAME "elf32-bigmips-vxworks" + +#undef elf32_bed +#define elf32_bed elf32_mips_vxworks_bed + +#undef ELF_MAXPAGESIZE +#define ELF_MAXPAGESIZE 0x1000 + +#undef elf_backend_want_got_plt +#define elf_backend_want_got_plt 1 +#undef elf_backend_want_plt_sym +#define elf_backend_want_plt_sym 1 +#undef elf_backend_got_symbol_offset +#define elf_backend_got_symbol_offset 0 +#undef elf_backend_want_dynbss +#define elf_backend_want_dynbss 1 +#undef elf_backend_may_use_rel_p +#define elf_backend_may_use_rel_p 0 +#undef elf_backend_may_use_rela_p +#define elf_backend_may_use_rela_p 1 +#undef elf_backend_default_use_rela_p +#define elf_backend_default_use_rela_p 1 +#undef elf_backend_got_header_size +#define elf_backend_got_header_size (4 * 3) +#undef elf_backend_plt_readonly +#define elf_backend_plt_readonly 1 + +#undef bfd_elf32_bfd_reloc_type_lookup +#define bfd_elf32_bfd_reloc_type_lookup \ + mips_vxworks_bfd_reloc_type_lookup +#undef elf_backend_mips_rtype_to_howto +#define elf_backend_mips_rtype_to_howto \ + mips_vxworks_rtype_to_howto +#undef elf_backend_adjust_dynamic_symbol +#define elf_backend_adjust_dynamic_symbol \ + _bfd_mips_vxworks_adjust_dynamic_symbol +#undef elf_backend_finish_dynamic_symbol +#define elf_backend_finish_dynamic_symbol \ + _bfd_mips_vxworks_finish_dynamic_symbol +#undef bfd_elf32_bfd_link_hash_table_create +#define bfd_elf32_bfd_link_hash_table_create \ + _bfd_mips_vxworks_link_hash_table_create +#undef elf_backend_add_symbol_hook +#define elf_backend_add_symbol_hook \ + elf_vxworks_add_symbol_hook +#undef elf_backend_link_output_symbol_hook +#define elf_backend_link_output_symbol_hook \ + elf_vxworks_link_output_symbol_hook +#undef elf_backend_emit_relocs +#define elf_backend_emit_relocs \ + elf_vxworks_emit_relocs +#undef elf_backend_final_write_processing +#define elf_backend_final_write_processing \ + mips_vxworks_final_write_processing + +#undef elf_backend_additional_program_headers +#undef elf_backend_modify_segment_map +#undef elf_backend_symbol_processing +/* NOTE: elf_backend_rela_normal is not defined for MIPS. */ + +#include "elf32-target.h" diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index b3d8308..6a2d517 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -1,6 +1,6 @@ /* PowerPC-specific support for 32-bit ELF Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + 2004, 2005, 2006 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -2430,8 +2430,9 @@ ppc_elf_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, - ppc_elf_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, + ppc_elf_link_hash_newfunc, + sizeof (struct ppc_elf_link_hash_entry))) { free (ret); return NULL; @@ -3335,7 +3336,9 @@ ppc_elf_check_relocs (bfd *abfd, if (s == got2) htab->plt_type = PLT_OLD; } - /* fall through */ + if (h == NULL || h == htab->elf.hgot) + break; + goto dodyn1; case R_PPC_REL24: case R_PPC_REL14: @@ -3343,9 +3346,10 @@ ppc_elf_check_relocs (bfd *abfd, case R_PPC_REL14_BRNTAKEN: if (h == NULL) break; - if (h == htab->elf.hgot && htab->plt_type == PLT_UNSET) + if (h == htab->elf.hgot) { - htab->plt_type = PLT_OLD; + if (htab->plt_type == PLT_UNSET) + htab->plt_type = PLT_OLD; break; } /* fall through */ @@ -3361,6 +3365,7 @@ ppc_elf_check_relocs (bfd *abfd, case R_PPC_ADDR14_BRNTAKEN: case R_PPC_UADDR32: case R_PPC_UADDR16: + dodyn1: if (h != NULL && !info->shared) { /* We may need a plt entry if the symbol turns out to be @@ -5763,6 +5768,7 @@ ppc_elf_relocate_section (bfd *output_bfd, insn1 |= 32 << 26; /* lwz */ insn2 = 0x7c631214; /* add 3,3,2 */ rel[1].r_info = ELF32_R_INFO (r_symndx2, R_PPC_NONE); + rel[1].r_addend = 0; r_type = (((r_type - (R_PPC_GOT_TLSGD16 & 3)) & 3) + R_PPC_GOT_TPREL16); rel->r_info = ELF32_R_INFO (r_symndx, r_type); @@ -5777,13 +5783,13 @@ ppc_elf_relocate_section (bfd *output_bfd, /* Was an LD reloc. */ r_symndx = 0; rel->r_addend = htab->elf.tls_sec->vma + DTP_OFFSET; - rel[1].r_addend = htab->elf.tls_sec->vma + DTP_OFFSET; } r_type = R_PPC_TPREL16_HA; rel->r_info = ELF32_R_INFO (r_symndx, r_type); rel[1].r_info = ELF32_R_INFO (r_symndx, R_PPC_TPREL16_LO); rel[1].r_offset += 2; + rel[1].r_addend = rel->r_addend; } bfd_put_32 (output_bfd, insn1, contents + rel->r_offset - 2); bfd_put_32 (output_bfd, insn2, contents + offset); diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index 1c52755..eb8e172 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -771,7 +771,8 @@ elf_s390_link_hash_table_create (abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc, + sizeof (struct elf_s390_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index d03f60b..118690d 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -3612,8 +3612,9 @@ sh_elf_link_hash_table_create (bfd *abfd) if (ret == (struct elf_sh_link_hash_table *) NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - sh_elf_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + sh_elf_link_hash_newfunc, + sizeof (struct elf_sh_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index e0d059c..bf481e4 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -1,6 +1,6 @@ /* VAX series support for 32-bit ELF Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004, 2005 Free Software Foundation, Inc. + 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Matt Thomas . This file is part of BFD, the Binary File Descriptor library. @@ -468,8 +468,9 @@ elf_vax_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - elf_vax_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + elf_vax_link_hash_newfunc, + sizeof (struct elf_vax_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index 18610c7..4dce0ea 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -640,7 +640,6 @@ xtensa_read_table_entries (bfd *abfd, { bfd_vma sym_off = get_elf_r_symndx_offset (abfd, r_symndx); BFD_ASSERT (sym_off == 0); - BFD_ASSERT (rel->r_addend == 0); blocks[block_count].address = (section_addr + sym_off + rel->r_addend + bfd_get_32 (abfd, table_data + rel->r_offset)); diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 60deadb..76d0661 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -1,6 +1,6 @@ /* Alpha specific support for 64-bit ELF - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. Contributed by Richard Henderson . This file is part of BFD, the Binary File Descriptor library. @@ -273,8 +273,9 @@ elf64_alpha_bfd_link_hash_table_create (bfd *abfd) if (ret == (struct alpha_elf_link_hash_table *) NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - elf64_alpha_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + elf64_alpha_link_hash_newfunc, + sizeof (struct alpha_elf_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index fbd6458..4e0b83c 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -1,5 +1,5 @@ /* Support for HPPA 64-bit ELF - Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -157,9 +157,6 @@ struct elf64_hppa_link_hash_table typedef struct bfd_hash_entry *(*new_hash_entry_func) PARAMS ((struct bfd_hash_entry *, struct bfd_hash_table *, const char *)); -static bfd_boolean elf64_hppa_dyn_hash_table_init - PARAMS ((struct elf64_hppa_dyn_hash_table *ht, bfd *abfd, - new_hash_entry_func new)); static struct bfd_hash_entry *elf64_hppa_new_dyn_hash_entry PARAMS ((struct bfd_hash_entry *entry, struct bfd_hash_table *table, const char *string)); @@ -276,13 +273,13 @@ static int elf64_hppa_elf_get_symbol_type PARAMS ((Elf_Internal_Sym *, int)); static bfd_boolean -elf64_hppa_dyn_hash_table_init (ht, abfd, new) - struct elf64_hppa_dyn_hash_table *ht; - bfd *abfd ATTRIBUTE_UNUSED; - new_hash_entry_func new; +elf64_hppa_dyn_hash_table_init (struct elf64_hppa_dyn_hash_table *ht, + bfd *abfd ATTRIBUTE_UNUSED, + new_hash_entry_func new, + unsigned int entsize) { memset (ht, 0, sizeof (*ht)); - return bfd_hash_table_init (&ht->root, new); + return bfd_hash_table_init (&ht->root, new, entsize); } static struct bfd_hash_entry* @@ -328,14 +325,16 @@ elf64_hppa_hash_table_create (abfd) if (!ret) return 0; if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, - _bfd_elf_link_hash_newfunc)) + _bfd_elf_link_hash_newfunc, + sizeof (struct elf_link_hash_entry))) { bfd_release (abfd, ret); return 0; } if (!elf64_hppa_dyn_hash_table_init (&ret->dyn_hash_table, abfd, - elf64_hppa_new_dyn_hash_entry)) + elf64_hppa_new_dyn_hash_entry, + sizeof (struct elf64_hppa_dyn_hash_entry))) return 0; return &ret->root.root; } @@ -1130,6 +1129,7 @@ allocate_global_data_opd (dyn_h, data) /* We never need an opd entry for a symbol which is not defined by this output file. */ if (h && (h->root.type == bfd_link_hash_undefined + || h->root.type == bfd_link_hash_undefweak || h->root.u.def.section->output_section == NULL)) dyn_h->want_opd = 0; @@ -2703,7 +2703,7 @@ static const struct bfd_elf_special_section elf64_hppa_special_sections[] = { ".dlt", 4, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, { ".sdata", 6, 0, SHT_PROGBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, { ".sbss", 5, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_SHORT }, - { ".tbss", 5, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_PARISC_WEAKORDER }, + { ".tbss", 5, 0, SHT_NOBITS, SHF_ALLOC + SHF_WRITE + SHF_HP_TLS }, { NULL, 0, 0, 0, 0 } }; @@ -2814,7 +2814,5 @@ const struct elf_size_info hppa64_elf_size_info = #undef TARGET_BIG_NAME #define TARGET_BIG_NAME "elf64-hppa-linux" -#undef elf_backend_special_sections - #define INCLUDED_TARGET_FILE 1 #include "elf64-target.h" diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 1cfac82..fc8c182 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3464,18 +3464,21 @@ ppc64_elf_link_hash_table_create (bfd *abfd) if (htab == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&htab->elf, abfd, link_hash_newfunc, + sizeof (struct ppc_link_hash_entry))) { free (htab); return NULL; } /* Init the stub hash table too. */ - if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc)) + if (!bfd_hash_table_init (&htab->stub_hash_table, stub_hash_newfunc, + sizeof (struct ppc_stub_hash_entry))) return NULL; /* And the branch hash table. */ - if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc)) + if (!bfd_hash_table_init (&htab->branch_hash_table, branch_hash_newfunc, + sizeof (struct ppc_branch_hash_entry))) return NULL; /* Initializing two fields of the union is just cosmetic. We really diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 7beda9d..1fe0c6c 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -724,7 +724,8 @@ elf_s390_link_hash_table_create (abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc, + sizeof (struct elf_s390_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index f76e916..4d6d8d5 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -1,5 +1,5 @@ /* SuperH SH64-specific support for 64-bit ELF - Copyright 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -3138,8 +3138,9 @@ sh64_elf64_link_hash_table_create (bfd *abfd) if (ret == (struct elf_sh64_link_hash_table *) NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - sh64_elf64_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + sh64_elf64_link_hash_newfunc, + sizeof (struct elf_sh64_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 8c1a712..9befd69 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -31,8 +31,8 @@ #define MINUS_ONE (~ (bfd_vma) 0) /* The relocation "howto" table. Order of fields: - type, size, bitsize, pc_relative, complain_on_overflow, - special_function, name, partial_inplace, src_mask, dst_pack, pcrel_offset. */ + type, rightshift, size, bitsize, pc_relative, bitpos, complain_on_overflow, + special_function, name, partial_inplace, src_mask, dst_mask, pcrel_offset. */ static reloc_howto_type x86_64_elf_howto_table[] = { HOWTO(R_X86_64_NONE, 0, 0, 0, FALSE, 0, complain_overflow_dont, @@ -112,11 +112,21 @@ static reloc_howto_type x86_64_elf_howto_table[] = HOWTO(R_X86_64_GOTPC32, 0, 2, 32, TRUE, 0, complain_overflow_signed, bfd_elf_generic_reloc, "R_X86_64_GOTPC32", FALSE, 0xffffffff, 0xffffffff, TRUE), - EMPTY_HOWTO (27), - EMPTY_HOWTO (28), - EMPTY_HOWTO (29), - EMPTY_HOWTO (30), - EMPTY_HOWTO (31), + HOWTO(R_X86_64_GOT64, 0, 4, 64, FALSE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_GOT64", FALSE, MINUS_ONE, MINUS_ONE, + FALSE), + HOWTO(R_X86_64_GOTPCREL64, 0, 4, 64, TRUE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_GOTPCREL64", FALSE, MINUS_ONE, + MINUS_ONE, TRUE), + HOWTO(R_X86_64_GOTPC64, 0, 4, 64, TRUE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_GOTPC64", + FALSE, MINUS_ONE, MINUS_ONE, TRUE), + HOWTO(R_X86_64_GOTPLT64, 0, 4, 64, FALSE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_GOTPLT64", FALSE, MINUS_ONE, + MINUS_ONE, FALSE), + HOWTO(R_X86_64_PLTOFF64, 0, 4, 64, FALSE, 0, complain_overflow_signed, + bfd_elf_generic_reloc, "R_X86_64_PLTOFF64", FALSE, MINUS_ONE, + MINUS_ONE, FALSE), EMPTY_HOWTO (32), EMPTY_HOWTO (33), HOWTO(R_X86_64_GOTPC32_TLSDESC, 0, 2, 32, TRUE, 0, @@ -185,6 +195,11 @@ static const struct elf_reloc_map x86_64_reloc_map[] = { BFD_RELOC_64_PCREL, R_X86_64_PC64, }, { BFD_RELOC_X86_64_GOTOFF64, R_X86_64_GOTOFF64, }, { BFD_RELOC_X86_64_GOTPC32, R_X86_64_GOTPC32, }, + { BFD_RELOC_X86_64_GOT64, R_X86_64_GOT64, }, + { BFD_RELOC_X86_64_GOTPCREL64,R_X86_64_GOTPCREL64, }, + { BFD_RELOC_X86_64_GOTPC64, R_X86_64_GOTPC64, }, + { BFD_RELOC_X86_64_GOTPLT64, R_X86_64_GOTPLT64, }, + { BFD_RELOC_X86_64_PLTOFF64, R_X86_64_PLTOFF64, }, { BFD_RELOC_X86_64_GOTPC32_TLSDESC, R_X86_64_GOTPC32_TLSDESC, }, { BFD_RELOC_X86_64_TLSDESC_CALL, R_X86_64_TLSDESC_CALL, }, { BFD_RELOC_X86_64_TLSDESC, R_X86_64_TLSDESC, }, @@ -510,7 +525,8 @@ elf64_x86_64_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc, + sizeof (struct elf64_x86_64_link_hash_entry))) { free (ret); return NULL; @@ -776,6 +792,9 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, case R_X86_64_GOT32: case R_X86_64_GOTPCREL: case R_X86_64_TLSGD: + case R_X86_64_GOT64: + case R_X86_64_GOTPCREL64: + case R_X86_64_GOTPLT64: case R_X86_64_GOTPC32_TLSDESC: case R_X86_64_TLSDESC_CALL: /* This symbol requires a global offset table entry. */ @@ -794,6 +813,14 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, if (h != NULL) { + if (r_type == R_X86_64_GOTPLT64) + { + /* This relocation indicates that we also need + a PLT entry, as this is a function. We don't need + a PLT entry for local symbols. */ + h->needs_plt = 1; + h->plt.refcount += 1; + } h->got.refcount += 1; old_tls_type = elf64_x86_64_hash_entry (h)->tls_type; } @@ -857,6 +884,7 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, case R_X86_64_GOTOFF64: case R_X86_64_GOTPC32: + case R_X86_64_GOTPC64: create_got: if (htab->sgot == NULL) { @@ -884,6 +912,16 @@ elf64_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec, h->plt.refcount += 1; break; + case R_X86_64_PLTOFF64: + /* This tries to form the 'address' of a function relative + to GOT. For global symbols we need a PLT entry. */ + if (h != NULL) + { + h->needs_plt = 1; + h->plt.refcount += 1; + } + goto create_got; + case R_X86_64_8: case R_X86_64_16: case R_X86_64_32: @@ -1188,8 +1226,13 @@ elf64_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, case R_X86_64_GOTTPOFF: case R_X86_64_GOT32: case R_X86_64_GOTPCREL: + case R_X86_64_GOT64: + case R_X86_64_GOTPCREL64: + case R_X86_64_GOTPLT64: if (h != NULL) { + if (r_type == R_X86_64_GOTPLT64 && h->plt.refcount > 0) + h->plt.refcount -= 1; if (h->got.refcount > 0) h->got.refcount -= 1; } @@ -1214,6 +1257,7 @@ elf64_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, /* Fall thru */ case R_X86_64_PLT32: + case R_X86_64_PLTOFF64: if (h != NULL) { if (h->plt.refcount > 0) @@ -2095,11 +2139,23 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, copied into the output file to be resolved at run time. */ switch (r_type) { + asection *base_got; case R_X86_64_GOT32: + case R_X86_64_GOT64: /* Relocation is to the entry for this symbol in the global offset table. */ case R_X86_64_GOTPCREL: - /* Use global offset table as symbol value. */ + case R_X86_64_GOTPCREL64: + /* Use global offset table entry as symbol value. */ + case R_X86_64_GOTPLT64: + /* This is the same as GOT64 for relocation purposes, but + indicates the existence of a PLT entry. The difficulty is, + that we must calculate the GOT slot offset from the PLT + offset, if this symbol got a PLT entry (it was global). + Additionally if it's computed from the PLT entry, then that + GOT offset is relative to .got.plt, not to .got. */ + base_got = htab->sgot; + if (htab->sgot == NULL) abort (); @@ -2108,6 +2164,19 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, bfd_boolean dyn; off = h->got.offset; + if (h->needs_plt + && h->plt.offset != (bfd_vma)-1 + && off == (bfd_vma)-1) + { + /* We can't use h->got.offset here to save + state, or even just remember the offset, as + finish_dynamic_symbol would use that as offset into + .got. */ + bfd_vma plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; + off = (plt_index + 3) * GOT_ENTRY_SIZE; + base_got = htab->sgotplt; + } + dyn = htab->elf.dynamic_sections_created; if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) @@ -2132,7 +2201,9 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, else { bfd_put_64 (output_bfd, relocation, - htab->sgot->contents + off); + base_got->contents + off); + /* Note that this is harmless for the GOTPLT64 case, + as -1 | 1 still is -1. */ h->got.offset |= 1; } } @@ -2154,7 +2225,7 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, else { bfd_put_64 (output_bfd, relocation, - htab->sgot->contents + off); + base_got->contents + off); if (info->shared) { @@ -2168,8 +2239,8 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if (s == NULL) abort (); - outrel.r_offset = (htab->sgot->output_section->vma - + htab->sgot->output_offset + outrel.r_offset = (base_got->output_section->vma + + base_got->output_offset + off); outrel.r_info = ELF64_R_INFO (0, R_X86_64_RELATIVE); outrel.r_addend = relocation; @@ -2185,9 +2256,9 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, if (off >= (bfd_vma) -2) abort (); - relocation = htab->sgot->output_section->vma - + htab->sgot->output_offset + off; - if (r_type != R_X86_64_GOTPCREL) + relocation = base_got->output_section->vma + + base_got->output_offset + off; + if (r_type != R_X86_64_GOTPCREL && r_type != R_X86_64_GOTPCREL64) relocation -= htab->sgotplt->output_section->vma - htab->sgotplt->output_offset; @@ -2223,12 +2294,31 @@ elf64_x86_64_relocate_section (bfd *output_bfd, struct bfd_link_info *info, break; case R_X86_64_GOTPC32: + case R_X86_64_GOTPC64: /* Use global offset table as symbol value. */ relocation = htab->sgotplt->output_section->vma + htab->sgotplt->output_offset; unresolved_reloc = FALSE; break; + case R_X86_64_PLTOFF64: + /* Relocation is PLT entry relative to GOT. For local + symbols it's the symbol itself relative to GOT. */ + if (h != NULL + /* See PLT32 handling. */ + && h->plt.offset != (bfd_vma) -1 + && htab->splt != NULL) + { + relocation = (htab->splt->output_section->vma + + htab->splt->output_offset + + h->plt.offset); + unresolved_reloc = FALSE; + } + + relocation -= htab->sgotplt->output_section->vma + + htab->sgotplt->output_offset; + break; + case R_X86_64_PLT32: /* Relocation is to the entry for this symbol in the procedure linkage table. */ diff --git a/bfd/elflink.c b/bfd/elflink.c index a95ac44..88e56da 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -26,6 +26,7 @@ #include "elf-bfd.h" #include "safe-ctype.h" #include "libiberty.h" +#include "objalloc.h" /* Define a symbol in a dynamic linkage section. */ @@ -2875,98 +2876,6 @@ elf_add_dt_needed_tag (bfd *abfd, return 0; } -/* Called via elf_link_hash_traverse, elf_smash_syms sets all symbols - belonging to NOT_NEEDED to bfd_link_hash_new. We know there are no - references from regular objects to these symbols. - - ??? Should we do something about references from other dynamic - obects? If not, we potentially lose some warnings about undefined - symbols. But how can we recover the initial undefined / undefweak - state? */ - -struct elf_smash_syms_data -{ - bfd *not_needed; - struct elf_link_hash_table *htab; - bfd_boolean twiddled; -}; - -static bfd_boolean -elf_smash_syms (struct elf_link_hash_entry *h, void *data) -{ - struct elf_smash_syms_data *inf = (struct elf_smash_syms_data *) data; - struct bfd_link_hash_entry *bh; - - switch (h->root.type) - { - default: - case bfd_link_hash_new: - return TRUE; - - case bfd_link_hash_undefined: - if (h->root.u.undef.abfd != inf->not_needed) - return TRUE; - if (h->root.u.undef.weak != NULL - && h->root.u.undef.weak != inf->not_needed) - { - /* Symbol was undefweak in u.undef.weak bfd, and has become - undefined in as-needed lib. Restore weak. */ - h->root.type = bfd_link_hash_undefweak; - h->root.u.undef.abfd = h->root.u.undef.weak; - if (h->root.u.undef.next != NULL - || inf->htab->root.undefs_tail == &h->root) - inf->twiddled = TRUE; - return TRUE; - } - break; - - case bfd_link_hash_undefweak: - if (h->root.u.undef.abfd != inf->not_needed) - return TRUE; - break; - - case bfd_link_hash_defined: - case bfd_link_hash_defweak: - if (h->root.u.def.section->owner != inf->not_needed) - return TRUE; - break; - - case bfd_link_hash_common: - if (h->root.u.c.p->section->owner != inf->not_needed) - return TRUE; - break; - - case bfd_link_hash_warning: - case bfd_link_hash_indirect: - elf_smash_syms ((struct elf_link_hash_entry *) h->root.u.i.link, data); - if (h->root.u.i.link->type != bfd_link_hash_new) - return TRUE; - if (h->root.u.i.link->u.undef.abfd != inf->not_needed) - return TRUE; - break; - } - - /* There is no way we can undo symbol table state from defined or - defweak back to undefined. */ - if (h->ref_regular) - abort (); - - /* Set sym back to newly created state, but keep undef.next if it is - being used as a list pointer. */ - bh = h->root.u.undef.next; - if (bh == &h->root) - bh = NULL; - if (bh != NULL || inf->htab->root.undefs_tail == &h->root) - inf->twiddled = TRUE; - (*inf->htab->root.table.newfunc) (&h->root.root, - &inf->htab->root.table, - h->root.root.string); - h->root.u.undef.next = bh; - h->root.u.undef.abfd = inf->not_needed; - h->non_elf = 0; - return TRUE; -} - /* Sort symbol by value and section. */ static int elf_sort_symbol (const void *arg1, const void *arg2) @@ -3136,14 +3045,6 @@ elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info) static bfd_boolean elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) { - bfd_boolean (*add_symbol_hook) - (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, - const char **, flagword *, asection **, bfd_vma *); - bfd_boolean (*check_relocs) - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - bfd_boolean (*check_directives) - (bfd *, struct bfd_link_info *); - bfd_boolean collect; Elf_Internal_Shdr *hdr; bfd_size_type symcount; bfd_size_type extsymcount; @@ -3160,14 +3061,20 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) Elf_Internal_Sym *isymend; const struct elf_backend_data *bed; bfd_boolean add_needed; - struct elf_link_hash_table * hash_table; + struct elf_link_hash_table *htab; bfd_size_type amt; + void *alloc_mark = NULL; + void *old_tab = NULL; + void *old_hash; + void *old_ent; + struct bfd_link_hash_entry *old_undefs = NULL; + struct bfd_link_hash_entry *old_undefs_tail = NULL; + long old_dynsymcount = 0; + size_t tabsize = 0; + size_t hashsize = 0; - hash_table = elf_hash_table (info); - + htab = elf_hash_table (info); bed = get_elf_backend_data (abfd); - add_symbol_hook = bed->elf_add_symbol_hook; - collect = bed->collect; if ((abfd->flags & DYNAMIC) == 0) dynamic = FALSE; @@ -3179,8 +3086,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) hope of using a dynamic object which does not exactly match the format of the output file. */ if (info->relocatable - || !is_elf_hash_table (hash_table) - || hash_table->root.creator != abfd->xvec) + || !is_elf_hash_table (htab) + || htab->root.creator != abfd->xvec) { if (info->relocatable) bfd_set_error (bfd_error_invalid_operation); @@ -3223,8 +3130,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) { struct elf_link_hash_entry *h; - h = elf_link_hash_lookup (hash_table, name, - FALSE, FALSE, TRUE); + h = elf_link_hash_lookup (htab, name, FALSE, FALSE, TRUE); /* FIXME: What about bfd_link_hash_common? */ if (h != NULL @@ -3251,7 +3157,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (! (_bfd_generic_link_add_one_symbol (info, abfd, name, BSF_WARNING, s, 0, msg, - FALSE, collect, NULL))) + FALSE, bed->collect, NULL))) goto error_return; if (! info->relocatable) @@ -3277,15 +3183,15 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) format. FIXME: If there are no input BFD's of the same format as the output, we can't make a shared library. */ if (info->shared - && is_elf_hash_table (hash_table) - && hash_table->root.creator == abfd->xvec - && ! hash_table->dynamic_sections_created) + && is_elf_hash_table (htab) + && htab->root.creator == abfd->xvec + && !htab->dynamic_sections_created) { if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) goto error_return; } } - else if (!is_elf_hash_table (hash_table)) + else if (!is_elf_hash_table (htab)) goto error_return; else { @@ -3360,9 +3266,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) n->name = anm; n->by = abfd; n->next = NULL; - for (pn = & hash_table->needed; - *pn != NULL; - pn = &(*pn)->next) + for (pn = &htab->needed; *pn != NULL; pn = &(*pn)->next) ; *pn = n; } @@ -3434,9 +3338,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (rpath) { struct bfd_link_needed_list **pn; - for (pn = & hash_table->runpath; - *pn != NULL; - pn = &(*pn)->next) + for (pn = &htab->runpath; *pn != NULL; pn = &(*pn)->next) ; *pn = rpath; } @@ -3544,8 +3446,70 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } } - weaks = NULL; + /* If we are loading an as-needed shared lib, save the symbol table + state before we start adding symbols. If the lib turns out + to be unneeded, restore the state. */ + if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0) + { + unsigned int i; + size_t entsize; + + for (entsize = 0, i = 0; i < htab->root.table.size; i++) + { + struct bfd_hash_entry *p; + struct elf_link_hash_entry *h; + + for (p = htab->root.table.table[i]; p != NULL; p = p->next) + { + h = (struct elf_link_hash_entry *) p; + entsize += htab->root.table.entsize; + if (h->root.type == bfd_link_hash_warning) + entsize += htab->root.table.entsize; + } + } + + tabsize = htab->root.table.size * sizeof (struct bfd_hash_entry *); + hashsize = extsymcount * sizeof (struct elf_link_hash_entry *); + old_tab = bfd_malloc (tabsize + entsize + hashsize); + if (old_tab == NULL) + goto error_free_vers; + + /* Remember the current objalloc pointer, so that all mem for + symbols added can later be reclaimed. */ + alloc_mark = bfd_hash_allocate (&htab->root.table, 1); + if (alloc_mark == NULL) + goto error_free_vers; + + /* Clone the symbol table and sym hashes. Remember some + pointers into the symbol table, and dynamic symbol count. */ + old_hash = (char *) old_tab + tabsize; + old_ent = (char *) old_hash + hashsize; + memcpy (old_tab, htab->root.table.table, tabsize); + memcpy (old_hash, sym_hash, hashsize); + old_undefs = htab->root.undefs; + old_undefs_tail = htab->root.undefs_tail; + old_dynsymcount = htab->dynsymcount; + + for (i = 0; i < htab->root.table.size; i++) + { + struct bfd_hash_entry *p; + struct elf_link_hash_entry *h; + + for (p = htab->root.table.table[i]; p != NULL; p = p->next) + { + memcpy (old_ent, p, htab->root.table.entsize); + old_ent = (char *) old_ent + htab->root.table.entsize; + h = (struct elf_link_hash_entry *) p; + if (h->root.type == bfd_link_hash_warning) + { + memcpy (old_ent, h->root.u.i.link, htab->root.table.entsize); + old_ent = (char *) old_ent + htab->root.table.entsize; + } + } + } + } + weaks = NULL; ever = extversym != NULL ? extversym + extsymoff : NULL; for (isym = isymbuf, isymend = isymbuf + extsymcount; isym < isymend; @@ -3597,7 +3561,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (isym->st_shndx == SHN_UNDEF) sec = bfd_und_section_ptr; - else if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE) + else if (isym->st_shndx < SHN_LORESERVE + || isym->st_shndx > SHN_HIRESERVE) { sec = bfd_section_from_elf_index (abfd, isym->st_shndx); if (sec == NULL) @@ -3608,8 +3573,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) default visibility. */ sec = bfd_und_section_ptr; isym->st_shndx = SHN_UNDEF; - isym->st_other = STV_DEFAULT - | (isym->st_other & ~ ELF_ST_VISIBILITY(-1)); + isym->st_other = (STV_DEFAULT + | (isym->st_other & ~ ELF_ST_VISIBILITY (-1))); } else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) value -= sec->vma; @@ -3650,10 +3615,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } sec = tcomm; } - else if (add_symbol_hook) + else if (bed->elf_add_symbol_hook) { - if (! (*add_symbol_hook) (abfd, info, isym, &name, &flags, &sec, - &value)) + if (! (*bed->elf_add_symbol_hook) (abfd, info, isym, &name, &flags, + &sec, &value)) goto error_free_vers; /* The hook function sets the name to NULL if this symbol @@ -3676,12 +3641,12 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) definition = TRUE; size_change_ok = FALSE; - type_change_ok = get_elf_backend_data (abfd)->type_change_ok; + type_change_ok = bed->type_change_ok; old_alignment = 0; old_bfd = NULL; new_sec = sec; - if (is_elf_hash_table (hash_table)) + if (is_elf_hash_table (htab)) { Elf_Internal_Versym iver; unsigned int vernum = 0; @@ -3776,7 +3741,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) && isym->st_shndx != SHN_UNDEF) ++newlen; - newname = bfd_alloc (abfd, newlen); + newname = bfd_hash_allocate (&htab->root.table, newlen); if (newname == NULL) goto error_free_vers; memcpy (newname, name, namelen); @@ -3840,7 +3805,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } if (! (_bfd_generic_link_add_one_symbol - (info, abfd, name, flags, sec, value, NULL, FALSE, collect, + (info, abfd, name, flags, sec, value, NULL, FALSE, bed->collect, (struct bfd_link_hash_entry **) sym_hash))) goto error_free_vers; @@ -3855,7 +3820,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) && definition && (flags & BSF_WEAK) != 0 && ELF_ST_TYPE (isym->st_info) != STT_FUNC - && is_elf_hash_table (hash_table) + && is_elf_hash_table (htab) && h->u.weakdef == NULL) { /* Keep a list of all weak defined non function symbols from @@ -3898,7 +3863,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) h->root.u.c.p->alignment_power = old_alignment; } - if (is_elf_hash_table (hash_table)) + if (is_elf_hash_table (htab)) { bfd_boolean dynsym; @@ -3998,7 +3963,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) && (abfd->no_export || (abfd->my_archive && abfd->my_archive->no_export)) && ELF_ST_VISIBILITY (isym->st_other) != STV_INTERNAL) - isym->st_other = STV_HIDDEN | (isym->st_other & ~ ELF_ST_VISIBILITY (-1)); + isym->st_other = (STV_HIDDEN + | (isym->st_other & ~ELF_ST_VISIBILITY (-1))); if (isym->st_other != 0 && !dynamic) { @@ -4071,13 +4037,13 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) { /* Queue non-default versions so that .symver x, x@FOO aliases can be checked. */ - if (! nondeflt_vers) + if (!nondeflt_vers) { - amt = (isymend - isym + 1) - * sizeof (struct elf_link_hash_entry *); + amt = ((isymend - isym + 1) + * sizeof (struct elf_link_hash_entry *)); nondeflt_vers = bfd_malloc (amt); } - nondeflt_vers [nondeflt_vers_cnt++] = h; + nondeflt_vers[nondeflt_vers_cnt++] = h; } } @@ -4089,7 +4055,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) && ! new_weakdef && h->u.weakdef->dynindx == -1) { - if (! bfd_elf_link_record_dynamic_symbol (info, h->u.weakdef)) + if (!bfd_elf_link_record_dynamic_symbol (info, h->u.weakdef)) goto error_free_vers; } } @@ -4139,6 +4105,68 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } } + if (extversym != NULL) + { + free (extversym); + extversym = NULL; + } + + if (isymbuf != NULL) + { + free (isymbuf); + isymbuf = NULL; + } + + if ((elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0) + { + unsigned int i; + + /* Restore the symbol table. */ + old_hash = (char *) old_tab + tabsize; + old_ent = (char *) old_hash + hashsize; + sym_hash = elf_sym_hashes (abfd); + memcpy (htab->root.table.table, old_tab, tabsize); + memcpy (sym_hash, old_hash, hashsize); + htab->root.undefs = old_undefs; + htab->root.undefs_tail = old_undefs_tail; + for (i = 0; i < htab->root.table.size; i++) + { + struct bfd_hash_entry *p; + struct elf_link_hash_entry *h; + + for (p = htab->root.table.table[i]; p != NULL; p = p->next) + { + h = (struct elf_link_hash_entry *) p; + if (h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + if (h->dynindx >= old_dynsymcount) + _bfd_elf_strtab_delref (htab->dynstr, h->dynstr_index); + + memcpy (p, old_ent, htab->root.table.entsize); + old_ent = (char *) old_ent + htab->root.table.entsize; + h = (struct elf_link_hash_entry *) p; + if (h->root.type == bfd_link_hash_warning) + { + memcpy (h->root.u.i.link, old_ent, htab->root.table.entsize); + old_ent = (char *) old_ent + htab->root.table.entsize; + } + } + } + + free (old_tab); + objalloc_free_block ((struct objalloc *) htab->root.table.memory, + alloc_mark); + if (nondeflt_vers != NULL) + free (nondeflt_vers); + return TRUE; + } + + if (old_tab != NULL) + { + free (old_tab); + old_tab = NULL; + } + /* Now that all the symbols from this input file are created, handle .symver foo, foo@BAR such that any relocs against foo become foo@BAR. */ if (nondeflt_vers != NULL) @@ -4162,7 +4190,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) shortname[amt] = '\0'; hi = (struct elf_link_hash_entry *) - bfd_link_hash_lookup (&hash_table->root, shortname, + bfd_link_hash_lookup (&htab->root, shortname, FALSE, FALSE, FALSE); if (hi != NULL && hi->root.type == h->root.type @@ -4188,31 +4216,6 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) nondeflt_vers = NULL; } - if (extversym != NULL) - { - free (extversym); - extversym = NULL; - } - - if (isymbuf != NULL) - free (isymbuf); - isymbuf = NULL; - - if (!add_needed - && (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0) - { - /* Remove symbols defined in an as-needed shared lib that wasn't - needed. */ - struct elf_smash_syms_data inf; - inf.not_needed = abfd; - inf.htab = hash_table; - inf.twiddled = FALSE; - elf_link_hash_traverse (hash_table, elf_smash_syms, &inf); - if (inf.twiddled) - bfd_link_repair_undef_list (&hash_table->root); - weaks = NULL; - } - /* Now set the weakdefs field correctly for all the weak defined symbols we found. The only way to do this is to search all the symbols. Since we only need the information for non functions in @@ -4352,9 +4355,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) free (sorted_sym_hash); } - check_directives = get_elf_backend_data (abfd)->check_directives; - if (check_directives) - check_directives (abfd, info); + if (bed->check_directives) + (*bed->check_directives) (abfd, info); /* If this object is the same format as the output object, and it is not a shared library, then let the backend look through the @@ -4373,11 +4375,10 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) I have no idea how to handle linking PIC code into a file of a different format. It probably can't be done. */ - check_relocs = get_elf_backend_data (abfd)->check_relocs; if (! dynamic - && is_elf_hash_table (hash_table) - && hash_table->root.creator == abfd->xvec - && check_relocs != NULL) + && is_elf_hash_table (htab) + && htab->root.creator == abfd->xvec + && bed->check_relocs != NULL) { asection *o; @@ -4398,7 +4399,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (internal_relocs == NULL) goto error_return; - ok = (*check_relocs) (abfd, info, o, internal_relocs); + ok = (*bed->check_relocs) (abfd, info, o, internal_relocs); if (elf_section_data (o)->relocs != internal_relocs) free (internal_relocs); @@ -4412,7 +4413,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) of the .stab/.stabstr sections. */ if (! dynamic && ! info->traditional_format - && is_elf_hash_table (hash_table) + && is_elf_hash_table (htab) && (info->strip != strip_all && info->strip != strip_debugger)) { asection *stabstr; @@ -4433,10 +4434,8 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) struct bfd_elf_section_data *secdata; secdata = elf_section_data (stab); - if (! _bfd_link_section_stabs (abfd, - &hash_table->stab_info, - stab, stabstr, - &secdata->sec_info, + if (! _bfd_link_section_stabs (abfd, &htab->stab_info, stab, + stabstr, &secdata->sec_info, &string_offset)) goto error_return; if (secdata->sec_info) @@ -4445,7 +4444,7 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) } } - if (is_elf_hash_table (hash_table) && add_needed) + if (is_elf_hash_table (htab) && add_needed) { /* Add this bfd to the loaded list. */ struct elf_link_loaded_list *n; @@ -4454,13 +4453,15 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) if (n == NULL) goto error_return; n->abfd = abfd; - n->next = hash_table->loaded; - hash_table->loaded = n; + n->next = htab->loaded; + htab->loaded = n; } return TRUE; error_free_vers: + if (old_tab != NULL) + free (old_tab); if (nondeflt_vers != NULL) free (nondeflt_vers); if (extversym != NULL) @@ -7664,7 +7665,7 @@ elf_fixup_link_order (bfd *abfd, asection *o) struct bfd_link_order *p; bfd *sub; const struct elf_backend_data *bed = get_elf_backend_data (abfd); - int elfsec; + unsigned elfsec; struct bfd_link_order **sections; asection *s, *other_sec, *linkorder_sec; bfd_vma offset; @@ -7681,7 +7682,8 @@ elf_fixup_link_order (bfd *abfd, asection *o) sub = s->owner; if (bfd_get_flavour (sub) == bfd_target_elf_flavour && elf_elfheader (sub)->e_ident[EI_CLASS] == bed->s->elfclass - && (elfsec = _bfd_elf_section_from_bfd_section (sub, s)) != -1 + && (elfsec = _bfd_elf_section_from_bfd_section (sub, s)) + && elfsec < elf_numsections (sub) && elf_elfsections (sub)[elfsec]->sh_flags & SHF_LINK_ORDER) { seen_linkorder++; @@ -7781,8 +7783,7 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info) dynobj = elf_hash_table (info)->dynobj; emit_relocs = (info->relocatable - || info->emitrelocations - || bed->elf_backend_emit_relocs); + || info->emitrelocations); finfo.info = info; finfo.output_bfd = abfd; @@ -9170,7 +9171,7 @@ bfd_elf_gc_sections (bfd *abfd, struct bfd_link_info *info) /* Keep .gcc_except_table.* if the associated .text.* is marked. This isn't very nice, but the proper solution, - splitting .eh_frame up and using comdat doesn't pan out + splitting .eh_frame up and using comdat doesn't pan out easily due to needing special relocs to handle the difference of two symbols in separate sections. Don't keep code sections referenced by .eh_frame. */ diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 7a0cc90..f0bb0fa 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -1,5 +1,5 @@ /* IA-64 support for 64-bit ELF - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by David Mosberger-Tang @@ -1918,7 +1918,8 @@ elfNN_ia64_hash_table_create (abfd) return 0; if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, - elfNN_ia64_new_elf_hash_entry)) + elfNN_ia64_new_elf_hash_entry, + sizeof (struct elfNN_ia64_link_hash_entry))) { free (ret); return 0; @@ -3928,14 +3929,16 @@ elfNN_ia64_choose_gp (abfd, info) gp_val = got_sec->output_section->vma; else if (max_short_vma != 0) gp_val = min_short_vma; - else + else if (max_vma - min_vma < 0x200000) gp_val = min_vma; + else + gp_val = max_vma - 0x200000 + 8; /* If it is possible to address the entire image, but we don't with the choice above, adjust. */ if (max_vma - min_vma < 0x400000 - && max_vma - gp_val <= 0x200000 - && gp_val - min_vma > 0x200000) + && (max_vma - gp_val >= 0x200000 + || gp_val - min_vma > 0x200000)) gp_val = min_vma + 0x200000; else if (max_short_vma != 0) { diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 89acbc5..4e27a53 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -1,6 +1,6 @@ /* MIPS-specific support for ELF Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Most of the information added by Ian Lance Taylor, Cygnus Support, . @@ -34,6 +34,7 @@ #include "elf-bfd.h" #include "elfxx-mips.h" #include "elf/mips.h" +#include "elf-vxworks.h" /* Get the ECOFF swapping routines. */ #include "coff/sym.h" @@ -43,8 +44,39 @@ #include "hashtab.h" -/* This structure is used to hold .got entries while estimating got - sizes. */ +/* This structure is used to hold information about one GOT entry. + There are three types of entry: + + (1) absolute addresses + (abfd == NULL) + (2) SYMBOL + OFFSET addresses, where SYMBOL is local to an input bfd + (abfd != NULL, symndx >= 0) + (3) global and forced-local symbols + (abfd != NULL, symndx == -1) + + Type (3) entries are treated differently for different types of GOT. + In the "master" GOT -- i.e. the one that describes every GOT + reference needed in the link -- the mips_got_entry is keyed on both + the symbol and the input bfd that references it. If it turns out + that we need multiple GOTs, we can then use this information to + create separate GOTs for each input bfd. + + However, we want each of these separate GOTs to have at most one + entry for a given symbol, so their type (3) entries are keyed only + on the symbol. The input bfd given by the "abfd" field is somewhat + arbitrary in this case. + + This means that when there are multiple GOTs, each GOT has a unique + mips_got_entry for every symbol within it. We can therefore use the + mips_got_entry fields (tls_type and gotidx) to track the symbol's + GOT index. + + However, if it turns out that we need only a single GOT, we continue + to use the master GOT to describe it. There may therefore be several + mips_got_entries for the same symbol, each with a different input bfd. + We want to make sure that each symbol gets a unique GOT entry, so when + there's a single GOT, we use the symbol's hash entry, not the + mips_got_entry fields, to track a symbol's GOT index. */ struct mips_got_entry { /* The input bfd in which the symbol is defined. */ @@ -246,6 +278,12 @@ struct mips_elf_link_hash_entry the initial global GOT entry to a local GOT entry. */ bfd_boolean forced_local; + /* Are we referenced by some kind of relocation? */ + bfd_boolean is_relocation_target; + + /* Are we referenced by branch relocations? */ + bfd_boolean is_branch_target; + #define GOT_NORMAL 0 #define GOT_TLS_GD 1 #define GOT_TLS_LDM 2 @@ -283,6 +321,20 @@ struct mips_elf_link_hash_table bfd_vma rld_value; /* This is set if we see any mips16 stub sections. */ bfd_boolean mips16_stubs_seen; + /* True if we're generating code for VxWorks. */ + bfd_boolean is_vxworks; + /* Shortcuts to some dynamic sections, or NULL if they are not + being used. */ + asection *srelbss; + asection *sdynbss; + asection *srelplt; + asection *srelplt2; + asection *sgotplt; + asection *splt; + /* The size of the PLT header in bytes (VxWorks only). */ + bfd_vma plt_header_size; + /* The size of a PLT entry in bytes (VxWorks only). */ + bfd_vma plt_entry_size; }; #define TLS_RELOC_P(r_type) \ @@ -433,8 +485,8 @@ typedef struct runtime_pdr { #define rpdNil ((pRPDR) 0) static struct mips_got_entry *mips_elf_create_local_got_entry - (bfd *, bfd *, struct mips_got_info *, asection *, bfd_vma, unsigned long, - struct mips_elf_link_hash_entry *, int); + (bfd *, struct bfd_link_info *, bfd *, struct mips_got_info *, asection *, + asection *, bfd_vma, unsigned long, struct mips_elf_link_hash_entry *, int); static bfd_boolean mips_elf_sort_hash_table_f (struct mips_elf_link_hash_entry *, void *); static bfd_vma mips_elf_high @@ -490,6 +542,10 @@ static bfd *reldyn_sorting_bfd; #define MIPS_ELF_REL_SIZE(abfd) \ (get_elf_backend_data (abfd)->s->sizeof_rel) +/* The size of an external RELA relocation. */ +#define MIPS_ELF_RELA_SIZE(abfd) \ + (get_elf_backend_data (abfd)->s->sizeof_rela) + /* The size of an external dynamic table entry. */ #define MIPS_ELF_DYN_SIZE(abfd) \ (get_elf_backend_data (abfd)->s->sizeof_dyn) @@ -540,20 +596,26 @@ static bfd *reldyn_sorting_bfd; == (ABI_64_P (abfd) ? sizeof (Elf64_External_Rela) \ : sizeof (Elf32_External_Rela)))) +/* The name of the dynamic relocation section. */ +#define MIPS_ELF_REL_DYN_NAME(INFO) \ + (mips_elf_hash_table (INFO)->is_vxworks ? ".rela.dyn" : ".rel.dyn") + /* In case we're on a 32-bit machine, construct a 64-bit "-1" value from smaller values. Start with zero, widen, *then* decrement. */ #define MINUS_ONE (((bfd_vma)0) - 1) #define MINUS_TWO (((bfd_vma)0) - 2) /* The number of local .got entries we reserve. */ -#define MIPS_RESERVED_GOTNO (2) +#define MIPS_RESERVED_GOTNO(INFO) \ + (mips_elf_hash_table (INFO)->is_vxworks ? 3 : 2) /* The offset of $gp from the beginning of the .got section. */ -#define ELF_MIPS_GP_OFFSET(abfd) (0x7ff0) +#define ELF_MIPS_GP_OFFSET(INFO) \ + (mips_elf_hash_table (INFO)->is_vxworks ? 0x0 : 0x7ff0) /* The maximum size of the GOT for it to be addressable using 16-bit offsets from $gp. */ -#define MIPS_ELF_GOT_MAX_SIZE(abfd) (ELF_MIPS_GP_OFFSET(abfd) + 0x7fff) +#define MIPS_ELF_GOT_MAX_SIZE(INFO) (ELF_MIPS_GP_OFFSET (INFO) + 0x7fff) /* Instructions which appear in a stub. */ #define STUB_LW(abfd) \ @@ -636,6 +698,44 @@ static bfd *reldyn_sorting_bfd; #define CALL_STUB ".mips16.call." #define CALL_FP_STUB ".mips16.call.fp." +/* The format of the first PLT entry in a VxWorks executable. */ +static const bfd_vma mips_vxworks_exec_plt0_entry[] = { + 0x3c190000, /* lui t9, %hi(_GLOBAL_OFFSET_TABLE_) */ + 0x27390000, /* addiu t9, t9, %lo(_GLOBAL_OFFSET_TABLE_) */ + 0x8f390008, /* lw t9, 8(t9) */ + 0x00000000, /* nop */ + 0x03200008, /* jr t9 */ + 0x00000000 /* nop */ +}; + +/* The format of subsequent PLT entries. */ +static const bfd_vma mips_vxworks_exec_plt_entry[] = { + 0x10000000, /* b .PLT_resolver */ + 0x24180000, /* li t8, */ + 0x3c190000, /* lui t9, %hi(<.got.plt slot>) */ + 0x27390000, /* addiu t9, t9, %lo(<.got.plt slot>) */ + 0x8f390000, /* lw t9, 0(t9) */ + 0x00000000, /* nop */ + 0x03200008, /* jr t9 */ + 0x00000000 /* nop */ +}; + +/* The format of the first PLT entry in a VxWorks shared object. */ +static const bfd_vma mips_vxworks_shared_plt0_entry[] = { + 0x8f990008, /* lw t9, 8(gp) */ + 0x00000000, /* nop */ + 0x03200008, /* jr t9 */ + 0x00000000, /* nop */ + 0x00000000, /* nop */ + 0x00000000 /* nop */ +}; + +/* The format of subsequent PLT entries. */ +static const bfd_vma mips_vxworks_shared_plt_entry[] = { + 0x10000000, /* b .PLT_resolver */ + 0x24180000 /* li t8, */ +}; + /* Look up an entry in a MIPS ELF linker hash table. */ #define mips_elf_link_hash_lookup(table, string, create, copy, follow) \ @@ -715,6 +815,8 @@ mips_elf_link_hash_newfunc (struct bfd_hash_entry *entry, ret->call_stub = NULL; ret->call_fp_stub = NULL; ret->forced_local = FALSE; + ret->is_branch_target = FALSE; + ret->is_relocation_target = FALSE; ret->tls_type = GOT_NORMAL; } @@ -1896,14 +1998,19 @@ mips_elf_multi_got_entry_eq (const void *entry1, const void *entry2) : e1->d.h == e2->d.h); } -/* Returns the dynamic relocation section for DYNOBJ. */ +/* Return the dynamic relocation section. If it doesn't exist, try to + create a new it if CREATE_P, otherwise return NULL. Also return NULL + if creation fails. */ static asection * -mips_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p) +mips_elf_rel_dyn_section (struct bfd_link_info *info, bfd_boolean create_p) { - static const char dname[] = ".rel.dyn"; + const char *dname; asection *sreloc; + bfd *dynobj; + dname = MIPS_ELF_REL_DYN_NAME (info); + dynobj = elf_hash_table (info)->dynobj; sreloc = bfd_get_section_by_name (dynobj, dname); if (sreloc == NULL && create_p) { @@ -2121,7 +2228,7 @@ mips_elf_initialize_tls_slots (bfd *abfd, bfd_vma got_offset, || h->root.root.type == bfd_link_hash_undefweak); /* Emit necessary relocations. */ - sreloc = mips_elf_rel_dyn_section (dynobj, FALSE); + sreloc = mips_elf_rel_dyn_section (info, FALSE); /* General Dynamic. */ if (*tls_type_p & GOT_TLS_GD) @@ -2240,14 +2347,46 @@ mips_tls_got_index (bfd *abfd, bfd_vma got_index, unsigned char *tls_type, return got_index; } -/* Returns the GOT offset at which the indicated address can be found. - If there is not yet a GOT entry for this value, create one. If - R_SYMNDX refers to a TLS symbol, create a TLS GOT entry instead. - Returns -1 if no satisfactory GOT offset can be found. */ +/* Return the offset from _GLOBAL_OFFSET_TABLE_ of the .got.plt entry + for global symbol H. .got.plt comes before the GOT, so the offset + will be negative. */ + +static bfd_vma +mips_elf_gotplt_index (struct bfd_link_info *info, + struct elf_link_hash_entry *h) +{ + bfd_vma plt_index, got_address, got_value; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); + BFD_ASSERT (h->plt.offset != (bfd_vma) -1); + + /* Calculate the index of the symbol's PLT entry. */ + plt_index = (h->plt.offset - htab->plt_header_size) / htab->plt_entry_size; + + /* Calculate the address of the associated .got.plt entry. */ + got_address = (htab->sgotplt->output_section->vma + + htab->sgotplt->output_offset + + plt_index * 4); + + /* Calculate the value of _GLOBAL_OFFSET_TABLE_. */ + got_value = (htab->root.hgot->root.u.def.section->output_section->vma + + htab->root.hgot->root.u.def.section->output_offset + + htab->root.hgot->root.u.def.value); + + return got_address - got_value; +} + +/* Return the GOT offset for address VALUE, which was derived from + a symbol belonging to INPUT_SECTION. If there is not yet a GOT + entry for this value, create one. If R_SYMNDX refers to a TLS symbol, + create a TLS GOT entry instead. Return -1 if no satisfactory GOT + offset can be found. */ static bfd_vma mips_elf_local_got_index (bfd *abfd, bfd *ibfd, struct bfd_link_info *info, - bfd_vma value, unsigned long r_symndx, + asection *input_section, bfd_vma value, + unsigned long r_symndx, struct mips_elf_link_hash_entry *h, int r_type) { asection *sgot; @@ -2256,14 +2395,23 @@ mips_elf_local_got_index (bfd *abfd, bfd *ibfd, struct bfd_link_info *info, g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); - entry = mips_elf_create_local_got_entry (abfd, ibfd, g, sgot, value, + entry = mips_elf_create_local_got_entry (abfd, info, ibfd, g, sgot, + input_section, value, r_symndx, h, r_type); if (!entry) return MINUS_ONE; if (TLS_RELOC_P (r_type)) - return mips_tls_got_index (abfd, entry->gotidx, &entry->tls_type, r_type, - info, h, value); + { + if (entry->symndx == -1 && g->next == NULL) + /* A type (3) entry in the single-GOT case. We use the symbol's + hash table entry to track the index. */ + return mips_tls_got_index (abfd, h->tls_got_offset, &h->tls_type, + r_type, info, h, value); + else + return mips_tls_got_index (abfd, entry->gotidx, &entry->tls_type, + r_type, info, h, value); + } else return entry->gotidx; } @@ -2350,26 +2498,27 @@ mips_elf_global_got_index (bfd *abfd, bfd *ibfd, struct elf_link_hash_entry *h, return index; } -/* Find a GOT entry that is within 32KB of the VALUE. These entries - are supposed to be placed at small offsets in the GOT, i.e., - within 32KB of GP. Return the index into the GOT for this page, - and store the offset from this entry to the desired address in - OFFSETP, if it is non-NULL. */ +/* Find a GOT page entry that points to within 32KB of VALUE, which was + calculated from a symbol belonging to INPUT_SECTION. These entries + are supposed to be placed at small offsets in the GOT, i.e., within + 32KB of GP. Return the index of the GOT entry, or -1 if no entry + could be created. If OFFSETP is nonnull, use it to return the + offset of the GOT entry from VALUE. */ static bfd_vma mips_elf_got_page (bfd *abfd, bfd *ibfd, struct bfd_link_info *info, - bfd_vma value, bfd_vma *offsetp) + asection *input_section, bfd_vma value, bfd_vma *offsetp) { asection *sgot; struct mips_got_info *g; - bfd_vma index; + bfd_vma page, index; struct mips_got_entry *entry; g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); - entry = mips_elf_create_local_got_entry (abfd, ibfd, g, sgot, - (value + 0x8000) - & (~(bfd_vma)0xffff), 0, + page = (value + 0x8000) & ~(bfd_vma) 0xffff; + entry = mips_elf_create_local_got_entry (abfd, info, ibfd, g, sgot, + input_section, page, 0, NULL, R_MIPS_GOT_PAGE); if (!entry) @@ -2383,30 +2532,32 @@ mips_elf_got_page (bfd *abfd, bfd *ibfd, struct bfd_link_info *info, return index; } -/* Find a GOT entry whose higher-order 16 bits are the same as those - for value. Return the index into the GOT for this entry. */ +/* Find a local GOT entry for an R_MIPS_GOT16 relocation against VALUE, + which was calculated from a symbol belonging to INPUT_SECTION. + EXTERNAL is true if the relocation was against a global symbol + that has been forced local. */ static bfd_vma mips_elf_got16_entry (bfd *abfd, bfd *ibfd, struct bfd_link_info *info, - bfd_vma value, bfd_boolean external) + asection *input_section, bfd_vma value, + bfd_boolean external) { asection *sgot; struct mips_got_info *g; struct mips_got_entry *entry; + /* GOT16 relocations against local symbols are followed by a LO16 + relocation; those against global symbols are not. Thus if the + symbol was originally local, the GOT16 relocation should load the + equivalent of %hi(VALUE), otherwise it should load VALUE itself. */ if (! external) - { - /* Although the ABI says that it is "the high-order 16 bits" that we - want, it is really the %high value. The complete value is - calculated with a `addiu' of a LO16 relocation, just as with a - HI16/LO16 pair. */ - value = mips_elf_high (value) << 16; - } + value = mips_elf_high (value) << 16; g = mips_elf_got_info (elf_hash_table (info)->dynobj, &sgot); - entry = mips_elf_create_local_got_entry (abfd, ibfd, g, sgot, value, 0, NULL, - R_MIPS_GOT16); + entry = mips_elf_create_local_got_entry (abfd, info, ibfd, g, sgot, + input_section, value, 0, + NULL, R_MIPS_GOT16); if (entry) return entry->gotidx; else @@ -2431,20 +2582,24 @@ mips_elf_got_offset_from_index (bfd *dynobj, bfd *output_bfd, return sgot->output_section->vma + sgot->output_offset + index - gp; } -/* Create a local GOT entry for VALUE. Return the index of the entry, - or -1 if it could not be created. If R_SYMNDX refers to a TLS symbol, - create a TLS entry instead. */ +/* Create and return a local GOT entry for VALUE, which was calculated + from a symbol belonging to INPUT_SECTON. Return NULL if it could not + be created. If R_SYMNDX refers to a TLS symbol, create a TLS entry + instead. */ static struct mips_got_entry * -mips_elf_create_local_got_entry (bfd *abfd, bfd *ibfd, - struct mips_got_info *gg, - asection *sgot, bfd_vma value, - unsigned long r_symndx, +mips_elf_create_local_got_entry (bfd *abfd, struct bfd_link_info *info, + bfd *ibfd, struct mips_got_info *gg, + asection *sgot, asection *input_section, + bfd_vma value, unsigned long r_symndx, struct mips_elf_link_hash_entry *h, int r_type) { struct mips_got_entry entry, **loc; struct mips_got_info *g; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); entry.abfd = NULL; entry.symndx = -1; @@ -2517,6 +2672,33 @@ mips_elf_create_local_got_entry (bfd *abfd, bfd *ibfd, MIPS_ELF_PUT_WORD (abfd, value, (sgot->contents + entry.gotidx)); + /* These GOT entries need a dynamic relocation on VxWorks. Because + the offset between segments is not fixed, the relocation must be + against a symbol in the same segment as the original symbol. + The easiest way to do this is to take INPUT_SECTION's output + section and emit a relocation against its section symbol. */ + if (htab->is_vxworks) + { + Elf_Internal_Rela outrel; + asection *s, *output_section; + bfd_byte *loc; + bfd_vma got_address; + int dynindx; + + s = mips_elf_rel_dyn_section (info, FALSE); + output_section = input_section->output_section; + dynindx = elf_section_data (output_section)->dynindx; + got_address = (sgot->output_section->vma + + sgot->output_offset + + entry.gotidx); + + loc = s->contents + (s->reloc_count++ * sizeof (Elf32_External_Rela)); + outrel.r_offset = got_address; + outrel.r_info = ELF32_R_INFO (dynindx, R_MIPS_32); + outrel.r_addend = value - output_section->vma; + bfd_elf32_swap_reloca_out (abfd, &outrel, loc); + } + return *loc; } @@ -2892,7 +3074,7 @@ mips_elf_merge_gots (void **bfd2got_, void *p) { unsigned int primary_total = lcount + tcount + arg->global_count; if (primary_total * MIPS_ELF_GOT_SIZE (bfd2got->bfd) - >= MIPS_ELF_GOT_MAX_SIZE (bfd2got->bfd)) + >= MIPS_ELF_GOT_MAX_SIZE (arg->info)) too_many_for_tls = TRUE; } @@ -2975,55 +3157,54 @@ mips_elf_merge_gots (void **bfd2got_, void *p) return 1; } -/* Set the TLS GOT index for the GOT entry in ENTRYP. */ +/* Set the TLS GOT index for the GOT entry in ENTRYP. ENTRYP's NEXT field + is null iff there is just a single GOT. */ static int mips_elf_initialize_tls_index (void **entryp, void *p) { struct mips_got_entry *entry = (struct mips_got_entry *)*entryp; struct mips_got_info *g = p; + bfd_vma next_index; /* We're only interested in TLS symbols. */ if (entry->tls_type == 0) return 1; - if (entry->symndx == -1) + next_index = MIPS_ELF_GOT_SIZE (entry->abfd) * (long) g->tls_assigned_gotno; + + if (entry->symndx == -1 && g->next == NULL) { - /* There may be multiple mips_got_entry structs for a global variable - if there is just one GOT. Just do this once. */ - if (g->next == NULL) + /* A type (3) got entry in the single-GOT case. We use the symbol's + hash table entry to track its index. */ + if (entry->d.h->tls_type & GOT_TLS_OFFSET_DONE) + return 1; + entry->d.h->tls_type |= GOT_TLS_OFFSET_DONE; + entry->d.h->tls_got_offset = next_index; + } + else + { + if (entry->tls_type & GOT_TLS_LDM) { - if (entry->d.h->tls_type & GOT_TLS_OFFSET_DONE) + /* There are separate mips_got_entry objects for each input bfd + that requires an LDM entry. Make sure that all LDM entries in + a GOT resolve to the same index. */ + if (g->tls_ldm_offset != MINUS_TWO && g->tls_ldm_offset != MINUS_ONE) { - entry->gotidx = entry->d.h->tls_got_offset; + entry->gotidx = g->tls_ldm_offset; return 1; } - entry->d.h->tls_type |= GOT_TLS_OFFSET_DONE; - } - } - else if (entry->tls_type & GOT_TLS_LDM) - { - /* Similarly, there may be multiple structs for the LDM entry. */ - if (g->tls_ldm_offset != MINUS_TWO && g->tls_ldm_offset != MINUS_ONE) - { - entry->gotidx = g->tls_ldm_offset; - return 1; + g->tls_ldm_offset = next_index; } + entry->gotidx = next_index; } - /* Initialize the GOT offset. */ - entry->gotidx = MIPS_ELF_GOT_SIZE (entry->abfd) * (long) g->tls_assigned_gotno; - if (g->next == NULL && entry->symndx == -1) - entry->d.h->tls_got_offset = entry->gotidx; - + /* Account for the entries we've just allocated. */ if (entry->tls_type & (GOT_TLS_GD | GOT_TLS_LDM)) g->tls_assigned_gotno += 2; if (entry->tls_type & GOT_TLS_IE) g->tls_assigned_gotno += 1; - if (entry->tls_type & GOT_TLS_LDM) - g->tls_ldm_offset = entry->gotidx; - return 1; } @@ -3207,9 +3388,9 @@ mips_elf_multi_got (bfd *abfd, struct bfd_link_info *info, /* Taking out PAGES entries is a worst-case estimate. We could compute the maximum number of pages that each separate input bfd uses, but it's probably not worth it. */ - got_per_bfd_arg.max_count = ((MIPS_ELF_GOT_MAX_SIZE (abfd) + got_per_bfd_arg.max_count = ((MIPS_ELF_GOT_MAX_SIZE (info) / MIPS_ELF_GOT_SIZE (abfd)) - - MIPS_RESERVED_GOTNO - pages); + - MIPS_RESERVED_GOTNO (info) - pages); /* The number of globals that will be included in the primary GOT. See the calls to mips_elf_set_global_got_offset below for more information. */ @@ -3344,21 +3525,24 @@ mips_elf_multi_got (bfd *abfd, struct bfd_link_info *info, { struct mips_got_info *gn; - assign += MIPS_RESERVED_GOTNO; + assign += MIPS_RESERVED_GOTNO (info); g->assigned_gotno = assign; g->local_gotno += assign + pages; assign = g->local_gotno + g->global_gotno + g->tls_gotno; + /* Take g out of the direct list, and push it onto the reversed + list that gg points to. g->next is guaranteed to be nonnull after + this operation, as required by mips_elf_initialize_tls_index. */ + gn = g->next; + g->next = gg->next; + gg->next = g; + /* Set up any TLS entries. We always place the TLS entries after all non-TLS entries. */ g->tls_assigned_gotno = g->local_gotno + g->global_gotno; htab_traverse (g->got_entries, mips_elf_initialize_tls_index, g); - /* Take g out of the direct list, and push it onto the reversed - list that gg points to. */ - gn = g->next; - g->next = gg->next; - gg->next = g; + /* Move onto the next GOT. It will be a secondary GOT if nonull. */ g = gn; /* Mark global symbols in every non-primary GOT as ineligible for @@ -3540,6 +3724,9 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info, struct bfd_link_hash_entry *bh; struct mips_got_info *g; bfd_size_type amt; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); /* This function may be called more than once. */ s = mips_elf_got_section (abfd, TRUE); @@ -3576,6 +3763,7 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info, h->non_elf = 0; h->def_regular = 1; h->type = STT_OBJECT; + elf_hash_table (info)->hgot = h; if (info->shared && ! bfd_elf_link_record_dynamic_symbol (info, h)) @@ -3588,8 +3776,8 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info, g->global_gotsym = NULL; g->global_gotno = 0; g->tls_gotno = 0; - g->local_gotno = MIPS_RESERVED_GOTNO; - g->assigned_gotno = MIPS_RESERVED_GOTNO; + g->local_gotno = MIPS_RESERVED_GOTNO (info); + g->assigned_gotno = MIPS_RESERVED_GOTNO (info); g->bfd2got = NULL; g->next = NULL; g->tls_ldm_offset = MINUS_ONE; @@ -3601,9 +3789,33 @@ mips_elf_create_got_section (bfd *abfd, struct bfd_link_info *info, mips_elf_section_data (s)->elf.this_hdr.sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL; + /* VxWorks also needs a .got.plt section. */ + if (htab->is_vxworks) + { + s = bfd_make_section_with_flags (abfd, ".got.plt", + SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS + | SEC_IN_MEMORY | SEC_LINKER_CREATED); + if (s == NULL || !bfd_set_section_alignment (abfd, s, 4)) + return FALSE; + + htab->sgotplt = s; + } return TRUE; } +/* Return true if H refers to the special VxWorks __GOTT_BASE__ or + __GOTT_INDEX__ symbols. These symbols are only special for + shared objects; they are not used in executables. */ + +static bfd_boolean +is_gott_symbol (struct bfd_link_info *info, struct elf_link_hash_entry *h) +{ + return (mips_elf_hash_table (info)->is_vxworks + && info->shared + && (strcmp (h->root.root.string, "__GOTT_BASE__") == 0 + || strcmp (h->root.root.string, "__GOTT_INDEX__") == 0)); +} + /* Calculate the value produced by the RELOCATION (which comes from the INPUT_BFD). The ADDEND is the addend to use for this RELOCATION; RELOCATION->R_ADDEND is ignored. @@ -3666,6 +3878,11 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, bfd_boolean overflowed_p; /* TRUE if this relocation refers to a MIPS16 function. */ bfd_boolean target_is_16_bit_code_p = FALSE; + struct mips_elf_link_hash_table *htab; + bfd *dynobj; + + dynobj = elf_hash_table (info)->dynobj; + htab = mips_elf_hash_table (info); /* Parse the relocation. */ r_symndx = ELF_R_SYM (input_bfd, relocation->r_info); @@ -3915,52 +4132,61 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, /* Find the index into the GOT where this value is located. */ if (r_type == R_MIPS_TLS_LDM) { - g = mips_elf_local_got_index (abfd, input_bfd, info, 0, 0, NULL, - r_type); + g = mips_elf_local_got_index (abfd, input_bfd, info, + sec, 0, 0, NULL, r_type); if (g == MINUS_ONE) return bfd_reloc_outofrange; } else if (!local_p) { - /* GOT_PAGE may take a non-zero addend, that is ignored in a - GOT_PAGE relocation that decays to GOT_DISP because the - symbol turns out to be global. The addend is then added - as GOT_OFST. */ - BFD_ASSERT (addend == 0 || r_type == R_MIPS_GOT_PAGE); - g = mips_elf_global_got_index (elf_hash_table (info)->dynobj, - input_bfd, - (struct elf_link_hash_entry *) h, - r_type, info); - if (h->tls_type == GOT_NORMAL - && (! elf_hash_table(info)->dynamic_sections_created - || (info->shared - && (info->symbolic || h->root.forced_local) - && h->root.def_regular))) + /* On VxWorks, CALL relocations should refer to the .got.plt + entry, which is initialized to point at the PLT stub. */ + if (htab->is_vxworks + && (r_type == R_MIPS_CALL_HI16 + || r_type == R_MIPS_CALL_LO16 + || r_type == R_MIPS_CALL16)) { - /* This is a static link or a -Bsymbolic link. The - symbol is defined locally, or was forced to be local. - We must initialize this entry in the GOT. */ - bfd *tmpbfd = elf_hash_table (info)->dynobj; - asection *sgot = mips_elf_got_section (tmpbfd, FALSE); - MIPS_ELF_PUT_WORD (tmpbfd, symbol, sgot->contents + g); + BFD_ASSERT (addend == 0); + BFD_ASSERT (h->root.needs_plt); + g = mips_elf_gotplt_index (info, &h->root); + } + else + { + /* GOT_PAGE may take a non-zero addend, that is ignored in a + GOT_PAGE relocation that decays to GOT_DISP because the + symbol turns out to be global. The addend is then added + as GOT_OFST. */ + BFD_ASSERT (addend == 0 || r_type == R_MIPS_GOT_PAGE); + g = mips_elf_global_got_index (dynobj, input_bfd, + &h->root, r_type, info); + if (h->tls_type == GOT_NORMAL + && (! elf_hash_table(info)->dynamic_sections_created + || (info->shared + && (info->symbolic || h->root.forced_local) + && h->root.def_regular))) + { + /* This is a static link or a -Bsymbolic link. The + symbol is defined locally, or was forced to be local. + We must initialize this entry in the GOT. */ + asection *sgot = mips_elf_got_section (dynobj, FALSE); + MIPS_ELF_PUT_WORD (dynobj, symbol, sgot->contents + g); + } } } - else if (r_type == R_MIPS_GOT16 || r_type == R_MIPS_CALL16) - /* There's no need to create a local GOT entry here; the - calculation for a local GOT16 entry does not involve G. */ + else if (!htab->is_vxworks + && (r_type == R_MIPS_CALL16 || (r_type == R_MIPS_GOT16))) + /* The calculation below does not involve "g". */ break; else { - g = mips_elf_local_got_index (abfd, input_bfd, - info, symbol + addend, r_symndx, h, - r_type); + g = mips_elf_local_got_index (abfd, input_bfd, info, sec, + symbol + addend, r_symndx, h, r_type); if (g == MINUS_ONE) return bfd_reloc_outofrange; } /* Convert GOT indices to actual offsets. */ - g = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj, - abfd, input_bfd, g); + g = mips_elf_got_offset_from_index (dynobj, abfd, input_bfd, g); break; case R_MIPS_HI16: @@ -3973,10 +4199,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, case R_MIPS16_GPREL: gp0 = _bfd_get_gp_value (input_bfd); gp = _bfd_get_gp_value (abfd); - if (elf_hash_table (info)->dynobj) - gp += mips_elf_adjust_gp (abfd, - mips_elf_got_info - (elf_hash_table (info)->dynobj, NULL), + if (dynobj) + gp += mips_elf_adjust_gp (abfd, mips_elf_got_info (dynobj, NULL), input_bfd); break; @@ -3987,6 +4211,27 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, if (gnu_local_gp_p) symbol = gp; + /* Relocations against the VxWorks __GOTT_BASE__ and __GOTT_INDEX__ + symbols are resolved by the loader. Add them to .rela.dyn. */ + if (h != NULL && is_gott_symbol (info, &h->root)) + { + Elf_Internal_Rela outrel; + bfd_byte *loc; + asection *s; + + s = mips_elf_rel_dyn_section (info, FALSE); + loc = s->contents + s->reloc_count++ * sizeof (Elf32_External_Rela); + + outrel.r_offset = (input_section->output_section->vma + + input_section->output_offset + + relocation->r_offset); + outrel.r_info = ELF32_R_INFO (h->root.dynindx, r_type); + outrel.r_addend = addend; + bfd_elf32_swap_reloca_out (abfd, &outrel, loc); + *valuep = 0; + return bfd_reloc_ok; + } + /* Figure out what kind of relocation is being performed. */ switch (r_type) { @@ -4002,7 +4247,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, case R_MIPS_REL32: case R_MIPS_64: if ((info->shared - || (elf_hash_table (info)->dynamic_sections_created + || (!htab->is_vxworks + && htab->root.dynamic_sections_created && h != NULL && h->root.def_dynamic && !h->root.def_regular)) @@ -4013,7 +4259,11 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, against a symbol in a shared library, then we can't know where the symbol will end up. So, we create a relocation record in the output, and leave the job up to the dynamic - linker. */ + linker. + + In VxWorks executables, references to external symbols + are handled using copy relocs or PLT stubs, so there's + no need to add a dynamic relocation here. */ value = addend; if (!mips_elf_create_dynamic_relocation (abfd, info, @@ -4165,22 +4415,20 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, case R_MIPS_GOT16: case R_MIPS_CALL16: - if (local_p) + /* VxWorks does not have separate local and global semantics for + R_MIPS_GOT16; every relocation evaluates to "G". */ + if (!htab->is_vxworks && local_p) { bfd_boolean forced; - /* The special case is when the symbol is forced to be local. We - need the full address in the GOT since no R_MIPS_LO16 relocation - follows. */ forced = ! mips_elf_local_relocation_p (input_bfd, relocation, local_sections, FALSE); - value = mips_elf_got16_entry (abfd, input_bfd, info, + value = mips_elf_got16_entry (abfd, input_bfd, info, sec, symbol + addend, forced); if (value == MINUS_ONE) return bfd_reloc_outofrange; value - = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj, - abfd, input_bfd, value); + = mips_elf_got_offset_from_index (dynobj, abfd, input_bfd, value); overflowed_p = mips_elf_overflow_p (value, 16); break; } @@ -4230,17 +4478,18 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd, 0. */ if (! local_p) goto got_disp; - value = mips_elf_got_page (abfd, input_bfd, info, symbol + addend, NULL); + value = mips_elf_got_page (abfd, input_bfd, info, sec, + symbol + addend, NULL); if (value == MINUS_ONE) return bfd_reloc_outofrange; - value = mips_elf_got_offset_from_index (elf_hash_table (info)->dynobj, - abfd, input_bfd, value); + value = mips_elf_got_offset_from_index (dynobj, abfd, input_bfd, value); overflowed_p = mips_elf_overflow_p (value, 16); break; case R_MIPS_GOT_OFST: if (local_p) - mips_elf_got_page (abfd, input_bfd, info, symbol + addend, &value); + mips_elf_got_page (abfd, input_bfd, info, sec, + symbol + addend, &value); else value = addend; overflowed_p = mips_elf_overflow_p (value, 16); @@ -4425,23 +4674,31 @@ mips_elf_stub_section_p (bfd *abfd ATTRIBUTE_UNUSED, asection *section) || strncmp (name, CALL_FP_STUB, sizeof CALL_FP_STUB - 1) == 0); } -/* Add room for N relocations to the .rel.dyn section in ABFD. */ +/* Add room for N relocations to the .rel(a).dyn section in ABFD. */ static void -mips_elf_allocate_dynamic_relocations (bfd *abfd, unsigned int n) +mips_elf_allocate_dynamic_relocations (bfd *abfd, struct bfd_link_info *info, + unsigned int n) { asection *s; + struct mips_elf_link_hash_table *htab; - s = mips_elf_rel_dyn_section (abfd, FALSE); + htab = mips_elf_hash_table (info); + s = mips_elf_rel_dyn_section (info, FALSE); BFD_ASSERT (s != NULL); - if (s->size == 0) + if (htab->is_vxworks) + s->size += n * MIPS_ELF_RELA_SIZE (abfd); + else { - /* Make room for a null element. */ - s->size += MIPS_ELF_REL_SIZE (abfd); - ++s->reloc_count; + if (s->size == 0) + { + /* Make room for a null element. */ + s->size += MIPS_ELF_REL_SIZE (abfd); + ++s->reloc_count; + } + s->size += n * MIPS_ELF_REL_SIZE (abfd); } - s->size += n * MIPS_ELF_REL_SIZE (abfd); } /* Create a rel.dyn relocation for the dynamic linker to resolve. REL @@ -4463,10 +4720,12 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd, int r_type; long indx; bfd_boolean defined_p; + struct mips_elf_link_hash_table *htab; + htab = mips_elf_hash_table (info); r_type = ELF_R_TYPE (output_bfd, rel->r_info); dynobj = elf_hash_table (info)->dynobj; - sreloc = mips_elf_rel_dyn_section (dynobj, FALSE); + sreloc = mips_elf_rel_dyn_section (info, FALSE); BFD_ASSERT (sreloc != NULL); BFD_ASSERT (sreloc->contents != NULL); BFD_ASSERT (sreloc->reloc_count * MIPS_ELF_REL_SIZE (output_bfd) @@ -4551,10 +4810,15 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd, if (defined_p && r_type != R_MIPS_REL32) *addendp += symbol; - /* The relocation is always an REL32 relocation because we don't - know where the shared library will wind up at load-time. */ - outrel[0].r_info = ELF_R_INFO (output_bfd, (unsigned long) indx, - R_MIPS_REL32); + if (htab->is_vxworks) + /* VxWorks uses non-relative relocations for this. */ + outrel[0].r_info = ELF32_R_INFO (indx, R_MIPS_32); + else + /* The relocation is always an REL32 relocation because we don't + know where the shared library will wind up at load-time. */ + outrel[0].r_info = ELF_R_INFO (output_bfd, (unsigned long) indx, + R_MIPS_REL32); + /* For strict adherence to the ABI specification, we should generate a R_MIPS_64 relocation record by itself before the _REL32/_64 record as well, such that the addend is read in as @@ -4592,6 +4856,15 @@ mips_elf_create_dynamic_relocation (bfd *output_bfd, (sreloc->contents + sreloc->reloc_count * sizeof (Elf64_Mips_External_Rel))); } + else if (htab->is_vxworks) + { + /* VxWorks uses RELA rather than REL dynamic relocations. */ + outrel[0].r_addend = *addendp; + bfd_elf32_swap_reloca_out + (output_bfd, &outrel[0], + (sreloc->contents + + sreloc->reloc_count * sizeof (Elf32_External_Rela))); + } else bfd_elf32_swap_reloc_out (output_bfd, &outrel[0], @@ -5608,23 +5881,29 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) flagword flags; register asection *s; const char * const *namep; + struct mips_elf_link_hash_table *htab; + htab = mips_elf_hash_table (info); flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED | SEC_READONLY); - /* Mips ABI requests the .dynamic section to be read only. */ - s = bfd_get_section_by_name (abfd, ".dynamic"); - if (s != NULL) + /* The psABI requires a read-only .dynamic section, but the VxWorks + EABI doesn't. */ + if (!htab->is_vxworks) { - if (! bfd_set_section_flags (abfd, s, flags)) - return FALSE; + s = bfd_get_section_by_name (abfd, ".dynamic"); + if (s != NULL) + { + if (! bfd_set_section_flags (abfd, s, flags)) + return FALSE; + } } /* We need to create .got section. */ if (! mips_elf_create_got_section (abfd, info, FALSE)) return FALSE; - if (! mips_elf_rel_dyn_section (elf_hash_table (info)->dynobj, TRUE)) + if (! mips_elf_rel_dyn_section (info, TRUE)) return FALSE; /* Create .stub section. */ @@ -5745,6 +6024,45 @@ _bfd_mips_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info) } } + if (htab->is_vxworks) + { + /* Create the .plt, .rela.plt, .dynbss and .rela.bss sections. + Also create the _PROCEDURE_LINKAGE_TABLE symbol. */ + if (!_bfd_elf_create_dynamic_sections (abfd, info)) + return FALSE; + + /* Cache the sections created above. */ + htab->sdynbss = bfd_get_section_by_name (abfd, ".dynbss"); + htab->srelbss = bfd_get_section_by_name (abfd, ".rela.bss"); + htab->srelplt = bfd_get_section_by_name (abfd, ".rela.plt"); + htab->splt = bfd_get_section_by_name (abfd, ".plt"); + if (!htab->sdynbss + || (!htab->srelbss && !info->shared) + || !htab->srelplt + || !htab->splt) + abort (); + + /* Do the usual VxWorks handling. */ + if (!elf_vxworks_create_dynamic_sections (abfd, info, &htab->srelplt2)) + return FALSE; + + /* Work out the PLT sizes. */ + if (info->shared) + { + htab->plt_header_size + = 4 * ARRAY_SIZE (mips_vxworks_shared_plt0_entry); + htab->plt_entry_size + = 4 * ARRAY_SIZE (mips_vxworks_shared_plt_entry); + } + else + { + htab->plt_header_size + = 4 * ARRAY_SIZE (mips_vxworks_exec_plt0_entry); + htab->plt_entry_size + = 4 * ARRAY_SIZE (mips_vxworks_exec_plt_entry); + } + } + return TRUE; } @@ -5766,10 +6084,12 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sgot; asection *sreloc; const struct elf_backend_data *bed; + struct mips_elf_link_hash_table *htab; if (info->relocatable) return TRUE; + htab = mips_elf_hash_table (info); dynobj = elf_hash_table (info)->dynobj; symtab_hdr = &elf_tdata (abfd)->symtab_hdr; sym_hashes = elf_sym_hashes (abfd); @@ -6011,13 +6331,24 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, if (! mips_elf_create_got_section (dynobj, info, FALSE)) return FALSE; g = mips_elf_got_info (dynobj, &sgot); + if (htab->is_vxworks && !info->shared) + { + (*_bfd_error_handler) + (_("%B: GOT reloc at 0x%lx not expected in executables"), + abfd, (unsigned long) rel->r_offset); + bfd_set_error (bfd_error_bad_value); + return FALSE; + } break; case R_MIPS_32: case R_MIPS_REL32: case R_MIPS_64: + /* In VxWorks executables, references to external symbols + are handled using copy relocs or PLT stubs, so there's + no need to add a dynamic relocation here. */ if (dynobj == NULL - && (info->shared || h != NULL) + && (info->shared || (h != NULL && !htab->is_vxworks)) && (sec->flags & SEC_ALLOC) != 0) elf_hash_table (info)->dynobj = dynobj = abfd; break; @@ -6027,15 +6358,35 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, } } - if (!h && (r_type == R_MIPS_CALL_LO16 - || r_type == R_MIPS_GOT_LO16 - || r_type == R_MIPS_GOT_DISP)) + if (h) + { + ((struct mips_elf_link_hash_entry *) h)->is_relocation_target = TRUE; + + /* Relocations against the special VxWorks __GOTT_BASE__ and + __GOTT_INDEX__ symbols must be left to the loader. Allocate + room for them in .rela.dyn. */ + if (is_gott_symbol (info, h)) + { + if (sreloc == NULL) + { + sreloc = mips_elf_rel_dyn_section (info, TRUE); + if (sreloc == NULL) + return FALSE; + } + mips_elf_allocate_dynamic_relocations (dynobj, info, 1); + } + } + else if (r_type == R_MIPS_CALL_LO16 + || r_type == R_MIPS_GOT_LO16 + || r_type == R_MIPS_GOT_DISP + || (r_type == R_MIPS_GOT16 && htab->is_vxworks)) { /* We may need a local GOT entry for this relocation. We don't count R_MIPS_GOT_PAGE because we can estimate the maximum number of pages needed by looking at the size of the segment. Similar comments apply to R_MIPS_GOT16 and - R_MIPS_CALL16. We don't count R_MIPS_GOT_HI16, or + R_MIPS_CALL16, except on VxWorks, where GOT relocations + always evaluate to "G". We don't count R_MIPS_GOT_HI16, or R_MIPS_CALL_HI16 because these are always followed by an R_MIPS_GOT_LO16 or R_MIPS_CALL_LO16. */ if (! mips_elf_record_local_got_symbol (abfd, r_symndx, @@ -6060,8 +6411,11 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_MIPS_CALL_LO16: if (h != NULL) { - /* This symbol requires a global offset table entry. */ - if (! mips_elf_record_global_got_symbol (h, abfd, info, g, 0)) + /* VxWorks call relocations point the function's .got.plt + entry, which will be allocated by adjust_dynamic_symbol. + Otherwise, this symbol requires a global GOT entry. */ + if (!htab->is_vxworks + && !mips_elf_record_global_got_symbol (h, abfd, info, g, 0)) return FALSE; /* We need a stub, not a plt entry for the undefined @@ -6147,12 +6501,15 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, case R_MIPS_32: case R_MIPS_REL32: case R_MIPS_64: - if ((info->shared || h != NULL) + /* In VxWorks executables, references to external symbols + are handled using copy relocs or PLT stubs, so there's + no need to add a .rela.dyn entry for this relocation. */ + if ((info->shared || (h != NULL && !htab->is_vxworks)) && (sec->flags & SEC_ALLOC) != 0) { if (sreloc == NULL) { - sreloc = mips_elf_rel_dyn_section (dynobj, TRUE); + sreloc = mips_elf_rel_dyn_section (info, TRUE); if (sreloc == NULL) return FALSE; } @@ -6161,9 +6518,8 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, { /* When creating a shared object, we must copy these reloc types into the output file as R_MIPS_REL32 - relocs. We make room for this reloc in the - .rel.dyn reloc section. */ - mips_elf_allocate_dynamic_relocations (dynobj, 1); + relocs. Make room for this reloc in .rel(a).dyn. */ + mips_elf_allocate_dynamic_relocations (dynobj, info, 1); if ((sec->flags & MIPS_READONLY_SECTION) == MIPS_READONLY_SECTION) /* We tell the dynamic linker that there are @@ -6188,8 +6544,10 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, /* Even though we don't directly need a GOT entry for this symbol, a symbol must have a dynamic symbol table index greater that DT_MIPS_GOTSYM if there are - dynamic relocations against it. */ - if (h != NULL) + dynamic relocations against it. This does not apply + to VxWorks, which does not have the usual coupling + between global GOT entries and .dynsym entries. */ + if (h != NULL && !htab->is_vxworks) { if (dynobj == NULL) elf_hash_table (info)->dynobj = dynobj = abfd; @@ -6206,7 +6564,16 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, sizeof (Elf32_External_crinfo); break; + case R_MIPS_PC16: + if (h) + ((struct mips_elf_link_hash_entry *) h)->is_branch_target = TRUE; + break; + case R_MIPS_26: + if (h) + ((struct mips_elf_link_hash_entry *) h)->is_branch_target = TRUE; + /* Fall through. */ + case R_MIPS_GPREL16: case R_MIPS_LITERAL: case R_MIPS_GPREL32: @@ -6234,24 +6601,21 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, } /* We must not create a stub for a symbol that has relocations - related to taking the function's address. */ - switch (r_type) - { - default: - if (h != NULL) - { - struct mips_elf_link_hash_entry *mh; - - mh = (struct mips_elf_link_hash_entry *) h; - mh->no_fn_stub = TRUE; - } - break; - case R_MIPS_CALL16: - case R_MIPS_CALL_HI16: - case R_MIPS_CALL_LO16: - case R_MIPS_JALR: - break; - } + related to taking the function's address. This doesn't apply to + VxWorks, where CALL relocs refer to a .got.plt entry instead of + a normal .got entry. */ + if (!htab->is_vxworks && h != NULL) + switch (r_type) + { + default: + ((struct mips_elf_link_hash_entry *) h)->no_fn_stub = TRUE; + break; + case R_MIPS_CALL16: + case R_MIPS_CALL_HI16: + case R_MIPS_CALL_LO16: + case R_MIPS_JALR: + break; + } /* If this reloc is not a 16 bit call, and it has a global symbol, then we will need the fn_stub if there is one. @@ -6478,8 +6842,8 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, && (h->root.type == bfd_link_hash_defweak || !h->def_regular)) { - mips_elf_allocate_dynamic_relocations (dynobj, - hmips->possibly_dynamic_relocs); + mips_elf_allocate_dynamic_relocations + (dynobj, info, hmips->possibly_dynamic_relocs); if (hmips->readonly_reloc) /* We tell the dynamic linker that there are relocations against the text segment. */ @@ -6544,6 +6908,160 @@ _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *info, return TRUE; } + +/* Likewise, for VxWorks. */ + +bfd_boolean +_bfd_mips_vxworks_adjust_dynamic_symbol (struct bfd_link_info *info, + struct elf_link_hash_entry *h) +{ + bfd *dynobj; + struct mips_elf_link_hash_entry *hmips; + struct mips_elf_link_hash_table *htab; + unsigned int power_of_two; + + htab = mips_elf_hash_table (info); + dynobj = elf_hash_table (info)->dynobj; + hmips = (struct mips_elf_link_hash_entry *) h; + + /* Make sure we know what is going on here. */ + BFD_ASSERT (dynobj != NULL + && (h->needs_plt + || h->needs_copy + || h->u.weakdef != NULL + || (h->def_dynamic + && h->ref_regular + && !h->def_regular))); + + /* If the symbol is defined by a dynamic object, we need a PLT stub if + either (a) we want to branch to the symbol or (b) we're linking an + executable that needs a canonical function address. In the latter + case, the canonical address will be the address of the executable's + load stub. */ + if ((hmips->is_branch_target + || (!info->shared + && h->type == STT_FUNC + && hmips->is_relocation_target)) + && h->def_dynamic + && h->ref_regular + && !h->def_regular + && !h->forced_local) + h->needs_plt = 1; + + /* Locally-binding symbols do not need a PLT stub; we can refer to + the functions directly. */ + else if (h->needs_plt + && (SYMBOL_CALLS_LOCAL (info, h) + || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT + && h->root.type == bfd_link_hash_undefweak))) + { + h->needs_plt = 0; + return TRUE; + } + + if (h->needs_plt) + { + /* If this is the first symbol to need a PLT entry, allocate room + for the header, and for the header's .rela.plt.unloaded entries. */ + if (htab->splt->size == 0) + { + htab->splt->size += htab->plt_header_size; + if (!info->shared) + htab->srelplt2->size += 2 * sizeof (Elf32_External_Rela); + } + + /* Assign the next .plt entry to this symbol. */ + h->plt.offset = htab->splt->size; + htab->splt->size += htab->plt_entry_size; + + /* If the output file has no definition of the symbol, set the + symbol's value to the address of the stub. For executables, + point at the PLT load stub rather than the lazy resolution stub; + this stub will become the canonical function address. */ + if (!h->def_regular) + { + h->root.u.def.section = htab->splt; + h->root.u.def.value = h->plt.offset; + if (!info->shared) + h->root.u.def.value += 8; + } + + /* Make room for the .got.plt entry and the R_JUMP_SLOT relocation. */ + htab->sgotplt->size += 4; + htab->srelplt->size += sizeof (Elf32_External_Rela); + + /* Make room for the .rela.plt.unloaded relocations. */ + if (!info->shared) + htab->srelplt2->size += 3 * sizeof (Elf32_External_Rela); + + return TRUE; + } + + /* If a function symbol is defined by a dynamic object, and we do not + need a PLT stub for it, the symbol's value should be zero. */ + if (h->type == STT_FUNC + && h->def_dynamic + && h->ref_regular + && !h->def_regular) + { + h->root.u.def.value = 0; + return TRUE; + } + + /* If this is a weak symbol, and there is a real definition, the + processor independent code will have arranged for us to see the + real definition first, and we can just use the same value. */ + if (h->u.weakdef != NULL) + { + BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined + || h->u.weakdef->root.type == bfd_link_hash_defweak); + h->root.u.def.section = h->u.weakdef->root.u.def.section; + h->root.u.def.value = h->u.weakdef->root.u.def.value; + return TRUE; + } + + /* This is a reference to a symbol defined by a dynamic object which + is not a function. */ + if (info->shared) + return TRUE; + + /* We must allocate the symbol in our .dynbss section, which will + become part of the .bss section of the executable. There will be + an entry for this symbol in the .dynsym section. The dynamic + object will contain position independent code, so all references + from the dynamic object to this symbol will go through the global + offset table. The dynamic linker will use the .dynsym entry to + determine the address it must put in the global offset table, so + both the dynamic object and the regular object will refer to the + same memory location for the variable. */ + + if ((h->root.u.def.section->flags & SEC_ALLOC) != 0) + { + htab->srelbss->size += sizeof (Elf32_External_Rela); + h->needs_copy = 1; + } + + /* We need to figure out the alignment required for this symbol. */ + power_of_two = bfd_log2 (h->size); + if (power_of_two > 4) + power_of_two = 4; + + /* Apply the required alignment. */ + htab->sdynbss->size = BFD_ALIGN (htab->sdynbss->size, + (bfd_size_type) 1 << power_of_two); + if (power_of_two > bfd_get_section_alignment (dynobj, htab->sdynbss) + && !bfd_set_section_alignment (dynobj, htab->sdynbss, power_of_two)) + return FALSE; + + /* Define the symbol as being at this point in the section. */ + h->root.u.def.section = htab->sdynbss; + h->root.u.def.value = htab->sdynbss->size; + + /* Increment the section size to make room for the symbol. */ + htab->sdynbss->size += h->size; + + return TRUE; +} /* This function is called after all the input files have been read, and the input sections have been assigned to output sections. We @@ -6563,6 +7081,9 @@ _bfd_mips_elf_always_size_sections (bfd *output_bfd, bfd_size_type local_gotno; bfd *sub; struct mips_elf_count_tls_arg count_tls_arg; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); /* The .reginfo section has a fixed size. */ ri = bfd_get_section_by_name (output_bfd, ".reginfo"); @@ -6621,9 +7142,15 @@ _bfd_mips_elf_always_size_sections (bfd *output_bfd, rld. */ loadable_size += MIPS_FUNCTION_STUB_SIZE * (i + 1); - /* Assume there are two loadable segments consisting of - contiguous sections. Is 5 enough? */ - local_gotno = (loadable_size >> 16) + 5; + if (htab->is_vxworks) + /* There's no need to allocate page entries for VxWorks; R_MIPS_GOT16 + relocations against local symbols evaluate to "G", and the EABI does + not include R_MIPS_GOT_PAGE. */ + local_gotno = 0; + else + /* Assume there are two loadable segments consisting of contiguous + sections. Is 5 enough? */ + local_gotno = (loadable_size >> 16) + 5; g->local_gotno += local_gotno; s->size += g->local_gotno * MIPS_ELF_GOT_SIZE (output_bfd); @@ -6644,7 +7171,10 @@ _bfd_mips_elf_always_size_sections (bfd *output_bfd, mips_elf_resolve_final_got_entries (g); - if (s->size > MIPS_ELF_GOT_MAX_SIZE (output_bfd)) + /* VxWorks does not support multiple GOTs. It initializes $gp to + __GOTT_BASE__[__GOTT_INDEX__], the value of which is set by the + dynamic loader. */ + if (!htab->is_vxworks && s->size > MIPS_ELF_GOT_MAX_SIZE (info)) { if (! mips_elf_multi_got (output_bfd, info, g, s, local_gotno)) return FALSE; @@ -6666,9 +7196,11 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) { bfd *dynobj; - asection *s; + asection *s, *sreldyn; bfd_boolean reltext; + struct mips_elf_link_hash_table *htab; + htab = mips_elf_hash_table (info); dynobj = elf_hash_table (info)->dynobj; BFD_ASSERT (dynobj != NULL); @@ -6690,6 +7222,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, determined the sizes of the various dynamic sections. Allocate memory for them. */ reltext = FALSE; + sreldyn = NULL; for (s = dynobj->sections; s != NULL; s = s->next) { const char *name; @@ -6710,7 +7243,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, /* If this relocation section applies to a read only section, then we probably need a DT_TEXTREL entry. - If the relocation section is .rel.dyn, we always + If the relocation section is .rel(a).dyn, we always assert a DT_TEXTREL entry rather than testing whether there exists a relocation to a read only section or not. */ @@ -6720,12 +7253,12 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, if ((target != NULL && (target->flags & SEC_READONLY) != 0 && (target->flags & SEC_ALLOC) != 0) - || strcmp (outname, ".rel.dyn") == 0) + || strcmp (outname, MIPS_ELF_REL_DYN_NAME (info)) == 0) reltext = TRUE; /* We use the reloc_count field as a counter if we need to copy relocs into the output file. */ - if (strcmp (name, ".rel.dyn") != 0) + if (strcmp (name, MIPS_ELF_REL_DYN_NAME (info)) != 0) s->reloc_count = 0; /* If combreloc is enabled, elf_link_sort_relocs() will @@ -6737,7 +7270,23 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, info->combreloc = 0; } } - else if (strncmp (name, ".got", 4) == 0) + else if (htab->is_vxworks && strcmp (name, ".got") == 0) + { + /* Executables do not need a GOT. */ + if (info->shared) + { + /* Allocate relocations for all but the reserved entries. */ + struct mips_got_info *g; + unsigned int count; + + g = mips_elf_got_info (dynobj, NULL); + count = (g->global_gotno + + g->local_gotno + - MIPS_RESERVED_GOTNO (info)); + mips_elf_allocate_dynamic_relocations (dynobj, info, count); + } + } + else if (!htab->is_vxworks && strncmp (name, ".got", 4) == 0) { /* _bfd_mips_elf_always_size_sections() has already done most of the work, but some symbols may have been mapped @@ -6782,7 +7331,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, BFD_ASSERT (g->assigned_gotno == g->next->local_gotno + g->next->global_gotno + g->next->tls_gotno - + MIPS_RESERVED_GOTNO); + + MIPS_RESERVED_GOTNO (info)); } } } @@ -6802,7 +7351,8 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, } if (needed_relocs) - mips_elf_allocate_dynamic_relocations (dynobj, needed_relocs); + mips_elf_allocate_dynamic_relocations (dynobj, info, + needed_relocs); } else if (strcmp (name, MIPS_ELF_STUB_SECTION_NAME (output_bfd)) == 0) { @@ -6821,7 +7371,9 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, else if (SGI_COMPAT (output_bfd) && strncmp (name, ".compact_rel", 12) == 0) s->size += mips_elf_hash_table (info)->compact_rel_size; - else if (strncmp (name, ".init", 5) != 0) + else if (strncmp (name, ".init", 5) != 0 + && s != htab->sgotplt + && s != htab->splt) { /* It's not one of our sections, so don't allocate space. */ continue; @@ -6836,6 +7388,14 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, if ((s->flags & SEC_HAS_CONTENTS) == 0) continue; + /* Allocate memory for this section last, since we may increase its + size above. */ + if (strcmp (name, MIPS_ELF_REL_DYN_NAME (info)) == 0) + { + sreldyn = s; + continue; + } + /* Allocate memory for the section contents. */ s->contents = bfd_zalloc (dynobj, s->size); if (s->contents == NULL) @@ -6845,6 +7405,17 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, } } + /* Allocate memory for the .rel(a).dyn section. */ + if (sreldyn != NULL) + { + sreldyn->contents = bfd_zalloc (dynobj, sreldyn->size); + if (sreldyn->contents == NULL) + { + bfd_set_error (bfd_error_no_memory); + return FALSE; + } + } + if (elf_hash_table (info)->dynamic_sections_created) { /* Add some entries to the .dynamic section. We fill in the @@ -6874,7 +7445,7 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, } } - if (reltext && SGI_COMPAT (output_bfd)) + if (reltext && (SGI_COMPAT (output_bfd) || htab->is_vxworks)) info->flags |= DF_TEXTREL; if ((info->flags & DF_TEXTREL) != 0) @@ -6886,53 +7457,125 @@ _bfd_mips_elf_size_dynamic_sections (bfd *output_bfd, if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTGOT, 0)) return FALSE; - if (mips_elf_rel_dyn_section (dynobj, FALSE)) + if (htab->is_vxworks) { - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0)) - return FALSE; + /* VxWorks uses .rela.dyn instead of .rel.dyn. It does not + use any of the DT_MIPS_* tags. */ + if (mips_elf_rel_dyn_section (info, FALSE)) + { + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELA, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELASZ, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELAENT, 0)) + return FALSE; + } + if (htab->splt->size > 0) + { + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTREL, 0)) + return FALSE; + + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_JMPREL, 0)) + return FALSE; + + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTRELSZ, 0)) + return FALSE; + } } + else + { + if (mips_elf_rel_dyn_section (info, FALSE)) + { + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_VERSION, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_FLAGS, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0)) + return FALSE; + } - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_BASE_ADDRESS, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_RLD_VERSION, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LOCAL_GOTNO, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_FLAGS, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_SYMTABNO, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_BASE_ADDRESS, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_UNREFEXTNO, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_LOCAL_GOTNO, 0)) + return FALSE; - if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_GOTSYM, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_SYMTABNO, 0)) + return FALSE; - if (IRIX_COMPAT (dynobj) == ict_irix5 - && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_UNREFEXTNO, 0)) + return FALSE; - if (IRIX_COMPAT (dynobj) == ict_irix6 - && (bfd_get_section_by_name - (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj))) - && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0)) - return FALSE; + if (! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_GOTSYM, 0)) + return FALSE; + + if (IRIX_COMPAT (dynobj) == ict_irix5 + && ! MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_HIPAGENO, 0)) + return FALSE; + + if (IRIX_COMPAT (dynobj) == ict_irix6 + && (bfd_get_section_by_name + (dynobj, MIPS_ELF_OPTIONS_SECTION_NAME (dynobj))) + && !MIPS_ELF_ADD_DYNAMIC_ENTRY (info, DT_MIPS_OPTIONS, 0)) + return FALSE; + } } return TRUE; } +/* REL is a relocation in INPUT_BFD that is being copied to OUTPUT_BFD. + Adjust its R_ADDEND field so that it is correct for the output file. + LOCAL_SYMS and LOCAL_SECTIONS are arrays of INPUT_BFD's local symbols + and sections respectively; both use symbol indexes. */ + +static void +mips_elf_adjust_addend (bfd *output_bfd, struct bfd_link_info *info, + bfd *input_bfd, Elf_Internal_Sym *local_syms, + asection **local_sections, Elf_Internal_Rela *rel) +{ + unsigned int r_type, r_symndx; + Elf_Internal_Sym *sym; + asection *sec; + + if (mips_elf_local_relocation_p (input_bfd, rel, local_sections, FALSE)) + { + r_type = ELF_R_TYPE (output_bfd, rel->r_info); + if (r_type == R_MIPS16_GPREL + || r_type == R_MIPS_GPREL16 + || r_type == R_MIPS_GPREL32 + || r_type == R_MIPS_LITERAL) + { + rel->r_addend += _bfd_get_gp_value (input_bfd); + rel->r_addend -= _bfd_get_gp_value (output_bfd); + } + + r_symndx = ELF_R_SYM (output_bfd, rel->r_info); + sym = local_syms + r_symndx; + + /* Adjust REL's addend to account for section merging. */ + if (!info->relocatable) + { + sec = local_sections[r_symndx]; + _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); + } + + /* This would normally be done by the rela_normal code in elflink.c. */ + if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) + rel->r_addend += local_sections[r_symndx]->output_offset; + } +} + /* Relocate a MIPS ELF section. */ bfd_boolean @@ -7083,47 +7726,19 @@ _bfd_mips_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, } else addend = rel->r_addend; + mips_elf_adjust_addend (output_bfd, info, input_bfd, + local_syms, local_sections, rel); } if (info->relocatable) { - Elf_Internal_Sym *sym; - unsigned long r_symndx; - if (r_type == R_MIPS_64 && ! NEWABI_P (output_bfd) && bfd_big_endian (input_bfd)) rel->r_offset -= 4; - /* Since we're just relocating, all we need to do is copy - the relocations back out to the object file, unless - they're against a section symbol, in which case we need - to adjust by the section offset, or unless they're GP - relative in which case we need to adjust by the amount - that we're adjusting GP in this relocatable object. */ - - if (! mips_elf_local_relocation_p (input_bfd, rel, local_sections, - FALSE)) - /* There's nothing to do for non-local relocations. */ - continue; - - if (r_type == R_MIPS16_GPREL - || r_type == R_MIPS_GPREL16 - || r_type == R_MIPS_GPREL32 - || r_type == R_MIPS_LITERAL) - addend -= (_bfd_get_gp_value (output_bfd) - - _bfd_get_gp_value (input_bfd)); - - r_symndx = ELF_R_SYM (output_bfd, rel->r_info); - sym = local_syms + r_symndx; - if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) - /* Adjust the addend appropriately. */ - addend += local_sections[r_symndx]->output_offset; - - if (rela_relocation_p) - /* If this is a RELA relocation, just update the addend. */ - rel->r_addend = addend; - else + if (!rela_relocation_p && rel->r_addend) { + addend += rel->r_addend; if (r_type == R_MIPS_HI16 || r_type == R_MIPS_GOT16) addend = mips_elf_high (addend); @@ -7569,6 +8184,268 @@ _bfd_mips_elf_finish_dynamic_symbol (bfd *output_bfd, return TRUE; } +/* Likewise, for VxWorks. */ + +bfd_boolean +_bfd_mips_vxworks_finish_dynamic_symbol (bfd *output_bfd, + struct bfd_link_info *info, + struct elf_link_hash_entry *h, + Elf_Internal_Sym *sym) +{ + bfd *dynobj; + asection *sgot; + struct mips_got_info *g; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); + dynobj = elf_hash_table (info)->dynobj; + + if (h->plt.offset != (bfd_vma) -1) + { + bfd_byte *loc; + bfd_vma plt_address, plt_index, got_address, got_offset, branch_offset; + Elf_Internal_Rela rel; + static const bfd_vma *plt_entry; + + BFD_ASSERT (h->dynindx != -1); + BFD_ASSERT (htab->splt != NULL); + BFD_ASSERT (h->plt.offset <= htab->splt->size); + + /* Calculate the address of the .plt entry. */ + plt_address = (htab->splt->output_section->vma + + htab->splt->output_offset + + h->plt.offset); + + /* Calculate the index of the entry. */ + plt_index = ((h->plt.offset - htab->plt_header_size) + / htab->plt_entry_size); + + /* Calculate the address of the .got.plt entry. */ + got_address = (htab->sgotplt->output_section->vma + + htab->sgotplt->output_offset + + plt_index * 4); + + /* Calculate the offset of the .got.plt entry from + _GLOBAL_OFFSET_TABLE_. */ + got_offset = mips_elf_gotplt_index (info, h); + + /* Calculate the offset for the branch at the start of the PLT + entry. The branch jumps to the beginning of .plt. */ + branch_offset = -(h->plt.offset / 4 + 1) & 0xffff; + + /* Fill in the initial value of the .got.plt entry. */ + bfd_put_32 (output_bfd, plt_address, + htab->sgotplt->contents + plt_index * 4); + + /* Find out where the .plt entry should go. */ + loc = htab->splt->contents + h->plt.offset; + + if (info->shared) + { + plt_entry = mips_vxworks_shared_plt_entry; + bfd_put_32 (output_bfd, plt_entry[0] | branch_offset, loc); + bfd_put_32 (output_bfd, plt_entry[1] | plt_index, loc + 4); + } + else + { + bfd_vma got_address_high, got_address_low; + + plt_entry = mips_vxworks_exec_plt_entry; + got_address_high = ((got_address + 0x8000) >> 16) & 0xffff; + got_address_low = got_address & 0xffff; + + bfd_put_32 (output_bfd, plt_entry[0] | branch_offset, loc); + bfd_put_32 (output_bfd, plt_entry[1] | plt_index, loc + 4); + bfd_put_32 (output_bfd, plt_entry[2] | got_address_high, loc + 8); + bfd_put_32 (output_bfd, plt_entry[3] | got_address_low, loc + 12); + bfd_put_32 (output_bfd, plt_entry[4], loc + 16); + bfd_put_32 (output_bfd, plt_entry[5], loc + 20); + bfd_put_32 (output_bfd, plt_entry[6], loc + 24); + bfd_put_32 (output_bfd, plt_entry[7], loc + 28); + + loc = (htab->srelplt2->contents + + (plt_index * 3 + 2) * sizeof (Elf32_External_Rela)); + + /* Emit a relocation for the .got.plt entry. */ + rel.r_offset = got_address; + rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_MIPS_32); + rel.r_addend = h->plt.offset; + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + + /* Emit a relocation for the lui of %hi(<.got.plt slot>). */ + loc += sizeof (Elf32_External_Rela); + rel.r_offset = plt_address + 8; + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_MIPS_HI16); + rel.r_addend = got_offset; + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + + /* Emit a relocation for the addiu of %lo(<.got.plt slot>). */ + loc += sizeof (Elf32_External_Rela); + rel.r_offset += 4; + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_MIPS_LO16); + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + } + + /* Emit an R_MIPS_JUMP_SLOT relocation against the .got.plt entry. */ + loc = htab->srelplt->contents + plt_index * sizeof (Elf32_External_Rela); + rel.r_offset = got_address; + rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_JUMP_SLOT); + rel.r_addend = 0; + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + + if (!h->def_regular) + sym->st_shndx = SHN_UNDEF; + } + + BFD_ASSERT (h->dynindx != -1 || h->forced_local); + + sgot = mips_elf_got_section (dynobj, FALSE); + BFD_ASSERT (sgot != NULL); + BFD_ASSERT (mips_elf_section_data (sgot) != NULL); + g = mips_elf_section_data (sgot)->u.got_info; + BFD_ASSERT (g != NULL); + + /* See if this symbol has an entry in the GOT. */ + if (g->global_gotsym != NULL + && h->dynindx >= g->global_gotsym->dynindx) + { + bfd_vma offset; + Elf_Internal_Rela outrel; + bfd_byte *loc; + asection *s; + + /* Install the symbol value in the GOT. */ + offset = mips_elf_global_got_index (dynobj, output_bfd, h, + R_MIPS_GOT16, info); + MIPS_ELF_PUT_WORD (output_bfd, sym->st_value, sgot->contents + offset); + + /* Add a dynamic relocation for it. */ + s = mips_elf_rel_dyn_section (info, FALSE); + loc = s->contents + (s->reloc_count++ * sizeof (Elf32_External_Rela)); + outrel.r_offset = (sgot->output_section->vma + + sgot->output_offset + + offset); + outrel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_32); + outrel.r_addend = 0; + bfd_elf32_swap_reloca_out (dynobj, &outrel, loc); + } + + /* Emit a copy reloc, if needed. */ + if (h->needs_copy) + { + Elf_Internal_Rela rel; + + BFD_ASSERT (h->dynindx != -1); + + rel.r_offset = (h->root.u.def.section->output_section->vma + + h->root.u.def.section->output_offset + + h->root.u.def.value); + rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_COPY); + rel.r_addend = 0; + bfd_elf32_swap_reloca_out (output_bfd, &rel, + htab->srelbss->contents + + (htab->srelbss->reloc_count + * sizeof (Elf32_External_Rela))); + ++htab->srelbss->reloc_count; + } + + /* If this is a mips16 symbol, force the value to be even. */ + if (sym->st_other == STO_MIPS16) + sym->st_value &= ~1; + + return TRUE; +} + +/* Install the PLT header for a VxWorks executable and finalize the + contents of .rela.plt.unloaded. */ + +static void +mips_vxworks_finish_exec_plt (bfd *output_bfd, struct bfd_link_info *info) +{ + Elf_Internal_Rela rela; + bfd_byte *loc; + bfd_vma got_value, got_value_high, got_value_low, plt_address; + static const bfd_vma *plt_entry; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); + plt_entry = mips_vxworks_exec_plt0_entry; + + /* Calculate the value of _GLOBAL_OFFSET_TABLE_. */ + got_value = (htab->root.hgot->root.u.def.section->output_section->vma + + htab->root.hgot->root.u.def.section->output_offset + + htab->root.hgot->root.u.def.value); + + got_value_high = ((got_value + 0x8000) >> 16) & 0xffff; + got_value_low = got_value & 0xffff; + + /* Calculate the address of the PLT header. */ + plt_address = htab->splt->output_section->vma + htab->splt->output_offset; + + /* Install the PLT header. */ + loc = htab->splt->contents; + bfd_put_32 (output_bfd, plt_entry[0] | got_value_high, loc); + bfd_put_32 (output_bfd, plt_entry[1] | got_value_low, loc + 4); + bfd_put_32 (output_bfd, plt_entry[2], loc + 8); + bfd_put_32 (output_bfd, plt_entry[3], loc + 12); + bfd_put_32 (output_bfd, plt_entry[4], loc + 16); + bfd_put_32 (output_bfd, plt_entry[5], loc + 20); + + /* Output the relocation for the lui of %hi(_GLOBAL_OFFSET_TABLE_). */ + loc = htab->srelplt2->contents; + rela.r_offset = plt_address; + rela.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_MIPS_HI16); + rela.r_addend = 0; + bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); + loc += sizeof (Elf32_External_Rela); + + /* Output the relocation for the following addiu of + %lo(_GLOBAL_OFFSET_TABLE_). */ + rela.r_offset += 4; + rela.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_MIPS_LO16); + bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); + loc += sizeof (Elf32_External_Rela); + + /* Fix up the remaining relocations. They may have the wrong + symbol index for _G_O_T_ or _P_L_T_ depending on the order + in which symbols were output. */ + while (loc < htab->srelplt2->contents + htab->srelplt2->size) + { + Elf_Internal_Rela rel; + + bfd_elf32_swap_reloca_in (output_bfd, loc, &rel); + rel.r_info = ELF32_R_INFO (htab->root.hplt->indx, R_MIPS_32); + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + loc += sizeof (Elf32_External_Rela); + + bfd_elf32_swap_reloca_in (output_bfd, loc, &rel); + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_MIPS_HI16); + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + loc += sizeof (Elf32_External_Rela); + + bfd_elf32_swap_reloca_in (output_bfd, loc, &rel); + rel.r_info = ELF32_R_INFO (htab->root.hgot->indx, R_MIPS_LO16); + bfd_elf32_swap_reloca_out (output_bfd, &rel, loc); + loc += sizeof (Elf32_External_Rela); + } +} + +/* Install the PLT header for a VxWorks shared library. */ + +static void +mips_vxworks_finish_shared_plt (bfd *output_bfd, struct bfd_link_info *info) +{ + unsigned int i; + struct mips_elf_link_hash_table *htab; + + htab = mips_elf_hash_table (info); + + /* We just need to copy the entry byte-by-byte. */ + for (i = 0; i < ARRAY_SIZE (mips_vxworks_shared_plt0_entry); i++) + bfd_put_32 (output_bfd, mips_vxworks_shared_plt0_entry[i], + htab->splt->contents + i * 4); +} + /* Finish up the dynamic sections. */ bfd_boolean @@ -7579,7 +8456,9 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, asection *sdyn; asection *sgot; struct mips_got_info *gg, *g; + struct mips_elf_link_hash_table *htab; + htab = mips_elf_hash_table (info); dynobj = elf_hash_table (info)->dynobj; sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); @@ -7622,11 +8501,14 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, switch (dyn.d_tag) { case DT_RELENT: - s = mips_elf_rel_dyn_section (dynobj, FALSE); - BFD_ASSERT (s != NULL); dyn.d_un.d_val = MIPS_ELF_REL_SIZE (dynobj); break; + case DT_RELAENT: + BFD_ASSERT (htab->is_vxworks); + dyn.d_un.d_val = MIPS_ELF_RELA_SIZE (dynobj); + break; + case DT_STRSZ: /* Rewrite DT_STRSZ. */ dyn.d_un.d_val = @@ -7635,9 +8517,20 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, case DT_PLTGOT: name = ".got"; - s = bfd_get_section_by_name (output_bfd, name); - BFD_ASSERT (s != NULL); - dyn.d_un.d_ptr = s->vma; + if (htab->is_vxworks) + { + /* _GLOBAL_OFFSET_TABLE_ is defined to be the beginning + of the ".got" section in DYNOBJ. */ + s = bfd_get_section_by_name (dynobj, name); + BFD_ASSERT (s != NULL); + dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; + } + else + { + s = bfd_get_section_by_name (output_bfd, name); + BFD_ASSERT (s != NULL); + dyn.d_un.d_ptr = s->vma; + } break; case DT_MIPS_RLD_VERSION: @@ -7703,7 +8596,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, break; case DT_MIPS_HIPAGENO: - dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO; + dyn.d_un.d_val = g->local_gotno - MIPS_RESERVED_GOTNO (info); break; case DT_MIPS_RLD_MAP: @@ -7716,6 +8609,29 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, dyn.d_un.d_ptr = s->vma; break; + case DT_RELASZ: + BFD_ASSERT (htab->is_vxworks); + /* The count does not include the JUMP_SLOT relocations. */ + if (htab->srelplt) + dyn.d_un.d_val -= htab->srelplt->size; + break; + + case DT_PLTREL: + BFD_ASSERT (htab->is_vxworks); + dyn.d_un.d_val = DT_RELA; + break; + + case DT_PLTRELSZ: + BFD_ASSERT (htab->is_vxworks); + dyn.d_un.d_val = htab->srelplt->size; + break; + + case DT_JMPREL: + BFD_ASSERT (htab->is_vxworks); + dyn.d_un.d_val = (htab->srelplt->output_section->vma + + htab->srelplt->output_offset); + break; + default: swap_out_p = FALSE; break; @@ -7727,14 +8643,33 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, } } - /* The first entry of the global offset table will be filled at - runtime. The second entry will be used by some runtime loaders. - This isn't the case of IRIX rld. */ if (sgot != NULL && sgot->size > 0) { - MIPS_ELF_PUT_WORD (output_bfd, 0, sgot->contents); - MIPS_ELF_PUT_WORD (output_bfd, 0x80000000, - sgot->contents + MIPS_ELF_GOT_SIZE (output_bfd)); + if (htab->is_vxworks) + { + /* The first entry of the global offset table points to the + ".dynamic" section. The second is initialized by the + loader and contains the shared library identifier. + The third is also initialized by the loader and points + to the lazy resolution stub. */ + MIPS_ELF_PUT_WORD (output_bfd, + sdyn->output_offset + sdyn->output_section->vma, + sgot->contents); + MIPS_ELF_PUT_WORD (output_bfd, 0, + sgot->contents + MIPS_ELF_GOT_SIZE (output_bfd)); + MIPS_ELF_PUT_WORD (output_bfd, 0, + sgot->contents + + 2 * MIPS_ELF_GOT_SIZE (output_bfd)); + } + else + { + /* The first entry of the global offset table will be filled at + runtime. The second entry will be used by some runtime loaders. + This isn't the case of IRIX rld. */ + MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0, sgot->contents); + MIPS_ELF_PUT_WORD (output_bfd, (bfd_vma) 0x80000000, + sgot->contents + MIPS_ELF_GOT_SIZE (output_bfd)); + } } if (sgot != NULL) @@ -7808,7 +8743,7 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, decided not to make. This is for the n64 irix rld, which doesn't seem to apply any relocations if there are trailing null entries. */ - s = mips_elf_rel_dyn_section (dynobj, FALSE); + s = mips_elf_rel_dyn_section (info, FALSE); dyn.d_un.d_val = (s->reloc_count * (ABI_64_P (output_bfd) ? sizeof (Elf64_Mips_External_Rel) @@ -7862,24 +8797,37 @@ _bfd_mips_elf_finish_dynamic_sections (bfd *output_bfd, } } - /* We need to sort the entries of the dynamic relocation section. */ - - s = mips_elf_rel_dyn_section (dynobj, FALSE); - - if (s != NULL - && s->size > (bfd_vma)2 * MIPS_ELF_REL_SIZE (output_bfd)) + /* The psABI says that the dynamic relocations must be sorted in + increasing order of r_symndx. The VxWorks EABI doesn't require + this, and because the code below handles REL rather than RELA + relocations, using it for VxWorks would be outright harmful. */ + if (!htab->is_vxworks) { - reldyn_sorting_bfd = output_bfd; + s = mips_elf_rel_dyn_section (info, FALSE); + if (s != NULL + && s->size > (bfd_vma)2 * MIPS_ELF_REL_SIZE (output_bfd)) + { + reldyn_sorting_bfd = output_bfd; - if (ABI_64_P (output_bfd)) - qsort ((Elf64_External_Rel *) s->contents + 1, s->reloc_count - 1, - sizeof (Elf64_Mips_External_Rel), sort_dynamic_relocs_64); - else - qsort ((Elf32_External_Rel *) s->contents + 1, s->reloc_count - 1, - sizeof (Elf32_External_Rel), sort_dynamic_relocs); + if (ABI_64_P (output_bfd)) + qsort ((Elf64_External_Rel *) s->contents + 1, + s->reloc_count - 1, sizeof (Elf64_Mips_External_Rel), + sort_dynamic_relocs_64); + else + qsort ((Elf32_External_Rel *) s->contents + 1, + s->reloc_count - 1, sizeof (Elf32_External_Rel), + sort_dynamic_relocs); + } } } + if (htab->is_vxworks && htab->splt->size > 0) + { + if (info->shared) + mips_vxworks_finish_shared_plt (output_bfd, info); + else + mips_vxworks_finish_exec_plt (output_bfd, info); + } return TRUE; } @@ -8929,8 +9877,9 @@ _bfd_mips_elf_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; - if (! _bfd_elf_link_hash_table_init (&ret->root, abfd, - mips_elf_link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, + mips_elf_link_hash_newfunc, + sizeof (struct mips_elf_link_hash_entry))) { free (ret); return NULL; @@ -8946,9 +9895,36 @@ _bfd_mips_elf_link_hash_table_create (bfd *abfd) ret->use_rld_obj_head = FALSE; ret->rld_value = 0; ret->mips16_stubs_seen = FALSE; + ret->is_vxworks = FALSE; + ret->srelbss = NULL; + ret->sdynbss = NULL; + ret->srelplt = NULL; + ret->srelplt2 = NULL; + ret->sgotplt = NULL; + ret->splt = NULL; + ret->plt_header_size = 0; + ret->plt_entry_size = 0; return &ret->root.root; } + +/* Likewise, but indicate that the target is VxWorks. */ + +struct bfd_link_hash_table * +_bfd_mips_vxworks_link_hash_table_create (bfd *abfd) +{ + struct bfd_link_hash_table *ret; + + ret = _bfd_mips_elf_link_hash_table_create (abfd); + if (ret) + { + struct mips_elf_link_hash_table *htab; + + htab = (struct mips_elf_link_hash_table *) ret; + htab->is_vxworks = 1; + } + return ret; +} /* We need to use a special link routine to handle the .reginfo and the .mdebug sections. We need to merge all instances of these @@ -8971,6 +9947,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) EXTR esym; unsigned int i; bfd_size_type amt; + struct mips_elf_link_hash_table *htab; static const char * const secname[] = { @@ -8987,6 +9964,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) generic size_dynamic_sections renumbered them out from under us. Rather than trying somehow to prevent the renumbering, just do the sort again. */ + htab = mips_elf_hash_table (info); if (elf_hash_table (info)->dynamic_sections_created) { bfd *dynobj; @@ -9037,6 +10015,14 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) elf_gp (abfd) = (h->u.def.value + h->u.def.section->output_section->vma + h->u.def.section->output_offset); + else if (htab->is_vxworks + && (h = bfd_link_hash_lookup (info->hash, + "_GLOBAL_OFFSET_TABLE_", + FALSE, FALSE, TRUE)) + && h->type == bfd_link_hash_defined) + elf_gp (abfd) = (h->u.def.section->output_section->vma + + h->u.def.section->output_offset + + h->u.def.value); else if (info->relocatable) { bfd_vma lo = MINUS_ONE; @@ -9048,7 +10034,7 @@ _bfd_mips_elf_final_link (bfd *abfd, struct bfd_link_info *info) lo = o->vma; /* And calculate GP relative to that. */ - elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (abfd); + elf_gp (abfd) = lo + ELF_MIPS_GP_OFFSET (info); } else { @@ -9780,6 +10766,12 @@ _bfd_mips_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) new_flags &= ~EF_MIPS_UCODE; old_flags &= ~EF_MIPS_UCODE; + /* Don't care about the PIC flags from dynamic objects; they are + PIC by design. */ + if ((new_flags & (EF_MIPS_PIC | EF_MIPS_CPIC)) != 0 + && (ibfd->flags & DYNAMIC) != 0) + new_flags &= ~ (EF_MIPS_PIC | EF_MIPS_CPIC); + if (new_flags == old_flags) return TRUE; diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index 07e661d..6c3c9a3 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -48,6 +48,8 @@ extern bfd_boolean _bfd_mips_elf_check_relocs (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); extern bfd_boolean _bfd_mips_elf_adjust_dynamic_symbol (struct bfd_link_info *, struct elf_link_hash_entry *); +extern bfd_boolean _bfd_mips_vxworks_adjust_dynamic_symbol + (struct bfd_link_info *, struct elf_link_hash_entry *); extern bfd_boolean _bfd_mips_elf_always_size_sections (bfd *, struct bfd_link_info *); extern bfd_boolean _bfd_mips_elf_size_dynamic_sections @@ -58,6 +60,9 @@ extern bfd_boolean _bfd_mips_elf_relocate_section extern bfd_boolean _bfd_mips_elf_finish_dynamic_symbol (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, Elf_Internal_Sym *); +extern bfd_boolean _bfd_mips_vxworks_finish_dynamic_symbol + (bfd *, struct bfd_link_info *, struct elf_link_hash_entry *, + Elf_Internal_Sym *); extern bfd_boolean _bfd_mips_elf_finish_dynamic_sections (bfd *, struct bfd_link_info *); extern void _bfd_mips_elf_final_write_processing @@ -90,6 +95,8 @@ extern bfd_byte *_bfd_elf_mips_get_relocated_section_contents bfd_byte *, bfd_boolean, asymbol **); extern struct bfd_link_hash_table *_bfd_mips_elf_link_hash_table_create (bfd *); +extern struct bfd_link_hash_table *_bfd_mips_vxworks_link_hash_table_create + (bfd *); extern bfd_boolean _bfd_mips_elf_final_link (bfd *, struct bfd_link_info *); extern bfd_boolean _bfd_mips_elf_merge_private_bfd_data diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c index cdf8c83..cb5f7cb 100644 --- a/bfd/elfxx-sparc.c +++ b/bfd/elfxx-sparc.c @@ -810,7 +810,8 @@ _bfd_sparc_elf_link_hash_table_create (bfd *abfd) ret->dynamic_interpreter_size = sizeof ELF32_DYNAMIC_INTERPRETER; } - if (! _bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc)) + if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc, + sizeof (struct _bfd_sparc_elf_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/hash.c b/bfd/hash.c index e53eda1..ce9ba5c 100644 --- a/bfd/hash.c +++ b/bfd/hash.c @@ -1,6 +1,6 @@ /* hash.c -- hash table routines for BFD - Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1997, 1999, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. Written by Steve Chamberlain This file is part of BFD, the Binary File Descriptor library. @@ -308,6 +308,7 @@ bfd_hash_table_init_n (struct bfd_hash_table *table, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), + unsigned int entsize, unsigned int size) { unsigned int alloc; @@ -328,6 +329,7 @@ bfd_hash_table_init_n (struct bfd_hash_table *table, } memset ((void *) table->table, 0, alloc); table->size = size; + table->entsize = entsize; table->newfunc = newfunc; return TRUE; } @@ -338,9 +340,11 @@ bfd_boolean bfd_hash_table_init (struct bfd_hash_table *table, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { - return bfd_hash_table_init_n (table, newfunc, bfd_default_hash_table_size); + return bfd_hash_table_init_n (table, newfunc, entsize, + bfd_default_hash_table_size); } /* Free a hash table. */ @@ -591,7 +595,8 @@ _bfd_stringtab_init (void) if (table == NULL) return NULL; - if (! bfd_hash_table_init (& table->table, strtab_hash_newfunc)) + if (!bfd_hash_table_init (&table->table, strtab_hash_newfunc, + sizeof (struct strtab_hash_entry))) { free (table); return NULL; diff --git a/bfd/i386linux.c b/bfd/i386linux.c index 8b55b35..17c6180 100644 --- a/bfd/i386linux.c +++ b/bfd/i386linux.c @@ -1,6 +1,6 @@ /* BFD back-end for linux flavored i386 a.out binaries. Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2001, 2002, 2003, - 2004 Free Software Foundation, Inc. + 2004, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -231,8 +231,9 @@ linux_link_hash_table_create (abfd) ret = (struct linux_link_hash_table *) bfd_alloc (abfd, amt); if (ret == (struct linux_link_hash_table *) NULL) return (struct bfd_link_hash_table *) NULL; - if (! NAME(aout,link_hash_table_init) (&ret->root, abfd, - linux_link_hash_newfunc)) + if (!NAME(aout,link_hash_table_init) (&ret->root, abfd, + linux_link_hash_newfunc, + sizeof (struct linux_link_hash_entry))) { free (ret); return (struct bfd_link_hash_table *) NULL; diff --git a/bfd/ieee.c b/bfd/ieee.c index 248551f..be8455c 100644 --- a/bfd/ieee.c +++ b/bfd/ieee.c @@ -3466,22 +3466,22 @@ ieee_write_processor (bfd *abfd) case bfd_mach_m68040: id = "68040"; break; case bfd_mach_m68060: id = "68060"; break; case bfd_mach_cpu32: id = "cpu32"; break; + case bfd_mach_mcf_isa_a_nodiv: id = "isa-a:nodiv"; break; case bfd_mach_mcf_isa_a: id = "isa-a"; break; - case bfd_mach_mcf_isa_a_div: id = "isa-a:div"; break; - case bfd_mach_mcf_isa_a_div_mac: id = "isa-a:div:mac"; break; - case bfd_mach_mcf_isa_a_div_emac: id = "isa-a:div:emac"; break; - case bfd_mach_mcf_isa_aplus: id = "isa-a+"; break; - case bfd_mach_mcf_isa_aplus_mac: id = "isa-a+:mac"; break; - case bfd_mach_mcf_isa_aplus_emac: id = "isa-a+:mac"; break; - case bfd_mach_mcf_isa_aplus_usp: id = "isa-a+:usp"; break; - case bfd_mach_mcf_isa_aplus_usp_mac: id = "isa-a+:usp:mac"; break; - case bfd_mach_mcf_isa_aplus_usp_emac: id = "isa-a+:usp:emac"; break; + case bfd_mach_mcf_isa_a_mac: id = "isa-a:mac"; break; + case bfd_mach_mcf_isa_a_emac: id = "isa-a:emac"; break; + case bfd_mach_mcf_isa_aplus: id = "isa-aplus"; break; + case bfd_mach_mcf_isa_aplus_mac: id = "isa-aplus:mac"; break; + case bfd_mach_mcf_isa_aplus_emac: id = "isa-aplus:mac"; break; + case bfd_mach_mcf_isa_b_nousp: id = "isa-b:nousp"; break; + case bfd_mach_mcf_isa_b_nousp_mac: id = "isa-b:nousp:mac"; break; + case bfd_mach_mcf_isa_b_nousp_emac: id = "isa-b:nousp:emac"; break; case bfd_mach_mcf_isa_b: id = "isa-b"; break; case bfd_mach_mcf_isa_b_mac: id = "isa-b:mac"; break; case bfd_mach_mcf_isa_b_emac: id = "isa-b:emac"; break; - case bfd_mach_mcf_isa_b_usp_float: id = "isa-b:usp:float"; break; - case bfd_mach_mcf_isa_b_usp_float_mac: id = "isa-b:usp:float:mac"; break; - case bfd_mach_mcf_isa_b_usp_float_emac: id = "isa-b:usp:float:emac"; break; + case bfd_mach_mcf_isa_b_float: id = "isa-b:float"; break; + case bfd_mach_mcf_isa_b_float_mac: id = "isa-b:float:mac"; break; + case bfd_mach_mcf_isa_b_float_emac: id = "isa-b:float:emac"; break; } if (! ieee_write_id (abfd, id)) diff --git a/bfd/libaout.h b/bfd/libaout.h index 79f5402..bb3ee80 100644 --- a/bfd/libaout.h +++ b/bfd/libaout.h @@ -1,6 +1,6 @@ /* BFD back-end data structures for a.out (and similar) files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -575,7 +575,8 @@ extern bfd_boolean NAME (aout, link_hash_table_init) (struct aout_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); extern struct bfd_link_hash_table * NAME (aout, link_hash_table_create) (bfd *); diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index e3468c1..ee2484f 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -2,7 +2,7 @@ (This include file is not for users of the library.) Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -53,6 +53,12 @@ struct bfd_in_memory bfd_byte *buffer; }; +struct section_hash_entry +{ + struct bfd_hash_entry root; + asection section; +}; + /* tdata for an archive. For an input archive, cache needs to be free()'d. For an output archive, symdefs do. */ @@ -468,7 +474,8 @@ extern bfd_boolean _bfd_link_hash_table_init (struct bfd_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); /* Generic link hash table creation routine. */ extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 03e2fa5..2a590a3 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -7,7 +7,7 @@ (This include file is not for users of the library.) Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -58,6 +58,12 @@ struct bfd_in_memory bfd_byte *buffer; }; +struct section_hash_entry +{ + struct bfd_hash_entry root; + asection section; +}; + /* tdata for an archive. For an input archive, cache needs to be free()'d. For an output archive, symdefs do. */ @@ -473,7 +479,8 @@ extern bfd_boolean _bfd_link_hash_table_init (struct bfd_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); /* Generic link hash table creation routine. */ extern struct bfd_link_hash_table *_bfd_generic_link_hash_table_create @@ -965,6 +972,9 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_MIPS_TLS_TPREL_HI16", "BFD_RELOC_MIPS_TLS_TPREL_LO16", + "BFD_RELOC_MIPS_COPY", + "BFD_RELOC_MIPS_JUMP_SLOT", + "BFD_RELOC_FRV_LABEL16", "BFD_RELOC_FRV_LABEL24", "BFD_RELOC_FRV_LO16", @@ -1055,6 +1065,11 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_X86_64_TPOFF32", "BFD_RELOC_X86_64_GOTOFF64", "BFD_RELOC_X86_64_GOTPC32", + "BFD_RELOC_X86_64_GOT64", + "BFD_RELOC_X86_64_GOTPCREL64", + "BFD_RELOC_X86_64_GOTPC64", + "BFD_RELOC_X86_64_GOTPLT64", + "BFD_RELOC_X86_64_PLTOFF64", "BFD_RELOC_X86_64_GOTPC32_TLSDESC", "BFD_RELOC_X86_64_TLSDESC_CALL", "BFD_RELOC_X86_64_TLSDESC", @@ -1333,6 +1348,20 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_BFIN_12_PCREL_JUMP_S", "BFD_RELOC_BFIN_24_PCREL_CALL_X", "BFD_RELOC_BFIN_24_PCREL_JUMP_L", + "BFD_RELOC_BFIN_GOT17M4", + "BFD_RELOC_BFIN_GOTHI", + "BFD_RELOC_BFIN_GOTLO", + "BFD_RELOC_BFIN_FUNCDESC", + "BFD_RELOC_BFIN_FUNCDESC_GOT17M4", + "BFD_RELOC_BFIN_FUNCDESC_GOTHI", + "BFD_RELOC_BFIN_FUNCDESC_GOTLO", + "BFD_RELOC_BFIN_FUNCDESC_VALUE", + "BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4", + "BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI", + "BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO", + "BFD_RELOC_BFIN_GOTOFF17M4", + "BFD_RELOC_BFIN_GOTOFFHI", + "BFD_RELOC_BFIN_GOTOFFLO", "BFD_RELOC_BFIN_GOT", "BFD_RELOC_BFIN_PLTPC", "BFD_ARELOC_BFIN_PUSH", diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 490f2a8..f2bc264 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -1,6 +1,6 @@ /* BFD COFF object file private structure. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -421,7 +421,8 @@ struct coff_debug_merge_hash_table /* Initialize a COFF debug merge hash table. */ #define coff_debug_merge_hash_table_init(table) \ - (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc)) + (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \ + sizeof (struct coff_debug_merge_hash_entry))) /* Free a COFF debug merge hash table. */ @@ -537,7 +538,8 @@ extern bfd_boolean _bfd_coff_link_hash_table_init (struct coff_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create (bfd *); extern const char *_bfd_coff_internal_syment_name diff --git a/bfd/libcoff.h b/bfd/libcoff.h index 67ff404..f756f30 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -4,7 +4,7 @@ /* BFD COFF object file private structure. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -425,7 +425,8 @@ struct coff_debug_merge_hash_table /* Initialize a COFF debug merge hash table. */ #define coff_debug_merge_hash_table_init(table) \ - (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc)) + (bfd_hash_table_init (&(table)->root, _bfd_coff_debug_merge_hash_newfunc, \ + sizeof (struct coff_debug_merge_hash_entry))) /* Free a COFF debug merge hash table. */ @@ -541,7 +542,8 @@ extern bfd_boolean _bfd_coff_link_hash_table_init (struct coff_link_hash_table *, bfd *, struct bfd_hash_entry *(*) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)); + const char *), + unsigned int); extern struct bfd_link_hash_table *_bfd_coff_link_hash_table_create (bfd *); extern const char *_bfd_coff_internal_syment_name diff --git a/bfd/linker.c b/bfd/linker.c index 67fe804..14eeae4 100644 --- a/bfd/linker.c +++ b/bfd/linker.c @@ -1,6 +1,6 @@ /* linker.c -- BFD linker routines Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003, 2004, 2005 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Steve Chamberlain and Ian Lance Taylor, Cygnus Support This file is part of BFD, the Binary File Descriptor library. @@ -472,14 +472,15 @@ _bfd_link_hash_table_init bfd *abfd, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { table->creator = abfd->xvec; table->undefs = NULL; table->undefs_tail = NULL; table->type = bfd_link_generic_hash_table; - return bfd_hash_table_init (&table->table, newfunc); + return bfd_hash_table_init (&table->table, newfunc, entsize); } /* Look up a symbol in a link hash table. If follow is TRUE, we @@ -709,7 +710,8 @@ _bfd_generic_link_hash_table_create (bfd *abfd) if (ret == NULL) return NULL; if (! _bfd_link_hash_table_init (&ret->root, abfd, - _bfd_generic_link_hash_newfunc)) + _bfd_generic_link_hash_newfunc, + sizeof (struct generic_link_hash_entry))) { free (ret); return NULL; @@ -901,9 +903,10 @@ archive_hash_table_init (struct archive_hash_table *table, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { - return bfd_hash_table_init (&table->table, newfunc); + return bfd_hash_table_init (&table->table, newfunc, entsize); } /* Look up an entry in an archive hash table. */ @@ -981,7 +984,8 @@ _bfd_generic_link_add_archive_symbols /* In order to quickly determine whether an symbol is defined in this archive, we build a hash table of the symbols. */ - if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc)) + if (! archive_hash_table_init (&arsym_hash, archive_hash_newfunc, + sizeof (struct archive_hash_entry))) return FALSE; for (arsym = arsyms, indx = 0; arsym < arsym_end; arsym++, indx++) { @@ -2952,7 +2956,9 @@ bfd_boolean bfd_section_already_linked_table_init (void) { return bfd_hash_table_init_n (&_bfd_section_already_linked_table, - already_linked_newfunc, 42); + already_linked_newfunc, + sizeof (struct bfd_section_already_linked_hash_entry), + 42); } void diff --git a/bfd/m68klinux.c b/bfd/m68klinux.c index e55fd54..2c12a7c 100644 --- a/bfd/m68klinux.c +++ b/bfd/m68klinux.c @@ -1,6 +1,6 @@ /* BFD back-end for linux flavored m68k a.out binaries. Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, - 2003, 2004 Free Software Foundation, Inc. + 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -235,8 +235,9 @@ linux_link_hash_table_create (abfd) bfd_set_error (bfd_error_no_memory); return (struct bfd_link_hash_table *) NULL; } - if (! NAME(aout,link_hash_table_init) (&ret->root, abfd, - linux_link_hash_newfunc)) + if (!NAME(aout,link_hash_table_init) (&ret->root, abfd, + linux_link_hash_newfunc, + sizeof (struct linux_link_hash_entry))) { free (ret); return (struct bfd_link_hash_table *) NULL; diff --git a/bfd/merge.c b/bfd/merge.c index 0c34821..c1795d2 100644 --- a/bfd/merge.c +++ b/bfd/merge.c @@ -1,5 +1,6 @@ /* SEC_MERGE support. - Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. Written by Jakub Jelinek . This file is part of BFD, the Binary File Descriptor library. @@ -242,7 +243,7 @@ sec_merge_init (unsigned int entsize, bfd_boolean strings) return NULL; if (! bfd_hash_table_init_n (&table->table, sec_merge_hash_newfunc, - 16699)) + sizeof (struct sec_merge_hash_entry), 16699)) { free (table); return NULL; diff --git a/bfd/opncls.c b/bfd/opncls.c index 63f7b74..b02b137 100644 --- a/bfd/opncls.c +++ b/bfd/opncls.c @@ -1,6 +1,6 @@ /* opncls.c -- open and close a BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, - 2001, 2002, 2003, 2004, 2005 + 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -71,7 +71,7 @@ _bfd_new_bfd (void) nbfd->iostream = NULL; nbfd->where = 0; if (!bfd_hash_table_init_n (& nbfd->section_htab, bfd_section_hash_newfunc, - 251)) + sizeof (struct section_hash_entry), 251)) { free (nbfd); return NULL; diff --git a/bfd/pdp11.c b/bfd/pdp11.c index 83029c4..37f960f 100644 --- a/bfd/pdp11.c +++ b/bfd/pdp11.c @@ -1,5 +1,6 @@ /* BFD back-end for PDP-11 a.out binaries. - Copyright 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -2446,9 +2447,10 @@ NAME (aout, link_hash_table_init) (struct aout_link_hash_table *table, bfd *abfd, struct bfd_hash_entry *(*newfunc) (struct bfd_hash_entry *, struct bfd_hash_table *, - const char *)) + const char *), + unsigned int entsize) { - return _bfd_link_hash_table_init (&table->root, abfd, newfunc); + return _bfd_link_hash_table_init (&table->root, abfd, newfunc, entsize); } /* Create an a.out link hash table. */ @@ -2463,7 +2465,8 @@ NAME (aout, link_hash_table_create) (bfd *abfd) if (ret == NULL) return NULL; if (! NAME (aout, link_hash_table_init) (ret, abfd, - NAME (aout, link_hash_newfunc))) + NAME (aout, link_hash_newfunc), + sizeof (struct aout_link_hash_entry))) { free (ret); return NULL; @@ -3657,9 +3660,10 @@ NAME (aout, final_link) (bfd *abfd, aout_info.symbol_map = NULL; aout_info.output_syms = NULL; - if (! bfd_hash_table_init_n (&aout_info.includes.root, - aout_link_includes_newfunc, - 251)) + if (!bfd_hash_table_init_n (&aout_info.includes.root, + aout_link_includes_newfunc, + sizeof (struct aout_link_includes_entry), + 251)) goto error_return; includes_hash_initialized = TRUE; diff --git a/bfd/reloc.c b/bfd/reloc.c index 31314e7..f1d09a5 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -2140,6 +2140,14 @@ ENUMDOC COMMENT ENUM + BFD_RELOC_MIPS_COPY +ENUMX + BFD_RELOC_MIPS_JUMP_SLOT +ENUMDOC + MIPS ELF relocations (VxWorks extensions). +COMMENT + +ENUM BFD_RELOC_FRV_LABEL16 ENUMX BFD_RELOC_FRV_LABEL24 @@ -2344,6 +2352,16 @@ ENUMX ENUMX BFD_RELOC_X86_64_GOTPC32 ENUMX + BFD_RELOC_X86_64_GOT64 +ENUMX + BFD_RELOC_X86_64_GOTPCREL64 +ENUMX + BFD_RELOC_X86_64_GOTPC64 +ENUMX + BFD_RELOC_X86_64_GOTPLT64 +ENUMX + BFD_RELOC_X86_64_PLTOFF64 +ENUMX BFD_RELOC_X86_64_GOTPC32_TLSDESC ENUMX BFD_RELOC_X86_64_TLSDESC_CALL @@ -3014,6 +3032,36 @@ ENUM ENUMDOC ADI Blackfin Long Jump pcrel. ENUM + BFD_RELOC_BFIN_GOT17M4 +ENUMX + BFD_RELOC_BFIN_GOTHI +ENUMX + BFD_RELOC_BFIN_GOTLO +ENUMX + BFD_RELOC_BFIN_FUNCDESC +ENUMX + BFD_RELOC_BFIN_FUNCDESC_GOT17M4 +ENUMX + BFD_RELOC_BFIN_FUNCDESC_GOTHI +ENUMX + BFD_RELOC_BFIN_FUNCDESC_GOTLO +ENUMX + BFD_RELOC_BFIN_FUNCDESC_VALUE +ENUMX + BFD_RELOC_BFIN_FUNCDESC_GOTOFF17M4 +ENUMX + BFD_RELOC_BFIN_FUNCDESC_GOTOFFHI +ENUMX + BFD_RELOC_BFIN_FUNCDESC_GOTOFFLO +ENUMX + BFD_RELOC_BFIN_GOTOFF17M4 +ENUMX + BFD_RELOC_BFIN_GOTOFFHI +ENUMX + BFD_RELOC_BFIN_GOTOFFLO +ENUMDOC + ADI Blackfin FD-PIC relocations. +ENUM BFD_RELOC_BFIN_GOT ENUMDOC ADI Blackfin GOT relocation. diff --git a/bfd/section.c b/bfd/section.c index 42554b9..f870e6b 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1,6 +1,6 @@ /* Object file "section" support for the BFD library. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005 + 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. @@ -713,12 +713,6 @@ STD_SECTION (bfd_abs_section, 0, bfd_abs_symbol, BFD_ABS_SECTION_NAME, 2); STD_SECTION (bfd_ind_section, 0, bfd_ind_symbol, BFD_IND_SECTION_NAME, 3); #undef STD_SECTION -struct section_hash_entry -{ - struct bfd_hash_entry root; - asection section; -}; - /* Initialize an entry in the section hash table. */ struct bfd_hash_entry * diff --git a/bfd/sparclinux.c b/bfd/sparclinux.c index 27e5f2f..d8659ee 100644 --- a/bfd/sparclinux.c +++ b/bfd/sparclinux.c @@ -1,6 +1,6 @@ /* BFD back-end for linux flavored sparc a.out binaries. Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, - 2003, 2004 Free Software Foundation, Inc. + 2003, 2004, 2006 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -232,8 +232,9 @@ linux_link_hash_table_create (abfd) ret = (struct linux_link_hash_table *) bfd_malloc (amt); if (ret == (struct linux_link_hash_table *) NULL) return (struct bfd_link_hash_table *) NULL; - if (! NAME(aout,link_hash_table_init) (&ret->root, abfd, - linux_link_hash_newfunc)) + if (!NAME(aout,link_hash_table_init) (&ret->root, abfd, + linux_link_hash_newfunc, + sizeof (struct linux_link_hash_entry))) { free (ret); return (struct bfd_link_hash_table *) NULL; diff --git a/bfd/stabs.c b/bfd/stabs.c index 25fae29..ba3f934 100644 --- a/bfd/stabs.c +++ b/bfd/stabs.c @@ -1,6 +1,6 @@ /* Stabs in sections linking support. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -195,7 +195,8 @@ _bfd_link_section_stabs (bfd *abfd, /* Make sure the first byte is zero. */ (void) _bfd_stringtab_add (sinfo->strings, "", TRUE, TRUE); if (! bfd_hash_table_init (&sinfo->includes, - stab_link_includes_newfunc)) + stab_link_includes_newfunc, + sizeof (struct stab_link_includes_entry))) goto error_return; sinfo->stabstr = bfd_make_section_anyway (abfd, ".stabstr"); if (sinfo->stabstr == NULL) diff --git a/bfd/sunos.c b/bfd/sunos.c index 03d386a..024320f 100644 --- a/bfd/sunos.c +++ b/bfd/sunos.c @@ -1,6 +1,6 @@ /* BFD backend for SunOS binaries. Copyright 1990, 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Written by Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -679,8 +679,9 @@ sunos_link_hash_table_create (bfd *abfd) ret = bfd_malloc (amt); if (ret == NULL) return NULL; - if (! NAME (aout, link_hash_table_init) (&ret->root, abfd, - sunos_link_hash_newfunc)) + if (!NAME (aout, link_hash_table_init) (&ret->root, abfd, + sunos_link_hash_newfunc, + sizeof (struct sunos_link_hash_entry))) { free (ret); return NULL; diff --git a/bfd/targets.c b/bfd/targets.c index 99f3006..0649179 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -554,12 +554,14 @@ extern const bfd_target bfd_efi_app_ia32_vec; extern const bfd_target bfd_efi_app_ia64_vec; extern const bfd_target bfd_elf32_avr_vec; extern const bfd_target bfd_elf32_bfin_vec; +extern const bfd_target bfd_elf32_bfinfdpic_vec; extern const bfd_target bfd_elf32_big_generic_vec; extern const bfd_target bfd_elf32_bigarc_vec; extern const bfd_target bfd_elf32_bigarm_vec; extern const bfd_target bfd_elf32_bigarm_symbian_vec; extern const bfd_target bfd_elf32_bigarm_vxworks_vec; extern const bfd_target bfd_elf32_bigmips_vec; +extern const bfd_target bfd_elf32_bigmips_vxworks_vec; extern const bfd_target bfd_elf32_cr16c_vec; extern const bfd_target bfd_elf32_cris_vec; extern const bfd_target bfd_elf32_crx_vec; @@ -590,6 +592,7 @@ extern const bfd_target bfd_elf32_littlearm_vec; extern const bfd_target bfd_elf32_littlearm_symbian_vec; extern const bfd_target bfd_elf32_littlearm_vxworks_vec; extern const bfd_target bfd_elf32_littlemips_vec; +extern const bfd_target bfd_elf32_littlemips_vxworks_vec; extern const bfd_target bfd_elf32_m32c_vec; extern const bfd_target bfd_elf32_m32r_vec; extern const bfd_target bfd_elf32_m32rle_vec; @@ -852,6 +855,7 @@ static const bfd_target * const _bfd_target_vector[] = { #endif &bfd_elf32_avr_vec, &bfd_elf32_bfin_vec, + &bfd_elf32_bfinfdpic_vec, /* This, and other vectors, may not be used in any *.mt configuration. But that does not mean they are unnecessary. If configured with @@ -863,6 +867,7 @@ static const bfd_target * const _bfd_target_vector[] = { &bfd_elf32_bigarm_symbian_vec, &bfd_elf32_bigarm_vxworks_vec, &bfd_elf32_bigmips_vec, + &bfd_elf32_bigmips_vxworks_vec, &bfd_elf32_cr16c_vec, &bfd_elf32_cris_vec, &bfd_elf32_crx_vec, @@ -897,6 +902,7 @@ static const bfd_target * const _bfd_target_vector[] = { &bfd_elf32_littlearm_symbian_vec, &bfd_elf32_littlearm_vxworks_vec, &bfd_elf32_littlemips_vec, + &bfd_elf32_littlemips_vxworks_vec, &bfd_elf32_m32c_vec, &bfd_elf32_m32r_vec, &bfd_elf32_m32rle_vec, diff --git a/bfd/version.h b/bfd/version.h index bdc58dc..6166019 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -1,3 +1,3 @@ -#define BFD_VERSION_DATE 20060303 +#define BFD_VERSION_DATE 20060330 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_string@ diff --git a/bfd/vms.c b/bfd/vms.c index cdac381..e6ee98a 100644 --- a/bfd/vms.c +++ b/bfd/vms.c @@ -1,7 +1,7 @@ /* vms.c -- BFD back-end for VAX (openVMS/VAX) and EVAX (openVMS/Alpha) files. - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, + 2006 Free Software Foundation, Inc. Written by Klaus K"ampf (kkaempf@rmi.de) @@ -77,7 +77,8 @@ vms_initialize (bfd * abfd) if (PRIV (vms_symbol_table) == NULL) goto error_ret1; - if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc)) + if (!bfd_hash_table_init (PRIV (vms_symbol_table), _bfd_vms_hash_newfunc, + sizeof (vms_symbol_entry))) goto error_ret1; amt = sizeof (struct location_struct) * LOCATION_SAVE_SIZE; diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c index b1cac27..47c330b 100644 --- a/bfd/xcofflink.c +++ b/bfd/xcofflink.c @@ -1,6 +1,6 @@ /* POWER/PowerPC XCOFF linker support. - Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 - Free Software Foundation, Inc. + Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, + 2005, 2006 Free Software Foundation, Inc. Written by Ian Lance Taylor , Cygnus Support. This file is part of BFD, the Binary File Descriptor library. @@ -444,7 +444,8 @@ _bfd_xcoff_bfd_link_hash_table_create (bfd *abfd) ret = bfd_malloc (amt); if (ret == NULL) return NULL; - if (! _bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc)) + if (!_bfd_link_hash_table_init (&ret->root, abfd, xcoff_link_hash_newfunc, + sizeof (struct xcoff_link_hash_entry))) { free (ret); return NULL; diff --git a/configure b/configure index d74e611..2dae3f1 100755 --- a/configure +++ b/configure @@ -1098,7 +1098,6 @@ else fi if test "${ENABLE_LIBADA}" != "yes" ; then - noconfigdirs="$noconfigdirs target-libada" noconfigdirs="$noconfigdirs gnattools" fi @@ -1110,9 +1109,6 @@ else ENABLE_LIBSSP=yes fi -if test "${ENABLE_LIBSSP}" != "yes" ; then - noconfigdirs="$noconfigdirs target-libssp" -fi # Set the default so we build libgcc-math for ix86 and x86_64 # Check whether --enable-libgcc-math or --disable-libgcc-math was given. @@ -1130,9 +1126,6 @@ esac fi -if test "${enable_libgcc_math}" != "yes"; then - noconfigdirs="$noconfigdirs target-libgcc-math" -fi # Save it here so that, even in case of --enable-libgcj, if the Java # front-end isn't enabled, we still get libgcj disabled. @@ -1151,14 +1144,8 @@ no) esac -# Allow --disable-libmudflap to exclude target-libmudflap -case $enable_libmudflap in -yes) - ;; -no) - noconfigdirs="$noconfigdirs target-libmudflap" - ;; -"") +# Disable libmudflap on some systems. +if test x$enable_libmudflap = x ; then case "${target}" in *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu) # Enable libmudflap by default in GNU and friends. @@ -1171,16 +1158,10 @@ no) noconfigdirs="$noconfigdirs target-libmudflap" ;; esac -esac +fi -# Allow --disable-libgomp to exclude target-libgomp -case $enable_libgomp in -yes) - ;; -no) - noconfigdirs="$noconfigdirs target-libgomp" - ;; -"") +# Disable libgomp on non POSIX hosted systems. +if test x$enable_libgomp = x ; then # Enable libgomp by default on hosted POSIX systems. case "${target}" in *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu) @@ -1195,7 +1176,7 @@ no) noconfigdirs="$noconfigdirs target-libgomp" ;; esac -esac +fi case "${target}" in @@ -1876,7 +1857,7 @@ else # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1880: checking for $ac_word" >&5 +echo "configure:1861: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1906,7 +1887,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1910: checking for $ac_word" >&5 +echo "configure:1891: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1957,7 +1938,7 @@ fi # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1961: checking for $ac_word" >&5 +echo "configure:1942: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1989,7 +1970,7 @@ fi fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 -echo "configure:1993: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 +echo "configure:1974: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -2000,12 +1981,12 @@ cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF -#line 2004 "configure" +#line 1985 "configure" #include "confdefs.h" main(){return(0);} EOF -if { (eval echo configure:2009: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1990: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then @@ -2031,12 +2012,12 @@ if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 -echo "configure:2035: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "configure:2016: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:2040: checking whether we are using GNU C" >&5 +echo "configure:2021: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2045,7 +2026,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:2030: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -2064,7 +2045,7 @@ ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:2068: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:2049: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2131,7 +2112,7 @@ fi # Extract the first word of "${ac_tool_prefix}gnatbind", so it can be a program name with args. set dummy ${ac_tool_prefix}gnatbind; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2135: checking for $ac_word" >&5 +echo "configure:2116: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GNATBIND'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2163,7 +2144,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "gnatbind", so it can be a program name with args. set dummy gnatbind; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2167: checking for $ac_word" >&5 +echo "configure:2148: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GNATBIND'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2196,7 +2177,7 @@ fi fi echo $ac_n "checking whether compiler driver understands Ada""... $ac_c" 1>&6 -echo "configure:2200: checking whether compiler driver understands Ada" >&5 +echo "configure:2181: checking whether compiler driver understands Ada" >&5 if eval "test \"`echo '$''{'acx_cv_cc_gcc_supports_ada'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2228,7 +2209,7 @@ else fi echo $ac_n "checking how to compare bootstrapped objects""... $ac_c" 1>&6 -echo "configure:2232: checking how to compare bootstrapped objects" >&5 +echo "configure:2213: checking how to compare bootstrapped objects" >&5 if eval "test \"`echo '$''{'gcc_cv_prog_cmp_skip'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2326,9 +2307,9 @@ saved_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $gmpinc" # Check GMP actually works echo $ac_n "checking for correct version of gmp.h""... $ac_c" 1>&6 -echo "configure:2330: checking for correct version of gmp.h" >&5 +echo "configure:2311: checking for correct version of gmp.h" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:2324: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -2352,12 +2333,12 @@ rm -f conftest* if test x"$have_gmp" = xyes; then echo $ac_n "checking for MPFR""... $ac_c" 1>&6 -echo "configure:2356: checking for MPFR" >&5 +echo "configure:2337: checking for MPFR" >&5 saved_LIBS="$LIBS" LIBS="$LIBS $gmplibs" cat > conftest.$ac_ext < #include @@ -2365,7 +2346,7 @@ int main() { mpfr_t n; mpfr_init(n); ; return 0; } EOF -if { (eval echo configure:2369: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2350: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 else @@ -2549,6 +2530,14 @@ Recognised languages are: ${potential_languages}" 1>&2; exit 1; } ac_configure_args=`echo " $ac_configure_args" | sed -e 's/ --enable-languages=[^ ]*//' -e 's/$/ --enable-languages='"$enable_languages"/ ` fi +# Handle --disable- generically. +for dir in $configdirs $build_configdirs $target_configdirs ; do + dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g` + if eval test x\${enable_${dirname}} "=" xno ; then + noconfigdirs="$noconfigdirs $dir" + fi +done + # Remove the entries in $skipdirs and $noconfigdirs from $configdirs, # $build_configdirs and $target_configdirs. # If we have the source for $noconfigdirs entries, add them to $notsupp. @@ -3408,7 +3397,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3412: checking for $ac_word" >&5 +echo "configure:3401: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3448,7 +3437,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3452: checking for $ac_word" >&5 +echo "configure:3441: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_BISON'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3487,7 +3476,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3491: checking for $ac_word" >&5 +echo "configure:3480: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_M4'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3526,7 +3515,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3530: checking for $ac_word" >&5 +echo "configure:3519: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3566,7 +3555,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3570: checking for $ac_word" >&5 +echo "configure:3559: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_FLEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3605,7 +3594,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3609: checking for $ac_word" >&5 +echo "configure:3598: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_MAKEINFO'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3658,7 +3647,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3662: checking for $ac_word" >&5 +echo "configure:3651: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_EXPECT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3699,7 +3688,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3703: checking for $ac_word" >&5 +echo "configure:3692: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RUNTEST'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3747,7 +3736,7 @@ test -n "$target_alias" && ncn_target_tool_prefix=$target_alias- # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3751: checking for $ac_word" >&5 +echo "configure:3740: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3778,7 +3767,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3782: checking for $ac_word" >&5 +echo "configure:3771: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3822,7 +3811,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3826: checking for $ac_word" >&5 +echo "configure:3815: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3853,7 +3842,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3857: checking for $ac_word" >&5 +echo "configure:3846: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3897,7 +3886,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3901: checking for $ac_word" >&5 +echo "configure:3890: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3928,7 +3917,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3932: checking for $ac_word" >&5 +echo "configure:3921: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3972,7 +3961,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3976: checking for $ac_word" >&5 +echo "configure:3965: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4003,7 +3992,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4007: checking for $ac_word" >&5 +echo "configure:3996: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4047,7 +4036,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4051: checking for $ac_word" >&5 +echo "configure:4040: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LIPO'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4078,7 +4067,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4082: checking for $ac_word" >&5 +echo "configure:4071: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LIPO'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4122,7 +4111,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4126: checking for $ac_word" >&5 +echo "configure:4115: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4153,7 +4142,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4157: checking for $ac_word" >&5 +echo "configure:4146: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4197,7 +4186,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4201: checking for $ac_word" >&5 +echo "configure:4190: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4228,7 +4217,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4232: checking for $ac_word" >&5 +echo "configure:4221: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4267,7 +4256,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4271: checking for $ac_word" >&5 +echo "configure:4260: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4298,7 +4287,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4302: checking for $ac_word" >&5 +echo "configure:4291: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4337,7 +4326,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4341: checking for $ac_word" >&5 +echo "configure:4330: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4368,7 +4357,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4372: checking for $ac_word" >&5 +echo "configure:4361: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4412,7 +4401,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4416: checking for $ac_word" >&5 +echo "configure:4405: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4443,7 +4432,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4447: checking for $ac_word" >&5 +echo "configure:4436: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJCOPY'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4487,7 +4476,7 @@ fi # Extract the first word of "${ncn_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4491: checking for $ac_word" >&5 +echo "configure:4480: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4518,7 +4507,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4522: checking for $ac_word" >&5 +echo "configure:4511: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4582,7 +4571,7 @@ fi if test -n "$with_build_time_tools"; then for ncn_progname in cc gcc; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:4586: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:4575: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_CC_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -4599,7 +4588,7 @@ if test -z "$ac_cv_prog_CC_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4603: checking for $ac_word" >&5 +echo "configure:4592: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4630,7 +4619,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4634: checking for $ac_word" >&5 +echo "configure:4623: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4673,7 +4662,7 @@ fi if test -n "$with_build_time_tools"; then for ncn_progname in c++ g++ cxx gxx; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:4677: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:4666: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_CXX_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -4690,7 +4679,7 @@ if test -z "$ac_cv_prog_CXX_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4694: checking for $ac_word" >&5 +echo "configure:4683: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4721,7 +4710,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4725: checking for $ac_word" >&5 +echo "configure:4714: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4764,7 +4753,7 @@ fi if test -n "$with_build_time_tools"; then for ncn_progname in gcc; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:4768: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:4757: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_GCC_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -4781,7 +4770,7 @@ if test -z "$ac_cv_prog_GCC_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4785: checking for $ac_word" >&5 +echo "configure:4774: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GCC_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4812,7 +4801,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4816: checking for $ac_word" >&5 +echo "configure:4805: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GCC_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4850,7 +4839,7 @@ fi if test -n "$with_build_time_tools"; then for ncn_progname in gcj; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:4854: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:4843: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_GCJ_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -4867,7 +4856,7 @@ if test -z "$ac_cv_prog_GCJ_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4871: checking for $ac_word" >&5 +echo "configure:4860: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GCJ_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4898,7 +4887,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4902: checking for $ac_word" >&5 +echo "configure:4891: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GCJ_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4941,7 +4930,7 @@ fi if test -n "$with_build_time_tools"; then for ncn_progname in gfortran; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:4945: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:4934: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_GFORTRAN_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -4958,7 +4947,7 @@ if test -z "$ac_cv_prog_GFORTRAN_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4962: checking for $ac_word" >&5 +echo "configure:4951: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GFORTRAN_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -4989,7 +4978,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:4993: checking for $ac_word" >&5 +echo "configure:4982: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_GFORTRAN_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5096,7 +5085,7 @@ rm conftest.c if test -z "$ac_cv_path_AR_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for ar in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5100: checking for ar in $with_build_time_tools" >&5 +echo "configure:5089: checking for ar in $with_build_time_tools" >&5 if test -x $with_build_time_tools/ar; then AR_FOR_TARGET=`cd $with_build_time_tools && pwd`/ar ac_cv_path_AR_FOR_TARGET=$AR_FOR_TARGET @@ -5114,7 +5103,7 @@ if test -z "$ac_cv_path_AR_FOR_TARGET" ; then # Extract the first word of "ar", so it can be a program name with args. set dummy ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5118: checking for $ac_word" >&5 +echo "configure:5107: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_AR_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5151,7 +5140,7 @@ if test -z "$ac_cv_path_AR_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in ar; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5155: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:5144: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_AR_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -5168,7 +5157,7 @@ if test -z "$ac_cv_prog_AR_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5172: checking for $ac_word" >&5 +echo "configure:5161: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5199,7 +5188,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5203: checking for $ac_word" >&5 +echo "configure:5192: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5249,7 +5238,7 @@ fi if test -z "$ac_cv_path_AS_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for as in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5253: checking for as in $with_build_time_tools" >&5 +echo "configure:5242: checking for as in $with_build_time_tools" >&5 if test -x $with_build_time_tools/as; then AS_FOR_TARGET=`cd $with_build_time_tools && pwd`/as ac_cv_path_AS_FOR_TARGET=$AS_FOR_TARGET @@ -5267,7 +5256,7 @@ if test -z "$ac_cv_path_AS_FOR_TARGET" ; then # Extract the first word of "as", so it can be a program name with args. set dummy as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5271: checking for $ac_word" >&5 +echo "configure:5260: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_AS_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5304,7 +5293,7 @@ if test -z "$ac_cv_path_AS_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in as; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5308: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:5297: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_AS_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -5321,7 +5310,7 @@ if test -z "$ac_cv_prog_AS_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5325: checking for $ac_word" >&5 +echo "configure:5314: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5352,7 +5341,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5356: checking for $ac_word" >&5 +echo "configure:5345: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5402,7 +5391,7 @@ fi if test -z "$ac_cv_path_DLLTOOL_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for dlltool in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5406: checking for dlltool in $with_build_time_tools" >&5 +echo "configure:5395: checking for dlltool in $with_build_time_tools" >&5 if test -x $with_build_time_tools/dlltool; then DLLTOOL_FOR_TARGET=`cd $with_build_time_tools && pwd`/dlltool ac_cv_path_DLLTOOL_FOR_TARGET=$DLLTOOL_FOR_TARGET @@ -5420,7 +5409,7 @@ if test -z "$ac_cv_path_DLLTOOL_FOR_TARGET" ; then # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5424: checking for $ac_word" >&5 +echo "configure:5413: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5457,7 +5446,7 @@ if test -z "$ac_cv_path_DLLTOOL_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in dlltool; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5461: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:5450: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_DLLTOOL_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -5474,7 +5463,7 @@ if test -z "$ac_cv_prog_DLLTOOL_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5478: checking for $ac_word" >&5 +echo "configure:5467: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5505,7 +5494,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5509: checking for $ac_word" >&5 +echo "configure:5498: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5555,7 +5544,7 @@ fi if test -z "$ac_cv_path_LD_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for ld in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5559: checking for ld in $with_build_time_tools" >&5 +echo "configure:5548: checking for ld in $with_build_time_tools" >&5 if test -x $with_build_time_tools/ld; then LD_FOR_TARGET=`cd $with_build_time_tools && pwd`/ld ac_cv_path_LD_FOR_TARGET=$LD_FOR_TARGET @@ -5573,7 +5562,7 @@ if test -z "$ac_cv_path_LD_FOR_TARGET" ; then # Extract the first word of "ld", so it can be a program name with args. set dummy ld; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5577: checking for $ac_word" >&5 +echo "configure:5566: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_LD_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5610,7 +5599,7 @@ if test -z "$ac_cv_path_LD_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in ld; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5614: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:5603: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_LD_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -5627,7 +5616,7 @@ if test -z "$ac_cv_prog_LD_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5631: checking for $ac_word" >&5 +echo "configure:5620: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5658,7 +5647,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5662: checking for $ac_word" >&5 +echo "configure:5651: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LD_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5708,7 +5697,7 @@ fi if test -z "$ac_cv_path_LIPO_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for lipo in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5712: checking for lipo in $with_build_time_tools" >&5 +echo "configure:5701: checking for lipo in $with_build_time_tools" >&5 if test -x $with_build_time_tools/lipo; then LIPO_FOR_TARGET=`cd $with_build_time_tools && pwd`/lipo ac_cv_path_LIPO_FOR_TARGET=$LIPO_FOR_TARGET @@ -5726,7 +5715,7 @@ if test -z "$ac_cv_path_LIPO_FOR_TARGET" ; then # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5730: checking for $ac_word" >&5 +echo "configure:5719: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_LIPO_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5763,7 +5752,7 @@ if test -z "$ac_cv_path_LIPO_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in lipo; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5767: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:5756: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_LIPO_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -5780,7 +5769,7 @@ if test -z "$ac_cv_prog_LIPO_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5784: checking for $ac_word" >&5 +echo "configure:5773: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LIPO_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5811,7 +5800,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5815: checking for $ac_word" >&5 +echo "configure:5804: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LIPO_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5861,7 +5850,7 @@ fi if test -z "$ac_cv_path_NM_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for nm in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5865: checking for nm in $with_build_time_tools" >&5 +echo "configure:5854: checking for nm in $with_build_time_tools" >&5 if test -x $with_build_time_tools/nm; then NM_FOR_TARGET=`cd $with_build_time_tools && pwd`/nm ac_cv_path_NM_FOR_TARGET=$NM_FOR_TARGET @@ -5879,7 +5868,7 @@ if test -z "$ac_cv_path_NM_FOR_TARGET" ; then # Extract the first word of "nm", so it can be a program name with args. set dummy nm; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5883: checking for $ac_word" >&5 +echo "configure:5872: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_NM_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5916,7 +5905,7 @@ if test -z "$ac_cv_path_NM_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in nm; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:5920: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:5909: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_NM_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -5933,7 +5922,7 @@ if test -z "$ac_cv_prog_NM_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5937: checking for $ac_word" >&5 +echo "configure:5926: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NM_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5964,7 +5953,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:5968: checking for $ac_word" >&5 +echo "configure:5957: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_NM_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6014,7 +6003,7 @@ fi if test -z "$ac_cv_path_OBJDUMP_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for objdump in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6018: checking for objdump in $with_build_time_tools" >&5 +echo "configure:6007: checking for objdump in $with_build_time_tools" >&5 if test -x $with_build_time_tools/objdump; then OBJDUMP_FOR_TARGET=`cd $with_build_time_tools && pwd`/objdump ac_cv_path_OBJDUMP_FOR_TARGET=$OBJDUMP_FOR_TARGET @@ -6032,7 +6021,7 @@ if test -z "$ac_cv_path_OBJDUMP_FOR_TARGET" ; then # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6036: checking for $ac_word" >&5 +echo "configure:6025: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_OBJDUMP_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6069,7 +6058,7 @@ if test -z "$ac_cv_path_OBJDUMP_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in objdump; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6073: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:6062: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_OBJDUMP_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -6086,7 +6075,7 @@ if test -z "$ac_cv_prog_OBJDUMP_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6090: checking for $ac_word" >&5 +echo "configure:6079: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6117,7 +6106,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6121: checking for $ac_word" >&5 +echo "configure:6110: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_OBJDUMP_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6167,7 +6156,7 @@ fi if test -z "$ac_cv_path_RANLIB_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for ranlib in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6171: checking for ranlib in $with_build_time_tools" >&5 +echo "configure:6160: checking for ranlib in $with_build_time_tools" >&5 if test -x $with_build_time_tools/ranlib; then RANLIB_FOR_TARGET=`cd $with_build_time_tools && pwd`/ranlib ac_cv_path_RANLIB_FOR_TARGET=$RANLIB_FOR_TARGET @@ -6185,7 +6174,7 @@ if test -z "$ac_cv_path_RANLIB_FOR_TARGET" ; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6189: checking for $ac_word" >&5 +echo "configure:6178: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_RANLIB_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6222,7 +6211,7 @@ if test -z "$ac_cv_path_RANLIB_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in ranlib; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6226: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:6215: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_RANLIB_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -6239,7 +6228,7 @@ if test -z "$ac_cv_prog_RANLIB_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6243: checking for $ac_word" >&5 +echo "configure:6232: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6270,7 +6259,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6274: checking for $ac_word" >&5 +echo "configure:6263: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6320,7 +6309,7 @@ fi if test -z "$ac_cv_path_STRIP_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for strip in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6324: checking for strip in $with_build_time_tools" >&5 +echo "configure:6313: checking for strip in $with_build_time_tools" >&5 if test -x $with_build_time_tools/strip; then STRIP_FOR_TARGET=`cd $with_build_time_tools && pwd`/strip ac_cv_path_STRIP_FOR_TARGET=$STRIP_FOR_TARGET @@ -6338,7 +6327,7 @@ if test -z "$ac_cv_path_STRIP_FOR_TARGET" ; then # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6342: checking for $ac_word" >&5 +echo "configure:6331: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_STRIP_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6375,7 +6364,7 @@ if test -z "$ac_cv_path_STRIP_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in strip; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6379: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:6368: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_STRIP_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -6392,7 +6381,7 @@ if test -z "$ac_cv_prog_STRIP_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6396: checking for $ac_word" >&5 +echo "configure:6385: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6423,7 +6412,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6427: checking for $ac_word" >&5 +echo "configure:6416: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_STRIP_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6473,7 +6462,7 @@ fi if test -z "$ac_cv_path_WINDRES_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then echo $ac_n "checking for windres in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6477: checking for windres in $with_build_time_tools" >&5 +echo "configure:6466: checking for windres in $with_build_time_tools" >&5 if test -x $with_build_time_tools/windres; then WINDRES_FOR_TARGET=`cd $with_build_time_tools && pwd`/windres ac_cv_path_WINDRES_FOR_TARGET=$WINDRES_FOR_TARGET @@ -6491,7 +6480,7 @@ if test -z "$ac_cv_path_WINDRES_FOR_TARGET" ; then # Extract the first word of "windres", so it can be a program name with args. set dummy windres; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6495: checking for $ac_word" >&5 +echo "configure:6484: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_WINDRES_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6528,7 +6517,7 @@ if test -z "$ac_cv_path_WINDRES_FOR_TARGET" ; then if test -n "$with_build_time_tools"; then for ncn_progname in windres; do echo $ac_n "checking for ${ncn_progname} in $with_build_time_tools""... $ac_c" 1>&6 -echo "configure:6532: checking for ${ncn_progname} in $with_build_time_tools" >&5 +echo "configure:6521: checking for ${ncn_progname} in $with_build_time_tools" >&5 if test -x $with_build_time_tools/${ncn_progname}; then ac_cv_prog_WINDRES_FOR_TARGET=$with_build_time_tools/${ncn_progname} echo "$ac_t""yes" 1>&6 @@ -6545,7 +6534,7 @@ if test -z "$ac_cv_prog_WINDRES_FOR_TARGET"; then # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6549: checking for $ac_word" >&5 +echo "configure:6538: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6576,7 +6565,7 @@ fi # Extract the first word of "${ncn_progname}", so it can be a program name with args. set dummy ${ncn_progname}; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:6580: checking for $ac_word" >&5 +echo "configure:6569: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_WINDRES_FOR_TARGET'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -6624,7 +6613,7 @@ fi RAW_CXX_FOR_TARGET="$CXX_FOR_TARGET" echo $ac_n "checking where to find the target ar""... $ac_c" 1>&6 -echo "configure:6628: checking where to find the target ar" >&5 +echo "configure:6617: checking where to find the target ar" >&5 if test "x${build}" != "x${host}" ; then if expr "x$AR_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6657,7 +6646,7 @@ else fi fi echo $ac_n "checking where to find the target as""... $ac_c" 1>&6 -echo "configure:6661: checking where to find the target as" >&5 +echo "configure:6650: checking where to find the target as" >&5 if test "x${build}" != "x${host}" ; then if expr "x$AS_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6690,7 +6679,7 @@ else fi fi echo $ac_n "checking where to find the target cc""... $ac_c" 1>&6 -echo "configure:6694: checking where to find the target cc" >&5 +echo "configure:6683: checking where to find the target cc" >&5 if test "x${build}" != "x${host}" ; then if expr "x$CC_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6723,7 +6712,7 @@ else fi fi echo $ac_n "checking where to find the target c++""... $ac_c" 1>&6 -echo "configure:6727: checking where to find the target c++" >&5 +echo "configure:6716: checking where to find the target c++" >&5 if test "x${build}" != "x${host}" ; then if expr "x$CXX_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6759,7 +6748,7 @@ else fi fi echo $ac_n "checking where to find the target c++ for libstdc++""... $ac_c" 1>&6 -echo "configure:6763: checking where to find the target c++ for libstdc++" >&5 +echo "configure:6752: checking where to find the target c++ for libstdc++" >&5 if test "x${build}" != "x${host}" ; then if expr "x$RAW_CXX_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6795,7 +6784,7 @@ else fi fi echo $ac_n "checking where to find the target dlltool""... $ac_c" 1>&6 -echo "configure:6799: checking where to find the target dlltool" >&5 +echo "configure:6788: checking where to find the target dlltool" >&5 if test "x${build}" != "x${host}" ; then if expr "x$DLLTOOL_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6828,7 +6817,7 @@ else fi fi echo $ac_n "checking where to find the target gcc""... $ac_c" 1>&6 -echo "configure:6832: checking where to find the target gcc" >&5 +echo "configure:6821: checking where to find the target gcc" >&5 if test "x${build}" != "x${host}" ; then if expr "x$GCC_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6861,7 +6850,7 @@ else fi fi echo $ac_n "checking where to find the target gcj""... $ac_c" 1>&6 -echo "configure:6865: checking where to find the target gcj" >&5 +echo "configure:6854: checking where to find the target gcj" >&5 if test "x${build}" != "x${host}" ; then if expr "x$GCJ_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6897,7 +6886,7 @@ else fi fi echo $ac_n "checking where to find the target gfortran""... $ac_c" 1>&6 -echo "configure:6901: checking where to find the target gfortran" >&5 +echo "configure:6890: checking where to find the target gfortran" >&5 if test "x${build}" != "x${host}" ; then if expr "x$GFORTRAN_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6933,7 +6922,7 @@ else fi fi echo $ac_n "checking where to find the target ld""... $ac_c" 1>&6 -echo "configure:6937: checking where to find the target ld" >&5 +echo "configure:6926: checking where to find the target ld" >&5 if test "x${build}" != "x${host}" ; then if expr "x$LD_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6966,7 +6955,7 @@ else fi fi echo $ac_n "checking where to find the target lipo""... $ac_c" 1>&6 -echo "configure:6970: checking where to find the target lipo" >&5 +echo "configure:6959: checking where to find the target lipo" >&5 if test "x${build}" != "x${host}" ; then if expr "x$LIPO_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -6989,7 +6978,7 @@ else fi fi echo $ac_n "checking where to find the target nm""... $ac_c" 1>&6 -echo "configure:6993: checking where to find the target nm" >&5 +echo "configure:6982: checking where to find the target nm" >&5 if test "x${build}" != "x${host}" ; then if expr "x$NM_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -7022,7 +7011,7 @@ else fi fi echo $ac_n "checking where to find the target objdump""... $ac_c" 1>&6 -echo "configure:7026: checking where to find the target objdump" >&5 +echo "configure:7015: checking where to find the target objdump" >&5 if test "x${build}" != "x${host}" ; then if expr "x$OBJDUMP_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -7055,7 +7044,7 @@ else fi fi echo $ac_n "checking where to find the target ranlib""... $ac_c" 1>&6 -echo "configure:7059: checking where to find the target ranlib" >&5 +echo "configure:7048: checking where to find the target ranlib" >&5 if test "x${build}" != "x${host}" ; then if expr "x$RANLIB_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -7088,7 +7077,7 @@ else fi fi echo $ac_n "checking where to find the target strip""... $ac_c" 1>&6 -echo "configure:7092: checking where to find the target strip" >&5 +echo "configure:7081: checking where to find the target strip" >&5 if test "x${build}" != "x${host}" ; then if expr "x$STRIP_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -7121,7 +7110,7 @@ else fi fi echo $ac_n "checking where to find the target windres""... $ac_c" 1>&6 -echo "configure:7125: checking where to find the target windres" >&5 +echo "configure:7114: checking where to find the target windres" >&5 if test "x${build}" != "x${host}" ; then if expr "x$WINDRES_FOR_TARGET" : "x/" > /dev/null; then # We already found the complete path @@ -7182,7 +7171,7 @@ fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:7186: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:7175: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -7438,7 +7427,6 @@ s%@build_configdirs@%$build_configdirs%g s%@host_configargs@%$host_configargs%g s%@configdirs@%$configdirs%g s%@target_configargs@%$target_configargs%g -s%@target_configdirs@%$target_configdirs%g s%@CC_FOR_BUILD@%$CC_FOR_BUILD%g s%@config_shell@%$config_shell%g s%@YACC@%$YACC%g diff --git a/configure.in b/configure.in index adb53b9..da7c63f 100644 --- a/configure.in +++ b/configure.in @@ -305,7 +305,6 @@ AC_ARG_ENABLE(libada, ENABLE_LIBADA=$enableval, ENABLE_LIBADA=yes) if test "${ENABLE_LIBADA}" != "yes" ; then - noconfigdirs="$noconfigdirs target-libada" noconfigdirs="$noconfigdirs gnattools" fi @@ -313,9 +312,6 @@ AC_ARG_ENABLE(libssp, [ --enable-libssp Builds libssp directory], ENABLE_LIBSSP=$enableval, ENABLE_LIBSSP=yes) -if test "${ENABLE_LIBSSP}" != "yes" ; then - noconfigdirs="$noconfigdirs target-libssp" -fi # Set the default so we build libgcc-math for ix86 and x86_64 AC_ARG_ENABLE(libgcc-math, @@ -328,9 +324,6 @@ case "${target}" in enable_libgcc_math=no ;; esac ]) -if test "${enable_libgcc_math}" != "yes"; then - noconfigdirs="$noconfigdirs target-libgcc-math" -fi # Save it here so that, even in case of --enable-libgcj, if the Java # front-end isn't enabled, we still get libgcj disabled. @@ -349,14 +342,8 @@ no) esac -# Allow --disable-libmudflap to exclude target-libmudflap -case $enable_libmudflap in -yes) - ;; -no) - noconfigdirs="$noconfigdirs target-libmudflap" - ;; -"") +# Disable libmudflap on some systems. +if test x$enable_libmudflap = x ; then case "${target}" in *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu) # Enable libmudflap by default in GNU and friends. @@ -369,16 +356,10 @@ no) noconfigdirs="$noconfigdirs target-libmudflap" ;; esac -esac +fi -# Allow --disable-libgomp to exclude target-libgomp -case $enable_libgomp in -yes) - ;; -no) - noconfigdirs="$noconfigdirs target-libgomp" - ;; -"") +# Disable libgomp on non POSIX hosted systems. +if test x$enable_libgomp = x ; then # Enable libgomp by default on hosted POSIX systems. case "${target}" in *-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu) @@ -393,7 +374,7 @@ no) noconfigdirs="$noconfigdirs target-libgomp" ;; esac -esac +fi case "${target}" in @@ -1337,6 +1318,14 @@ Recognised languages are: ${potential_languages}]) ac_configure_args=`echo " $ac_configure_args" | sed -e 's/ --enable-languages=[[^ ]]*//' -e 's/$/ --enable-languages='"$enable_languages"/ ` fi +# Handle --disable- generically. +for dir in $configdirs $build_configdirs $target_configdirs ; do + dirname=`echo $dir | sed -e s/target-//g -e s/build-//g -e s/-/_/g` + if eval test x\${enable_${dirname}} "=" xno ; then + noconfigdirs="$noconfigdirs $dir" + fi +done + # Remove the entries in $skipdirs and $noconfigdirs from $configdirs, # $build_configdirs and $target_configdirs. # If we have the source for $noconfigdirs entries, add them to $notsupp. @@ -2171,7 +2160,7 @@ AC_SUBST(configdirs) # Target module lists & subconfigure args. AC_SUBST(target_configargs) -AC_SUBST(target_configdirs) + # Build tools. AC_SUBST(CC_FOR_BUILD) diff --git a/cpu/ChangeLog b/cpu/ChangeLog index 74e89b1..2a888e0 100644 --- a/cpu/ChangeLog +++ b/cpu/ChangeLog @@ -1,3 +1,20 @@ +2006-03-13 DJ Delorie + + * m32c.cpu (Bit3-S): New. + (btst:s): New. + * m32c.opc (parse_bit3_S): New. + + * m32c.cpu (decimal-subtraction16-insn): Add second operand. + (btst): Add optional :G suffix for MACH32. + (or.b:S): New. + (pop.w:G): Add optional :G suffix for MACH16. + (push.b.imm): Fix syntax. + +2006-03-10 DJ Delorie + + * m32c.cpu (mul.l): New. + (mulu.l): New. + 2006-03-03 Shrirang Khisti ldc #imm,intbh ; ldc #imm,intbl + (dni ldipl16.imm "ldipl #imm" ((machine 16)) ("ldipl #${Imm-13-u3}") (+ (f-0-4 #x7) (f-4-4 #xD) (f-8-4 #xA) (f-12-1 0) Imm-13-u3) @@ -8909,6 +8923,17 @@ ; mul.BW src,dst (binary-arith-src-dst mul G (f-0-4 #x7) (f-4-3 4) #x1 #xC mul-sem) +(dni mul_l "mul.l src,r2r0" ((machine 32)) + ("mul.l ${dst32-24-Prefixed-SI},r2r0") + (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x1) (f-20-4 #xf) + dst32-24-Prefixed-SI) + () ()) + +(dni mulu_l "mulu.l src,r2r0" ((machine 32)) + ("mulu.l ${dst32-24-Prefixed-SI},r2r0") + (+ (f-0-4 #x0) (f-4-4 #x1) (f-8-4 #x8) (f-15-1 #x1) (f-18-2 #x0) (f-20-4 #xf) + dst32-24-Prefixed-SI) + () ()) ;------------------------------------------------------------- ; mulex - multiple extend sign (m32) ;------------------------------------------------------------- @@ -9021,6 +9046,8 @@ (binary-arith32-s-imm-dst HI .w 1 or #x1 #x2 or-sem) ; or.BW src,dst (m16 #3 m32 #3) (binary-arith-src-dst or G (f-0-4 #x9) (f-4-3 4) #x1 #x5 or-sem) +; or.b:S src,r0[lh] (m16) +(binary-arith16-b-S-src2 or (f-0-4 1) (f-4-1 1) or-sem) ;------------------------------------------------------------- ; pop - restore register/memory @@ -9046,7 +9073,7 @@ (define-pmacro (pop-sem32 mode dest) (pop-sem-mach 32 mode dest)) ; pop.BW:G (m16 #1) -(unary-insn-mach 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16) +(unary-insn-mach-g 16 pop (f-0-4 7) (f-4-3 2) (f-8-4 #xD) pop-sem16 $G) ; pop.BW:G (m32 #1) (unary-insn-mach 32 pop #xB #x2 #xF pop-sem32) @@ -9357,7 +9384,7 @@ ()) (dni push32.b.imm "push.b #Imm-8-QI" ((machine 32)) - ("push.b #Imm-8-QI") + ("push.b #${Imm-8-QI}") (+ (f-0-4 #xA) (f-4-4 #xE) Imm-8-QI) (push-sem32 QI Imm-8-QI) ()) diff --git a/cpu/m32c.opc b/cpu/m32c.opc index 6235326..f664e9a 100644 --- a/cpu/m32c.opc +++ b/cpu/m32c.opc @@ -534,6 +534,24 @@ parse_imm3_S (CGEN_CPU_DESC cd, const char **strp, } static const char * +parse_bit3_S (CGEN_CPU_DESC cd, const char **strp, + int opindex, signed long *valuep) +{ + const char *errmsg = 0; + signed long value; + + errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); + if (errmsg) + return errmsg; + + if (value < 0 || value > 7) + return _("immediate is out of range 0-7"); + + *valuep = value; + return 0; +} + +static const char * parse_lab_5_3 (CGEN_CPU_DESC cd, const char **strp, int opindex ATTRIBUTE_UNUSED, diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cbd4d1e..69d3ba7 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,298 @@ +2006-03-29 Daniel Jacobowitz + + * NEWS: Mention the removal of NLM. + +2006-03-29 Steve Ellcey + + * Makefile.in (nlm): Remove target. + * configure.tgt (i[34567]86-*-netware*): Do not set build_nlm. + * configure.ac: Remove AC_CONFIG_SUBDIRS of nlm. + * configure: Regenerate. + * doc/gdb.texinfo: Remove gdbserve.nlm documentation. + * nlm: Remove directory. + +2006-03-29 Daniel Jacobowitz + + * Makefile.in (utils.o): Update. + * top.c (in_user_command): New. + (command_line_input): Use input_from_terminal_p. + (input_from_terminal_p): Don't check caution. Handle + stdin == NULL for Insight. + * top.h (in_user_command, caution): New declarations. + * utils.c: Include "top.h". + (query, defaulted_query): Check caution here. Move the call + to input_from_terminal_p higher. + * cli/cli-script.c (do_restore_user_call_depth): Only decrement + the depth. Update in_user_command if necessary. + (execute_user_command): Don't clobber old_chain. Set + in_user_command. Let do_restore_user_call_depth handle + user_call_depth. + (read_command_lines): Check whether to prompt before calling + Insight hooks. + * tui/tui-hooks.c (tui_query_hook): Remove newly unnecessary + input_from_terminal_p check. + +2006-03-29 Ulrich Weigand + + * s390-nat.c (s390_insert_watchpoint): Add missing argument. + (s390_remove_watchpoint): Likewise. + +2006-03-28 Jim Blandy + + * prologue-value.c, prologue-value.h: New files. + * Makefile.in (prologue_value_h): New variable. + (HFILES_NO_SRCDIR): List prologue-value.h. + (SFILES): List prologue-value.c. + (COMMON_OBS): List prologue-value.o. + (prologue-value.o): New rule. + +2006-03-27 Michael Snyder + + * xstormy16-tdep.c (xstormy16_return_value, xstormy16_push_dummy_call, + xstormy16_pointer_to_address, xstormy16_address_to_pointer, + xstormy16_frame_prev_register): Change void* to gdb_byte*. + (xstormy16_push_dummy_call): Add block-local char* val, + to avoid type conflict with outer scope variable. + +2006-03-27 Andrew Stubbs + + * sh-tdep.c (sh_gdbarch_init): Add missing architectures. + +2006-03-27 Nick Roberts + + * varobj.c (c_name_of_child, c_value_of_child): Allow non-zero + offsets for languages like Fortran. + +2006-03-26 Randolph Chung + + * config/pa/hppa64.mt: Use HPUX version of the tm file. + +2006-03-25 Nick Roberts + + * mi/gdb-mi.el (gdbmi-send): Improve regexp to repeat commands. + Try to deal with continuation line. + (gdbmi, gdbmi-prompt1, gud-gdbmi-marker-filter): Update to new + variable names. + (gdb-break-list-regexp, gdb-stack-list-frames-regexp): + Future proof against new fields being added to MI output. + (gdbmi-prompt2, gdb-break-list-handler,gdb-get-source-file) + (gdbmi-frame-handler): Update to new variable name + gdb-get-buffer-create. + (gdbmi-frame-handler): Use hollow-right-triangle for all selected + frames which except the innermost (where execution has stopped). + +2006-03-24 Randolph Chung + + * solib-som.c (link_map_start): Don't error out if there is + not yet a link map. + +2006-03-24 Daniel Jacobowitz + + * linux-nat.c (linux_ops_saved): New. + (super_mourn_inferior, kill_inferior, threaded, linux_nat_ops) + (child_mourn_inferior, child_wait, linux_nat_create_inferior) + (linux_nat_fetch_registers, linux_nat_store_registers) + (linux_nat_child_post_startup_inferior, init_linux_nat_ops): Delete. + (init_lwp_list): Don't set threaded. + (add_lwp): Don't modify threaded. + (delete_lwp): Don't mention non-threaded mode. + (linux_nat_switch_fork): New. + (linux_nat_attach): Update inferior_ptid. + (linux_nat_wait): Handle num_lwps == 0 at entry. Don't check + threaded flag. + (linux_nat_kill): Handle pending forks and saved forks. + (linux_nat_mourn_inferior): Handle saved forks. + (linux_nat_pid_to_str): Don't use the LWP form when there is + only one thread. + (linux_target): Don't set to_wait, to_kill, or to_mourn_inferior. + (linux_nat_add_target): New. + (_initialize_linux_nat): Don't initialize the linux native target + here. + * linux-nat.h (linux_nat_add_target, linux_nat_switch_fork): New + prototypes. + * linux-fork.c: Include "linux-nat.h". + (add_fork): Update initial PID. + (fork_load_infrun_state): Call linux_nat_switch_fork. + * Makefile.in (linux-fork.o): Update. + + * alpha-linux-nat.c (_initialize_alpha_linux_nat): Use + linux_nat_add_target instead of add_target. + * amd64-linux-nat.c (_initialize_amd64_linux_nat): Likewise. + * arm-linux-nat.c (_initialize_arm_linux_nat): Likewise. + * hppa-linux-nat.c (_initialize_hppa_linux_nat): Likewise. + * ia64-linux-nat.c (_initialize_ia64_linux_nat): Likewise. + * i386-linux-nat.c (_initialize_i386_linux_nat): Likewise. + * m32r-linux-nat.c (_initialize_m32r_linux_nat): Likewise. + * m68klinux-nat.c (_initialize_m68k_linux_nat): Likewise. + * mips-linux-nat.c (_initialize_mips_linux_nat): Likewise. + * ppc-linux-nat.c (_initialize_ppc_linux_nat): Likewise. + * s390-nat.c (_initialize_s390_nat): Likewise. + * sparc-linux-nat.c (_initialize_sparc_linux_nat): Likewise. + * sparc64-linux-nat.c (_initialize_sparc64_linux_nat): Likewise. + +2006-03-24 Daniel Jacobowitz + + * linux-fork.c: Include "gdb_assert.h". + (fork_load_infrun_state): Set inferior_ptid and stop_pc here. + Update the register cache and selected frame also. + (linux_fork_mourn_inferior): Use fork_load_infrun_state. Return + to single fork mode if necessary. + (linux_fork_context): Remove bits handled by fork_load_infrun_state. + * Makefile.in (linux_fork_h): New. + (linux-fork.o, linux-nat.o): Update. + +2006-03-23 Andreas Schwab + + * config/s390/s390.mh (NATDEPFILES): Add linux-fork.o. + +2006-03-18 Jim Blandy + + * symtab.h (enum address_class): Doc fix. + +2006-03-16 Michael Snyder + + * tracepoint.c (tracepoint_save_command): Fix typo in error msg. + * target.c (push_target): Fix typo in comment. + * remote.c (remote_watch_data_address): Fix typo in comment. + * i386-tdep.c (i386_push_dummy_call): Fix typo in comment. + +2006-03-15 Kevin Buettner + + * frv-linux-tdep.c (gdbcore.h, regcache.h, regset.h, gdb_string.h): + Include. + (FRV_ELF_NGREG, FRV_PT_PSR, FRV_PT_ISR, FRV_PT_CCR, FRV_PT_CCCR) + (FRV_PT_LR, FRV_PT_LCR, FRV_PT_PC, FRV_PT_GNER0, FRV_PT_GNER1) + (FRV_PT_IACC0H, FRV_PT_IACC0L, FRV_PT_GR, FRV_PT_TBR) + (FRV_PT_EXEC_FDPIC_LOADMAP, FRV_PT_INTERP_FDPIC_LOADMAP): Define. + (frv_elf_greg_t, frv_elf_gregset_t, frv_elf_fpreg_t) + (frv_elf_fpregset_t): Define types. + (frv_linux_supply_gregset, frv_linux_supply_fpregset) + (frv_linux_regset_from_core_section: New functions. + (frv_linux_gregset, frv_linux_fpregset): New static globals. + (frv_linux_init_abi): Register the `regset_from_core_section' method. + * Makefile.in (frv-linux-tdep.o): Update dependencies. + * solib-frv.c (frv_current_sos): Relocate main executable after + loading core file. + (frv_clear_solib): Clean up space associated with + `main_executable_lm_info'. + * config/frv/frv.mt (TDEPFILES): Add corelow.o to this list. + +2006-03-15 Daniel Jacobowitz + + * Makefile.in (mips_linux_tdep_h): New. + (mpis-linux-nat.o, mips-linux-tdep.o): Update. + * mips-linux-nat.c: Include "inferior.h", "mips-linux-tdep.h", and + . + (have_ptrace_regsets, super_fetch_registers, super_store_registers) + (mips64_linux_regsets_fetch_registers) + (mips64_linux_regsets_store_registers, mips64_linux_fetch_registers) + (mips64_linux_store_registers): New. + (_initialize_mips_linux_nat): Override to_fetch_registers and + to_store_registers. + * mips-linux-tdep.h: New file. + * mips-linux-tdep.c: Include "mips-linux-tdep.c". + (ELF_NGREG, ELF_NFPREG, elf_greg_t, elf_gregset_t, elf_fpreg_t) + (elf_fpregset_t, FPR_BASE, PC, CAUSE, BADVADDR, MMHI, MMLO) + (FPC_CSR, FPC_EIR, EF_REG0, EF_REG31, EF_LO, EF_HI, EF_CP0_EPC) + (EF_CP0_BADVADDR, EF_CP0_STATUS, EF_CP0_CAUSE, EF_SIZE) + (MIPS64_ELF_NGREG, MIPS64_ELF_NFPREG, mips64_elf_greg_t) + (mips64_elf_gregset_t, mips64_elf_fpreg_t, mips64_elf_fpregset_t) + (MIPS64_FPR_BASE, MIPS64_PC, MIPS64_CAUSE, MIPS64_BADVADDR) + (MIPS64_MMHI, MIPS64_MMLO, MIPS64_FPC_CSR, MIPS64_FPC_EIR) + (MIPS64_EF_REG0, MIPS64_EF_REG31, MIPS64_EF_LO, MIPS64_EF_HI) + (MIPS64_EF_CP0_EPC, MIPS64_EF_CP0_BADVADDR, MIPS64_EF_CP0_STATUS) + (MIPS64_EF_CP0_CAUSE, MIPS64_EF_SIZE): Delete. + (supply_32bit_reg): Use gdb_byte. + (supply_64bit_reg): New. + (mips_supply_gregset, mips_fill_gregset, mips_supply_fpregset) + (mips_fill_fpregset, fetch_core_registers, supply_gregset) + (fill_gregset, supply_fpregset): Update for renamed types. + (mips64_supply_gregset): Use gdb_byte and supply_64bit_reg. + (mips64_fill_gregset): Make global. Handle 32-bit register + sizes. + (mips64_fill_fpregset): Make global. Use gdb_byte. Handle + FP regsets properly. + +2006-03-15 Daniel Jacobowitz + + * mips-linux-tdep.c (mips_supply_gregset): Renamed from supply_gregset. + (mips_fill_gregset): Renamed from fill_gregset. + (mips_supply_fpregset): Renamed from supply_fpregset. + (mips_fill_fpregset): Renamed from fill_fpregset. + (fetch_core_registers): Update calls. + (supply_gregset, fill_gregset, supply_fpregset, fill_fpregset): New + functions. + +2006-03-15 Daniel Jacobowitz + + * mips-tdep.c (mips_gdbarch_init): Default 64-bit ELF files to N64. + +2006-03-15 Daniel Jacobowitz + + * mips-tdep.c (is_mips16_addr, mips32_next_pc, add_offset_16): + Correct arithmetic for 64-bit CORE_ADDR. + +2006-03-15 Daniel Jacobowitz + + * mips-linux-tdep.c: Include "floatformat.h". + (mips_linux_init_abi): Use 128-bit long double for N32 and N64. + * mips-tdep.c (mips_n32n64_return_value): Support 128-bit long + double. + (print_gp_register_row): Don't print spaces before ignored + or floating point registers. + * Makefile.in (mips-linux-tdep.o): Update. + +2006-03-15 Daniel Jacobowitz + + * mips-mdebug-tdep.c (compare_pdr_entries): Use bfd_get_signed_32 + for code addresses. + (non_heuristic_proc_desc): Likewise. + +2006-03-15 Daniel Jacobowitz + + * mips-linux-nat.c: Include "gdb_proc_service.h". + (PTRACE_GET_THREAD_AREA): Define. + (ps_get_thread_area): New. + * Makefile.in (mips-linux-nat.o): Update. + +2006-03-13 Jim Blandy + + * MAINTAINERS: Use my work address. + +2006-03-09 Michael Snyder + + * linux-nat.c (kill_inferior): Just call target_mourn_inferior + instead of getting tricky for the multi-fork case. + * linux-fork.c (linux_fork_killall): Call PT_KILL and waitpid + for each fork, and then use init_fork_list to delete them. + +2006-03-08 Alexandre Oliva + + * solib-svr4.c (svr4_current_sos): Move up initialization of + l_addr, such that it clearly covers all cases. + +2006-03-08 Andreas Schwab + + * ia64-tdep.c (ia64_libunwind_frame_this_id): Adapt use of + libunwind_frame_prev_register to use a gdb_byte buffer and + extract_unsigned_integer. + (ia64_libunwind_sigtramp_frame_prev_register): Likewise. + + * libunwind-frame.c (libunwind_frame_prev_register): Change type + of last argument to `gdb_byte *' + * libunwind-frame.h: Adjust declaration. + +2006-03-08 Paul Brook + + * arm-tdep.c (arm_push_dummy_call): Remove stack alignment. + (arm_frame_align): New function. + (arm_gdbarch_init): Use it. + +2006-03-03 Khem Raj + + * remote-rdp.c (remote_rdp_xfer_inferior_memory): Use gdb_byte. + Committed by Andrew Cagney. + 2006-03-02 Corinna Vinschen * mn10300-tdep.c (mn10300_push_dummy_call): Write breakpoint @@ -331,7 +626,7 @@ * mi/gdb-mi.el: Use more functions from gdb-ui.el. (gdb-break-list-regexp): Match "what" field if present. - (gdb-stack-list-frames-regexp): Match "from" if present field. + (gdb-stack-list-frames-regexp): Match "from" field if present. (gdb-stack-list-frames-handler): Present output like "info breakpoints" so regexps can be shared with gdb-ui diff --git a/gdb/MAINTAINERS b/gdb/MAINTAINERS index fee5ebc..59b93c9 100644 --- a/gdb/MAINTAINERS +++ b/gdb/MAINTAINERS @@ -112,7 +112,7 @@ alphabetical order. Their affiliations are provided for reference only - their membership on the Steering Committee is individual and not through their affiliation, and they act on behalf of the GNU project. - Jim Blandy (Red Hat) + Jim Blandy (CodeSourcery) Andrew Cagney (Red Hat) Robert Dewar (AdaCore, NYU) Klee Dienes (Apple) @@ -155,7 +155,7 @@ future, if there are, a reference to the list will be included here. The current global maintainers are (in alphabetical order): -Jim Blandy jimb@red-bean.com +Jim Blandy jimb@codesourcery.com Kevin Buettner kevinb@redhat.com Andrew Cagney cagney@gnu.org Fred Fish fnf@ninemoons.com @@ -192,7 +192,6 @@ patches; and ensure that contributors are given credit. Current patch champions (in alphabetical order): - Joel Brobecker Daniel Jacobowitz @@ -433,7 +432,7 @@ John David Anglin dave.anglin@nrc-cnrc.gc.ca Shrinivas Atre shrinivasa@kpitcummins.com Scott Bambrough scottb@netwinder.org Jan Beulich jbeulich@novell.com -Jim Blandy jimb@red-bean.com +Jim Blandy jimb@codesourcery.com Philip Blundell philb@gnu.org Per Bothner per@bothner.com Joel Brobecker brobecker@adacore.com diff --git a/gdb/Makefile.in b/gdb/Makefile.in index d5abb4f..644e9d9 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -542,6 +542,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c \ objc-exp.y objc-lang.c \ objfiles.c osabi.c observer.c \ p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \ + prologue-value.c \ regcache.c reggroups.c remote.c remote-fileio.c \ scm-exp.c scm-lang.c scm-valprint.c \ sentinel-frame.c \ @@ -726,6 +727,7 @@ kod_h = kod.h language_h = language.h libunwind_frame_h = libunwind-frame.h $(libunwind_h) linespec_h = linespec.h +linux_fork_h = linux-fork.h linux_nat_h = linux-nat.h $(target_h) m2_lang_h = m2-lang.h m32r_tdep_h = m32r-tdep.h @@ -737,6 +739,7 @@ macrotab_h = macrotab.h main_h = main.h mdebugread_h = mdebugread.h $(coff_sym_h) $(coff_symconst_h) memattr_h = memattr.h +mips_linux_tdep_h = mips-linux-tdep.h mips_mdebug_tdep_h = mips-mdebug-tdep.h mipsnbsd_tdep_h = mipsnbsd-tdep.h mips_tdep_h = mips-tdep.h @@ -755,6 +758,7 @@ ppcnbsd_tdep_h = ppcnbsd-tdep.h ppcobsd_tdep_h = ppcobsd-tdep.h ppc_tdep_h = ppc-tdep.h proc_utils_h = proc-utils.h +prologue_value_h = prologue-value.h regcache_h = regcache.h reggroups_h = reggroups.h regset_h = regset.h @@ -865,6 +869,7 @@ HFILES_NO_SRCDIR = bcache.h buildsym.h call-cmds.h coff-solib.h defs.h \ symfile.h stabsread.h target.h terminal.h typeprint.h \ xcoffsolib.h \ macrotab.h macroexp.h macroscope.h \ + prologue-value.h \ ada-lang.h c-lang.h f-lang.h \ jv-lang.h \ m2-lang.h p-lang.h \ @@ -1201,9 +1206,6 @@ $(TUI)$(EXEEXT): tui-main.o libgdb.a $(ADD_DEPS) $(CDEPS) $(TDEPLIBS) -o $(TUI)$(EXEEXT) tui-main.o libgdb.a \ $(TDEPLIBS) $(TUI_LIBRARY) $(CLIBS) $(LOADLIBES) -nlm: force - rootme=`pwd`; export rootme; $(MAKE) $(TARGET_FLAGS_TO_PASS) DO=all DODIRS=nlm subdir_do - # Create a library of the gdb object files and build GDB by linking # against that. # @@ -1963,9 +1965,10 @@ frame.o: frame.c $(defs_h) $(frame_h) $(target_h) $(value_h) $(inferior_h) \ $(command_h) $(gdbcmd_h) $(observer_h) $(objfiles_h) $(exceptions_h) frame-unwind.o: frame-unwind.c $(defs_h) $(frame_h) $(frame_unwind_h) \ $(gdb_assert_h) $(dummy_frame_h) $(gdb_obstack_h) -frv-linux-tdep.o: frv-linux-tdep.c $(defs_h) $(target_h) $(frame_h) \ - $(osabi_h) $(elf_bfd_h) $(elf_frv_h) $(frv_tdep_h) $(trad_frame_h) \ - $(frame_unwind_h) +frv-linux-tdep.o: frv-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \ + $(frame_h) $(osabi_h) $(regcache_h) $(elf_bfd_h) $(elf_frv_h) \ + $(frv_tdep_h) $(trad_frame_h) $(frame_unwind_h) $(regset_h) \ + $(gdb_string_h) frv-tdep.o: frv-tdep.c $(defs_h) $(gdb_string_h) $(inferior_h) $(gdbcore_h) \ $(arch_utils_h) $(regcache_h) $(frame_h) $(frame_unwind_h) \ $(frame_base_h) $(trad_frame_h) $(dis_asm_h) $(gdb_assert_h) \ @@ -2186,12 +2189,14 @@ linespec.o: linespec.c $(defs_h) $(symtab_h) $(frame_h) $(command_h) \ $(symfile_h) $(objfiles_h) $(source_h) $(demangle_h) $(value_h) \ $(completer_h) $(cp_abi_h) $(parser_defs_h) $(block_h) \ $(objc_lang_h) $(linespec_h) $(exceptions_h) -linux-fork.o: linux-fork.c linux-fork.h $(defs_h) $(inferior_h) \ - $(regcache_h) $(gdbcmd_h) $(infcall_h) +linux-fork.o: linux-fork.c $(defs_h) $(inferior_h) $(regcache_h) $(gdbcmd_h) \ + $(infcall_h) $(gdb_assert_h) $(gdb_string_h) $(linux_fork_h) \ + $(linux_nat_h) linux-nat.o: linux-nat.c $(defs_h) $(inferior_h) $(target_h) $(gdb_string_h) \ $(gdb_wait_h) $(gdb_assert_h) $(linux_nat_h) $(gdbthread_h) \ $(gdbcmd_h) $(regcache_h) $(inf_ptrace.h) $(auxv.h) $(elf_bfd_h) \ - $(gregset_h) $(gdbcore_h) $(gdbthread_h) $(gdb_stat_h) linux-fork.h + $(gregset_h) $(gdbcore_h) $(gdbthread_h) $(gdb_stat_h) \ + $(linux_fork_h) linux-thread-db.o: linux-thread-db.c $(defs_h) $(gdb_assert_h) \ $(gdb_proc_service_h) $(gdb_thread_db_h) $(bfd_h) $(exceptions_h) \ $(gdbthread_h) $(inferior_h) $(symfile_h) $(objfiles_h) $(target_h) \ @@ -2295,11 +2300,12 @@ mips64obsd-tdep.o: mips64obsd-tdep.c $(defs_h) $(osabi_h) $(regcache_h) \ $(gdb_string_h) $(mips_tdep_h) $(solib_svr4_h) mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h) mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) $(target_h) \ - $(linux_nat_h) + $(linux_nat_h) $(gdb_proc_service_h) $(mips_linux_tdep_h) \ + $(inferior_h) mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \ $(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \ $(gdb_assert_h) $(frame_h) $(regcache_h) $(trad_frame_h) \ - $(tramp_frame_h) + $(tramp_frame_h) $(floatformat_h) $(mips_linux_tdep_h) mips-mdebug-tdep.o: mips-mdebug-tdep.c $(defs_h) $(frame_h) $(mips_tdep_h) \ $(trad_frame_h) $(block_h) $(symtab_h) $(objfiles_h) $(elf_mips_h) \ $(elf_bfd_h) $(gdb_assert_h) $(frame_unwind_h) $(frame_base_h) \ @@ -2431,6 +2437,8 @@ procfs.o: procfs.c $(defs_h) $(inferior_h) $(target_h) $(gdbcore_h) \ proc-service.o: proc-service.c $(defs_h) $(gdb_proc_service_h) $(inferior_h) \ $(symtab_h) $(target_h) $(gregset_h) proc-why.o: proc-why.c $(defs_h) $(proc_utils_h) +prologue-value.o: prologue-value.c $(defs_h) $(gdb_string_h) $(gdb_assert_h) \ + $(prologue_value_h) $(regcache_h) p-typeprint.o: p-typeprint.c $(defs_h) $(gdb_obstack_h) $(bfd_h) $(symtab_h) \ $(gdbtypes_h) $(expression_h) $(value_h) $(gdbcore_h) $(target_h) \ $(language_h) $(p_lang_h) $(typeprint_h) $(gdb_string_h) @@ -2733,7 +2741,7 @@ user-regs.o: user-regs.c $(defs_h) $(user_regs_h) $(gdbtypes_h) \ utils.o: utils.c $(defs_h) $(gdb_assert_h) $(gdb_string_h) $(event_top_h) \ $(exceptions_h) $(tui_h) $(gdbcmd_h) $(serial_h) $(bfd_h) \ $(target_h) $(demangle_h) $(expression_h) $(language_h) $(charset_h) \ - $(annotate_h) $(filenames_h) $(symfile_h) $(inferior_h) \ + $(annotate_h) $(filenames_h) $(symfile_h) $(inferior_h) $(top_h) \ $(gdb_curses_h) $(readline_h) $(gdb_obstack_h) uw-thread.o: uw-thread.c $(defs_h) $(gdbthread_h) $(target_h) $(inferior_h) \ $(regcache_h) $(gregset_h) diff --git a/gdb/NEWS b/gdb/NEWS index c42313c..526f45a 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -51,6 +51,8 @@ network sockets or serial ports. The ARM rdi-share module. +The Netware NLM debug server. + *** Changes in GDB 6.4 * New native configurations diff --git a/gdb/alpha-linux-nat.c b/gdb/alpha-linux-nat.c index c855992..183a7a4 100644 --- a/gdb/alpha-linux-nat.c +++ b/gdb/alpha-linux-nat.c @@ -1,5 +1,5 @@ /* Low level Alpha GNU/Linux interface, for GDB when running native. - Copyright (C) 2005 + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -28,5 +28,5 @@ void _initialialize_alpha_linux_nat (void); void _initialize_alpha_linux_nat (void) { - add_target (linux_target ()); + linux_nat_add_target (linux_target ()); } diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index 8fa6df9..b4a7112 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -1,6 +1,7 @@ /* Native-dependent code for GNU/Linux x86-64. - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. Contributed by Jiri Smid, SuSE Labs. This file is part of GDB. @@ -399,5 +400,5 @@ _initialize_amd64_linux_nat (void) t->to_store_registers = amd64_linux_store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 16298cc..8023026 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -1,5 +1,5 @@ /* GNU/Linux on ARM native support. - Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005 + Copyright (C) 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -736,5 +736,5 @@ _initialize_arm_linux_nat (void) t->to_store_registers = arm_linux_store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 652be4b..cb3c261 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1173,11 +1173,6 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, argreg = ARM_A1_REGNUM; nstack = 0; - /* Some platforms require a double-word aligned stack. Make sure sp - is correctly aligned before we start. We always do this even if - it isn't really needed -- it can never hurt things. */ - sp &= ~(CORE_ADDR)(2 * DEPRECATED_REGISTER_SIZE - 1); - /* The struct_return pointer occupies the first parameter passing register. */ if (struct_return) @@ -1299,6 +1294,17 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function, return sp; } + +/* Always align the frame to an 8-byte boundary. This is required on + some platforms and harmless on the rest. */ + +static CORE_ADDR +arm_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp) +{ + /* Align the stack to eight bytes. */ + return sp & ~ (CORE_ADDR) 7; +} + static void print_fpu_flags (int flags) { @@ -2738,6 +2744,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->jb_pc = -1; /* Longjump support not enabled by default. */ set_gdbarch_push_dummy_call (gdbarch, arm_push_dummy_call); + set_gdbarch_frame_align (gdbarch, arm_frame_align); set_gdbarch_write_pc (gdbarch, arm_write_pc); diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index ee986d1..b8e9d4f 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -1,8 +1,8 @@ /* GDB CLI command scripting. Copyright (c) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005 Free - Software Foundation, Inc. + 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of GDB. @@ -241,9 +241,9 @@ static void do_restore_user_call_depth (void * call_depth) { int * depth = call_depth; - /* We will be returning_to_top_level() at this point, so we want to - reset our depth. */ - (*depth) = 0; + (*depth)--; + if ((*depth) == 0) + in_user_command = 0; } @@ -266,12 +266,17 @@ execute_user_command (struct cmd_list_element *c, char *args) if (++user_call_depth > max_user_call_depth) error (_("Max user call depth exceeded -- command aborted.")); - old_chain = make_cleanup (do_restore_user_call_depth, &user_call_depth); + make_cleanup (do_restore_user_call_depth, &user_call_depth); /* Set the instream to 0, indicating execution of a user-defined function. */ - old_chain = make_cleanup (do_restore_instream_cleanup, instream); + make_cleanup (do_restore_instream_cleanup, instream); instream = (FILE *) 0; + + /* Also set the global in_user_command, so that NULL instream is + not confused with Insight. */ + in_user_command = 1; + while (cmdlines) { ret = execute_control_command (cmdlines); @@ -283,8 +288,6 @@ execute_user_command (struct cmd_list_element *c, char *args) cmdlines = cmdlines->next; } do_cleanups (old_chain); - - user_call_depth--; } enum command_control_type @@ -920,15 +923,19 @@ read_command_lines (char *prompt_arg, int from_tty) enum misc_command_type val; control_level = 0; - if (deprecated_readline_begin_hook) - { - /* Note - intentional to merge messages with no newline */ - (*deprecated_readline_begin_hook) ("%s %s\n", prompt_arg, END_MESSAGE); - } - else if (from_tty && input_from_terminal_p ()) + + if (from_tty && input_from_terminal_p ()) { - printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE); - gdb_flush (gdb_stdout); + if (deprecated_readline_begin_hook) + { + /* Note - intentional to merge messages with no newline */ + (*deprecated_readline_begin_hook) ("%s %s\n", prompt_arg, END_MESSAGE); + } + else + { + printf_unfiltered ("%s\n%s\n", prompt_arg, END_MESSAGE); + gdb_flush (gdb_stdout); + } } head = tail = NULL; @@ -989,7 +996,7 @@ read_command_lines (char *prompt_arg, int from_tty) do_cleanups (old_chain); } - if (deprecated_readline_end_hook) + if (deprecated_readline_end_hook && from_tty && input_from_terminal_p ()) { (*deprecated_readline_end_hook) (); } diff --git a/gdb/config/frv/frv.mt b/gdb/config/frv/frv.mt index 3ce8983..f532cb0 100644 --- a/gdb/config/frv/frv.mt +++ b/gdb/config/frv/frv.mt @@ -1,5 +1,5 @@ # Target: Fujitsu FRV processor -TDEPFILES= frv-tdep.o frv-linux-tdep.o solib.o solib-frv.o +TDEPFILES= frv-tdep.o frv-linux-tdep.o solib.o solib-frv.o corelow.o DEPRECATED_TM_FILE= tm-frv.h SIM_OBS = remote-sim.o SIM = ../sim/frv/libsim.a diff --git a/gdb/config/pa/hppa64.mt b/gdb/config/pa/hppa64.mt index c7714c2..206939b 100644 --- a/gdb/config/pa/hppa64.mt +++ b/gdb/config/pa/hppa64.mt @@ -1,3 +1,3 @@ # Target: HP PA-RISC 2.0 running HPUX 11.00 in wide mode TDEPFILES= hppa-tdep.o hppa-hpux-tdep.o solib-som.o solib-pa64.o somread.o hpread.o solib.o -DEPRECATED_TM_FILE= tm-hppa.h +DEPRECATED_TM_FILE= tm-hppah.h diff --git a/gdb/config/s390/s390.mh b/gdb/config/s390/s390.mh index b018828..d81fb77 100644 --- a/gdb/config/s390/s390.mh +++ b/gdb/config/s390/s390.mh @@ -1,5 +1,5 @@ # Host: S390, running Linux NAT_FILE= nm-linux.h NATDEPFILES= inf-ptrace.o fork-child.o corelow.o s390-nat.o \ - gcore.o linux-thread-db.o proc-service.o linux-nat.o + gcore.o linux-thread-db.o proc-service.o linux-nat.o linux-fork.o LOADLIBES = -ldl -rdynamic diff --git a/gdb/configure b/gdb/configure index 869eb4b..3bce08f 100755 --- a/gdb/configure +++ b/gdb/configure @@ -313,7 +313,6 @@ ac_subdirs_all="$ac_subdirs_all doc testsuite" ac_subdirs_all="$ac_subdirs_all gdbtk" ac_subdirs_all="$ac_subdirs_all multi-ice" ac_subdirs_all="$ac_subdirs_all gdbserver" -ac_subdirs_all="$ac_subdirs_all nlm" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os SET_MAKE RANLIB ac_ct_RANLIB ALLOCA USE_NLS MSGFMT GMSGFMT XGETTEXT USE_INCLUDED_LIBINTL CATALOGS CATOBJEXT DATADIRNAME GMOFILES INSTOBJEXT INTLDEPS INTLLIBS INTLOBJS POFILES POSUB INCLUDE_LOCALE_H GT_NO GT_YES MKINSTALLDIRS l localedir PACKAGE subdirs AWK INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S YACC AR ac_ct_AR DLLTOOL ac_ct_DLLTOOL WINDRES ac_ct_WINDRES MIG ac_ct_MIG CONFIG_LDFLAGS TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS WERROR_CFLAGS SER_HARDWIRE WIN32LIBS LIBGUI GUI_CFLAGS_X WIN32LDAPP TCL_VERSION TCL_MAJOR_VERSION TCL_MINOR_VERSION TCL_CC TCL_DEFS TCL_SHLIB_CFLAGS TCL_SHLIB_LD TCL_SHLIB_LD_LIBS TCL_SHLIB_SUFFIX TCL_DL_LIBS TCL_LD_FLAGS TCL_LD_SEARCH_FLAGS TCL_CC_SEARCH_FLAGS TCL_COMPAT_OBJS TCL_RANLIB TCL_BUILD_LIB_SPEC TCL_LIB_SPEC TCL_LIB_VERSIONS_OK TK_VERSION TK_DEFS TK_BUILD_INCLUDES TK_XINCLUDES TK_XLIBSW TK_BUILD_LIB_SPEC TK_LIB_SPEC TCLHDIR TKHDIR ITCLHDIR ITKHDIR ITCL_VERSION ITCL_DEFS ITCL_BUILD_INCLUDES ITCL_BUILD_LIB_SPEC ITCL_LIB_SPEC ITK_VERSION ITK_DEFS ITK_BUILD_INCLUDES ITK_BUILD_LIB_SPEC ITK_LIB_SPEC X_CFLAGS X_LDFLAGS X_LIBS TCL_DEPS TK_DEPS ITCLLIB ITCL_DEPS ITKLIB ITK_DEPS GDBTKLIBS GDBTK_CFLAGS GDBTK_SRC_DIR IGNORE_SIM IGNORE_SIM_OBS ENABLE_CFLAGS PROFILE_CFLAGS CONFIG_OBS CONFIG_DEPS CONFIG_SRCS CONFIG_ALL CONFIG_CLEAN CONFIG_INSTALL CONFIG_UNINSTALL target_subdir frags xm_h tm_h nm_h LIBICONV LIBOBJS LTLIBOBJS' ac_subst_files='host_makefile_frag target_makefile_frag' @@ -21638,15 +21637,6 @@ echo "${ECHO_T}no" >&6 fi fi -# We configure the nlm subdirectory on netware targets, as instructed -# by configure.tgt. -if test "x$build_nlm" = xyes; then - - -subdirs="$subdirs nlm" - -fi - # If hostfile (XM_FILE) and/or targetfile (DEPRECATED_TM_FILE) and/or # nativefile (NAT_FILE) is not set in config/*/*.m[ht] files, we link # to an empty version. diff --git a/gdb/configure.ac b/gdb/configure.ac index 2725e18..8f66b4d 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -1513,12 +1513,6 @@ if test "x$target" = "x$host"; then fi fi -# We configure the nlm subdirectory on netware targets, as instructed -# by configure.tgt. -if test "x$build_nlm" = xyes; then - AC_CONFIG_SUBDIRS(nlm) -fi - # If hostfile (XM_FILE) and/or targetfile (DEPRECATED_TM_FILE) and/or # nativefile (NAT_FILE) is not set in config/*/*.m[ht] files, we link # to an empty version. diff --git a/gdb/configure.tgt b/gdb/configure.tgt index d305b68..4092fe1 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -96,9 +96,7 @@ i[34567]86-*-linux*) gdb_target=linux build_gdbserver=yes ;; i[34567]86-*-gnu*) gdb_target=i386gnu ;; -i[34567]86-*-netware*) gdb_target=i386 - build_nlm=yes - ;; +i[34567]86-*-netware*) gdb_target=i386 ;; i[34567]86-*-cygwin*) gdb_target=cygwin ;; i[34567]86-*-*) gdb_target=i386 ;; diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 34e6358..40c8020 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,27 @@ +2006-03-31 Michael Snyder + + * gdb.texinfo: Update copyright dates. + +2006-03-31 Eli Zaretskii + + * gdb.texinfo (Overview): Add an index entry to "empty response". + +2006-03-28 Jim Blandy + + * gdbint.texinfo (Prologue Analysis): New section. + +2006-03-07 Jim Blandy + + * gdb.texinfo (Connecting): Document 'target remote pipe'. + + * gdb.texinfo (Target Commands): Update text describing how to + specify a target. Refer to the detailed section on remote + debugging, not the brief mention. + + * gdb.texinfo (Connecting): Organize the different 'target remote' + connection methods into a table. Add a 'target remote' index + entry. (!!!) + 2006-02-17 Fred Fish * gdb.texinfo (Symbols): Update descriptions of 'whatis' and diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ca8d80f..59445d0 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -1,6 +1,6 @@ \input texinfo @c -*-texinfo-*- @c Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, -@c 1999, 2000, 2001, 2002, 2003, 2004, 2005 +@c 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 @c Free Software Foundation, Inc. @c @c %**start of header @@ -52,7 +52,7 @@ This is the @value{EDITION} Edition, of @cite{Debugging with Version @value{GDBVN}. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998,@* - 1999, 2000, 2001, 2002, 2003, 2004, 2005@* + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006@* Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document @@ -85,7 +85,7 @@ development.'' @vskip 0pt plus 1filll Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, -1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. @sp 2 Published by the Free Software Foundation @* @@ -117,7 +117,7 @@ This file describes @value{GDBN}, the @sc{gnu} symbolic debugger. This is the @value{EDITION} Edition, for @value{GDBN} Version @value{GDBVN}. -Copyright (C) 1988-2005 Free Software Foundation, Inc. +Copyright (C) 1988-2006 Free Software Foundation, Inc. @menu * Summary:: Summary of @value{GDBN} @@ -11906,14 +11906,23 @@ An executable file. @samp{target exec @var{program}} is the same as A core dump file. @samp{target core @var{filename}} is the same as @samp{core-file @var{filename}}. -@item target remote @var{dev} +@item target remote @var{medium} @cindex remote target -Remote serial target in GDB-specific protocol. The argument @var{dev} -specifies what serial device to use for the connection (e.g.@: -@file{/dev/ttya}). @xref{Remote, ,Remote debugging}. @code{target remote} -supports the @code{load} command. This is only useful if you have -some other way of getting the stub to the target system, and you can put -it somewhere in memory where it won't get clobbered by the download. +A remote system connected to @value{GDBN} via a serial line or network +connection. This command tells @value{GDBN} to use its own remote +protocol over @var{medium} for debugging. @xref{Remote Debugging}. + +For example, if you have a board connected to @file{/dev/ttya} on the +machine running @value{GDBN}, you could say: + +@smallexample +target remote /dev/ttya +@end smallexample + +@code{target remote} supports the @code{load} command. This is only +useful if you have some other way of getting the stub to the target +system, and you can put it somewhere in memory where it won't get +clobbered by the download. @item target sim @cindex built-in simulator target @@ -12130,7 +12139,6 @@ want to try. @menu * Connecting:: Connecting to a remote target * Server:: Using the gdbserver program -* NetWare:: Using the gdbserve.nlm program * Remote configuration:: Remote configuration * remote stub:: Implementing a remote stub @end menu @@ -12143,37 +12151,51 @@ your program, since @value{GDBN} needs symobl and debugging information. Start up @value{GDBN} as usual, using the name of the local copy of your program as the first argument. +@cindex @code{target remote} +@value{GDBN} can communicate with the target over a serial line, or +over an @acronym{IP} network using @acronym{TCP} or @acronym{UDP}. In +each case, @value{GDBN} uses the same protocol for debugging your +program; only the medium carrying the debugging packets varies. The +@code{target remote} command establishes a connection to the target. +Its arguments indicate which medium to use: + +@table @code + +@item target remote @var{serial-device} @cindex serial line, @code{target remote} +Use @var{serial-device} to communicate with the target. For example, +to use a serial line connected to the device named @file{/dev/ttyb}: + +@smallexample +target remote /dev/ttyb +@end smallexample + If you're using a serial line, you may want to give @value{GDBN} the @w{@samp{--baud}} option, or use the @code{set remotebaud} command (@pxref{Remote configuration, set remotebaud}) before the @code{target} command. -After that, use @code{target remote} to establish communications with -the target machine. Its argument specifies how to communicate---either -via a devicename attached to a direct serial line, or a TCP or UDP port -(possibly to a terminal server which in turn has a serial line to the -target). For example, to use a serial line connected to the device -named @file{/dev/ttyb}: - -@smallexample -target remote /dev/ttyb -@end smallexample +@item target remote @code{@var{host}:@var{port}} +@itemx target remote @code{tcp:@var{host}:@var{port}} +@cindex @acronym{TCP} port, @code{target remote} +Debug using a @acronym{TCP} connection to @var{port} on @var{host}. +The @var{host} may be either a host name or a numeric @acronym{IP} +address; @var{port} must be a decimal number. The @var{host} could be +the target machine itself, if it is directly connected to the net, or +it might be a terminal server which in turn has a serial line to the +target. -@cindex TCP port, @code{target remote} -To use a TCP connection, use an argument of the form -@code{@var{host}:@var{port}} or @code{tcp:@var{host}:@var{port}}. -For example, to connect to port 2828 on a -terminal server named @code{manyfarms}: +For example, to connect to port 2828 on a terminal server named +@code{manyfarms}: @smallexample target remote manyfarms:2828 @end smallexample -If your remote target is actually running on the same machine as -your debugger session (e.g.@: a simulator of your target running on -the same host), you can omit the hostname. For example, to connect -to port 1234 on your local machine: +If your remote target is actually running on the same machine as your +debugger session (e.g.@: a simulator for your target running on the +same host), you can omit the hostname. For example, to connect to +port 1234 on your local machine: @smallexample target remote :1234 @@ -12182,22 +12204,39 @@ target remote :1234 Note that the colon is still required here. -@cindex UDP port, @code{target remote} -To use a UDP connection, use an argument of the form -@code{udp:@var{host}:@var{port}}. For example, to connect to UDP port 2828 -on a terminal server named @code{manyfarms}: +@item target remote @code{udp:@var{host}:@var{port}} +@cindex @acronym{UDP} port, @code{target remote} +Debug using @acronym{UDP} packets to @var{port} on @var{host}. For example, to +connect to @acronym{UDP} port 2828 on a terminal server named @code{manyfarms}: @smallexample target remote udp:manyfarms:2828 @end smallexample -When using a UDP connection for remote debugging, you should keep in mind -that the `U' stands for ``Unreliable''. UDP can silently drop packets on -busy or unreliable networks, which will cause havoc with your debugging -session. +When using a @acronym{UDP} connection for remote debugging, you should +keep in mind that the `U' stands for ``Unreliable''. @acronym{UDP} +can silently drop packets on busy or unreliable networks, which will +cause havoc with your debugging session. + +@item target remote | @var{command} +@cindex pipe, @code{target remote} to +Run @var{command} in the background and communicate with it using a +pipe. The @var{command} is a shell command, to be parsed and expanded +by the system's command shell, @code{/bin/sh}; it should expect remote +protocol packets on its standard input, and send replies on its +standard output. You could use this to run a stand-alone simulator +that speaks the remote debugging protocol, to make net connections +using programs like @code{ssh}, or for other similar tricks. + +If @var{command} closes its standard output (perhaps by exiting), +@value{GDBN} will try to send it a @code{SIGTERM} signal. (If the +program has already exited, this will have no effect.) + +@end table -Now you can use all the usual commands to examine and change data and to -step and continue the remote program. +Once the connection has been established, you can use all the usual +commands to examine and change data and to step and continue the +remote program. @cindex interrupting remote programs @cindex remote programs, interrupting @@ -12356,51 +12395,6 @@ program is considered running after the connection. @end table -@node NetWare -@section Using the @code{gdbserve.nlm} program - -@kindex gdbserve.nlm -@code{gdbserve.nlm} is a control program for NetWare systems, which -allows you to connect your program with a remote @value{GDBN} via -@code{target remote}. - -@value{GDBN} and @code{gdbserve.nlm} communicate via a serial line, -using the standard @value{GDBN} remote serial protocol. - -@table @emph -@item On the target machine, -you need to have a copy of the program you want to debug. -@code{gdbserve.nlm} does not need your program's symbol table, so you -can strip the program if necessary to save space. @value{GDBN} on the -host system does all the symbol handling. - -To use the server, you must tell it how to communicate with -@value{GDBN}; the name of your program; and the arguments for your -program. The syntax is: - -@smallexample -load gdbserve [ BOARD=@var{board} ] [ PORT=@var{port} ] - [ BAUD=@var{baud} ] @var{program} [ @var{args} @dots{} ] -@end smallexample - -@var{board} and @var{port} specify the serial line; @var{baud} specifies -the baud rate used by the connection. @var{port} and @var{node} default -to 0, @var{baud} defaults to 9600@dmn{bps}. - -For example, to debug Emacs with the argument @samp{foo.txt}and -communicate with @value{GDBN} over serial port number 2 or board 1 -using a 19200@dmn{bps} connection: - -@smallexample -load gdbserve BOARD=1 PORT=2 BAUD=19200 emacs foo.txt -@end smallexample - -@item -On the @value{GDBN} host machine, connect to your target (@pxref{Connecting,, -Connecting to a remote target}). - -@end table - @node Remote configuration @section Remote configuration @@ -22468,6 +22462,7 @@ means the same as "0000". The error response returned for some packets includes a two character error number. That number is not well defined. +@cindex empty response, for unsupported packets For any @var{command} not supported by the stub, an empty response (@samp{$#00}) should be returned. That way it is possible to extend the protocol. A newer @value{GDBN} can tell if a packet is supported based diff --git a/gdb/doc/gdbint.texinfo b/gdb/doc/gdbint.texinfo index 8389f8f..e14aa2c 100644 --- a/gdb/doc/gdbint.texinfo +++ b/gdb/doc/gdbint.texinfo @@ -287,6 +287,175 @@ used to create a new @value{GDBN} frame struct, and then @code{DEPRECATED_INIT_EXTRA_FRAME_INFO} and @code{DEPRECATED_INIT_FRAME_PC} will be called for the new frame. +@section Prologue Analysis + +@cindex prologue analysis +@cindex call frame information +@cindex CFI (call frame information) +To produce a backtrace and allow the user to manipulate older frames' +variables and arguments, @value{GDBN} needs to find the base addresses +of older frames, and discover where those frames' registers have been +saved. Since a frame's ``callee-saves'' registers get saved by +younger frames if and when they're reused, a frame's registers may be +scattered unpredictably across younger frames. This means that +changing the value of a register-allocated variable in an older frame +may actually entail writing to a save slot in some younger frame. + +Modern versions of GCC emit Dwarf call frame information (``CFI''), +which describes how to find frame base addresses and saved registers. +But CFI is not always available, so as a fallback @value{GDBN} uses a +technique called @dfn{prologue analysis} to find frame sizes and saved +registers. A prologue analyzer disassembles the function's machine +code starting from its entry point, and looks for instructions that +allocate frame space, save the stack pointer in a frame pointer +register, save registers, and so on. Obviously, this can't be done +accurately in general, but it's tractible to do well enough to be very +helpful. Prologue analysis predates the GNU toolchain's support for +CFI; at one time, prologue analysis was the only mechanism +@value{GDBN} used for stack unwinding at all, when the function +calling conventions didn't specify a fixed frame layout. + +In the olden days, function prologues were generated by hand-written, +target-specific code in GCC, and treated as opaque and untouchable by +optimizers. Looking at this code, it was usually straightforward to +write a prologue analyzer for @value{GDBN} that would accurately +understand all the prologues GCC would generate. However, over time +GCC became more aggressive about instruction scheduling, and began to +understand more about the semantics of the prologue instructions +themselves; in response, @value{GDBN}'s analyzers became more complex +and fragile. Keeping the prologue analyzers working as GCC (and the +instruction sets themselves) evolved became a substantial task. + +@cindex @file{prologue-value.c} +@cindex abstract interpretation of function prologues +@cindex pseudo-evaluation of function prologues +To try to address this problem, the code in @file{prologue-value.h} +and @file{prologue-value.c} provides a general framework for writing +prologue analyzers that are simpler and more robust than ad-hoc +analyzers. When we analyze a prologue using the prologue-value +framework, we're really doing ``abstract interpretation'' or +``pseudo-evaluation'': running the function's code in simulation, but +using conservative approximations of the values registers and memory +would hold when the code actually runs. For example, if our function +starts with the instruction: + +@example +addi r1, 42 # add 42 to r1 +@end example +@noindent +we don't know exactly what value will be in @code{r1} after executing +this instruction, but we do know it'll be 42 greater than its original +value. + +If we then see an instruction like: + +@example +addi r1, 22 # add 22 to r1 +@end example +@noindent +we still don't know what @code{r1's} value is, but again, we can say +it is now 64 greater than its original value. + +If the next instruction were: + +@example +mov r2, r1 # set r2 to r1's value +@end example +@noindent +then we can say that @code{r2's} value is now the original value of +@code{r1} plus 64. + +It's common for prologues to save registers on the stack, so we'll +need to track the values of stack frame slots, as well as the +registers. So after an instruction like this: + +@example +mov (fp+4), r2 +@end example +@noindent +then we'd know that the stack slot four bytes above the frame pointer +holds the original value of @code{r1} plus 64. + +And so on. + +Of course, this can only go so far before it gets unreasonable. If we +wanted to be able to say anything about the value of @code{r1} after +the instruction: + +@example +xor r1, r3 # exclusive-or r1 and r3, place result in r1 +@end example +@noindent +then things would get pretty complex. But remember, we're just doing +a conservative approximation; if exclusive-or instructions aren't +relevant to prologues, we can just say @code{r1}'s value is now +``unknown''. We can ignore things that are too complex, if that loss of +information is acceptable for our application. + +So when we say ``conservative approximation'' here, what we mean is an +approximation that is either accurate, or marked ``unknown'', but +never inaccurate. + +Using this framework, a prologue analyzer is simply an interpreter for +machine code, but one that uses conservative approximations for the +contents of registers and memory instead of actual values. Starting +from the function's entry point, you simulate instructions up to the +current PC, or an instruction that you don't know how to simulate. +Now you can examine the state of the registers and stack slots you've +kept track of. + +@itemize @bullet + +@item +To see how large your stack frame is, just check the value of the +stack pointer register; if it's the original value of the SP +minus a constant, then that constant is the stack frame's size. +If the SP's value has been marked as ``unknown'', then that means +the prologue has done something too complex for us to track, and +we don't know the frame size. + +@item +To see where we've saved the previous frame's registers, we just +search the values we've tracked --- stack slots, usually, but +registers, too, if you want --- for something equal to the register's +original value. If the calling conventions suggest a standard place +to save a given register, then we can check there first, but really, +anything that will get us back the original value will probably work. +@end itemize + +This does take some work. But prologue analyzers aren't +quick-and-simple pattern patching to recognize a few fixed prologue +forms any more; they're big, hairy functions. Along with inferior +function calls, prologue analysis accounts for a substantial portion +of the time needed to stabilize a @value{GDBN} port. So it's +worthwhile to look for an approach that will be easier to understand +and maintain. In the approach described above: + +@itemize @bullet + +@item +It's easier to see that the analyzer is correct: you just see +whether the analyzer properly (albiet conservatively) simulates +the effect of each instruction. + +@item +It's easier to extend the analyzer: you can add support for new +instructions, and know that you haven't broken anything that +wasn't already broken before. + +@item +It's orthogonal: to gather new information, you don't need to +complicate the code for each instruction. As long as your domain +of conservative values is already detailed enough to tell you +what you need, then all the existing instruction simulations are +already gathering the right data for you. + +@end itemize + +The file @file{prologue-value.h} contains detailed comments explaining +the framework and how to use it. + + @section Breakpoint Handling @cindex breakpoints diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c index caa510c..b24dbd0 100644 --- a/gdb/frv-linux-tdep.c +++ b/gdb/frv-linux-tdep.c @@ -20,14 +20,18 @@ Boston, MA 02110-1301, USA. */ #include "defs.h" +#include "gdbcore.h" #include "target.h" #include "frame.h" #include "osabi.h" +#include "regcache.h" #include "elf-bfd.h" #include "elf/frv.h" #include "frv-tdep.h" #include "trad-frame.h" #include "frame-unwind.h" +#include "regset.h" +#include "gdb_string.h" /* Define the size (in bytes) of an FR-V instruction. */ static const int frv_instr_size = 4; @@ -329,11 +333,162 @@ frv_linux_sigtramp_frame_sniffer (struct frame_info *next_frame) return NULL; } + +/* The FRV kernel defines ELF_NGREG as 46. We add 2 in order to include + the loadmap addresses in the register set. (See below for more info.) */ +#define FRV_ELF_NGREG (46 + 2) +typedef unsigned char frv_elf_greg_t[4]; +typedef struct { frv_elf_greg_t reg[FRV_ELF_NGREG]; } frv_elf_gregset_t; + +typedef unsigned char frv_elf_fpreg_t[4]; +typedef struct +{ + frv_elf_fpreg_t fr[64]; + frv_elf_fpreg_t fner[2]; + frv_elf_fpreg_t msr[2]; + frv_elf_fpreg_t acc[8]; + unsigned char accg[8]; + frv_elf_fpreg_t fsr[1]; +} frv_elf_fpregset_t; + +/* Constants for accessing elements of frv_elf_gregset_t. */ + +#define FRV_PT_PSR 0 +#define FRV_PT_ISR 1 +#define FRV_PT_CCR 2 +#define FRV_PT_CCCR 3 +#define FRV_PT_LR 4 +#define FRV_PT_LCR 5 +#define FRV_PT_PC 6 +#define FRV_PT_GNER0 10 +#define FRV_PT_GNER1 11 +#define FRV_PT_IACC0H 12 +#define FRV_PT_IACC0L 13 + +/* Note: Only 32 of the GRs will be found in the corefile. */ +#define FRV_PT_GR(j) ( 14 + (j)) /* GRj for 0<=j<=63. */ + +#define FRV_PT_TBR FRV_PT_GR(0) /* gr0 is always 0, so TBR is stuffed + there. */ + +/* Technically, the loadmap addresses are not part of `pr_reg' as + found in the elf_prstatus struct. The fields which communicate the + loadmap address appear (by design) immediately after `pr_reg' + though, and the BFD function elf32_frv_grok_prstatus() has been + implemented to include these fields in the register section that it + extracts from the core file. So, for our purposes, they may be + viewed as registers. */ + +#define FRV_PT_EXEC_FDPIC_LOADMAP 46 +#define FRV_PT_INTERP_FDPIC_LOADMAP 47 + + +/* Unpack an frv_elf_gregset_t into GDB's register cache. */ + +static void +frv_linux_supply_gregset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *gregs, size_t len) +{ + int regi; + char zerobuf[MAX_REGISTER_SIZE]; + const frv_elf_gregset_t *gregsetp = gregs; + + memset (zerobuf, 0, MAX_REGISTER_SIZE); + + /* gr0 always contains 0. Also, the kernel passes the TBR value in + this slot. */ + regcache_raw_supply (regcache, first_gpr_regnum, zerobuf); + + for (regi = first_gpr_regnum + 1; regi <= last_gpr_regnum; regi++) + { + if (regi >= first_gpr_regnum + 32) + regcache_raw_supply (regcache, regi, zerobuf); + else + regcache_raw_supply (regcache, regi, + gregsetp->reg[FRV_PT_GR (regi - first_gpr_regnum)]); + } + + regcache_raw_supply (regcache, pc_regnum, gregsetp->reg[FRV_PT_PC]); + regcache_raw_supply (regcache, psr_regnum, gregsetp->reg[FRV_PT_PSR]); + regcache_raw_supply (regcache, ccr_regnum, gregsetp->reg[FRV_PT_CCR]); + regcache_raw_supply (regcache, cccr_regnum, gregsetp->reg[FRV_PT_CCCR]); + regcache_raw_supply (regcache, lr_regnum, gregsetp->reg[FRV_PT_LR]); + regcache_raw_supply (regcache, lcr_regnum, gregsetp->reg[FRV_PT_LCR]); + regcache_raw_supply (regcache, gner0_regnum, gregsetp->reg[FRV_PT_GNER0]); + regcache_raw_supply (regcache, gner1_regnum, gregsetp->reg[FRV_PT_GNER1]); + regcache_raw_supply (regcache, tbr_regnum, gregsetp->reg[FRV_PT_TBR]); + regcache_raw_supply (regcache, fdpic_loadmap_exec_regnum, + gregsetp->reg[FRV_PT_EXEC_FDPIC_LOADMAP]); + regcache_raw_supply (regcache, fdpic_loadmap_interp_regnum, + gregsetp->reg[FRV_PT_INTERP_FDPIC_LOADMAP]); +} + +/* Unpack an frv_elf_fpregset_t into GDB's register cache. */ + +static void +frv_linux_supply_fpregset (const struct regset *regset, + struct regcache *regcache, + int regnum, const void *gregs, size_t len) +{ + int regi; + const frv_elf_fpregset_t *fpregsetp = gregs; + + for (regi = first_fpr_regnum; regi <= last_fpr_regnum; regi++) + regcache_raw_supply (regcache, regi, fpregsetp->fr[regi - first_fpr_regnum]); + + regcache_raw_supply (regcache, fner0_regnum, fpregsetp->fner[0]); + regcache_raw_supply (regcache, fner1_regnum, fpregsetp->fner[1]); + + regcache_raw_supply (regcache, msr0_regnum, fpregsetp->msr[0]); + regcache_raw_supply (regcache, msr1_regnum, fpregsetp->msr[1]); + + for (regi = acc0_regnum; regi <= acc7_regnum; regi++) + regcache_raw_supply (regcache, regi, fpregsetp->acc[regi - acc0_regnum]); + + regcache_raw_supply (regcache, accg0123_regnum, fpregsetp->accg); + regcache_raw_supply (regcache, accg4567_regnum, fpregsetp->accg + 4); + + regcache_raw_supply (regcache, fsr0_regnum, fpregsetp->fsr[0]); +} + +/* FRV Linux register sets. */ + +static struct regset frv_linux_gregset = +{ + NULL, + frv_linux_supply_gregset +}; + +static struct regset frv_linux_fpregset = +{ + NULL, + frv_linux_supply_fpregset +}; + +static const struct regset * +frv_linux_regset_from_core_section (struct gdbarch *gdbarch, + const char *sect_name, size_t sect_size) +{ + if (strcmp (sect_name, ".reg") == 0 + && sect_size >= sizeof (frv_elf_gregset_t)) + return &frv_linux_gregset; + + if (strcmp (sect_name, ".reg2") == 0 + && sect_size >= sizeof (frv_elf_fpregset_t)) + return &frv_linux_fpregset; + + return NULL; +} + + static void frv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { /* Set the sigtramp frame sniffer. */ frame_unwind_append_sniffer (gdbarch, frv_linux_sigtramp_frame_sniffer); + set_gdbarch_regset_from_core_section (gdbarch, + frv_linux_regset_from_core_section); } static enum gdb_osabi diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 119736e..3c13ba6 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,23 @@ +2006-03-15 Daniel Jacobowitz + + * linux-mips-low.c: Include and "gdb_proc_service.h". + (PTRACE_GET_THREAD_AREA): Define. + (ps_get_thread_area): New function. + * Makefile.in (linux-i386-low.o, linux-mips-low.o) + (linux-x86-64-low.o): Update. + +2006-03-15 Daniel Jacobowitz + + * configure.ac: Remove checks for prfpregset_t. + * gdb_proc_service.h: New file. + * linux-i386-low.c, linux-x86-64-low.c, thread-db.c: Use the + new "gdb_proc_service.h". + * proc-service.c: Likewise. + (ps_pglobal_lookup, ps_pdread, ps_pdwrite): Use psaddr_t. + (ps_lgetfpregs, ps_lsetfpregs): Use a void* argument. + * Makefile.in (gdb_proc_service_h): Updated. + * configure, config.in: Regenerated. + 2006-03-03 Daniel Jacobowitz * remote-utils.c (prepare_resume_reply): Move declaration diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index 19ee78b..0da5f6c 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -242,7 +242,7 @@ version.o: version.c $(server_h) # will remove them. MAKEOVERRIDES= -gdb_proc_service_h = $(srcdir)/../gdb_proc_service.h $(srcdir)/../gregset.h +gdb_proc_service_h = $(srcdir)/gdb_proc_service.h regdat_sh = $(srcdir)/../regformats/regdat.sh regdef_h = $(srcdir)/../regformats/regdef.h regcache_h = $(srcdir)/regcache.h @@ -272,15 +272,18 @@ linux-low.o: linux-low.c $(linux_low_h) $(server_h) linux-arm-low.o: linux-arm-low.c $(linux_low_h) $(server_h) linux-cris-low.o: linux-cris-low.c $(linux_low_h) $(server_h) linux-crisv32-low.o: linux-crisv32-low.c $(linux_low_h) $(server_h) -linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h) +linux-i386-low.o: linux-i386-low.c $(linux_low_h) $(server_h) \ + $(gdb_proc_service_h) linux-ia64-low.o: linux-ia64-low.c $(linux_low_h) $(server_h) linux-m32r-low.o: linux-m32r-low.c $(linux_low_h) $(server_h) -linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) +linux-mips-low.o: linux-mips-low.c $(linux_low_h) $(server_h) \ + $(gdb_proc_service_h) linux-ppc-low.o: linux-ppc-low.c $(linux_low_h) $(server_h) linux-ppc64-low.o: linux-ppc64-low.c $(linux_low_h) $(server_h) linux-s390-low.o: linux-s390-low.c $(linux_low_h) $(server_h) linux-sh-low.o: linux-sh-low.c $(linux_low_h) $(server_h) -linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h) +linux-x86-64-low.o: linux-x86-64-low.c $(linux_low_h) $(server_h) \ + $(gdb_proc_service_h) reg-arm.o : reg-arm.c $(regdef_h) reg-arm.c : $(srcdir)/../regformats/reg-arm.dat $(regdat_sh) diff --git a/gdb/gdbserver/config.in b/gdb/gdbserver/config.in index 59e56bc..3aa2811 100644 --- a/gdb/gdbserver/config.in +++ b/gdb/gdbserver/config.in @@ -25,9 +25,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* Define if has prfpregset_t. */ -#undef HAVE_PRFPREGSET_T - /* Define if has prgregset_t. */ #undef HAVE_PRGREGSET_T @@ -104,8 +101,5 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Define if the prfpregset_t type is broken. */ -#undef PRFPREGSET_T_BROKEN - /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure index 1373538..262d5ef 100755 --- a/gdb/gdbserver/configure +++ b/gdb/gdbserver/configure @@ -3544,131 +3544,6 @@ _ACEOF echo "$as_me:$LINENO: result: $bfd_cv_have_sys_procfs_type_prgregset_t" >&5 echo "${ECHO_T}$bfd_cv_have_sys_procfs_type_prgregset_t" >&6 - echo "$as_me:$LINENO: checking for prfpregset_t in sys/procfs.h" >&5 -echo $ECHO_N "checking for prfpregset_t in sys/procfs.h... $ECHO_C" >&6 - if test "${bfd_cv_have_sys_procfs_type_prfpregset_t+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ - -#define _SYSCALL32 -#include -int -main () -{ -prfpregset_t avar - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 - (eval $ac_compile) 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && - { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; } && - { ac_try='test -s conftest.$ac_objext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - bfd_cv_have_sys_procfs_type_prfpregset_t=yes -else - echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -bfd_cv_have_sys_procfs_type_prfpregset_t=no - -fi -rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -fi - - if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_PRFPREGSET_T 1 -_ACEOF - - fi - echo "$as_me:$LINENO: result: $bfd_cv_have_sys_procfs_type_prfpregset_t" >&5 -echo "${ECHO_T}$bfd_cv_have_sys_procfs_type_prfpregset_t" >&6 - - - - - if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then - echo "$as_me:$LINENO: checking whether prfpregset_t type is broken" >&5 -echo $ECHO_N "checking whether prfpregset_t type is broken... $ECHO_C" >&6 - if test "${gdb_cv_prfpregset_t_broken+set}" = set; then - echo $ECHO_N "(cached) $ECHO_C" >&6 -else - if test "$cross_compiling" = yes; then - gdb_cv_prfpregset_t_broken=yes -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include - int main () - { - if (sizeof (prfpregset_t) == sizeof (void *)) - return 1; - return 0; - } -_ACEOF -rm -f conftest$ac_exeext -if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 - (eval $ac_link) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - gdb_cv_prfpregset_t_broken=no -else - echo "$as_me: program exited with status $ac_status" >&5 -echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -gdb_cv_prfpregset_t_broken=yes -fi -rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext -fi -fi - - echo "$as_me:$LINENO: result: $gdb_cv_prfpregset_t_broken" >&5 -echo "${ECHO_T}$gdb_cv_prfpregset_t_broken" >&6 - if test $gdb_cv_prfpregset_t_broken = yes; then - -cat >>confdefs.h <<\_ACEOF -#define PRFPREGSET_T_BROKEN 1 -_ACEOF - - fi - fi - echo "$as_me:$LINENO: checking for elf_fpregset_t in sys/procfs.h" >&5 echo $ECHO_N "checking for elf_fpregset_t in sys/procfs.h... $ECHO_C" >&6 if test "${bfd_cv_have_sys_procfs_type_elf_fpregset_t+set}" = set; then diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac index fabd94d..a952af5 100644 --- a/gdb/gdbserver/configure.ac +++ b/gdb/gdbserver/configure.ac @@ -1,5 +1,6 @@ dnl Autoconf configure script for GDB server. -dnl Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +dnl Copyright (C) 2000, 2002, 2003, 2004, 2005, 2006 +dnl Free Software Foundation, Inc. dnl dnl This file is part of GDB. dnl @@ -88,35 +89,6 @@ if test "$ac_cv_header_sys_procfs_h" = yes; then BFD_HAVE_SYS_PROCFS_TYPE(lwpid_t) BFD_HAVE_SYS_PROCFS_TYPE(psaddr_t) BFD_HAVE_SYS_PROCFS_TYPE(prgregset_t) - BFD_HAVE_SYS_PROCFS_TYPE(prfpregset_t) - - dnl Check for broken prfpregset_t type - - dnl For Linux/i386, glibc 2.1.3 was released with a bogus - dnl prfpregset_t type (it's a typedef for the pointer to a struct - dnl instead of the struct itself). We detect this here, and work - dnl around it in gdb_proc_service.h. - - if test $bfd_cv_have_sys_procfs_type_prfpregset_t = yes; then - AC_MSG_CHECKING(whether prfpregset_t type is broken) - AC_CACHE_VAL(gdb_cv_prfpregset_t_broken, - [AC_TRY_RUN([#include - int main () - { - if (sizeof (prfpregset_t) == sizeof (void *)) - return 1; - return 0; - }], - gdb_cv_prfpregset_t_broken=no, - gdb_cv_prfpregset_t_broken=yes, - gdb_cv_prfpregset_t_broken=yes)]) - AC_MSG_RESULT($gdb_cv_prfpregset_t_broken) - if test $gdb_cv_prfpregset_t_broken = yes; then - AC_DEFINE(PRFPREGSET_T_BROKEN, 1, - [Define if the prfpregset_t type is broken.]) - fi - fi - BFD_HAVE_SYS_PROCFS_TYPE(elf_fpregset_t) fi diff --git a/gdb/gdbserver/gdb_proc_service.h b/gdb/gdbserver/gdb_proc_service.h new file mode 100644 index 0000000..e5aefbd --- /dev/null +++ b/gdb/gdbserver/gdb_proc_service.h @@ -0,0 +1,75 @@ +/* replacement for systems that don't have it. + Copyright (C) 2000, 2006 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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. */ + +#ifndef GDB_PROC_SERVICE_H +#define GDB_PROC_SERVICE_H + +#include + +#ifdef HAVE_PROC_SERVICE_H +#include +#else + +#ifdef HAVE_SYS_PROCFS_H +#include +#endif + +/* Not all platforms bring in via . If + wasn't enough to find elf_fpregset_t, try the kernel + headers also (but don't if we don't need to). */ +#ifndef HAVE_ELF_FPREGSET_T +# ifdef HAVE_LINUX_ELF_H +# include +# endif +#endif + +typedef enum +{ + PS_OK, /* Success. */ + PS_ERR, /* Generic error. */ + PS_BADPID, /* Bad process handle. */ + PS_BADLID, /* Bad LWP id. */ + PS_BADADDR, /* Bad address. */ + PS_NOSYM, /* Symbol not found. */ + PS_NOFREGS /* FPU register set not available. */ +} ps_err_e; + +#ifndef HAVE_LWPID_T +typedef unsigned int lwpid_t; +#endif + +#ifndef HAVE_PSADDR_T +typedef unsigned long psaddr_t; +#endif + +#ifndef HAVE_PRGREGSET_T +typedef elf_gregset_t prgregset_t; +#endif + +#endif /* HAVE_PROC_SERVICE_H */ + +/* Structure that identifies the target process. */ +struct ps_prochandle +{ + /* The process id is all we need. */ + pid_t pid; +}; + +#endif /* gdb_proc_service.h */ diff --git a/gdb/gdbserver/linux-i386-low.c b/gdb/gdbserver/linux-i386-low.c index 96359fb..c0daf0b 100644 --- a/gdb/gdbserver/linux-i386-low.c +++ b/gdb/gdbserver/linux-i386-low.c @@ -1,5 +1,5 @@ /* GNU/Linux/i386 specific low level interface, for the remote server for GDB. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2004, 2005 + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -23,19 +23,7 @@ #include "linux-low.h" #include "i387-fp.h" -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" #include diff --git a/gdb/gdbserver/linux-mips-low.c b/gdb/gdbserver/linux-mips-low.c index 695bd29..7829550 100644 --- a/gdb/gdbserver/linux-mips-low.c +++ b/gdb/gdbserver/linux-mips-low.c @@ -1,5 +1,5 @@ /* GNU/Linux/MIPS specific low level interface, for the remote server for GDB. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2005 + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -22,6 +22,14 @@ #include "server.h" #include "linux-low.h" +#include + +#include "gdb_proc_service.h" + +#ifndef PTRACE_GET_THREAD_AREA +#define PTRACE_GET_THREAD_AREA 25 +#endif + #ifdef HAVE_SYS_REG_H #include #endif @@ -140,6 +148,23 @@ mips_breakpoint_at (CORE_ADDR where) return 0; } +/* Fetch the thread-local storage pointer for libthread_db. */ + +ps_err_e +ps_get_thread_area (const struct ps_prochandle *ph, + lwpid_t lwpid, int idx, void **base) +{ + if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0) + return PS_ERR; + + /* IDX is the bias from the thread pointer to the beginning of the + thread descriptor. It has to be subtracted due to implementation + quirks in libthread_db. */ + *base = (void *) ((char *)*base - idx); + + return PS_OK; +} + struct linux_target_ops the_low_target = { mips_num_regs, mips_regmap, diff --git a/gdb/gdbserver/linux-x86-64-low.c b/gdb/gdbserver/linux-x86-64-low.c index 7a4a76a..43cd10b 100644 --- a/gdb/gdbserver/linux-x86-64-low.c +++ b/gdb/gdbserver/linux-x86-64-low.c @@ -1,6 +1,6 @@ /* GNU/Linux/x86-64 specific low level interface, for the remote server for GDB. - Copyright (C) 2002, 2004, 2005 + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -24,19 +24,7 @@ #include "linux-low.h" #include "i387-fp.h" -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" #include #include diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c index a64919e..99083f1 100644 --- a/gdb/gdbserver/proc-service.c +++ b/gdb/gdbserver/proc-service.c @@ -1,5 +1,5 @@ /* libthread_db helper functions for the remote server for GDB. - Copyright (C) 2002, 2004, 2005 + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by MontaVista Software. @@ -29,19 +29,7 @@ #include "linux-low.h" -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" typedef struct ps_prochandle *gdb_ps_prochandle_t; typedef void *gdb_ps_read_buf_t; @@ -75,14 +63,14 @@ gregset_info(void) ps_err_e ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj, - const char *name, paddr_t *sym_addr) + const char *name, psaddr_t *sym_addr) { CORE_ADDR addr; if (look_up_one_symbol (name, &addr) == 0) return PS_NOSYM; - *sym_addr = (paddr_t) (unsigned long) addr; + *sym_addr = (psaddr_t) (unsigned long) addr; return PS_OK; } @@ -90,20 +78,20 @@ ps_pglobal_lookup (gdb_ps_prochandle_t ph, const char *obj, them into BUF. */ ps_err_e -ps_pdread (gdb_ps_prochandle_t ph, paddr_t addr, +ps_pdread (gdb_ps_prochandle_t ph, psaddr_t addr, gdb_ps_read_buf_t buf, gdb_ps_size_t size) { - read_inferior_memory (addr, buf, size); + read_inferior_memory ((unsigned long) addr, buf, size); return PS_OK; } /* Write SIZE bytes from BUF into the target process PH at address ADDR. */ ps_err_e -ps_pdwrite (gdb_ps_prochandle_t ph, paddr_t addr, +ps_pdwrite (gdb_ps_prochandle_t ph, psaddr_t addr, gdb_ps_write_buf_t buf, gdb_ps_size_t size) { - return write_inferior_memory (addr, buf, size); + return write_inferior_memory ((unsigned long) addr, buf, size); } /* Get the general registers of LWP LWPID within the target process PH @@ -149,8 +137,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset) process PH and store them in FPREGSET. */ ps_err_e -ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, - gdb_prfpregset_t *fpregset) +ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) { /* Unneeded. */ return PS_ERR; @@ -160,8 +147,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, process PH from FPREGSET. */ ps_err_e -ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, - const gdb_prfpregset_t *fpregset) +ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, void *fpregset) { /* Unneeded. */ return PS_ERR; diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c index 561e380..b47f576 100644 --- a/gdb/gdbserver/thread-db.c +++ b/gdb/gdbserver/thread-db.c @@ -1,5 +1,5 @@ /* Thread management interface, for the remote server for GDB. - Copyright (C) 2002, 2004, 2005 + Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by MontaVista Software. @@ -31,19 +31,7 @@ extern int debug_threads; #include #endif -/* Correct for all GNU/Linux targets (for quite some time). */ -#define GDB_GREGSET_T elf_gregset_t -#define GDB_FPREGSET_T elf_fpregset_t - -#ifndef HAVE_ELF_FPREGSET_T -/* Make sure we have said types. Not all platforms bring in - via . */ -#ifdef HAVE_LINUX_ELF_H -#include -#endif -#endif - -#include "../gdb_proc_service.h" +#include "gdb_proc_service.h" /* Structure that identifies the child process for the interface. */ diff --git a/gdb/hppa-linux-nat.c b/gdb/hppa-linux-nat.c index 48ad533..394c46d 100644 --- a/gdb/hppa-linux-nat.c +++ b/gdb/hppa-linux-nat.c @@ -1,6 +1,6 @@ /* Functions specific to running GDB native on HPPA running GNU/Linux. - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -392,5 +392,5 @@ _initialize_hppa_linux_nat (void) t->to_store_registers = hppa_linux_store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index 8fbbd4f..05501e2 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for GNU/Linux i386. - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -844,5 +844,5 @@ _initialize_i386_linux_nat (void) t->to_store_registers = i386_linux_store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index 036d1b6..1a67849 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -1296,7 +1296,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, multiple of [32-bit] words. This may require tail padding, depending on the size of the argument." - This makes sure the stack says word-aligned. */ + This makes sure the stack stays word-aligned. */ sp -= (len + 3) & ~3; write_memory (sp, value_contents_all (args[i]), len); } diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c index 6de171b..e223081 100644 --- a/gdb/ia64-linux-nat.c +++ b/gdb/ia64-linux-nat.c @@ -1,7 +1,7 @@ /* Functions specific to running gdb native on IA-64 running GNU/Linux. - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -700,5 +700,5 @@ _initialize_ia64_linux_nat (void) t->to_xfer_partial = ia64_linux_xfer_partial; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index 4ec5a95..f78f1fc 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -2732,7 +2732,8 @@ ia64_libunwind_frame_this_id (struct frame_info *next_frame, void **this_cache, and don't want to unwind past this frame. We return a null frame_id to indicate this. */ libunwind_frame_prev_register (next_frame, this_cache, IA64_IP_REGNUM, - &optimized, &lval, &addr, &realnum, &prev_ip); + &optimized, &lval, &addr, &realnum, buf); + prev_ip = extract_unsigned_integer (buf, 8); if (prev_ip != 0) (*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp); @@ -2892,6 +2893,7 @@ ia64_libunwind_sigtramp_frame_prev_register (struct frame_info *next_frame, int *realnump, gdb_byte *valuep) { + gdb_byte buf[8]; CORE_ADDR prev_ip, addr; int realnum, optimized; enum lval_type lval; @@ -2900,7 +2902,8 @@ ia64_libunwind_sigtramp_frame_prev_register (struct frame_info *next_frame, /* If the previous frame pc value is 0, then we want to use the SIGCONTEXT method of getting previous registers. */ libunwind_frame_prev_register (next_frame, this_cache, IA64_IP_REGNUM, - &optimized, &lval, &addr, &realnum, &prev_ip); + &optimized, &lval, &addr, &realnum, buf); + prev_ip = extract_unsigned_integer (buf, 8); if (prev_ip == 0) { diff --git a/gdb/libunwind-frame.c b/gdb/libunwind-frame.c index fbc84d4..6f39b72 100644 --- a/gdb/libunwind-frame.c +++ b/gdb/libunwind-frame.c @@ -1,6 +1,6 @@ /* Frame unwinder for frames using the libunwind library. - Copyright (C) 2003, 2004 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc. Written by Jeff Johnston, contributed by Red Hat Inc. @@ -248,7 +248,7 @@ void libunwind_frame_prev_register (struct frame_info *next_frame, void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, CORE_ADDR *addrp, - int *realnump, void *valuep) + int *realnump, gdb_byte *valuep) { struct libunwind_frame_cache *cache = libunwind_frame_cache (next_frame, this_cache); diff --git a/gdb/libunwind-frame.h b/gdb/libunwind-frame.h index 0aa2b2c..ffa43a0 100644 --- a/gdb/libunwind-frame.h +++ b/gdb/libunwind-frame.h @@ -1,6 +1,6 @@ /* Frame unwinder for frames with libunwind frame information. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2006 Free Software Foundation, Inc. Contributed by Jeff Johnston. @@ -51,7 +51,7 @@ void libunwind_frame_this_id (struct frame_info *next_frame, void **this_cache, void libunwind_frame_prev_register (struct frame_info *next_frame, void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, CORE_ADDR *addrp, - int *realnump, void *valuep); + int *realnump, gdb_byte *valuep); CORE_ADDR libunwind_frame_base_address (struct frame_info *next_frame, void **this_cache); int libunwind_is_initialized (void); diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 768c7da..bb44682 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -24,8 +24,10 @@ #include "regcache.h" #include "gdbcmd.h" #include "infcall.h" +#include "gdb_assert.h" #include "gdb_string.h" #include "linux-fork.h" +#include "linux-nat.h" #include #include @@ -72,8 +74,7 @@ add_fork (pid_t pid) { struct fork_info *fp; - if (fork_list == NULL && - pid != PIDGET (inferior_ptid)) + if (fork_list == NULL && pid != PIDGET (inferior_ptid)) { /* Special case -- if this is the first fork in the list (the list is hitherto empty), and if this new fork is @@ -84,7 +85,7 @@ add_fork (pid_t pid) } fp = XZALLOC (struct fork_info); - fp->ptid = pid_to_ptid (pid); + fp->ptid = ptid_build (pid, pid, 0); fp->num = ++highest_fork_num; fp->next = fork_list; fork_list = fp; @@ -239,9 +240,21 @@ fork_load_infrun_state (struct fork_info *fp) extern void nullify_last_target_wait_ptid (); int i; + inferior_ptid = fp->ptid; + + linux_nat_switch_fork (inferior_ptid); + if (fp->savedregs && fp->clobber_regs) regcache_cpy (current_regcache, fp->savedregs); + registers_changed (); + reinit_frame_cache (); + + /* We must select a new frame before making any inferior calls to + avoid warnings. */ + select_frame (get_current_frame ()); + + stop_pc = read_pc (); nullify_last_target_wait_ptid (); /* Now restore the file positions of open file descriptors. */ @@ -322,17 +335,22 @@ linux_fork_killall (void) status for it) -- however any process may be a child or a parent, so may get a SIGCHLD from a previously killed child. Wait them all out. */ + struct fork_info *fp; pid_t pid, ret; int status; - do { - pid = PIDGET (fork_list->ptid); - do { - ptrace (PT_KILL, pid, 0, 0); - ret = waitpid (pid, &status, 0); - } while (ret == pid && WIFSTOPPED (status)); - delete_fork (fork_list->ptid); - } while (fork_list != NULL); + for (fp = fork_list; fp; fp = fp->next) + { + pid = PIDGET (fp->ptid); + do { + ptrace (PT_KILL, pid, 0, 0); + ret = waitpid (pid, &status, 0); + /* We might get a SIGCHLD instead of an exit status. This is + aggravated by the first kill above - a child has just + died. MVS comment cut-and-pasted from linux-nat. */ + } while (ret == pid && WIFSTOPPED (status)); + } + init_fork_list (); /* Clear list, prepare to start fresh. */ } /* The current inferior_ptid has exited, but there are other viable @@ -354,12 +372,19 @@ linux_fork_mourn_inferior (void) We need to delete that one from the fork_list, and switch to the next available fork. */ delete_fork (inferior_ptid); - if (fork_list) /* Paranoia, shouldn't happen. */ - { - inferior_ptid = fork_list[0].ptid; - printf_filtered (_("[Switching to %s]\n"), - target_pid_to_str (inferior_ptid)); - } + + /* There should still be a fork - if there's only one left, + delete_fork won't remove it, because we haven't updated + inferior_ptid yet. */ + gdb_assert (fork_list); + + fork_load_infrun_state (fork_list); + printf_filtered (_("[Switching to %s]\n"), + target_pid_to_str (inferior_ptid)); + + /* If there's only one fork, switch back to non-fork mode. */ + if (fork_list->next == NULL) + delete_fork (inferior_ptid); } /* Fork list <-> user interface. */ @@ -555,17 +580,10 @@ linux_fork_context (struct fork_info *newfp, int from_tty) error (_("No such fork/process")); if (!oldfp) - { - oldfp = add_fork (ptid_get_pid (inferior_ptid)); - } + oldfp = add_fork (ptid_get_pid (inferior_ptid)); fork_save_infrun_state (oldfp, 1); - inferior_ptid = newfp->ptid; fork_load_infrun_state (newfp); - registers_changed (); - reinit_frame_cache (); - stop_pc = read_pc (); - select_frame (get_current_frame ()); printf_filtered (_("Switching to %s\n"), target_pid_to_str (inferior_ptid)); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index 0710ac7..88e0d7d 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -88,6 +88,7 @@ /* The single-threaded native GNU/Linux target_ops. We save a pointer for the use of the multi-threaded target. */ static struct target_ops *linux_ops; +static struct target_ops linux_ops_saved; /* The saved to_xfer_partial method, inherited from inf-ptrace.c. Called by our to_xfer_partial. */ @@ -97,10 +98,6 @@ static LONGEST (*super_xfer_partial) (struct target_ops *, const gdb_byte *, ULONGEST, LONGEST); -/* The saved to_mourn_inferior method, inherited from inf-ptrace.c. - Called by our to_mourn_inferior. */ -static void (*super_mourn_inferior) (void); - static int debug_linux_nat; static void show_debug_linux_nat (struct ui_file *file, int from_tty, @@ -600,56 +597,6 @@ child_insert_exec_catchpoint (int pid) error (_("Your system does not support exec catchpoints.")); } -void -kill_inferior (void) -{ - int status; - int pid = PIDGET (inferior_ptid); - struct target_waitstatus last; - ptid_t last_ptid; - int ret; - - if (pid == 0) - return; - - /* First cut -- let's crudely do everything inline. */ - if (forks_exist_p ()) - { - linux_fork_killall (); - pop_target (); - generic_mourn_inferior (); - } - else - { - /* If we're stopped while forking and we haven't followed yet, - kill the other task. We need to do this first because the - parent will be sleeping if this is a vfork. */ - - get_last_target_status (&last_ptid, &last); - - if (last.kind == TARGET_WAITKIND_FORKED - || last.kind == TARGET_WAITKIND_VFORKED) - { - ptrace (PT_KILL, last.value.related_pid, 0, 0); - wait (&status); - } - - /* Kill the current process. */ - ptrace (PT_KILL, pid, 0, 0); - ret = wait (&status); - - /* We might get a SIGCHLD instead of an exit status. This is - aggravated by the first kill above - a child has just died. */ - - while (ret == pid && WIFSTOPPED (status)) - { - ptrace (PT_KILL, pid, 0, 0); - ret = wait (&status); - } - target_mourn_inferior (); - } -} - /* On GNU/Linux there are no real LWP's. The closest thing to LWP's are processes sharing the same VM space. A multi-threaded process is basically a group of such processes. However, such a grouping @@ -688,9 +635,6 @@ static struct lwp_info *lwp_list; /* Number of LWPs in the list. */ static int num_lwps; - -/* Non-zero if we're running in "threaded" mode. */ -static int threaded; #define GET_LWP(ptid) ptid_get_lwp (ptid) @@ -703,9 +647,6 @@ static int threaded; ptid_t trap_ptid; -/* This module's target-specific operations. */ -static struct target_ops linux_nat_ops; - /* Since we cannot wait (in linux_nat_wait) for the initial process and any cloned processes with a single call to waitpid, we have to use the WNOHANG flag and call waitpid in a loop. To optimize @@ -770,12 +711,10 @@ init_lwp_list (void) lwp_list = NULL; num_lwps = 0; - threaded = 0; } -/* Add the LWP specified by PID to the list. If this causes the - number of LWPs to become larger than one, go into "threaded" mode. - Return a pointer to the structure describing the new LWP. */ +/* Add the LWP specified by PID to the list. Return a pointer to the + structure describing the new LWP. */ static struct lwp_info * add_lwp (ptid_t ptid) @@ -794,8 +733,7 @@ add_lwp (ptid_t ptid) lp->next = lwp_list; lwp_list = lp; - if (++num_lwps > 1) - threaded = 1; + ++num_lwps; return lp; } @@ -816,8 +754,6 @@ delete_lwp (ptid_t ptid) if (!lp) return; - /* We don't go back to "non-threaded" mode if the number of threads - becomes less than two. */ num_lwps--; if (lpprev) @@ -869,6 +805,21 @@ iterate_over_lwps (int (*callback) (struct lwp_info *, void *), void *data) return NULL; } +/* Update our internal state when changing from one fork (checkpoint, + et cetera) to another indicated by NEW_PTID. We can only switch + single-threaded applications, so we only create one new LWP, and + the previous list is discarded. */ + +void +linux_nat_switch_fork (ptid_t new_ptid) +{ + struct lwp_info *lp; + + init_lwp_list (); + lp = add_lwp (new_ptid); + lp->stopped = 1; +} + /* Record a PTID for later deletion. */ struct saved_ptids @@ -1048,7 +999,8 @@ linux_nat_attach (char *args, int from_tty) linux_ops->to_attach (args, from_tty); /* Add the initial process as the first LWP to the list. */ - lp = add_lwp (BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid))); + inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), GET_PID (inferior_ptid)); + lp = add_lwp (inferior_ptid); /* Make sure the initial process is stopped. The user-level threads layer might want to poke around in the inferior, and that won't @@ -1850,134 +1802,6 @@ resumed_callback (struct lwp_info *lp, void *data) return lp->resumed; } -/* Local mourn_inferior -- we need to override mourn_inferior - so that we can do something clever if one of several forks - has exited. */ - -static void -child_mourn_inferior (void) -{ - int status; - - if (! forks_exist_p ()) - { - /* Normal case, no other forks available. */ - super_mourn_inferior (); - return; - } - else - { - /* Multi-fork case. The current inferior_ptid has exited, but - there are other viable forks to debug. Delete the exiting - one and context-switch to the first available. */ - linux_fork_mourn_inferior (); - } -} - -/* We need to override child_wait to support attaching to cloned - processes, since a normal wait (as done by the default version) - ignores those processes. */ - -/* Wait for child PTID to do something. Return id of the child, - minus_one_ptid in case of error; store status into *OURSTATUS. */ - -ptid_t -child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) -{ - int save_errno; - int status; - pid_t pid; - - ourstatus->kind = TARGET_WAITKIND_IGNORE; - - do - { - set_sigint_trap (); /* Causes SIGINT to be passed on to the - attached process. */ - set_sigio_trap (); - - pid = my_waitpid (GET_PID (ptid), &status, 0); - if (pid == -1 && errno == ECHILD) - /* Try again with __WCLONE to check cloned processes. */ - pid = my_waitpid (GET_PID (ptid), &status, __WCLONE); - - if (debug_linux_nat) - { - fprintf_unfiltered (gdb_stdlog, - "CW: waitpid %ld received %s\n", - (long) pid, status_to_str (status)); - } - - save_errno = errno; - - /* Make sure we don't report an event for the exit of the - original program, if we've detached from it. */ - if (pid != -1 && !WIFSTOPPED (status) && pid != GET_PID (inferior_ptid)) - { - pid = -1; - save_errno = EINTR; - } - - /* Check for stop events reported by a process we didn't already - know about - in this case, anything other than inferior_ptid. - - If we're expecting to receive stopped processes after fork, - vfork, and clone events, then we'll just add the new one to - our list and go back to waiting for the event to be reported - - the stopped process might be returned from waitpid before - or after the event is. If we want to handle debugging of - CLONE_PTRACE processes we need to do more here, i.e. switch - to multi-threaded mode. */ - if (pid != -1 && WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP - && pid != GET_PID (inferior_ptid)) - { - linux_record_stopped_pid (pid); - pid = -1; - save_errno = EINTR; - } - - /* Handle GNU/Linux's extended waitstatus for trace events. */ - if (pid != -1 && WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP - && status >> 16 != 0) - { - linux_handle_extended_wait (pid, status, ourstatus); - - /* If we see a clone event, detach the child, and don't - report the event. It would be nice to offer some way to - switch into a non-thread-db based threaded mode at this - point. */ - if (ourstatus->kind == TARGET_WAITKIND_SPURIOUS) - { - ptrace (PTRACE_DETACH, ourstatus->value.related_pid, 0, 0); - ourstatus->kind = TARGET_WAITKIND_IGNORE; - ptrace (PTRACE_CONT, pid, 0, 0); - pid = -1; - save_errno = EINTR; - } - } - - clear_sigio_trap (); - clear_sigint_trap (); - } - while (pid == -1 && save_errno == EINTR); - - if (pid == -1) - { - warning (_("Child process unexpectedly missing: %s"), - safe_strerror (errno)); - - /* Claim it exited with unknown signal. */ - ourstatus->kind = TARGET_WAITKIND_SIGNALLED; - ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; - return minus_one_ptid; - } - - if (ourstatus->kind == TARGET_WAITKIND_IGNORE) - store_waitstatus (ourstatus, status); - - return pid_to_ptid (pid); -} - /* Stop an active thread, verify it still exists, then resume it. */ static int @@ -2009,6 +1833,19 @@ linux_nat_wait (ptid_t ptid, struct target_waitstatus *ourstatus) pid_t pid = PIDGET (ptid); sigset_t flush_mask; + /* The first time we get here after starting a new inferior, we may + not have added it to the LWP list yet - this is the earliest + moment at which we know its PID. */ + if (num_lwps == 0) + { + gdb_assert (!is_lwp (inferior_ptid)); + + inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), + GET_PID (inferior_ptid)); + lp = add_lwp (inferior_ptid); + lp->resumed = 1; + } + sigemptyset (&flush_mask); /* Make sure SIGCHLD is blocked. */ @@ -2020,9 +1857,8 @@ linux_nat_wait (ptid_t ptid, struct target_waitstatus *ourstatus) retry: - /* Make sure there is at least one LWP that has been resumed, at - least if there are any LWPs at all. */ - gdb_assert (num_lwps == 0 || iterate_over_lwps (resumed_callback, NULL)); + /* Make sure there is at least one LWP that has been resumed. */ + gdb_assert (iterate_over_lwps (resumed_callback, NULL)); /* First check if there is a LWP with a wait status pending. */ if (pid == -1) @@ -2161,23 +1997,20 @@ retry: if (options & __WCLONE) lp->cloned = 1; - if (threaded) - { - gdb_assert (WIFSTOPPED (status) - && WSTOPSIG (status) == SIGSTOP); - lp->signalled = 1; - - if (!in_thread_list (inferior_ptid)) - { - inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), - GET_PID (inferior_ptid)); - add_thread (inferior_ptid); - } + gdb_assert (WIFSTOPPED (status) + && WSTOPSIG (status) == SIGSTOP); + lp->signalled = 1; - add_thread (lp->ptid); - printf_unfiltered (_("[New %s]\n"), - target_pid_to_str (lp->ptid)); + if (!in_thread_list (inferior_ptid)) + { + inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), + GET_PID (inferior_ptid)); + add_thread (inferior_ptid); } + + add_thread (lp->ptid); + printf_unfiltered (_("[New %s]\n"), + target_pid_to_str (lp->ptid)); } /* Handle GNU/Linux's extended waitstatus for trace events. */ @@ -2379,12 +2212,9 @@ retry: the comment in cancel_breakpoints_callback to find out why. */ iterate_over_lwps (cancel_breakpoints_callback, lp); - /* If we're not running in "threaded" mode, we'll report the bare - process id. */ - if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP) { - trap_ptid = (threaded ? lp->ptid : pid_to_ptid (GET_LWP (lp->ptid))); + trap_ptid = lp->ptid; if (debug_linux_nat) fprintf_unfiltered (gdb_stdlog, "LLW: trap_ptid is %s.\n", @@ -2401,7 +2231,7 @@ retry: else store_waitstatus (ourstatus, status); - return (threaded ? lp->ptid : pid_to_ptid (GET_LWP (lp->ptid))); + return lp->ptid; } static int @@ -2466,20 +2296,35 @@ kill_wait_callback (struct lwp_info *lp, void *data) static void linux_nat_kill (void) { - /* Kill all LWP's ... */ - iterate_over_lwps (kill_callback, NULL); + struct target_waitstatus last; + ptid_t last_ptid; + int status; - /* ... and wait until we've flushed all events. */ - iterate_over_lwps (kill_wait_callback, NULL); + /* If we're stopped while forking and we haven't followed yet, + kill the other task. We need to do this first because the + parent will be sleeping if this is a vfork. */ - target_mourn_inferior (); -} + get_last_target_status (&last_ptid, &last); -static void -linux_nat_create_inferior (char *exec_file, char *allargs, char **env, - int from_tty) -{ - linux_ops->to_create_inferior (exec_file, allargs, env, from_tty); + if (last.kind == TARGET_WAITKIND_FORKED + || last.kind == TARGET_WAITKIND_VFORKED) + { + ptrace (PT_KILL, last.value.related_pid, 0, 0); + wait (&status); + } + + if (forks_exist_p ()) + linux_fork_killall (); + else + { + /* Kill all LWP's ... */ + iterate_over_lwps (kill_callback, NULL); + + /* ... and wait until we've flushed all events. */ + iterate_over_lwps (kill_wait_callback, NULL); + } + + target_mourn_inferior (); } static void @@ -2494,7 +2339,14 @@ linux_nat_mourn_inferior (void) sigprocmask (SIG_SETMASK, &normal_mask, NULL); sigemptyset (&blocked_mask); - linux_ops->to_mourn_inferior (); + if (! forks_exist_p ()) + /* Normal case, no other forks available. */ + linux_ops->to_mourn_inferior (); + else + /* Multi-fork case. The current inferior_ptid has exited, but + there are other viable forks to debug. Delete the exiting + one and context-switch to the first available. */ + linux_fork_mourn_inferior (); } static LONGEST @@ -2539,7 +2391,7 @@ linux_nat_pid_to_str (ptid_t ptid) { static char buf[64]; - if (is_lwp (ptid)) + if (lwp_list && lwp_list->next && is_lwp (ptid)) { snprintf (buf, sizeof (buf), "LWP %ld", GET_LWP (ptid)); return buf; @@ -2549,59 +2401,6 @@ linux_nat_pid_to_str (ptid_t ptid) } static void -linux_nat_fetch_registers (int regnum) -{ - /* to_fetch_registers will honor the LWP ID, so we can use it directly. */ - linux_ops->to_fetch_registers (regnum); -} - -static void -linux_nat_store_registers (int regnum) -{ - /* to_store_registers will honor the LWP ID, so we can use it directly. */ - linux_ops->to_store_registers (regnum); -} - -static void -linux_nat_child_post_startup_inferior (ptid_t ptid) -{ - linux_ops->to_post_startup_inferior (ptid); -} - -static void -init_linux_nat_ops (void) -{ -#if 0 - linux_nat_ops.to_open = linux_nat_open; -#endif - linux_nat_ops.to_shortname = "lwp-layer"; - linux_nat_ops.to_longname = "lwp-layer"; - linux_nat_ops.to_doc = "Low level threads support (LWP layer)"; - linux_nat_ops.to_attach = linux_nat_attach; - linux_nat_ops.to_detach = linux_nat_detach; - linux_nat_ops.to_resume = linux_nat_resume; - linux_nat_ops.to_wait = linux_nat_wait; - linux_nat_ops.to_fetch_registers = linux_nat_fetch_registers; - linux_nat_ops.to_store_registers = linux_nat_store_registers; - linux_nat_ops.to_xfer_partial = linux_nat_xfer_partial; - linux_nat_ops.to_kill = linux_nat_kill; - linux_nat_ops.to_create_inferior = linux_nat_create_inferior; - linux_nat_ops.to_mourn_inferior = linux_nat_mourn_inferior; - linux_nat_ops.to_thread_alive = linux_nat_thread_alive; - linux_nat_ops.to_pid_to_str = linux_nat_pid_to_str; - linux_nat_ops.to_post_startup_inferior - = linux_nat_child_post_startup_inferior; - linux_nat_ops.to_post_attach = child_post_attach; - linux_nat_ops.to_insert_fork_catchpoint = child_insert_fork_catchpoint; - linux_nat_ops.to_insert_vfork_catchpoint = child_insert_vfork_catchpoint; - linux_nat_ops.to_insert_exec_catchpoint = child_insert_exec_catchpoint; - - linux_nat_ops.to_stratum = thread_stratum; - linux_nat_ops.to_has_thread_control = tc_schedlock; - linux_nat_ops.to_magic = OPS_MAGIC; -} - -static void sigchld_handler (int signo) { /* Do nothing. The only reason for this handler is that it allows @@ -3312,8 +3111,6 @@ linux_target (void) #else t = inf_ptrace_trad_target (linux_register_u_offset); #endif - t->to_wait = child_wait; - t->to_kill = kill_inferior; t->to_insert_fork_catchpoint = child_insert_fork_catchpoint; t->to_insert_vfork_catchpoint = child_insert_vfork_catchpoint; t->to_insert_exec_catchpoint = child_insert_exec_catchpoint; @@ -3327,18 +3124,50 @@ linux_target (void) super_xfer_partial = t->to_xfer_partial; t->to_xfer_partial = linux_xfer_partial; - super_mourn_inferior = t->to_mourn_inferior; - t->to_mourn_inferior = child_mourn_inferior; - - linux_ops = t; return t; } void +linux_nat_add_target (struct target_ops *t) +{ + extern void thread_db_init (struct target_ops *); + + /* Save the provided single-threaded target. We save this in a separate + variable because another target we've inherited from (e.g. inf-ptrace) + may have saved a pointer to T; we want to use it for the final + process stratum target. */ + linux_ops_saved = *t; + linux_ops = &linux_ops_saved; + + /* Override some methods for multithreading. */ + t->to_attach = linux_nat_attach; + t->to_detach = linux_nat_detach; + t->to_resume = linux_nat_resume; + t->to_wait = linux_nat_wait; + t->to_xfer_partial = linux_nat_xfer_partial; + t->to_kill = linux_nat_kill; + t->to_mourn_inferior = linux_nat_mourn_inferior; + t->to_thread_alive = linux_nat_thread_alive; + t->to_pid_to_str = linux_nat_pid_to_str; + t->to_has_thread_control = tc_schedlock; + + /* We don't change the stratum; this target will sit at + process_stratum and thread_db will set at thread_stratum. This + is a little strange, since this is a multi-threaded-capable + target, but we want to be on the stack below thread_db, and we + also want to be used for single-threaded processes. */ + + add_target (t); + + /* TODO: Eliminate this and have libthread_db use + find_target_beneath. */ + thread_db_init (t); +} + +void _initialize_linux_nat (void) { struct sigaction action; - extern void thread_db_init (struct target_ops *); add_info ("proc", linux_nat_info_proc_cmd, _("\ Show /proc process information about any running process.\n\ @@ -3349,10 +3178,6 @@ Specify any of the following keywords for detailed info:\n\ status -- list a different bunch of random process info.\n\ all -- list all available /proc info.")); - init_linux_nat_ops (); - add_target (&linux_nat_ops); - thread_db_init (&linux_nat_ops); - /* Save the original signal mask. */ sigprocmask (SIG_SETMASK, NULL, &normal_mask); diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h index 92003c9..ecfaab7 100644 --- a/gdb/linux-nat.h +++ b/gdb/linux-nat.h @@ -1,6 +1,6 @@ /* Native debugging support for GNU/Linux (LWP layer). - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -83,3 +83,11 @@ struct lwp_info *iterate_over_lwps (int (*callback) (struct lwp_info *, /* Create a prototype generic Linux target. The client can override it with local methods. */ struct target_ops * linux_target (void); + +/* Register the customized Linux target. This should be used + instead of calling add_target directly. */ +void linux_nat_add_target (struct target_ops *); + +/* Update linux-nat internal state when changing from one fork + to another. */ +void linux_nat_switch_fork (ptid_t new_ptid); diff --git a/gdb/m32r-linux-nat.c b/gdb/m32r-linux-nat.c index bfe6435..454147b 100644 --- a/gdb/m32r-linux-nat.c +++ b/gdb/m32r-linux-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for GNU/Linux m32r. - Copyright (C) 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -250,5 +250,5 @@ _initialize_m32r_linux_nat (void) t->to_store_registers = m32r_linux_store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/m68klinux-nat.c b/gdb/m68klinux-nat.c index 777330c..0da875e 100644 --- a/gdb/m68klinux-nat.c +++ b/gdb/m68klinux-nat.c @@ -1,6 +1,6 @@ /* Motorola m68k native support for GNU/Linux. - Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005 + Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -633,7 +633,7 @@ _initialize_m68k_linux_nat (void) t->to_store_registers = m68k_linux_store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); deprecated_add_core_fns (&linux_elf_core_fns); } diff --git a/gdb/mi/gdb-mi.el b/gdb/mi/gdb-mi.el index 4c4c30a..ed1d7b7 100644 --- a/gdb/mi/gdb-mi.el +++ b/gdb/mi/gdb-mi.el @@ -115,7 +115,7 @@ detailed description of this mode. ;; Let's start with a basic gud-gdb buffer and then modify it a bit. (gdb command-line) ;; - (setq gdb-debug-log nil) + (setq gdb-debug-ring nil) (set (make-local-variable 'gud-minor-mode) 'gdbmi) (set (make-local-variable 'gud-marker-filter) 'gud-gdbmi-marker-filter) ;; @@ -177,7 +177,7 @@ detailed description of this mode. gdb-selected-frame nil gdb-frame-number nil gdb-var-list nil - gdb-var-changed nil + gdb-force-update t gdb-prompting nil gdb-input-queue nil gdb-current-item nil @@ -225,18 +225,21 @@ detailed description of this mode. (setq gdb-output-sink 'user) (setq gdb-prompting nil) ;; mimic key to repeat previous command in GDB - (if (string-match "\\S+" string) + (if (string-match "^\\S+$" string) (setq gdb-last-command string) (if gdb-last-command (setq string gdb-last-command))) - (if gdb-enable-debug-log - (push (cons 'mi-send (concat string "\n")) gdb-debug-log)) - (process-send-string - proc + (if gdb-enable-debug + (push (cons 'mi-send (concat string "\n")) gdb-debug-ring)) (if (string-match "^-" string) ;; MI command - (concat string "\n") + (process-send-string proc (concat string "\n")) ;; CLI command - (concat "-interpreter-exec console \"" string "\"\n"))))) + (if (string-match "\\\\$" string) + (setq gdb-continuation (concat gdb-continuation string "\n")) + (process-send-string proc + (concat "-interpreter-exec console \"" + gdb-continuation string "\"\n")) + (setq gdb-continuation nil))))) (defcustom gud-gdbmi-command-name "gdb -interp=mi" "Default command to execute an executable under the GDB-UI debugger." @@ -265,7 +268,7 @@ detailed description of this mode. "Queue any GDB commands that the user interface needs." (unless gdb-pending-triggers (when (and (boundp 'speedbar-frame) (frame-live-p speedbar-frame)) - (setq gdb-var-changed t) ; force update + (setq gdb-force-update t) (dolist (var gdb-var-list) (setcar (nthcdr 5 var) nil)) (gdb-var-update-1)) @@ -282,7 +285,7 @@ detailed description of this mode. (when (eq sink 'emacs) (let ((handler (car (cdr gdb-current-item)))) - (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (funcall handler))))) (let ((input (gdb-dequeue-input))) (if input @@ -296,8 +299,8 @@ detailed description of this mode. "Filter GDB/MI output." (if gdb-flush-pending-output nil - (if gdb-enable-debug-log (push (cons 'recv (list string gdb-output-sink)) - gdb-debug-log)) + (if gdb-enable-debug (push (cons 'recv (list string gdb-output-sink)) + gdb-debug-ring)) ;; Recall the left over gud-marker-acc from last time (setq gud-marker-acc (concat gud-marker-acc string)) ;; Start accumulating output for the GUD buffer @@ -400,16 +403,16 @@ detailed description of this mode. gdb-break-list-handler) (defconst gdb-break-list-regexp -"number=\"\\(.*?\\)\",type=\"\\(.*?\\)\",disp=\"\\(.*?\\)\",enabled=\"\\(.\\)\",\ -addr=\"\\(.*?\\)\",\ -\\(?:func=\"\\(.*?\\)\",file=\"\\(.*?\\)\",fullname=\".*?\",line=\"\\(.*?\\)\",\ -\\|\\(?:what=\"\\(.*?\\)\",\\)*\\)times=\"\\(.*?\\)\"") +"bkpt={.*?number=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\",.*?disp=\"\\(.*?\\)\",.*?\ +enabled=\"\\(.\\)\",.*?addr=\"\\(.*?\\)\",\\(?:.*?func=\"\\(.*?\\)\",.*?\ +file=\"\\(.*?\\)\",.*?fullname=\".*?\",.*?line=\"\\(.*?\\)\",\ +\\|\\(?:.*?what=\"\\(.*?\\)\",\\)*\\).*?times=\"\\(.*?\\)\".*?}") (defun gdb-break-list-handler () (setq gdb-pending-triggers (delq 'gdbmi-invalidate-breakpoints gdb-pending-triggers)) (let ((breakpoint) (breakpoints-list)) - (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (goto-char (point-min)) (while (re-search-forward gdb-break-list-regexp nil t) (let ((breakpoint (list (match-string 1) @@ -476,8 +479,8 @@ Add directory to search path for source files using the GDB command, dir.")) gdb-stack-list-frames-handler) (defconst gdb-stack-list-frames-regexp -"level=\"\\(.*?\\)\",addr=\"\\(.*?\\)\",func=\"\\(.*?\\)\",\ -\\(?:file=\".*?\",fullname=\"\\(.*?\\)\",line=\"\\(.*?\\)\"\\|\ +"{.*?level=\"\\(.*?\\)\",.*?addr=\"\\(.*?\\)\",.*?func=\"\\(.*?\\)\",\ +\\(?:.*?file=\".*?\",.*?fullname=\"\\(.*?\\)\",.*?line=\"\\(.*?\\)\".*?}\\|\ from=\"\\(.*?\\)\"\\)") (defun gdb-stack-list-frames-handler () @@ -485,7 +488,7 @@ from=\"\\(.*?\\)\"\\)") gdb-pending-triggers)) (let ((frame nil) (call-stack nil)) - (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (goto-char (point-min)) (while (re-search-forward gdb-stack-list-frames-regexp nil t) (let ((frame (list (match-string 1) @@ -540,7 +543,7 @@ buffers, if required." (setq gdb-main-file (match-string 1))) (if gdb-many-windows (gdb-setup-windows) - (gdb-get-create-buffer 'gdb-breakpoints-buffer) + (gdb-get-buffer-create 'gdb-breakpoints-buffer) (if gdb-show-main (let ((pop-up-windows t)) (display-buffer (gud-find-file gdb-main-file)))))) @@ -556,7 +559,7 @@ buffers, if required." (defun gdbmi-frame-handler () (setq gdb-pending-triggers (delq 'gdbmi-get-selected-frame gdb-pending-triggers)) - (with-current-buffer (gdb-get-create-buffer 'gdb-partial-output-buffer) + (with-current-buffer (gdb-get-buffer-create 'gdb-partial-output-buffer) (goto-char (point-min)) (when (re-search-forward gdb-stack-list-frames-regexp nil t) (setq gdb-frame-number (match-string 1)) @@ -565,6 +568,17 @@ buffers, if required." (setq gud-last-frame (cons (match-string 4) (string-to-number (match-string 5)))) (gud-display-frame) + (if gud-overlay-arrow-position + (let ((buffer (marker-buffer gud-overlay-arrow-position)) + (position (marker-position gud-overlay-arrow-position))) + (when buffer + (with-current-buffer buffer + (setq fringe-indicator-alist + (if (string-equal gdb-frame-number "0") + nil + '((overlay-arrow . hollow-right-triangle)))) + (setq gud-overlay-arrow-position (make-marker)) + (set-marker gud-overlay-arrow-position position))))) (if (gdb-get-buffer 'gdb-locals-buffer) (with-current-buffer (gdb-get-buffer 'gdb-locals-buffer) (setq mode-name (concat "Locals:" gdb-selected-frame)))) diff --git a/gdb/mips-linux-nat.c b/gdb/mips-linux-nat.c index 0d581d1..7796146 100644 --- a/gdb/mips-linux-nat.c +++ b/gdb/mips-linux-nat.c @@ -1,6 +1,7 @@ /* Native-dependent code for GNU/Linux on MIPS processors. - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of GDB. @@ -20,9 +21,29 @@ Boston, MA 02110-1301, USA. */ #include "defs.h" +#include "inferior.h" #include "mips-tdep.h" #include "target.h" #include "linux-nat.h" +#include "mips-linux-tdep.h" + +#include "gdb_proc_service.h" + +#include + +#ifndef PTRACE_GET_THREAD_AREA +#define PTRACE_GET_THREAD_AREA 25 +#endif + +/* Assume that we have PTRACE_GETREGS et al. support. If we do not, + we'll clear this and use PTRACE_PEEKUSER instead. */ +static int have_ptrace_regsets = 1; + +/* Saved function pointers to fetch and store a single register using + PTRACE_PEEKUSER and PTRACE_POKEUSER. */ + +void (*super_fetch_registers) (int); +void (*super_store_registers) (int); /* Pseudo registers can not be read. ptrace does not provide a way to read (or set) MIPS_PS_REGNUM, and there's no point in reading or @@ -65,10 +86,178 @@ mips_linux_cannot_store_register (int regno) return 1; } +/* Fetch the thread-local storage pointer for libthread_db. */ + +ps_err_e +ps_get_thread_area (const struct ps_prochandle *ph, + lwpid_t lwpid, int idx, void **base) +{ + if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0) + return PS_ERR; + + /* IDX is the bias from the thread pointer to the beginning of the + thread descriptor. It has to be subtracted due to implementation + quirks in libthread_db. */ + *base = (void *) ((char *)*base - idx); + + return PS_OK; +} + +/* Fetch REGNO (or all registers if REGNO == -1) from the target + using PTRACE_GETREGS et al. */ + +static void +mips64_linux_regsets_fetch_registers (int regno) +{ + int is_fp; + int tid; + + if (regno >= mips_regnum (current_gdbarch)->fp0 + && regno <= mips_regnum (current_gdbarch)->fp0 + 32) + is_fp = 1; + else if (regno == mips_regnum (current_gdbarch)->fp_control_status) + is_fp = 1; + else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) + is_fp = 1; + else + is_fp = 0; + + tid = ptid_get_lwp (inferior_ptid); + if (tid == 0) + tid = ptid_get_pid (inferior_ptid); + + if (regno == -1 || !is_fp) + { + mips64_elf_gregset_t regs; + + if (ptrace (PTRACE_GETREGS, tid, 0L, (PTRACE_TYPE_ARG3) ®s) == -1) + { + if (errno == EIO) + { + have_ptrace_regsets = 0; + return; + } + perror_with_name (_("Couldn't get registers")); + } + + mips64_supply_gregset (®s); + } + + if (regno == -1 || is_fp) + { + mips64_elf_fpregset_t fp_regs; + + if (ptrace (PTRACE_GETFPREGS, tid, 0L, + (PTRACE_TYPE_ARG3) &fp_regs) == -1) + { + if (errno == EIO) + { + have_ptrace_regsets = 0; + return; + } + perror_with_name (_("Couldn't get FP registers")); + } + + mips64_supply_fpregset (&fp_regs); + } +} + +/* Store REGNO (or all registers if REGNO == -1) to the target + using PTRACE_SETREGS et al. */ + +static void +mips64_linux_regsets_store_registers (int regno) +{ + int is_fp; + int tid; + + if (regno >= mips_regnum (current_gdbarch)->fp0 + && regno <= mips_regnum (current_gdbarch)->fp0 + 32) + is_fp = 1; + else if (regno == mips_regnum (current_gdbarch)->fp_control_status) + is_fp = 1; + else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) + is_fp = 1; + else + is_fp = 0; + + tid = ptid_get_lwp (inferior_ptid); + if (tid == 0) + tid = ptid_get_pid (inferior_ptid); + + if (regno == -1 || !is_fp) + { + mips64_elf_gregset_t regs; + + if (ptrace (PTRACE_GETREGS, tid, 0L, (PTRACE_TYPE_ARG3) ®s) == -1) + perror_with_name (_("Couldn't get registers")); + + mips64_fill_gregset (®s, regno); + + if (ptrace (PTRACE_SETREGS, tid, 0L, (PTRACE_TYPE_ARG3) ®s) == -1) + perror_with_name (_("Couldn't set registers")); + } + + if (regno == -1 || is_fp) + { + mips64_elf_fpregset_t fp_regs; + + if (ptrace (PTRACE_GETFPREGS, tid, 0L, + (PTRACE_TYPE_ARG3) &fp_regs) == -1) + perror_with_name (_("Couldn't get FP registers")); + + mips64_fill_fpregset (&fp_regs, regno); + + if (ptrace (PTRACE_SETFPREGS, tid, 0L, + (PTRACE_TYPE_ARG3) &fp_regs) == -1) + perror_with_name (_("Couldn't set FP registers")); + } +} + +/* Fetch REGNO (or all registers if REGNO == -1) from the target + using any working method. */ + +static void +mips64_linux_fetch_registers (int regnum) +{ + /* Unless we already know that PTRACE_GETREGS does not work, try it. */ + if (have_ptrace_regsets) + mips64_linux_regsets_fetch_registers (regnum); + + /* If we know, or just found out, that PTRACE_GETREGS does not work, fall + back to PTRACE_PEEKUSER. */ + if (!have_ptrace_regsets) + super_fetch_registers (regnum); +} + +/* Store REGNO (or all registers if REGNO == -1) to the target + using any working method. */ + +static void +mips64_linux_store_registers (int regnum) +{ + /* Unless we already know that PTRACE_GETREGS does not work, try it. */ + if (have_ptrace_regsets) + mips64_linux_regsets_store_registers (regnum); + + /* If we know, or just found out, that PTRACE_GETREGS does not work, fall + back to PTRACE_PEEKUSER. */ + if (!have_ptrace_regsets) + super_store_registers (regnum); +} + void _initialize_mips_linux_nat (void); void _initialize_mips_linux_nat (void) { - add_target (linux_target ()); + struct target_ops *t = linux_target (); + + super_fetch_registers = t->to_fetch_registers; + super_store_registers = t->to_store_registers; + + t->to_fetch_registers = mips64_linux_fetch_registers; + t->to_store_registers = mips64_linux_store_registers; + + linux_nat_add_target (t); } diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 021edc7..5d789d2 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -32,37 +32,8 @@ #include "regcache.h" #include "trad-frame.h" #include "tramp-frame.h" - -/* Copied from . */ -#define ELF_NGREG 45 -#define ELF_NFPREG 33 - -typedef unsigned char elf_greg_t[4]; -typedef elf_greg_t elf_gregset_t[ELF_NGREG]; - -typedef unsigned char elf_fpreg_t[8]; -typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; - -/* 0 - 31 are integer registers, 32 - 63 are fp registers. */ -#define FPR_BASE 32 -#define PC 64 -#define CAUSE 65 -#define BADVADDR 66 -#define MMHI 67 -#define MMLO 68 -#define FPC_CSR 69 -#define FPC_EIR 70 - -#define EF_REG0 6 -#define EF_REG31 37 -#define EF_LO 38 -#define EF_HI 39 -#define EF_CP0_EPC 40 -#define EF_CP0_BADVADDR 41 -#define EF_CP0_STATUS 42 -#define EF_CP0_CAUSE 43 - -#define EF_SIZE 180 +#include "floatformat.h" +#include "mips-linux-tdep.h" /* Figure out where the longjmp will land. We expect the first arg to be a pointer to the jmp_buf structure @@ -98,7 +69,7 @@ mips_linux_get_longjmp_target (CORE_ADDR *pc) static void supply_32bit_reg (int regnum, const void *addr) { - char buf[MAX_REGISTER_SIZE]; + gdb_byte buf[MAX_REGISTER_SIZE]; store_signed_integer (buf, register_size (current_gdbarch, regnum), extract_signed_integer (addr, 4)); regcache_raw_supply (current_regcache, regnum, buf); @@ -106,11 +77,11 @@ supply_32bit_reg (int regnum, const void *addr) /* Unpack an elf_gregset_t into GDB's register cache. */ -void -supply_gregset (elf_gregset_t *gregsetp) +void +mips_supply_gregset (mips_elf_gregset_t *gregsetp) { int regi; - elf_greg_t *regp = *gregsetp; + mips_elf_greg_t *regp = *gregsetp; char zerobuf[MAX_REGISTER_SIZE]; memset (zerobuf, 0, MAX_REGISTER_SIZE); @@ -142,23 +113,23 @@ supply_gregset (elf_gregset_t *gregsetp) /* Pack our registers (or one register) into an elf_gregset_t. */ void -fill_gregset (elf_gregset_t *gregsetp, int regno) +mips_fill_gregset (mips_elf_gregset_t *gregsetp, int regno) { int regaddr, regi; - elf_greg_t *regp = *gregsetp; + mips_elf_greg_t *regp = *gregsetp; void *dst; if (regno == -1) { - memset (regp, 0, sizeof (elf_gregset_t)); + memset (regp, 0, sizeof (mips_elf_gregset_t)); for (regi = 0; regi < 32; regi++) - fill_gregset (gregsetp, regi); - fill_gregset (gregsetp, mips_regnum (current_gdbarch)->lo); - fill_gregset (gregsetp, mips_regnum (current_gdbarch)->hi); - fill_gregset (gregsetp, mips_regnum (current_gdbarch)->pc); - fill_gregset (gregsetp, mips_regnum (current_gdbarch)->badvaddr); - fill_gregset (gregsetp, MIPS_PS_REGNUM); - fill_gregset (gregsetp, mips_regnum (current_gdbarch)->cause); + mips_fill_gregset (gregsetp, regi); + mips_fill_gregset (gregsetp, mips_regnum (current_gdbarch)->lo); + mips_fill_gregset (gregsetp, mips_regnum (current_gdbarch)->hi); + mips_fill_gregset (gregsetp, mips_regnum (current_gdbarch)->pc); + mips_fill_gregset (gregsetp, mips_regnum (current_gdbarch)->badvaddr); + mips_fill_gregset (gregsetp, MIPS_PS_REGNUM); + mips_fill_gregset (gregsetp, mips_regnum (current_gdbarch)->cause); return; } @@ -195,7 +166,7 @@ fill_gregset (elf_gregset_t *gregsetp, int regno) /* Likewise, unpack an elf_fpregset_t. */ void -supply_fpregset (elf_fpregset_t *fpregsetp) +mips_supply_fpregset (mips_elf_fpregset_t *fpregsetp) { int regi; char zerobuf[MAX_REGISTER_SIZE]; @@ -220,7 +191,7 @@ supply_fpregset (elf_fpregset_t *fpregsetp) elf_fpregset_t. */ void -fill_fpregset (elf_fpregset_t *fpregsetp, int regno) +mips_fill_fpregset (mips_elf_fpregset_t *fpregsetp, int regno) { char *from, *to; @@ -239,9 +210,9 @@ fill_fpregset (elf_fpregset_t *fpregsetp, int regno) int regi; for (regi = 0; regi < 32; regi++) - fill_fpregset (fpregsetp, FP0_REGNUM + regi); - fill_fpregset (fpregsetp, - mips_regnum (current_gdbarch)->fp_control_status); + mips_fill_fpregset (fpregsetp, FP0_REGNUM + regi); + mips_fill_fpregset (fpregsetp, + mips_regnum (current_gdbarch)->fp_control_status); } } @@ -283,37 +254,6 @@ mips_linux_register_addr (int regno, CORE_ADDR blockend) /* Support for 64-bit ABIs. */ -/* Copied from . */ -#define MIPS64_ELF_NGREG 45 -#define MIPS64_ELF_NFPREG 33 - -typedef unsigned char mips64_elf_greg_t[8]; -typedef mips64_elf_greg_t mips64_elf_gregset_t[MIPS64_ELF_NGREG]; - -typedef unsigned char mips64_elf_fpreg_t[8]; -typedef mips64_elf_fpreg_t mips64_elf_fpregset_t[MIPS64_ELF_NFPREG]; - -/* 0 - 31 are integer registers, 32 - 63 are fp registers. */ -#define MIPS64_FPR_BASE 32 -#define MIPS64_PC 64 -#define MIPS64_CAUSE 65 -#define MIPS64_BADVADDR 66 -#define MIPS64_MMHI 67 -#define MIPS64_MMLO 68 -#define MIPS64_FPC_CSR 69 -#define MIPS64_FPC_EIR 70 - -#define MIPS64_EF_REG0 0 -#define MIPS64_EF_REG31 31 -#define MIPS64_EF_LO 32 -#define MIPS64_EF_HI 33 -#define MIPS64_EF_CP0_EPC 34 -#define MIPS64_EF_CP0_BADVADDR 35 -#define MIPS64_EF_CP0_STATUS 36 -#define MIPS64_EF_CP0_CAUSE 37 - -#define MIPS64_EF_SIZE 304 - /* Figure out where the longjmp will land. We expect the first arg to be a pointer to the jmp_buf structure from which we extract the pc (MIPS_LINUX_JB_PC) that we will land @@ -342,39 +282,49 @@ mips64_linux_get_longjmp_target (CORE_ADDR *pc) return 1; } -/* Unpack an elf_gregset_t into GDB's register cache. */ +/* Register set support functions. These operate on standard 64-bit + regsets, but work whether the target is 32-bit or 64-bit. A 32-bit + target will still use the 64-bit format for PTRACE_GETREGS. */ + +/* Supply a 64-bit register. */ + +void +supply_64bit_reg (int regnum, const gdb_byte *buf) +{ + if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG + && register_size (current_gdbarch, regnum) == 4) + regcache_raw_supply (current_regcache, regnum, buf + 4); + else + regcache_raw_supply (current_regcache, regnum, buf); +} + +/* Unpack a 64-bit elf_gregset_t into GDB's register cache. */ -static void +void mips64_supply_gregset (mips64_elf_gregset_t *gregsetp) { int regi; mips64_elf_greg_t *regp = *gregsetp; - char zerobuf[MAX_REGISTER_SIZE]; + gdb_byte zerobuf[MAX_REGISTER_SIZE]; memset (zerobuf, 0, MAX_REGISTER_SIZE); for (regi = MIPS64_EF_REG0; regi <= MIPS64_EF_REG31; regi++) - regcache_raw_supply (current_regcache, (regi - MIPS64_EF_REG0), - (char *)(regp + regi)); - - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->lo, - (char *) (regp + MIPS64_EF_LO)); - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->hi, - (char *) (regp + MIPS64_EF_HI)); - - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->pc, - (char *) (regp + MIPS64_EF_CP0_EPC)); - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->badvaddr, - (char *) (regp + MIPS64_EF_CP0_BADVADDR)); - regcache_raw_supply (current_regcache, MIPS_PS_REGNUM, - (char *) (regp + MIPS64_EF_CP0_STATUS)); - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->cause, - (char *) (regp + MIPS64_EF_CP0_CAUSE)); + supply_64bit_reg (regi - MIPS64_EF_REG0, (gdb_byte *)(regp + regi)); + + supply_64bit_reg (mips_regnum (current_gdbarch)->lo, + (gdb_byte *) (regp + MIPS64_EF_LO)); + supply_64bit_reg (mips_regnum (current_gdbarch)->hi, + (gdb_byte *) (regp + MIPS64_EF_HI)); + + supply_64bit_reg (mips_regnum (current_gdbarch)->pc, + (gdb_byte *) (regp + MIPS64_EF_CP0_EPC)); + supply_64bit_reg (mips_regnum (current_gdbarch)->badvaddr, + (gdb_byte *) (regp + MIPS64_EF_CP0_BADVADDR)); + supply_64bit_reg (MIPS_PS_REGNUM, + (gdb_byte *) (regp + MIPS64_EF_CP0_STATUS)); + supply_64bit_reg (mips_regnum (current_gdbarch)->cause, + (gdb_byte *) (regp + MIPS64_EF_CP0_CAUSE)); /* Fill inaccessible registers with zero. */ regcache_raw_supply (current_regcache, MIPS_UNUSED_REGNUM, zerobuf); @@ -384,9 +334,9 @@ mips64_supply_gregset (mips64_elf_gregset_t *gregsetp) regcache_raw_supply (current_regcache, regi, zerobuf); } -/* Pack our registers (or one register) into an elf_gregset_t. */ +/* Pack our registers (or one register) into a 64-bit elf_gregset_t. */ -static void +void mips64_fill_gregset (mips64_elf_gregset_t *gregsetp, int regno) { int regaddr, regi; @@ -411,13 +361,8 @@ mips64_fill_gregset (mips64_elf_gregset_t *gregsetp, int regno) } if (regno < 32) - { - dst = regp + regno + MIPS64_EF_REG0; - regcache_raw_collect (current_regcache, regno, dst); - return; - } - - if (regno == mips_regnum (current_gdbarch)->lo) + regaddr = regno + MIPS64_EF_REG0; + else if (regno == mips_regnum (current_gdbarch)->lo) regaddr = MIPS64_EF_LO; else if (regno == mips_regnum (current_gdbarch)->hi) regaddr = MIPS64_EF_HI; @@ -434,52 +379,97 @@ mips64_fill_gregset (mips64_elf_gregset_t *gregsetp, int regno) if (regaddr != -1) { + gdb_byte buf[MAX_REGISTER_SIZE]; + LONGEST val; + + regcache_raw_collect (current_regcache, regno, buf); + val = extract_signed_integer (buf, + register_size (current_gdbarch, regno)); dst = regp + regaddr; - regcache_raw_collect (current_regcache, regno, dst); + store_signed_integer (dst, 8, val); } } /* Likewise, unpack an elf_fpregset_t. */ -static void +void mips64_supply_fpregset (mips64_elf_fpregset_t *fpregsetp) { int regi; - char zerobuf[MAX_REGISTER_SIZE]; - memset (zerobuf, 0, MAX_REGISTER_SIZE); - - for (regi = 0; regi < 32; regi++) - regcache_raw_supply (current_regcache, FP0_REGNUM + regi, - (char *)(*fpregsetp + regi)); - - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->fp_control_status, - (char *)(*fpregsetp + 32)); - - /* FIXME: how can we supply FCRIR? The ABI doesn't tell us. */ - regcache_raw_supply (current_regcache, - mips_regnum (current_gdbarch)->fp_implementation_revision, - zerobuf); + /* See mips_linux_o32_sigframe_init for a description of the + peculiar FP register layout. */ + if (register_size (current_gdbarch, FP0_REGNUM) == 4) + for (regi = 0; regi < 32; regi++) + { + gdb_byte *reg_ptr = (gdb_byte *) (*fpregsetp + (regi & ~1)); + if ((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) != (regi & 1)) + reg_ptr += 4; + regcache_raw_supply (current_regcache, FP0_REGNUM + regi, reg_ptr); + } + else + for (regi = 0; regi < 32; regi++) + regcache_raw_supply (current_regcache, FP0_REGNUM + regi, + (char *)(*fpregsetp + regi)); + + supply_32bit_reg (mips_regnum (current_gdbarch)->fp_control_status, + (gdb_byte *)(*fpregsetp + 32)); + + /* The ABI doesn't tell us how to supply FCRIR, and core dumps don't + include it - but the result of PTRACE_GETFPREGS does. The best we + can do is to assume that its value is present. */ + supply_32bit_reg (mips_regnum (current_gdbarch)->fp_implementation_revision, + (gdb_byte *)(*fpregsetp + 32) + 4); } /* Likewise, pack one or all floating point registers into an elf_fpregset_t. */ -static void +void mips64_fill_fpregset (mips64_elf_fpregset_t *fpregsetp, int regno) { - char *from, *to; + gdb_byte *to; if ((regno >= FP0_REGNUM) && (regno < FP0_REGNUM + 32)) { - to = (char *) (*fpregsetp + regno - FP0_REGNUM); - regcache_raw_collect (current_regcache, regno, to); + /* See mips_linux_o32_sigframe_init for a description of the + peculiar FP register layout. */ + if (register_size (current_gdbarch, regno) == 4) + { + int regi = regno - FP0_REGNUM; + + to = (gdb_byte *) (*fpregsetp + (regi & ~1)); + if ((TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) != (regi & 1)) + to += 4; + regcache_raw_collect (current_regcache, regno, to); + } + else + { + to = (gdb_byte *) (*fpregsetp + regno - FP0_REGNUM); + regcache_raw_collect (current_regcache, regno, to); + } } else if (regno == mips_regnum (current_gdbarch)->fp_control_status) { - to = (char *) (*fpregsetp + 32); - regcache_raw_collect (current_regcache, regno, to); + gdb_byte buf[MAX_REGISTER_SIZE]; + LONGEST val; + + regcache_raw_collect (current_regcache, regno, buf); + val = extract_signed_integer (buf, + register_size (current_gdbarch, regno)); + to = (gdb_byte *) (*fpregsetp + 32); + store_signed_integer (to, 4, val); + } + else if (regno == mips_regnum (current_gdbarch)->fp_implementation_revision) + { + gdb_byte buf[MAX_REGISTER_SIZE]; + LONGEST val; + + regcache_raw_collect (current_regcache, regno, buf); + val = extract_signed_integer (buf, + register_size (current_gdbarch, regno)); + to = (gdb_byte *) (*fpregsetp + 32) + 4; + store_signed_integer (to, 4, val); } else if (regno == -1) { @@ -487,8 +477,10 @@ mips64_fill_fpregset (mips64_elf_fpregset_t *fpregsetp, int regno) for (regi = 0; regi < 32; regi++) mips64_fill_fpregset (fpregsetp, FP0_REGNUM + regi); - mips64_fill_fpregset(fpregsetp, - mips_regnum (current_gdbarch)->fp_control_status); + mips64_fill_fpregset (fpregsetp, + mips_regnum (current_gdbarch)->fp_control_status); + mips64_fill_fpregset (fpregsetp, (mips_regnum (current_gdbarch) + ->fp_implementation_revision)); } } @@ -536,8 +528,8 @@ static void fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, int which, CORE_ADDR reg_addr) { - elf_gregset_t gregset; - elf_fpregset_t fpregset; + mips_elf_gregset_t gregset; + mips_elf_fpregset_t fpregset; mips64_elf_gregset_t gregset64; mips64_elf_fpregset_t fpregset64; @@ -546,7 +538,7 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, if (core_reg_size == sizeof (gregset)) { memcpy ((char *) &gregset, core_reg_sect, sizeof (gregset)); - supply_gregset (&gregset); + mips_supply_gregset (&gregset); } else if (core_reg_size == sizeof (gregset64)) { @@ -563,7 +555,7 @@ fetch_core_registers (char *core_reg_sect, unsigned core_reg_size, if (core_reg_size == sizeof (fpregset)) { memcpy ((char *) &fpregset, core_reg_sect, sizeof (fpregset)); - supply_fpregset (&fpregset); + mips_supply_fpregset (&fpregset); } else if (core_reg_size == sizeof (fpregset64)) { @@ -1084,6 +1076,49 @@ mips_linux_n32n64_sigframe_init (const struct tramp_frame *self, func)); } +/* Wrapper functions. These are only used by libthread_db. */ + +void +supply_gregset (mips_elf_gregset_t *gregsetp) +{ + if (mips_isa_regsize (current_gdbarch) == 4) + mips_supply_gregset (gregsetp); + else + mips64_supply_gregset ((void *) gregsetp); +} + +void +fill_gregset (mips_elf_gregset_t *gregsetp, int regno) +{ + if (mips_isa_regsize (current_gdbarch) == 4) + mips_fill_gregset (gregsetp, regno); + else + mips64_fill_gregset ((void *) gregsetp, regno); +} + +/* Likewise, unpack an elf_fpregset_t. */ + +void +supply_fpregset (mips_elf_fpregset_t *fpregsetp) +{ + if (mips_isa_regsize (current_gdbarch) == 4) + mips_supply_fpregset (fpregsetp); + else + mips64_supply_fpregset ((void *) fpregsetp); +} + +/* Likewise, pack one or all floating point registers into an + elf_fpregset_t. */ + +void +fill_fpregset (mips_elf_fpregset_t *fpregsetp, int regno) +{ + if (mips_isa_regsize (current_gdbarch) == 4) + mips_fill_fpregset (fpregsetp, regno); + else + mips64_fill_fpregset ((void *) fpregsetp, regno); +} + /* Initialize one of the GNU/Linux OS ABIs. */ static void @@ -1110,6 +1145,15 @@ mips_linux_init_abi (struct gdbarch_info info, set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_ilp32_fetch_link_map_offsets); set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr); + set_gdbarch_long_double_bit (gdbarch, 128); + /* These floatformats should probably be renamed. MIPS uses + the same 128-bit IEEE floating point format that IA-64 uses, + except that the quiet/signalling NaN bit is reversed (GDB + does not distinguish between quiet and signalling NaNs). */ + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big); + else + set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_little); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe); break; case MIPS_ABI_N64: @@ -1118,6 +1162,15 @@ mips_linux_init_abi (struct gdbarch_info info, set_solib_svr4_fetch_link_map_offsets (gdbarch, svr4_lp64_fetch_link_map_offsets); set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr); + set_gdbarch_long_double_bit (gdbarch, 128); + /* These floatformats should probably be renamed. MIPS uses + the same 128-bit IEEE floating point format that IA-64 uses, + except that the quiet/signalling NaN bit is reversed (GDB + does not distinguish between quiet and signalling NaNs). */ + if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) + set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_big); + else + set_gdbarch_long_double_format (gdbarch, &floatformat_ia64_quad_little); tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe); break; default: diff --git a/gdb/mips-linux-tdep.h b/gdb/mips-linux-tdep.h new file mode 100644 index 0000000..4914b63 --- /dev/null +++ b/gdb/mips-linux-tdep.h @@ -0,0 +1,94 @@ +/* Target-dependent code for GNU/Linux on MIPS processors. + + Copyright 2006 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* Copied from . */ +#define ELF_NGREG 45 +#define ELF_NFPREG 33 + +typedef unsigned char mips_elf_greg_t[4]; +typedef mips_elf_greg_t mips_elf_gregset_t[ELF_NGREG]; + +typedef unsigned char mips_elf_fpreg_t[8]; +typedef mips_elf_fpreg_t mips_elf_fpregset_t[ELF_NFPREG]; + +/* 0 - 31 are integer registers, 32 - 63 are fp registers. */ +#define FPR_BASE 32 +#define PC 64 +#define CAUSE 65 +#define BADVADDR 66 +#define MMHI 67 +#define MMLO 68 +#define FPC_CSR 69 +#define FPC_EIR 70 + +#define EF_REG0 6 +#define EF_REG31 37 +#define EF_LO 38 +#define EF_HI 39 +#define EF_CP0_EPC 40 +#define EF_CP0_BADVADDR 41 +#define EF_CP0_STATUS 42 +#define EF_CP0_CAUSE 43 + +#define EF_SIZE 180 + +void mips_supply_gregset (mips_elf_gregset_t *); +void mips_fill_gregset (mips_elf_gregset_t *, int); +void mips_supply_fpregset (mips_elf_fpregset_t *); +void mips_fill_fpregset (mips_elf_fpregset_t *, int); + +/* 64-bit support. */ + +/* Copied from . */ +#define MIPS64_ELF_NGREG 45 +#define MIPS64_ELF_NFPREG 33 + +typedef unsigned char mips64_elf_greg_t[8]; +typedef mips64_elf_greg_t mips64_elf_gregset_t[MIPS64_ELF_NGREG]; + +typedef unsigned char mips64_elf_fpreg_t[8]; +typedef mips64_elf_fpreg_t mips64_elf_fpregset_t[MIPS64_ELF_NFPREG]; + +/* 0 - 31 are integer registers, 32 - 63 are fp registers. */ +#define MIPS64_FPR_BASE 32 +#define MIPS64_PC 64 +#define MIPS64_CAUSE 65 +#define MIPS64_BADVADDR 66 +#define MIPS64_MMHI 67 +#define MIPS64_MMLO 68 +#define MIPS64_FPC_CSR 69 +#define MIPS64_FPC_EIR 70 + +#define MIPS64_EF_REG0 0 +#define MIPS64_EF_REG31 31 +#define MIPS64_EF_LO 32 +#define MIPS64_EF_HI 33 +#define MIPS64_EF_CP0_EPC 34 +#define MIPS64_EF_CP0_BADVADDR 35 +#define MIPS64_EF_CP0_STATUS 36 +#define MIPS64_EF_CP0_CAUSE 37 + +#define MIPS64_EF_SIZE 304 + +void mips64_supply_gregset (mips64_elf_gregset_t *); +void mips64_fill_gregset (mips64_elf_gregset_t *, int); +void mips64_supply_fpregset (mips64_elf_fpregset_t *); +void mips64_fill_fpregset (mips64_elf_fpregset_t *, int); diff --git a/gdb/mips-mdebug-tdep.c b/gdb/mips-mdebug-tdep.c index 43e1c96..db79713 100644 --- a/gdb/mips-mdebug-tdep.c +++ b/gdb/mips-mdebug-tdep.c @@ -2,8 +2,8 @@ the GNU Debugger. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. + 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006 + Free Software Foundation, Inc. This file is part of GDB. @@ -63,8 +63,8 @@ static bfd *the_bfd; static int compare_pdr_entries (const void *a, const void *b) { - CORE_ADDR lhs = bfd_get_32 (the_bfd, (bfd_byte *) a); - CORE_ADDR rhs = bfd_get_32 (the_bfd, (bfd_byte *) b); + CORE_ADDR lhs = bfd_get_signed_32 (the_bfd, (bfd_byte *) a); + CORE_ADDR rhs = bfd_get_signed_32 (the_bfd, (bfd_byte *) b); if (lhs < rhs) return -1; @@ -215,17 +215,17 @@ non_heuristic_proc_desc (CORE_ADDR pc, CORE_ADDR *addrptr) PROC_LOW_ADDR (proc_desc) = pdr_pc; PROC_FRAME_OFFSET (proc_desc) - = bfd_get_32 (sec->objfile->obfd, ptr + 20); + = bfd_get_signed_32 (sec->objfile->obfd, ptr + 20); PROC_FRAME_REG (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 24); PROC_REG_MASK (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 4); PROC_FREG_MASK (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 12); - PROC_REG_OFFSET (proc_desc) = bfd_get_32 (sec->objfile->obfd, - ptr + 8); + PROC_REG_OFFSET (proc_desc) + = bfd_get_signed_32 (sec->objfile->obfd, ptr + 8); PROC_FREG_OFFSET (proc_desc) - = bfd_get_32 (sec->objfile->obfd, ptr + 16); + = bfd_get_signed_32 (sec->objfile->obfd, ptr + 16); PROC_PC_REG (proc_desc) = bfd_get_32 (sec->objfile->obfd, ptr + 28); proc_desc->pdr.isym = (long) sym; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 679dd9d..880dfcc 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -1,7 +1,7 @@ /* Target-dependent code for the MIPS architecture, for GDB, the GNU Debugger. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, - 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 + 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. Contributed by Alessandro Forin(af@cs.cmu.edu) at CMU @@ -202,7 +202,7 @@ is_mips16_addr (CORE_ADDR addr) static CORE_ADDR unmake_mips16_addr (CORE_ADDR addr) { - return ((addr) & ~1); + return ((addr) & ~(CORE_ADDR) 1); } /* Return the contents of register REGNUM as a signed integer. */ @@ -989,14 +989,14 @@ mips32_next_pc (CORE_ADDR pc) unsigned long reg; reg = jtype_target (inst) << 2; /* Upper four bits get never changed... */ - pc = reg + ((pc + 4) & 0xf0000000); + pc = reg + ((pc + 4) & ~(CORE_ADDR) 0x0fffffff); } break; /* FIXME case JALX : */ { unsigned long reg; reg = jtype_target (inst) << 2; - pc = reg + ((pc + 4) & 0xf0000000) + 1; /* yes, +1 */ + pc = reg + ((pc + 4) & ~(CORE_ADDR) 0x0fffffff) + 1; /* yes, +1 */ /* Add 1 to indicate 16 bit mode - Invert ISA mode */ } break; /* The new PC will be alternate mode */ @@ -1202,7 +1202,7 @@ unpack_mips16 (CORE_ADDR pc, static CORE_ADDR add_offset_16 (CORE_ADDR pc, int offset) { - return ((offset << 2) | ((pc + 2) & (0xf0000000))); + return ((offset << 2) | ((pc + 2) & (~(CORE_ADDR) 0x0fffffff))); } static CORE_ADDR @@ -2911,6 +2911,24 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, || TYPE_LENGTH (type) > 2 * mips_abi_regsize (gdbarch)) return RETURN_VALUE_STRUCT_CONVENTION; else if (TYPE_CODE (type) == TYPE_CODE_FLT + && TYPE_LENGTH (type) == 16 + && tdep->mips_fpu_type != MIPS_FPU_NONE) + { + /* A 128-bit floating-point value fills both $f0 and $f2. The + two registers are used in the same as memory order, so the + eight bytes with the lower memory address are in $f0. */ + if (mips_debug) + fprintf_unfiltered (gdb_stderr, "Return float in $f0 and $f2\n"); + mips_xfer_register (regcache, + NUM_REGS + mips_regnum (current_gdbarch)->fp0, + 8, TARGET_BYTE_ORDER, readbuf, writebuf, 0); + mips_xfer_register (regcache, + NUM_REGS + mips_regnum (current_gdbarch)->fp0 + 2, + 8, TARGET_BYTE_ORDER, readbuf ? readbuf + 8 : readbuf, + writebuf ? writebuf + 8 : writebuf, 0); + return RETURN_VALUE_REGISTER_CONVENTION; + } + else if (TYPE_CODE (type) == TYPE_CODE_FLT && tdep->mips_fpu_type != MIPS_FPU_NONE) { /* A floating-point value belongs in the least significant part @@ -4037,7 +4055,6 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame, int regnum; /* For GP registers, we print a separate row of names above the vals */ - fprintf_filtered (file, " "); for (col = 0, regnum = start_regnum; col < ncols && regnum < NUM_REGS + NUM_PSEUDO_REGS; regnum++) { @@ -4046,11 +4063,17 @@ print_gp_register_row (struct ui_file *file, struct frame_info *frame, if (TYPE_CODE (gdbarch_register_type (gdbarch, regnum)) == TYPE_CODE_FLT) break; /* end the row: reached FP register */ + if (col == 0) + fprintf_filtered (file, " "); fprintf_filtered (file, mips_abi_regsize (current_gdbarch) == 8 ? "%17s" : "%9s", REGISTER_NAME (regnum)); col++; } + + if (col == 0) + return regnum; + /* print the R0 to R31 names */ if ((start_regnum % NUM_REGS) < MIPS_NUMREGS) fprintf_filtered (file, "\n R%-4d", start_regnum % NUM_REGS); @@ -4741,6 +4764,13 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } } + /* Default 64-bit objects to N64 instead of O32. */ + if (found_abi == MIPS_ABI_UNKNOWN + && info.abfd != NULL + && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour + && elf_elfheader (info.abfd)->e_ident[EI_CLASS] == ELFCLASS64) + found_abi = MIPS_ABI_N64; + if (gdbarch_debug) fprintf_unfiltered (gdb_stdlog, "mips_gdbarch_init: found_abi = %d\n", found_abi); diff --git a/gdb/nlm/Makefile.in b/gdb/nlm/Makefile.in deleted file mode 100644 index 18a74c4..0000000 --- a/gdb/nlm/Makefile.in +++ /dev/null @@ -1,176 +0,0 @@ -#Copyright (C) 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1999 -#Free Software Foundation, Inc. - -# This file is part of GDB. - -# 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 -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# 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. - -srcdir = @srcdir@ -VPATH = @srcdir@ - -prefix = @prefix@ -exec_prefix = @exec_prefix@ - -host_alias = @host_alias@ -target_alias = @target_alias@ -program_transform_name = @program_transform_name@ -bindir = @bindir@ -libdir = @libdir@ -tooldir = $(libdir)/$(target_alias) - -datadir = @datadir@ -mandir = @mandir@ -man1dir = $(mandir)/man1 -man2dir = $(mandir)/man2 -man3dir = $(mandir)/man3 -man4dir = $(mandir)/man4 -man5dir = $(mandir)/man5 -man6dir = $(mandir)/man6 -man7dir = $(mandir)/man7 -man8dir = $(mandir)/man8 -man9dir = $(mandir)/man9 -infodir = @infodir@ -htmldir = $(prefix)/html -includedir = @includedir@ - -SHELL = @SHELL@ - -INSTALL = @INSTALL@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_DATA = @INSTALL_DATA@ - -CC_FOR_TARGET = ` \ - if [ -f ../../gcc/xgcc ] ; then \ - echo ../../gcc/xgcc -B../../gcc/; \ - else \ - t='$(program_transform_name)'; echo gcc | sed -e '' $$t; \ - fi` - -NLMCONV_FOR_TARGET = ` \ - if [ -f ../../binutils/nlmconv ] ; then \ - echo ../../binutils/nlmconv; \ - else \ - t='$(program_transform_name)'; echo nlmconv | sed -e '' $$t; \ - fi` - -# All the includes used for CFLAGS and for lint. -INCLUDE_CFLAGS = -I. -I${srcdir} - -# CFLAGS is specifically reserved for setting from the command line -# when running make. I.E. "make CFLAGS=-Wmissing-prototypes". -CFLAGS = -g -# INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros. -INTERNAL_CFLAGS = ${CFLAGS} ${INCLUDE_CFLAGS} ${USER_CFLAGS} -LDFLAGS = $(CFLAGS) - -# Perhaps should come from parent Makefile -VERSION = gdbserve-4.12 -DIST=gdb - -# target-dependent makefile fragment come in here. -@target_makefile_frag@ -# End target-dependent makefile fragment - -# All source files that go into linking GDB remote server. - -DEPFILES = $(GDBSERVE_DEPFILES) - -SOURCES = $(ALLDEPFILES) -TAGFILES = $(SOURCES) ${HFILES} ${ALLPARAM} ${POSSLIBS} - -# Prevent Sun make from putting in the machine type. Setting -# TARGET_ARCH to nothing works for SunOS 3, 4.0, but not for 4.1. -.c.o: - ${CC_FOR_TARGET} -c ${INTERNAL_CFLAGS} $< - -.S.o: - ${CC_FOR_TARGET} -c ${INTERNAL_CFLAGS} $< - -all: gdbserve.nlm - -# Traditionally "install" depends on "all". But it may be useful -# not to; for example, if the user has made some trivial change to a -# source file and doesn't care about rebuilding or just wants to save the -# time it takes for make to check that all is up to date. -# install-only is intended to address that need. -install: all install-only -install-only: - $(INSTALL) gdbserve.nlm $(bindir)/gdbserve.nlm - -uninstall: force - rm -f $(bindir)/gdbserve.nlm - -installcheck: -check: -info dvi: -install-info: -clean-info: -html: -install-html: - -gdbserve.nlm: gdbserve.O $(srcdir)/gdbserve.def - ${NLMCONV_FOR_TARGET} -T $(srcdir)/gdbserve.def - -gdbserve.O: prelude.o gdbserve.o $(TDEPFILES) - ${CC_FOR_TARGET} $(LDFLAGS) -r -o gdbserve.O prelude.o gdbserve.o ${TDEPFILES} - -# Put the proper machine-specific files first, so M-. on a machine -# specific routine gets the one for the correct machine. -# The xyzzy stuff below deals with empty DEPFILES -TAGS: ${TAGFILES} - etags `find ${srcdir}/../config -name $(DEPRECATED_TM_FILE) -print` \ - `find ${srcdir}/../config -name ${XM_FILE} -print` \ - `find ${srcdir}/../config -name ${NAT_FILE} -print` \ - `for i in yzzy ${DEPFILES}; do \ - if [ x$$i != xyzzy ]; then \ - echo ${srcdir}/$$i | sed -e 's/\.o$$/\.c/' ; \ - fi; \ - done` \ - ${TAGFILES} -tags: TAGS - -clean: - rm -f *.o ${ADD_FILES} *~ - rm -f gdbserve.O gdbserve.nlm core make.log - -distclean: clean TAGS - rm -f config.log config.cache config.status - rm -f Makefile - -maintainer-clean realclean: clean - rm -f TAGS - rm -f config.log config.cache config.status - rm -f Makefile - -Makefile: Makefile.in config.status @target_makefile_frag_path@ - $(SHELL) config.status - -config.status: configure - $(SHELL) config.status --recheck - -force: - -# GNU Make has an annoying habit of putting *all* the Makefile variables -# into the environment, unless you include this target as a circumvention. -# Rumor is that this will be fixed (and this target can be removed) -# in GNU Make 4.0. -.NOEXPORT: - -# GNU Make 3.63 has a different problem: it keeps tacking command line -# overrides onto the definition of $(MAKE). This variable setting -# will remove them. -MAKEOVERRIDES= - -# This is the end of "Makefile.in". diff --git a/gdb/nlm/configure b/gdb/nlm/configure deleted file mode 100755 index ca1146a..0000000 --- a/gdb/nlm/configure +++ /dev/null @@ -1,1089 +0,0 @@ -#! /bin/sh - -# Guess values for system-dependent variables and create Makefiles. -# Generated automatically using autoconf version 2.13 -# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. -# -# This configure script is free software; the Free Software Foundation -# gives unlimited permission to copy, distribute and modify it. - -# Defaults: -ac_help= -ac_default_prefix=/usr/local -# Any additions from configure.in: - -# Initialize some variables set by options. -# The variables have the same names as the options, with -# dashes changed to underlines. -build=NONE -cache_file=./config.cache -exec_prefix=NONE -host=NONE -no_create= -nonopt=NONE -no_recursion= -prefix=NONE -program_prefix=NONE -program_suffix=NONE -program_transform_name=s,x,x, -silent= -site= -sitefile= -srcdir= -target=NONE -verbose= -x_includes=NONE -x_libraries=NONE -bindir='${exec_prefix}/bin' -sbindir='${exec_prefix}/sbin' -libexecdir='${exec_prefix}/libexec' -datadir='${prefix}/share' -sysconfdir='${prefix}/etc' -sharedstatedir='${prefix}/com' -localstatedir='${prefix}/var' -libdir='${exec_prefix}/lib' -includedir='${prefix}/include' -oldincludedir='/usr/include' -infodir='${prefix}/info' -mandir='${prefix}/man' - -# Initialize some other variables. -subdirs= -MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} -# Maximum number of lines to put in a shell here document. -ac_max_here_lines=12 - -ac_prev= -for ac_option -do - - # If the previous option needs an argument, assign it. - if test -n "$ac_prev"; then - eval "$ac_prev=\$ac_option" - ac_prev= - continue - fi - - case "$ac_option" in - -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) ac_optarg= ;; - esac - - # Accept the important Cygnus configure options, so we can diagnose typos. - - case "$ac_option" in - - -bindir | --bindir | --bindi | --bind | --bin | --bi) - ac_prev=bindir ;; - -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) - bindir="$ac_optarg" ;; - - -build | --build | --buil | --bui | --bu) - ac_prev=build ;; - -build=* | --build=* | --buil=* | --bui=* | --bu=*) - build="$ac_optarg" ;; - - -cache-file | --cache-file | --cache-fil | --cache-fi \ - | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) - ac_prev=cache_file ;; - -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ - | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) - cache_file="$ac_optarg" ;; - - -datadir | --datadir | --datadi | --datad | --data | --dat | --da) - ac_prev=datadir ;; - -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ - | --da=*) - datadir="$ac_optarg" ;; - - -disable-* | --disable-*) - ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - eval "enable_${ac_feature}=no" ;; - - -enable-* | --enable-*) - ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } - fi - ac_feature=`echo $ac_feature| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "enable_${ac_feature}='$ac_optarg'" ;; - - -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ - | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ - | --exec | --exe | --ex) - ac_prev=exec_prefix ;; - -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ - | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ - | --exec=* | --exe=* | --ex=*) - exec_prefix="$ac_optarg" ;; - - -gas | --gas | --ga | --g) - # Obsolete; use --with-gas. - with_gas=yes ;; - - -help | --help | --hel | --he) - # Omit some internal or obsolete options to make the list less imposing. - # This message is too long to be a string in the A/UX 3.1 sh. - cat << EOF -Usage: configure [options] [host] -Options: [defaults in brackets after descriptions] -Configuration: - --cache-file=FILE cache test results in FILE - --help print this message - --no-create do not create output files - --quiet, --silent do not print \`checking...' messages - --site-file=FILE use FILE as the site file - --version print the version of autoconf that created configure -Directory and file names: - --prefix=PREFIX install architecture-independent files in PREFIX - [$ac_default_prefix] - --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX - [same as prefix] - --bindir=DIR user executables in DIR [EPREFIX/bin] - --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] - --libexecdir=DIR program executables in DIR [EPREFIX/libexec] - --datadir=DIR read-only architecture-independent data in DIR - [PREFIX/share] - --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] - --sharedstatedir=DIR modifiable architecture-independent data in DIR - [PREFIX/com] - --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] - --libdir=DIR object code libraries in DIR [EPREFIX/lib] - --includedir=DIR C header files in DIR [PREFIX/include] - --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] - --infodir=DIR info documentation in DIR [PREFIX/info] - --mandir=DIR man documentation in DIR [PREFIX/man] - --srcdir=DIR find the sources in DIR [configure dir or ..] - --program-prefix=PREFIX prepend PREFIX to installed program names - --program-suffix=SUFFIX append SUFFIX to installed program names - --program-transform-name=PROGRAM - run sed PROGRAM on installed program names -EOF - cat << EOF -Host type: - --build=BUILD configure for building on BUILD [BUILD=HOST] - --host=HOST configure for HOST [guessed] - --target=TARGET configure for TARGET [TARGET=HOST] -Features and packages: - --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) - --enable-FEATURE[=ARG] include FEATURE [ARG=yes] - --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] - --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) - --x-includes=DIR X include files are in DIR - --x-libraries=DIR X library files are in DIR -EOF - if test -n "$ac_help"; then - echo "--enable and --with options recognized:$ac_help" - fi - exit 0 ;; - - -host | --host | --hos | --ho) - ac_prev=host ;; - -host=* | --host=* | --hos=* | --ho=*) - host="$ac_optarg" ;; - - -includedir | --includedir | --includedi | --included | --include \ - | --includ | --inclu | --incl | --inc) - ac_prev=includedir ;; - -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ - | --includ=* | --inclu=* | --incl=* | --inc=*) - includedir="$ac_optarg" ;; - - -infodir | --infodir | --infodi | --infod | --info | --inf) - ac_prev=infodir ;; - -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) - infodir="$ac_optarg" ;; - - -libdir | --libdir | --libdi | --libd) - ac_prev=libdir ;; - -libdir=* | --libdir=* | --libdi=* | --libd=*) - libdir="$ac_optarg" ;; - - -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ - | --libexe | --libex | --libe) - ac_prev=libexecdir ;; - -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ - | --libexe=* | --libex=* | --libe=*) - libexecdir="$ac_optarg" ;; - - -localstatedir | --localstatedir | --localstatedi | --localstated \ - | --localstate | --localstat | --localsta | --localst \ - | --locals | --local | --loca | --loc | --lo) - ac_prev=localstatedir ;; - -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ - | --localstate=* | --localstat=* | --localsta=* | --localst=* \ - | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) - localstatedir="$ac_optarg" ;; - - -mandir | --mandir | --mandi | --mand | --man | --ma | --m) - ac_prev=mandir ;; - -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) - mandir="$ac_optarg" ;; - - -nfp | --nfp | --nf) - # Obsolete; use --without-fp. - with_fp=no ;; - - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) - no_create=yes ;; - - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) - no_recursion=yes ;; - - -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ - | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ - | --oldin | --oldi | --old | --ol | --o) - ac_prev=oldincludedir ;; - -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ - | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ - | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) - oldincludedir="$ac_optarg" ;; - - -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) - ac_prev=prefix ;; - -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) - prefix="$ac_optarg" ;; - - -program-prefix | --program-prefix | --program-prefi | --program-pref \ - | --program-pre | --program-pr | --program-p) - ac_prev=program_prefix ;; - -program-prefix=* | --program-prefix=* | --program-prefi=* \ - | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) - program_prefix="$ac_optarg" ;; - - -program-suffix | --program-suffix | --program-suffi | --program-suff \ - | --program-suf | --program-su | --program-s) - ac_prev=program_suffix ;; - -program-suffix=* | --program-suffix=* | --program-suffi=* \ - | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) - program_suffix="$ac_optarg" ;; - - -program-transform-name | --program-transform-name \ - | --program-transform-nam | --program-transform-na \ - | --program-transform-n | --program-transform- \ - | --program-transform | --program-transfor \ - | --program-transfo | --program-transf \ - | --program-trans | --program-tran \ - | --progr-tra | --program-tr | --program-t) - ac_prev=program_transform_name ;; - -program-transform-name=* | --program-transform-name=* \ - | --program-transform-nam=* | --program-transform-na=* \ - | --program-transform-n=* | --program-transform-=* \ - | --program-transform=* | --program-transfor=* \ - | --program-transfo=* | --program-transf=* \ - | --program-trans=* | --program-tran=* \ - | --progr-tra=* | --program-tr=* | --program-t=*) - program_transform_name="$ac_optarg" ;; - - -q | -quiet | --quiet | --quie | --qui | --qu | --q \ - | -silent | --silent | --silen | --sile | --sil) - silent=yes ;; - - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) - ac_prev=sbindir ;; - -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ - | --sbi=* | --sb=*) - sbindir="$ac_optarg" ;; - - -sharedstatedir | --sharedstatedir | --sharedstatedi \ - | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ - | --sharedst | --shareds | --shared | --share | --shar \ - | --sha | --sh) - ac_prev=sharedstatedir ;; - -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ - | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ - | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ - | --sha=* | --sh=*) - sharedstatedir="$ac_optarg" ;; - - -site | --site | --sit) - ac_prev=site ;; - -site=* | --site=* | --sit=*) - site="$ac_optarg" ;; - - -site-file | --site-file | --site-fil | --site-fi | --site-f) - ac_prev=sitefile ;; - -site-file=* | --site-file=* | --site-fil=* | --site-fi=* | --site-f=*) - sitefile="$ac_optarg" ;; - - -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) - ac_prev=srcdir ;; - -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) - srcdir="$ac_optarg" ;; - - -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ - | --syscon | --sysco | --sysc | --sys | --sy) - ac_prev=sysconfdir ;; - -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ - | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) - sysconfdir="$ac_optarg" ;; - - -target | --target | --targe | --targ | --tar | --ta | --t) - ac_prev=target ;; - -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) - target="$ac_optarg" ;; - - -v | -verbose | --verbose | --verbos | --verbo | --verb) - verbose=yes ;; - - -version | --version | --versio | --versi | --vers) - echo "configure generated by autoconf version 2.13" - exit 0 ;; - - -with-* | --with-*) - ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - case "$ac_option" in - *=*) ;; - *) ac_optarg=yes ;; - esac - eval "with_${ac_package}='$ac_optarg'" ;; - - -without-* | --without-*) - ac_package=`echo $ac_option|sed -e 's/-*without-//'` - # Reject names that are not valid shell variable names. - if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then - { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } - fi - ac_package=`echo $ac_package| sed 's/-/_/g'` - eval "with_${ac_package}=no" ;; - - --x) - # Obsolete; use --with-x. - with_x=yes ;; - - -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ - | --x-incl | --x-inc | --x-in | --x-i) - ac_prev=x_includes ;; - -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ - | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) - x_includes="$ac_optarg" ;; - - -x-libraries | --x-libraries | --x-librarie | --x-librari \ - | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) - ac_prev=x_libraries ;; - -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ - | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) - x_libraries="$ac_optarg" ;; - - -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } - ;; - - *) - if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then - echo "configure: warning: $ac_option: invalid host type" 1>&2 - fi - if test "x$nonopt" != xNONE; then - { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } - fi - nonopt="$ac_option" - ;; - - esac -done - -if test -n "$ac_prev"; then - { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } -fi - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -# File descriptor usage: -# 0 standard input -# 1 file creation -# 2 errors and warnings -# 3 some systems may open it to /dev/tty -# 4 used on the Kubota Titan -# 6 checking for... messages and results -# 5 compiler messages saved in config.log -if test "$silent" = yes; then - exec 6>/dev/null -else - exec 6>&1 -fi -exec 5>./config.log - -echo "\ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. -" 1>&5 - -# Strip out --no-create and --no-recursion so they do not pile up. -# Also quote any args containing shell metacharacters. -ac_configure_args= -for ac_arg -do - case "$ac_arg" in - -no-create | --no-create | --no-creat | --no-crea | --no-cre \ - | --no-cr | --no-c) ;; - -no-recursion | --no-recursion | --no-recursio | --no-recursi \ - | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; - *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) - ac_configure_args="$ac_configure_args '$ac_arg'" ;; - *) ac_configure_args="$ac_configure_args $ac_arg" ;; - esac -done - -# NLS nuisances. -# Only set these to C if already set. These must not be set unconditionally -# because not all systems understand e.g. LANG=C (notably SCO). -# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! -# Non-C LC_CTYPE values break the ctype check. -if test "${LANG+set}" = set; then LANG=C; export LANG; fi -if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi -if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi -if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi - -# confdefs.h avoids OS command line length limits that DEFS can exceed. -rm -rf conftest* confdefs.h -# AIX cpp loses on an empty file, so make sure it contains at least a newline. -echo > confdefs.h - -# A filename unique to this package, relative to the directory that -# configure is in, which we can look for to find out if srcdir is correct. -ac_unique_file=gdbserve.c - -# Find the source files, if location was not specified. -if test -z "$srcdir"; then - ac_srcdir_defaulted=yes - # Try the directory containing this script, then its parent. - ac_prog=$0 - ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` - test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. - srcdir=$ac_confdir - if test ! -r $srcdir/$ac_unique_file; then - srcdir=.. - fi -else - ac_srcdir_defaulted=no -fi -if test ! -r $srcdir/$ac_unique_file; then - if test "$ac_srcdir_defaulted" = yes; then - { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } - else - { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } - fi -fi -srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` - -# Prefer explicitly selected file to automatically selected ones. -if test -z "$sitefile"; then - if test -z "$CONFIG_SITE"; then - if test "x$prefix" != xNONE; then - CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" - else - CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" - fi - fi -else - CONFIG_SITE="$sitefile" -fi -for ac_site_file in $CONFIG_SITE; do - if test -r "$ac_site_file"; then - echo "loading site script $ac_site_file" - . "$ac_site_file" - fi -done - -if test -r "$cache_file"; then - echo "loading cache $cache_file" - . $cache_file -else - echo "creating cache $cache_file" - > $cache_file -fi - -ac_ext=c -# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. -ac_cpp='$CPP $CPPFLAGS' -ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' -ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' -cross_compiling=$ac_cv_prog_cc_cross - -ac_exeext= -ac_objext=o -if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then - # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. - if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then - ac_n= ac_c=' -' ac_t=' ' - else - ac_n=-n ac_c= ac_t= - fi -else - ac_n= ac_c='\c' ac_t= -fi - - - -ac_aux_dir= -for ac_dir in `cd $srcdir;pwd`/../.. $srcdir/`cd $srcdir;pwd`/../..; do - if test -f $ac_dir/install-sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install-sh -c" - break - elif test -f $ac_dir/install.sh; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/install.sh -c" - break - fi -done -if test -z "$ac_aux_dir"; then - { echo "configure: error: can not find install-sh or install.sh in `cd $srcdir;pwd`/../.. $srcdir/`cd $srcdir;pwd`/../.." 1>&2; exit 1; } -fi -ac_config_guess=$ac_aux_dir/config.guess -ac_config_sub=$ac_aux_dir/config.sub -ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. - - -# Do some error checking and defaulting for the host and target type. -# The inputs are: -# configure --host=HOST --target=TARGET --build=BUILD NONOPT -# -# The rules are: -# 1. You are not allowed to specify --host, --target, and nonopt at the -# same time. -# 2. Host defaults to nonopt. -# 3. If nonopt is not specified, then host defaults to the current host, -# as determined by config.guess. -# 4. Target and build default to nonopt. -# 5. If nonopt is not specified, then target and build default to host. - -# The aliases save the names the user supplied, while $host etc. -# will get canonicalized. -case $host---$target---$nonopt in -NONE---*---* | *---NONE---* | *---*---NONE) ;; -*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; -esac - - -# Make sure we can run config.sub. -if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : -else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } -fi - -echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:584: checking host system type" >&5 - -host_alias=$host -case "$host_alias" in -NONE) - case $nonopt in - NONE) - if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : - else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } - fi ;; - *) host_alias=$nonopt ;; - esac ;; -esac - -host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` -host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$host" 1>&6 - -echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:605: checking target system type" >&5 - -target_alias=$target -case "$target_alias" in -NONE) - case $nonopt in - NONE) target_alias=$host_alias ;; - *) target_alias=$nonopt ;; - esac ;; -esac - -target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` -target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$target" 1>&6 - -echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:623: checking build system type" >&5 - -build_alias=$build -case "$build_alias" in -NONE) - case $nonopt in - NONE) build_alias=$host_alias ;; - *) build_alias=$nonopt ;; - esac ;; -esac - -build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` -build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` -build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` -build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` -echo "$ac_t""$build" 1>&6 - -test "$host_alias" != "$target_alias" && - test "$program_prefix$program_suffix$program_transform_name" = \ - NONENONEs,x,x, && - program_prefix=${target_alias}- - -if test "$program_transform_name" = s,x,x,; then - program_transform_name= -else - # Double any \ or $. echo might interpret backslashes. - cat <<\EOF_SED > conftestsed -s,\\,\\\\,g; s,\$,$$,g -EOF_SED - program_transform_name="`echo $program_transform_name|sed -f conftestsed`" - rm -f conftestsed -fi -test "$program_prefix" != NONE && - program_transform_name="s,^,${program_prefix},; $program_transform_name" -# Use a double $ so make ignores it. -test "$program_suffix" != NONE && - program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" - -# sed with no file args requires a program. -test "$program_transform_name" = "" && program_transform_name="s,x,x," - - -# Find a good install program. We prefer a C program (faster), -# so one script is as good as another. But avoid the broken or -# incompatible versions: -# SysV /etc/install, /usr/sbin/install -# SunOS /usr/etc/install -# IRIX /sbin/install -# AIX /bin/install -# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag -# AFS /usr/afsws/bin/install, which mishandles nonexistent args -# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" -# ./install, which can be erroneously created by make from ./install.sh. -echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:677: checking for a BSD compatible install" >&5 -if test -z "$INSTALL"; then -if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" - for ac_dir in $PATH; do - # Account for people who put trailing slashes in PATH elements. - case "$ac_dir/" in - /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; - *) - # OSF1 and SCO ODT 3.0 have their own names for install. - # Don't use installbsd from OSF since it installs stuff as root - # by default. - for ac_prog in ginstall scoinst install; do - if test -f $ac_dir/$ac_prog; then - if test $ac_prog = install && - grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then - # AIX install. It has an incompatible calling convention. - : - else - ac_cv_path_install="$ac_dir/$ac_prog -c" - break 2 - fi - fi - done - ;; - esac - done - IFS="$ac_save_IFS" - -fi - if test "${ac_cv_path_install+set}" = set; then - INSTALL="$ac_cv_path_install" - else - # As a last resort, use the slow shell script. We don't cache a - # path for INSTALL within a source directory, because that will - # break other packages using the cache if that directory is - # removed, or if the path is relative. - INSTALL="$ac_install_sh" - fi -fi -echo "$ac_t""$INSTALL" 1>&6 - -# Use test -z because SunOS4 sh mishandles braces in ${var-val}. -# It thinks the first close brace ends the variable substitution. -test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' - -test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' - -test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - -# Map target cpu into the config cpu subdirectory name. -# The default is $target_cpu. -case "${target_cpu}" in -alpha) gdb_target_cpu=alpha ;; -c[12]) gdb_target_cpu=convex ;; -hppa*) gdb_target_cpu=pa ;; -i[34567]86) gdb_target_cpu=i386 ;; -m68*) gdb_target_cpu=m68k ;; -np1) gdb_target_cpu=gould ;; -pn) gdb_target_cpu=gould ;; -pyramid) gdb_target_cpu=pyr ;; -sparc*) gdb_target_cpu=sparc ;; -*) gdb_target_cpu=$target_cpu ;; -esac - -target_makefile_frag=${srcdir}/../config/${gdb_target_cpu}/gdbserve.mt -if ! -f ${target_makefile_frag} ; then - { echo "configure: error: "*** GDBSERVE does not support target ${target}"" 1>&2; exit 1; } -fi - -target_makefile_frag_path=$target_makefile_frag - - - -cpufile=`sed -n ' -s/CPU_FILE *= *\(^ *\)/\1/p -' ${target_makefile_frag} - -files= -links= -rm -f cpu.h -if "${cpufile}" != "" ; then - files="${files} ${cpufile}.h" - links="${links} cpu.h" -fi - - -trap '' 1 2 15 -cat > confcache <<\EOF -# This file is a shell script that caches the results of configure -# tests run on this system so they can be shared between configure -# scripts and configure runs. It is not useful on other systems. -# If it contains results you don't want to keep, you may remove or edit it. -# -# By default, configure uses ./config.cache as the cache file, -# creating it if it does not exist already. You can give configure -# the --cache-file=FILE option to use a different cache file; that is -# what configure does when it calls configure scripts in -# subdirectories, so they share the cache. -# Giving --cache-file=/dev/null disables caching, for debugging configure. -# config.status only pays attention to the cache file if you give it the -# --recheck option to rerun configure. -# -EOF -# The following way of writing the cache mishandles newlines in values, -# but we know of no workaround that is simple, portable, and efficient. -# So, don't put newlines in cache variables' values. -# Ultrix sh set writes to stderr and can't be redirected directly, -# and sets the high bit in the cache file unless we assign to the vars. -(set) 2>&1 | - case `(ac_space=' '; set | grep ac_space) 2>&1` in - *ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote substitution - # turns \\\\ into \\, and sed turns \\ into \). - sed -n \ - -e "s/'/'\\\\''/g" \ - -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" - ;; - *) - # `set' quotes correctly as required by POSIX, so do not add quotes. - sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' - ;; - esac >> confcache -if cmp -s $cache_file confcache; then - : -else - if test -w $cache_file; then - echo "updating cache $cache_file" - cat confcache > $cache_file - else - echo "not updating unwritable cache $cache_file" - fi -fi -rm -f confcache - -trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 - -test "x$prefix" = xNONE && prefix=$ac_default_prefix -# Let make expand exec_prefix. -test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - -# Any assignment to VPATH causes Sun make to only execute -# the first set of double-colon rules, so remove it if not needed. -# If there is a colon in the path, we need to keep it. -if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' -fi - -trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 - -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -cat > conftest.defs <<\EOF -s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g -s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g -s%\[%\\&%g -s%\]%\\&%g -s%\$%$$%g -EOF -DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` -rm -f conftest.defs - - -# Without the "./", some shells look in PATH for config.status. -: ${CONFIG_STATUS=./config.status} - -echo creating $CONFIG_STATUS -rm -f $CONFIG_STATUS -cat > $CONFIG_STATUS </dev/null | sed 1q`: -# -# $0 $ac_configure_args -# -# Compiler output produced by configure, useful for debugging -# configure, is in ./config.log if it exists. - -ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" -for ac_option -do - case "\$ac_option" in - -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) - echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" - exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; - -version | --version | --versio | --versi | --vers | --ver | --ve | --v) - echo "$CONFIG_STATUS generated by autoconf version 2.13" - exit 0 ;; - -help | --help | --hel | --he | --h) - echo "\$ac_cs_usage"; exit 0 ;; - *) echo "\$ac_cs_usage"; exit 1 ;; - esac -done - -ac_given_srcdir=$srcdir -ac_given_INSTALL="$INSTALL" - -trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 -EOF -cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF -$ac_vpsub -$extrasub -s%@SHELL@%$SHELL%g -s%@CFLAGS@%$CFLAGS%g -s%@CPPFLAGS@%$CPPFLAGS%g -s%@CXXFLAGS@%$CXXFLAGS%g -s%@FFLAGS@%$FFLAGS%g -s%@DEFS@%$DEFS%g -s%@LDFLAGS@%$LDFLAGS%g -s%@LIBS@%$LIBS%g -s%@exec_prefix@%$exec_prefix%g -s%@prefix@%$prefix%g -s%@program_transform_name@%$program_transform_name%g -s%@bindir@%$bindir%g -s%@sbindir@%$sbindir%g -s%@libexecdir@%$libexecdir%g -s%@datadir@%$datadir%g -s%@sysconfdir@%$sysconfdir%g -s%@sharedstatedir@%$sharedstatedir%g -s%@localstatedir@%$localstatedir%g -s%@libdir@%$libdir%g -s%@includedir@%$includedir%g -s%@oldincludedir@%$oldincludedir%g -s%@infodir@%$infodir%g -s%@mandir@%$mandir%g -s%@host@%$host%g -s%@host_alias@%$host_alias%g -s%@host_cpu@%$host_cpu%g -s%@host_vendor@%$host_vendor%g -s%@host_os@%$host_os%g -s%@target@%$target%g -s%@target_alias@%$target_alias%g -s%@target_cpu@%$target_cpu%g -s%@target_vendor@%$target_vendor%g -s%@target_os@%$target_os%g -s%@build@%$build%g -s%@build_alias@%$build_alias%g -s%@build_cpu@%$build_cpu%g -s%@build_vendor@%$build_vendor%g -s%@build_os@%$build_os%g -s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g -s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g -s%@INSTALL_DATA@%$INSTALL_DATA%g -s%@target_makefile_frag_path@%$target_makefile_frag_path%g -/@target_makefile_frag@/r $target_makefile_frag -s%@target_makefile_frag@%%g - -CEOF -EOF - -cat >> $CONFIG_STATUS <<\EOF - -# Split the substitutions into bite-sized pieces for seds with -# small command number limits, like on Digital OSF/1 and HP-UX. -ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. -ac_file=1 # Number of current file. -ac_beg=1 # First line for current file. -ac_end=$ac_max_sed_cmds # Line after last line for current file. -ac_more_lines=: -ac_sed_cmds="" -while $ac_more_lines; do - if test $ac_beg -gt 1; then - sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file - else - sed "${ac_end}q" conftest.subs > conftest.s$ac_file - fi - if test ! -s conftest.s$ac_file; then - ac_more_lines=false - rm -f conftest.s$ac_file - else - if test -z "$ac_sed_cmds"; then - ac_sed_cmds="sed -f conftest.s$ac_file" - else - ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" - fi - ac_file=`expr $ac_file + 1` - ac_beg=$ac_end - ac_end=`expr $ac_end + $ac_max_sed_cmds` - fi -done -if test -z "$ac_sed_cmds"; then - ac_sed_cmds=cat -fi -EOF - -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then - # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". - case "$ac_file" in - *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` - ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; - *) ac_file_in="${ac_file}.in" ;; - esac - - # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. - - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` - if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then - # The file is in a subdirectory. - test ! -d "$ac_dir" && mkdir "$ac_dir" - ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dir_suffix. - ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dir_suffix= ac_dots= - fi - - case "$ac_given_srcdir" in - .) srcdir=. - if test -z "$ac_dots"; then top_srcdir=. - else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; - /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; - *) # Relative path. - srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" - top_srcdir="$ac_dots$ac_given_srcdir" ;; - esac - - case "$ac_given_INSTALL" in - [/$]*) INSTALL="$ac_given_INSTALL" ;; - *) INSTALL="$ac_dots$ac_given_INSTALL" ;; - esac - - echo creating "$ac_file" - rm -f "$ac_file" - configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." - case "$ac_file" in - *Makefile*) ac_comsub="1i\\ -# $configure_input" ;; - *) ac_comsub= ;; - esac - - ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` - sed -e "$ac_comsub -s%@configure_input@%$configure_input%g -s%@srcdir@%$srcdir%g -s%@top_srcdir@%$top_srcdir%g -s%@INSTALL@%$INSTALL%g -" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file -fi; done -rm -f conftest.s* - -EOF - -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF -srcdir=$ac_given_srcdir -while test -n "$ac_sources"; do - set $ac_dests; ac_dest=$1; shift; ac_dests=$* - set $ac_sources; ac_source=$1; shift; ac_sources=$* - - echo "linking $srcdir/$ac_source to $ac_dest" - - if test ! -r $srcdir/$ac_source; then - { echo "configure: error: $srcdir/$ac_source: File not found" 1>&2; exit 1; } - fi - rm -f $ac_dest - - # Make relative symlinks. - # Remove last slash and all that follows it. Not all systems have dirname. - ac_dest_dir=`echo $ac_dest|sed 's%/[^/][^/]*$%%'` - if test "$ac_dest_dir" != "$ac_dest" && test "$ac_dest_dir" != .; then - # The dest file is in a subdirectory. - test ! -d "$ac_dest_dir" && mkdir "$ac_dest_dir" - ac_dest_dir_suffix="/`echo $ac_dest_dir|sed 's%^\./%%'`" - # A "../" for each directory in $ac_dest_dir_suffix. - ac_dots=`echo $ac_dest_dir_suffix|sed 's%/[^/]*%../%g'` - else - ac_dest_dir_suffix= ac_dots= - fi - - case "$srcdir" in - [/$]*) ac_rel_source="$srcdir/$ac_source" ;; - *) ac_rel_source="$ac_dots$srcdir/$ac_source" ;; - esac - - # Make a symlink if possible; otherwise try a hard link. - if ln -s $ac_rel_source $ac_dest 2>/dev/null || - ln $srcdir/$ac_source $ac_dest; then : - else - { echo "configure: error: can not link $ac_dest to $srcdir/$ac_source" 1>&2; exit 1; } - fi -done -EOF -cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF - -exit 0 -EOF -chmod +x $CONFIG_STATUS -rm -fr confdefs* $ac_clean_files -test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 - - diff --git a/gdb/nlm/configure.in b/gdb/nlm/configure.in deleted file mode 100644 index ba415aa..0000000 --- a/gdb/nlm/configure.in +++ /dev/null @@ -1,55 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. -AC_PREREQ(2.12.1)dnl -AC_INIT(gdbserve.c) - -AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/../..) -AC_CANONICAL_SYSTEM -AC_ARG_PROGRAM - -AC_PROG_INSTALL - -# Map target cpu into the config cpu subdirectory name. -# The default is $target_cpu. -changequote(,)dnl -case "${target_cpu}" in -alpha) gdb_target_cpu=alpha ;; -c[12]) gdb_target_cpu=convex ;; -hppa*) gdb_target_cpu=pa ;; -i[34567]86) gdb_target_cpu=i386 ;; -m68*) gdb_target_cpu=m68k ;; -np1) gdb_target_cpu=gould ;; -pn) gdb_target_cpu=gould ;; -pyramid) gdb_target_cpu=pyr ;; -sparc*) gdb_target_cpu=sparc ;; -*) gdb_target_cpu=$target_cpu ;; -esac -changequote([,])dnl - -target_makefile_frag=${srcdir}/../config/${gdb_target_cpu}/gdbserve.mt -if [ ! -f ${target_makefile_frag} ]; then - AC_MSG_ERROR("*** GDBSERVE does not support target ${target}") -fi - -dnl We have to assign the same value to other variables because autoconf -dnl doesn't provide a mechanism to substitute a replacement keyword with -dnl arbitrary data or pathnames. -dnl -target_makefile_frag_path=$target_makefile_frag -AC_SUBST(target_makefile_frag_path) -AC_SUBST_FILE(target_makefile_frag) - -cpufile=`sed -n ' -s/CPU_FILE[ ]*=[ ]*\([^ ]*\)/\1/p -' ${target_makefile_frag} - -files= -links= -rm -f cpu.h -if [ "${cpufile}" != "" ]; then - files="${files} ${cpufile}.h" - links="${links} cpu.h" -fi - -AC_LINK_FILES($files, $links) -AC_OUTPUT(Makefile) - diff --git a/gdb/nlm/gdbserve.c b/gdb/nlm/gdbserve.c deleted file mode 100644 index 990a3f9..0000000 --- a/gdb/nlm/gdbserve.c +++ /dev/null @@ -1,1033 +0,0 @@ -/* gdbserve.c -- NLM debugging stub for Novell NetWare. - - This is originally based on an m68k software stub written by Glenn - Engel at HP, but has changed quite a bit. It was modified for the - i386 by Jim Kingdon, Cygnus Support. It was modified to run under - NetWare by Ian Lance Taylor, Cygnus Support. - - This code is intended to produce an NLM (a NetWare Loadable Module) - to run under Novell NetWare. To create the NLM, compile this code - into an object file using the NLM SDK on any i386 host, and use the - nlmconv program (available in the GNU binutils) to transform the - resulting object file into an NLM. */ - -/**************************************************************************** - - THIS SOFTWARE IS NOT COPYRIGHTED - - HP offers the following for use in the public domain. HP makes no - warranty with regard to the software or it's performance and the - user accepts the software "AS IS" with all faults. - - HP DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, WITH REGARD - TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. - -****************************************************************************/ - -/**************************************************************************** - * - * The following gdb commands are supported: - * - * command function Return value - * - * g return the value of the CPU registers hex data or ENN - * G set the value of the CPU registers OK or ENN - * - * mAA..AA,LLLL Read LLLL bytes at address AA..AA hex data or ENN - * MAA..AA,LLLL: Write LLLL bytes at address AA.AA OK or ENN - * - * c Resume at current address SNN ( signal NN) - * cAA..AA Continue at address AA..AA SNN - * - * s Step one instruction SNN - * sAA..AA Step one instruction from AA..AA SNN - * - * k kill - * - * ? What was the last sigval ? SNN (signal NN) - * - * All commands and responses are sent with a packet which includes a - * checksum. A packet consists of - * - * $#. - * - * where - * :: - * :: < two hex digits computed as modulo 256 sum of > - * - * When a packet is received, it is first acknowledged with either '+' or '-'. - * '+' indicates a successful transfer. '-' indicates a failed transfer. - * - * Example: - * - * Host: Reply: - * $m0,10#2a +$00010203040506070809101112131415#42 - * - ****************************************************************************/ - -#include -#include -#include -#include -#include -#include - -#ifdef __i386__ -#include -#include -#include -#include -#include -#else -#include -#include -#include -#include -#include -#include -#endif - -#include -#include "cpu.h" - - -/****************************************************/ -/* This information is from Novell. It is not in any of the standard - NetWare header files. */ - -struct DBG_LoadDefinitionStructure -{ - void *reserved1[4]; - LONG reserved5; - LONG LDCodeImageOffset; - LONG LDCodeImageLength; - LONG LDDataImageOffset; - LONG LDDataImageLength; - LONG LDUninitializedDataLength; - LONG LDCustomDataOffset; - LONG LDCustomDataSize; - LONG reserved6[2]; - LONG (*LDInitializationProcedure)(void); -}; - -#define LO_NORMAL 0x0000 -#define LO_STARTUP 0x0001 -#define LO_PROTECT 0x0002 -#define LO_DEBUG 0x0004 -#define LO_AUTO_LOAD 0x0008 - -/* Loader returned error codes */ -#define LOAD_COULD_NOT_FIND_FILE 1 -#define LOAD_ERROR_READING_FILE 2 -#define LOAD_NOT_NLM_FILE_FORMAT 3 -#define LOAD_WRONG_NLM_FILE_VERSION 4 -#define LOAD_REENTRANT_INITIALIZE_FAILURE 5 -#define LOAD_CAN_NOT_LOAD_MULTIPLE_COPIES 6 -#define LOAD_ALREADY_IN_PROGRESS 7 -#define LOAD_NOT_ENOUGH_MEMORY 8 -#define LOAD_INITIALIZE_FAILURE 9 -#define LOAD_INCONSISTENT_FILE_FORMAT 10 -#define LOAD_CAN_NOT_LOAD_AT_STARTUP 11 -#define LOAD_AUTO_LOAD_MODULES_NOT_LOADED 12 -#define LOAD_UNRESOLVED_EXTERNAL 13 -#define LOAD_PUBLIC_ALREADY_DEFINED 14 -/****************************************************/ - -/* The main thread ID. */ -static int mainthread; - -/* An error message for the main thread to print. */ -static char *error_message; - -/* The AIO port handle. */ -static int AIOhandle; - -/* BUFMAX defines the maximum number of characters in inbound/outbound - buffers. At least NUMREGBYTES*2 are needed for register packets */ -#define BUFMAX (REGISTER_BYTES * 2 + 16) - -/* remote_debug > 0 prints ill-formed commands in valid packets and - checksum errors. */ -static int remote_debug = 1; - -static const char hexchars[] = "0123456789abcdef"; - -unsigned char breakpoint_insn[] = BREAKPOINT; - -char *mem2hex (void *mem, char *buf, int count, int may_fault); -char *hex2mem (char *buf, void *mem, int count, int may_fault); -extern void set_step_traps (struct StackFrame *); -extern void clear_step_traps (struct StackFrame *); - -static int __main() {}; - -/* Read a character from the serial port. This must busy wait, but - that's OK because we will be the only thread running anyhow. */ - -static int -getDebugChar (void) -{ - int err; - LONG got; - unsigned char ret; - - do - { - err = AIOReadData (AIOhandle, (char *) &ret, 1, &got); - if (err != 0) - { - error_message = "AIOReadData failed"; - ResumeThread (mainthread); - return -1; - } - } - while (got == 0); - - return ret; -} - -/* Write a character to the serial port. Returns 0 on failure, - non-zero on success. */ - -static int -putDebugChar (unsigned char c) -{ - int err; - LONG put; - - put = 0; - while (put < 1) - { - err = AIOWriteData (AIOhandle, (char *) &c, 1, &put); - if (err != 0) - ConsolePrintf ("AIOWriteData: err = %d, put = %d\r\n", err, put); - } - return 1; -} - -/* Turn a hex character into a number. */ - -static int -hex (char ch) -{ - if ((ch >= 'a') && (ch <= 'f')) - return (ch-'a'+10); - if ((ch >= '0') && (ch <= '9')) - return (ch-'0'); - if ((ch >= 'A') && (ch <= 'F')) - return (ch-'A'+10); - return (-1); -} - -/* Scan for the sequence $#. Returns 0 on failure, - non-zero on success. */ - -static int -getpacket (char *buffer) -{ - unsigned char checksum; - unsigned char xmitcsum; - int i; - int count; - int ch; - - do - { - /* wait around for the start character, ignore all other characters */ - while ((ch = getDebugChar()) != '$') - if (ch == -1) - return 0; - checksum = 0; - xmitcsum = -1; - - count = 0; - - /* now, read until a # or end of buffer is found */ - while (count < BUFMAX) - { - ch = getDebugChar(); - if (ch == -1) - return 0; - if (ch == '#') - break; - checksum = checksum + ch; - buffer[count] = ch; - count = count + 1; - } - buffer[count] = 0; - - if (ch == '#') - { - ch = getDebugChar (); - if (ch == -1) - return 0; - xmitcsum = hex(ch) << 4; - ch = getDebugChar (); - if (ch == -1) - return 0; - xmitcsum += hex(ch); - - if (checksum != xmitcsum) - { - if (remote_debug) - ConsolePrintf ("bad checksum. My count = 0x%x, sent=0x%x. buf=%s\n", - checksum,xmitcsum,buffer); - /* failed checksum */ - if (! putDebugChar('-')) - return 0; - return 1; - } - else - { - /* successful transfer */ - if (! putDebugChar('+')) - return 0; - /* if a sequence char is present, reply the sequence ID */ - if (buffer[2] == ':') - { - if (! putDebugChar (buffer[0]) - || ! putDebugChar (buffer[1])) - return 0; - /* remove sequence chars from buffer */ - count = strlen(buffer); - for (i=3; i <= count; i++) - buffer[i-3] = buffer[i]; - } - } - } - } - while (checksum != xmitcsum); - - if (remote_debug) - ConsolePrintf ("Received packet \"%s\"\r\n", buffer); - - return 1; -} - -/* Send the packet in buffer. Returns 0 on failure, non-zero on - success. */ - -static int -putpacket (char *buffer) -{ - unsigned char checksum; - int count; - int ch; - - if (remote_debug) - ConsolePrintf ("Sending packet \"%s\"\r\n", buffer); - - /* $#. */ - do - { - if (! putDebugChar('$')) - return 0; - checksum = 0; - count = 0; - - while (ch=buffer[count]) - { - if (! putDebugChar(ch)) - return 0; - checksum += ch; - count += 1; - } - - if (! putDebugChar('#') - || ! putDebugChar(hexchars[checksum >> 4]) - || ! putDebugChar(hexchars[checksum % 16])) - return 0; - - ch = getDebugChar (); - if (ch == -1) - return 0; - } - while (ch != '+'); - - return 1; -} - -static char remcomInBuffer[BUFMAX]; -static char remcomOutBuffer[BUFMAX]; -static short error; - -static void -debug_error (char *format, char *parm) -{ - if (remote_debug) - { - ConsolePrintf (format, parm); - ConsolePrintf ("\n"); - } -} - -/* This is set if we could get a memory access fault. */ -static int mem_may_fault; - -/* Indicate to caller of mem2hex or hex2mem that there has been an - error. */ -volatile int mem_err = 0; - -#ifndef ALTERNATE_MEM_FUNCS -/* These are separate functions so that they are so short and sweet - that the compiler won't save any registers (if there is a fault - to mem_fault, they won't get restored, so there better not be any - saved). */ - -int -get_char (char *addr) -{ - return *addr; -} - -void -set_char (char *addr, int val) -{ - *addr = val; -} -#endif /* ALTERNATE_MEM_FUNCS */ - -/* convert the memory pointed to by mem into hex, placing result in buf */ -/* return a pointer to the last char put in buf (null) */ -/* If MAY_FAULT is non-zero, then we should set mem_err in response to - a fault; if zero treat a fault like any other fault in the stub. */ - -char * -mem2hex (void *mem, char *buf, int count, int may_fault) -{ - int i; - unsigned char ch; - char *ptr = mem; - - mem_may_fault = may_fault; - for (i = 0; i < count; i++) - { - ch = get_char (ptr++); - if (may_fault && mem_err) - return (buf); - *buf++ = hexchars[ch >> 4]; - *buf++ = hexchars[ch % 16]; - } - *buf = 0; - mem_may_fault = 0; - return(buf); -} - -/* convert the hex array pointed to by buf into binary to be placed in mem */ -/* return a pointer to the character AFTER the last byte written */ - -char * -hex2mem (char *buf, void *mem, int count, int may_fault) -{ - int i; - unsigned char ch; - char *ptr = mem; - - mem_may_fault = may_fault; - for (i=0;i=0) - { - *intValue = (*intValue <<4) | hexValue; - numChars ++; - } - else - break; - - (*ptr)++; - } - - return (numChars); -} - -/* This function does all command processing for interfacing to gdb. - It is called whenever an exception occurs in the module being - debugged. */ - -static LONG -handle_exception (struct StackFrame *frame) -{ - int addr, length; - char *ptr; - static struct DBG_LoadDefinitionStructure *ldinfo = 0; - static unsigned char first_insn[BREAKPOINT_SIZE]; /* The first instruction in the program. */ - -#if 0 - /* According to some documentation from Novell, the bell sometimes - may be ringing at this point. This can be stopped on Netware 4 - systems by calling the undocumented StopBell() function. */ - - StopBell (); -#endif - - if (remote_debug) - { - ConsolePrintf ("vector=%d: %s, pc=%08x, thread=%08x\r\n", - frame->ExceptionNumber, - frame->ExceptionDescription, - frame->ExceptionPC, - GetThreadID ()); - } - - switch (frame->ExceptionNumber) - { - case START_NLM_EVENT: - /* If the NLM just started, we record the module load information - and the thread ID, and set a breakpoint at the first instruction - in the program. */ - - ldinfo = ((struct DBG_LoadDefinitionStructure *) - frame->ExceptionErrorCode); - memcpy (first_insn, ldinfo->LDInitializationProcedure, - BREAKPOINT_SIZE); - memcpy (ldinfo->LDInitializationProcedure, breakpoint_insn, - BREAKPOINT_SIZE); - flush_i_cache (); - return RETURN_TO_PROGRAM; - - case ENTER_DEBUGGER_EVENT: - case KEYBOARD_BREAK_EVENT: - /* Pass some events on to the next debugger, in case it will handle - them. */ - return RETURN_TO_NEXT_DEBUGGER; - - case 3: /* Breakpoint */ - /* After we've reached the initial breakpoint, reset it. */ - if (frame->ExceptionPC - DECR_PC_AFTER_BREAK == (LONG) ldinfo->LDInitializationProcedure - && memcmp (ldinfo->LDInitializationProcedure, breakpoint_insn, - BREAKPOINT_SIZE) == 0) - { - memcpy (ldinfo->LDInitializationProcedure, first_insn, - BREAKPOINT_SIZE); - frame->ExceptionPC -= DECR_PC_AFTER_BREAK; - flush_i_cache (); - } - /* Normal breakpoints end up here */ - do_status (remcomOutBuffer, frame); - break; - - default: - /* At the moment, we don't care about most of the unusual NetWare - exceptions. */ - if (frame->ExceptionNumber > 31) - return RETURN_TO_PROGRAM; - - /* Most machine level exceptions end up here */ - do_status (remcomOutBuffer, frame); - break; - - case 11: /* Segment not present */ - case 13: /* General protection */ - case 14: /* Page fault */ - /* If we get a GP fault, and mem_may_fault is set, and the - instruction pointer is near set_char or get_char, then we caused - the fault ourselves accessing an illegal memory location. */ - if (mem_may_fault - && ((frame->ExceptionPC >= (long) &set_char - && frame->ExceptionPC < (long) &set_char + 50) - || (frame->ExceptionPC >= (long) &get_char - && frame->ExceptionPC < (long) &get_char + 50))) - { - mem_err = 1; - /* Point the instruction pointer at an assembly language stub - which just returns from the function. */ - - frame->ExceptionPC += 4; /* Skip the load or store */ - - /* Keep going. This will act as though it returned from - set_char or get_char. The calling routine will check - mem_err, and do the right thing. */ - return RETURN_TO_PROGRAM; - } - /* Random mem fault, report it */ - do_status (remcomOutBuffer, frame); - break; - - case TERMINATE_NLM_EVENT: - /* There is no way to get the exit status. */ - sprintf (remcomOutBuffer, "W%02x", 0); - break; /* We generate our own status */ - } - - /* FIXME: How do we know that this exception has anything to do with - the program we are debugging? We can check whether the PC is in - the range of the module we are debugging, but that doesn't help - much since an error could occur in a library routine. */ - - clear_step_traps (frame); - - if (! putpacket(remcomOutBuffer)) - return RETURN_TO_NEXT_DEBUGGER; - - if (frame->ExceptionNumber == TERMINATE_NLM_EVENT) - { - ResumeThread (mainthread); - return RETURN_TO_PROGRAM; - } - - while (1) - { - error = 0; - remcomOutBuffer[0] = 0; - if (! getpacket (remcomInBuffer)) - return RETURN_TO_NEXT_DEBUGGER; - switch (remcomInBuffer[0]) - { - case '?': - do_status (remcomOutBuffer, frame); - break; - case 'd': - remote_debug = !(remote_debug); /* toggle debug flag */ - break; - case 'g': - /* return the value of the CPU registers */ - frame_to_registers (frame, remcomOutBuffer); - break; - case 'G': - /* set the value of the CPU registers - return OK */ - registers_to_frame (&remcomInBuffer[1], frame); - strcpy(remcomOutBuffer,"OK"); - break; - - case 'm': - /* mAA..AA,LLLL Read LLLL bytes at address AA..AA */ - /* TRY TO READ %x,%x. IF SUCCEED, SET PTR = 0 */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - if (*(ptr++) == ',') - if (hexToInt(&ptr,&length)) - { - ptr = 0; - mem_err = 0; - mem2hex((char*) addr, remcomOutBuffer, length, 1); - if (mem_err) - { - strcpy (remcomOutBuffer, "E03"); - debug_error ("memory fault"); - } - } - - if (ptr) - { - strcpy(remcomOutBuffer,"E01"); - debug_error("malformed read memory command: %s",remcomInBuffer); - } - break; - - case 'M': - /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA return OK */ - /* TRY TO READ '%x,%x:'. IF SUCCEED, SET PTR = 0 */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - if (*(ptr++) == ',') - if (hexToInt(&ptr,&length)) - if (*(ptr++) == ':') - { - mem_err = 0; - hex2mem(ptr, (char*) addr, length, 1); - - if (mem_err) - { - strcpy (remcomOutBuffer, "E03"); - debug_error ("memory fault"); - } - else - { - strcpy(remcomOutBuffer,"OK"); - } - - ptr = 0; - } - if (ptr) - { - strcpy(remcomOutBuffer,"E02"); - debug_error("malformed write memory command: %s",remcomInBuffer); - } - break; - - case 'c': - case 's': - /* cAA..AA Continue at address AA..AA(optional) */ - /* sAA..AA Step one instruction from AA..AA(optional) */ - /* try to read optional parameter, pc unchanged if no parm */ - ptr = &remcomInBuffer[1]; - if (hexToInt(&ptr,&addr)) - { -/* registers[PC_REGNUM].lo = addr;*/ - fprintf (stderr, "Setting PC to 0x%x\n", addr); - while (1); - } - - if (remcomInBuffer[0] == 's') - set_step_traps (frame); - - flush_i_cache (); - return RETURN_TO_PROGRAM; - - case 'k': - /* kill the program */ - KillMe (ldinfo); - ResumeThread (mainthread); - return RETURN_TO_PROGRAM; - - case 'q': /* Query message */ - if (strcmp (&remcomInBuffer[1], "Offsets") == 0) - { - sprintf (remcomOutBuffer, "Text=%x;Data=%x;Bss=%x", - ldinfo->LDCodeImageOffset, - ldinfo->LDDataImageOffset, - ldinfo->LDDataImageOffset + ldinfo->LDDataImageLength); - } - else - sprintf (remcomOutBuffer, "E04, Unknown query %s", &remcomInBuffer[1]); - break; - } - - /* reply to the request */ - if (! putpacket(remcomOutBuffer)) - return RETURN_TO_NEXT_DEBUGGER; - } -} - -char *progname; - -struct bitRate { - BYTE bitRate; - const char *bitRateString; -}; - -struct bitRate bitRateTable[] = -{ - { AIO_BAUD_50 , "50" }, - { AIO_BAUD_75 , "75" }, - { AIO_BAUD_110 , "110" }, - { AIO_BAUD_134p5 , "134.5" }, - { AIO_BAUD_150 , "150" }, - { AIO_BAUD_300 , "300" }, - { AIO_BAUD_600 , "600" }, - { AIO_BAUD_1200 , "1200" }, - { AIO_BAUD_1800 , "1800" }, - { AIO_BAUD_2000 , "2000" }, - { AIO_BAUD_2400 , "2400" }, - { AIO_BAUD_3600 , "3600" }, - { AIO_BAUD_4800 , "4800" }, - { AIO_BAUD_7200 , "7200" }, - { AIO_BAUD_9600 , "9600" }, - { AIO_BAUD_19200 , "19200" }, - { AIO_BAUD_38400 , "38400" }, - { AIO_BAUD_57600 , "57600" }, - { AIO_BAUD_115200, "115200" }, - { -1, NULL } -}; - -char dataBitsTable[] = "5678"; - -char *stopBitsTable[] = { "1", "1.5", "2" }; - -char parity[] = "NOEMS"; - -/* Start up. The main thread opens the named serial I/O port, loads - the named NLM module and then goes to sleep. The serial I/O port - is named as a board number and a port number. It would be more DOS - like to provide a menu of available serial ports, but I don't want - to have to figure out how to do that. */ - -int -main (int argc, char **argv) -{ - int hardware, board, port; - BYTE bitRate; - BYTE dataBits; - BYTE stopBits; - BYTE parityMode; - LONG err; - struct debuggerStructure s; - int cmdindx; - char *cmdlin; - int i; - - /* set progname */ - progname = "gdbserve"; - - /* set default serial line */ - hardware = -1; - board = 0; - port = 0; - - /* set default serial line characteristics */ - bitRate = AIO_BAUD_9600; - dataBits = AIO_DATA_BITS_8; - stopBits = AIO_STOP_BITS_1; - parityMode = AIO_PARITY_NONE; - - cmdindx = 0; - for (argc--, argv++; *argv; argc--, argv++) - { - char *bp; - char *ep; - - if (strnicmp(*argv, "BAUD=", 5) == 0) - { - struct bitRate *brp; - - bp = *argv + 5; - for (brp = bitRateTable; brp->bitRate != (BYTE) -1; brp++) - { - if (strcmp(brp->bitRateString, bp) == 0) - { - bitRate = brp->bitRate; - break; - } - } - - if (brp->bitRateString == NULL) - { - fprintf(stderr, "%s: %s: unknown or unsupported bit rate", - progname, bp); - exit (1); - } - } - else if (strnicmp(*argv, "BOARD=", 6) == 0) - { - bp = *argv + 6; - board = strtol (bp, &ep, 0); - if (ep == bp || *ep != '\0') - { - fprintf (stderr, "%s: %s: expected integer argument\n", - progname, bp); - exit(1); - } - } -#if 1 /* FIXME: this option has been depricated */ - else if (strnicmp(*argv, "NODE=", 5) == 0) - { - bp = *argv + 5; - board = strtol (bp, &ep, 0); - if (ep == bp || *ep != '\0') - { - fprintf (stderr, "%s: %s: expected integer argument\n", - progname, bp); - exit(1); - } - } -#endif - else if (strnicmp(*argv, "PORT=", 5) == 0) - { - bp = *argv + 5; - port = strtol (bp, &ep, 0); - if (ep == bp || *ep != '\0') - { - fprintf (stderr, "%s: %s: expected integer argument\n", - progname, bp); - exit(1); - } - } - else - { - break; - } - - cmdindx++; - } - - if (argc == 0) - { - fprintf (stderr, - "Usage: load %s [options] program [arguments]\n", progname); - exit (1); - } - - err = AIOAcquirePort (&hardware, &board, &port, &AIOhandle); - if (err != AIO_SUCCESS) - { - switch (err) - { - case AIO_PORT_NOT_AVAILABLE: - fprintf (stderr, "Port not available\n"); - break; - - case AIO_BOARD_NUMBER_INVALID: - case AIO_PORT_NUMBER_INVALID: - fprintf (stderr, "No such port\n"); - break; - - default: - fprintf (stderr, "Could not open port: %d\n", err); - break; - } - - exit (1); - } - - err = AIOConfigurePort (AIOhandle, bitRate, dataBits, stopBits, parityMode, - AIO_HARDWARE_FLOW_CONTROL_OFF); - - if (err == AIO_QUALIFIED_SUCCESS) - { - AIOPORTCONFIG portConfig; - - fprintf (stderr, "Port configuration changed!\n"); - - portConfig.returnLength = sizeof(portConfig); - AIOGetPortConfiguration (AIOhandle, &portConfig, NULL); - - fprintf (stderr, - " Bit Rate: %s, Data Bits: %c, Stop Bits: %s, Parity: %c,\ - Flow:%s\n", - bitRateTable[portConfig.bitRate].bitRateString, - dataBitsTable[portConfig.dataBits], - stopBitsTable[portConfig.stopBits], - parity[portConfig.parityMode], - portConfig.flowCtrlMode ? "ON" : "OFF"); - } - else if (err != AIO_SUCCESS) - { - fprintf (stderr, "Could not configure port: %d\n", err); - AIOReleasePort (AIOhandle); - exit (1); - } - - if (AIOSetExternalControl(AIOhandle, AIO_EXTERNAL_CONTROL, - (AIO_EXTCTRL_DTR | AIO_EXTCTRL_RTS)) - != AIO_SUCCESS) - { - LONG extStatus, chgdExtStatus; - - fprintf (stderr, "Could not set desired port controls!\n"); - AIOGetExternalStatus (AIOhandle, &extStatus, &chgdExtStatus); - fprintf (stderr, "Port controls now: %d, %d\n", extStatus, - chgdExtStatus); - } - - /* Register ourselves as an alternate debugger. */ - memset (&s, 0, sizeof s); - s.DDSResourceTag = ((struct ResourceTagStructure *) - AllocateResourceTag (GetNLMHandle (), - (BYTE *)"gdbserver", - DebuggerSignature)); - if (s.DDSResourceTag == 0) - { - fprintf (stderr, "AllocateResourceTag failed\n"); - AIOReleasePort (AIOhandle); - exit (1); - } - s.DDSdebuggerEntry = handle_exception; - s.DDSFlags = TSS_FRAME_BIT; - - err = RegisterDebuggerRTag (&s, AT_FIRST); - if (err != 0) - { - fprintf (stderr, "RegisterDebuggerRTag failed\n"); - AIOReleasePort (AIOhandle); - exit (1); - } - - /* Get the command line we were invoked with, and advance it past - our name and the board and port arguments. */ - cmdlin = getcmd ((char *) NULL); - for (i = 0; i < cmdindx; i++) - { - while (! isspace (*cmdlin)) - ++cmdlin; - while (isspace (*cmdlin)) - ++cmdlin; - } - - /* In case GDB is started before us, ack any packets (presumably - "$?#xx") sitting there. */ - if (! putDebugChar ('+')) - { - fprintf (stderr, "putDebugChar failed\n"); - UnRegisterDebugger (&s); - AIOReleasePort (AIOhandle); - exit (1); - } - - mainthread = GetThreadID (); - - if (remote_debug > 0) - ConsolePrintf ("About to call LoadModule with \"%s\" %08x\r\n", - cmdlin, __GetScreenID (GetCurrentScreen())); - - /* Start up the module to be debugged. */ - err = LoadModule ((struct ScreenStruct *) __GetScreenID (GetCurrentScreen()), - (BYTE *)cmdlin, LO_DEBUG); - if (err != 0) - { - fprintf (stderr, "LoadModule failed: %d\n", err); - UnRegisterDebugger (&s); - AIOReleasePort (AIOhandle); - exit (1); - } - - /* Wait for the debugger to wake us up. */ - if (remote_debug > 0) - ConsolePrintf ("Suspending main thread (%08x)\r\n", mainthread); - SuspendThread (mainthread); - if (remote_debug > 0) - ConsolePrintf ("Resuming main thread (%08x)\r\n", mainthread); - - /* If we are woken up, print an optional error message, deregister - ourselves and exit. */ - if (error_message != NULL) - fprintf (stderr, "%s\n", error_message); - UnRegisterDebugger (&s); - AIOReleasePort (AIOhandle); - exit (0); -} diff --git a/gdb/nlm/gdbserve.def b/gdb/nlm/gdbserve.def deleted file mode 100644 index 588028d..0000000 --- a/gdb/nlm/gdbserve.def +++ /dev/null @@ -1,42 +0,0 @@ -description "GDB debugger stub" -version 1,2 -debug -module clib -screenname "System Console" -input gdbserve.O -output gdbserve.nlm -start _Prelude -exit _Stop -import - AllocateResourceTag - ConsolePrintf - GetCurrentScreen - GetNLMHandle - GetThreadID - KillMe - LoadModule - ReadByteAltDebugger - RegisterDebuggerRTag - ResumeThread - SuspendThread - UnRegisterDebugger - WriteByteAltDebugger - _GetCLibNLMLibHandle - _NWRegisterNLMLibraryUser - _SetupArgv - _StartNLM - _TerminateNLM - __GetScreenID - __get_errno_ptr - exit - fprintf - getcmd - memcmp - memcpy - memset - sprintf - strcmp - strcpy - strlen - strnicmp - strtol diff --git a/gdb/nlm/i386.c b/gdb/nlm/i386.c deleted file mode 100644 index 8fc6b1d..0000000 --- a/gdb/nlm/i386.c +++ /dev/null @@ -1,100 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "i386.h" - -extern char *mem2hex (void *mem, char *buf, int count, int may_fault); -extern char *hex2mem (char *buf, void *mem, int count, int may_fault); -extern int computeSignal (int exceptionVector); - -void -flush_i_cache (void) -{ -} - -/* Get the registers out of the frame information. */ - -void -frame_to_registers (struct StackFrame *frame, char *regs) -{ - /* Copy EAX -> EDI */ - mem2hex (&frame->ExceptionEAX, ®s[0 * 4 * 2], 4 * 8, 0); - - /* Copy EIP & PS */ - mem2hex (&frame->ExceptionPC, ®s[8 * 4 * 2], 4 * 2, 0); - - /* Copy CS, SS, DS */ - mem2hex (&frame->ExceptionCS, ®s[10 * 4 * 2], 4 * 3, 0); - - /* Copy ES */ - mem2hex (&frame->ExceptionES, ®s[13 * 4 * 2], 4 * 1, 0); - - /* Copy FS & GS */ - mem2hex (&frame->ExceptionFS, ®s[14 * 4 * 2], 4 * 2, 0); -} - -/* Put the registers back into the frame information. */ - -void -registers_to_frame (char *regs, struct StackFrame *frame) -{ - /* Copy EAX -> EDI */ - hex2mem (®s[0 * 4 * 2], &frame->ExceptionEAX, 4 * 8, 0); - - /* Copy EIP & PS */ - hex2mem (®s[8 * 4 * 2], &frame->ExceptionPC, 4 * 2, 0); - - /* Copy CS, SS, DS */ - hex2mem (®s[10 * 4 * 2], &frame->ExceptionCS, 4 * 3, 0); - - /* Copy ES */ - hex2mem (®s[13 * 4 * 2], &frame->ExceptionES, 4 * 1, 0); - - /* Copy FS & GS */ - hex2mem (®s[14 * 4 * 2], &frame->ExceptionFS, 4 * 2, 0); -} - -void -set_step_traps (struct StackFrame *frame) -{ - frame->ExceptionSystemFlags |= 0x100; -} - -void -clear_step_traps (struct StackFrame *frame) -{ - frame->ExceptionSystemFlags &= ~0x100; -} - -void -do_status (char *ptr, struct StackFrame *frame) -{ - int sigval; - - sigval = computeSignal (frame->ExceptionNumber); - - sprintf (ptr, "T%02x", sigval); - ptr += 3; - - sprintf (ptr, "%02x:", PC_REGNUM); - ptr = mem2hex (&frame->ExceptionPC, ptr + 3, 4, 0); - *ptr++ = ';'; - - sprintf (ptr, "%02x:", SP_REGNUM); - ptr = mem2hex (&frame->ExceptionESP, ptr + 3, 4, 0); - *ptr++ = ';'; - - sprintf (ptr, "%02x:", DEPRECATED_FP_REGNUM); - ptr = mem2hex (&frame->ExceptionEBP, ptr + 3, 4, 0); - *ptr++ = ';'; - - *ptr = '\000'; -} diff --git a/gdb/nlm/i386.h b/gdb/nlm/i386.h deleted file mode 100644 index ff97aed..0000000 --- a/gdb/nlm/i386.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Register values. All of these values *MUST* agree with tm.h */ -#define SP_REGNUM 4 /* Contains address of top of stack */ -#define PC_REGNUM 8 /* Contains program counter */ -#define DEPRECATED_FP_REGNUM 5 /* Virtual frame pointer */ -#define NUM_REGS 16 /* Number of machine registers */ -#define REGISTER_BYTES (NUM_REGS * 4) /* Total size of registers array */ - -#define ExceptionPC ExceptionEIP -#define DECR_PC_AFTER_BREAK 1 /* int 3 leaves PC pointing after insn */ -#define BREAKPOINT {0xcc} -#define BREAKPOINT_SIZE (sizeof breakpoint_insn) - -#define StackFrame T_TSS_StackFrame diff --git a/gdb/nlm/ppc.c b/gdb/nlm/ppc.c deleted file mode 100644 index c5850ab..0000000 --- a/gdb/nlm/ppc.c +++ /dev/null @@ -1,244 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include "ppc.h" - -extern char *mem2hex (void *mem, char *buf, int count, int may_fault); -extern char *hex2mem (char *buf, void *mem, int count, int may_fault); -extern int computeSignal (int exceptionVector); - -void -flush_i_cache (void) -{ -} - -/* Get the registers out of the frame information. */ - -void -frame_to_registers (struct StackFrame *frame, char *regs) -{ - mem2hex (&frame->ExceptionState.CsavedRegs, ®s[GP0_REGNUM * 4 * 2], 4 * 32, 0); - - mem2hex (&frame->ExceptionState.CSavedFPRegs, ®s[FP0_REGNUM * 4 * 2], 4 * 32, 0); - - mem2hex (&frame->ExceptionPC, ®s[PC_REGNUM * 4 * 2], 4 * 1, 0); - - mem2hex (&frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedSRR1, ®s[CR_REGNUM * 4 * 2], 4 * 1, 0); - mem2hex (&frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedLR, ®s[LR_REGNUM * 4 * 2], 4 * 1, 0); - mem2hex (&frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedCTR, ®s[CTR_REGNUM * 4 * 2], 4 * 1, 0); - mem2hex (&frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedXER, ®s[XER_REGNUM * 4 * 2], 4 * 1, 0); - mem2hex (&frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedMQ, ®s[MQ_REGNUM * 4 * 2], 4 * 1, 0); -} - -/* Put the registers back into the frame information. */ - -void -registers_to_frame (char *regs, struct StackFrame *frame) -{ - hex2mem (®s[GP0_REGNUM * 4 * 2], &frame->ExceptionState.CsavedRegs, 4 * 32, 0); - - hex2mem (®s[FP0_REGNUM * 4 * 2], &frame->ExceptionState.CSavedFPRegs, 4 * 32, 0); - - hex2mem (®s[PC_REGNUM * 4 * 2], &frame->ExceptionPC, 4 * 1, 0); - - hex2mem (®s[CR_REGNUM * 4 * 2], &frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedSRR1, 4 * 1, 0); - hex2mem (®s[LR_REGNUM * 4 * 2], &frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedLR, 4 * 1, 0); - hex2mem (®s[CTR_REGNUM * 4 * 2], &frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedCTR, 4 * 1, 0); - hex2mem (®s[XER_REGNUM * 4 * 2], &frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedXER, 4 * 1, 0); - hex2mem (®s[MQ_REGNUM * 4 * 2], &frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedMQ, 4 * 1, 0); -} - - -extern volatile int mem_err; - -#ifdef ALTERNATE_MEM_FUNCS -extern int ReadByteAltDebugger (char* addr, char *theByte); -extern int WriteByteAltDebugger (char* addr, char theByte); -int -get_char (char *addr) -{ - char c; - - if (!ReadByteAltDebugger (addr, &c)) - mem_err = 1; - - return c; -} - -void -set_char (char *addr, int val) -{ - if (!WriteByteAltDebugger (addr, val)) - mem_err = 1; -} -#endif - -int -mem_write (char *dst, char *src, int len) -{ - while (len-- && !mem_err) - set_char (dst++, *src++); - - return mem_err; -} - -union inst -{ - LONG l; - - struct - { - union - { - struct /* Unconditional branch */ - { - unsigned opcode : 6; /* 18 */ - signed li : 24; - unsigned aa : 1; - unsigned lk : 1; - } b; - struct /* Conditional branch */ - { - unsigned opcode : 6; /* 16 */ - unsigned bo : 5; - unsigned bi : 5; - signed bd : 14; - unsigned aa : 1; - unsigned lk : 1; - } bc; - struct /* Conditional branch to ctr or lr reg */ - { - unsigned opcode : 6; /* 19 */ - unsigned bo : 5; - unsigned bi : 5; - unsigned type : 15; /* 528 = ctr, 16 = lr */ - unsigned lk : 1; - } bclr; - } variant; - } inst; -}; - -static LONG saved_inst; -static LONG *saved_inst_pc = 0; -static LONG saved_target_inst; -static LONG *saved_target_inst_pc = 0; - -void -set_step_traps (struct StackFrame *frame) -{ - union inst inst; - LONG *target; - int opcode; - int ra, rb; - LONG *pc = (LONG *)frame->ExceptionPC; - - inst.l = *pc++; - - opcode = inst.inst.variant.b.opcode; - - target = pc; - - switch (opcode) - { - case 18: /* Unconditional branch */ - - if (inst.inst.variant.b.aa) /* Absolute? */ - target = 0; - target += inst.inst.variant.b.li; - - break; - case 16: /* Conditional branch */ - - if (!inst.inst.variant.bc.aa) /* Absolute? */ - target = 0; - target += inst.inst.variant.bc.bd; - - break; - case 19: /* Cond. branch via ctr or lr reg */ - switch (inst.inst.variant.bclr.type) - { - case 528: /* ctr */ - target = (LONG *)frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedCTR; - break; - case 16: /* lr */ - target = (LONG *)frame->ExceptionState.u.SpecialRegistersEnumerated.CsavedLR; - break; - } - break; - } - - saved_inst = *pc; - mem_write (pc, breakpoint_insn, BREAKPOINT_SIZE); - saved_inst_pc = pc; - - if (target != pc) - { - saved_target_inst = *target; - mem_write (target, breakpoint_insn, BREAKPOINT_SIZE); - saved_target_inst_pc = target; - } -} - -/* Remove step breakpoints. Returns non-zero if pc was at a step breakpoint, - zero otherwise. This routine works even if there were no step breakpoints - set. */ - -int -clear_step_traps (struct StackFrame *frame) -{ - int retcode; - LONG *pc = (LONG *)frame->ExceptionPC; - - if (saved_inst_pc == pc || saved_target_inst_pc == pc) - retcode = 1; - else - retcode = 0; - - if (saved_inst_pc) - { - mem_write (saved_inst_pc, saved_inst, BREAKPOINT_SIZE); - saved_inst_pc = 0; - } - - if (saved_target_inst_pc) - { - mem_write (saved_target_inst_pc, saved_target_inst, BREAKPOINT_SIZE); - saved_target_inst_pc = 0; - } - - return retcode; -} - -void -do_status (char *ptr, struct StackFrame *frame) -{ - int sigval; - - sigval = computeSignal (frame->ExceptionNumber); - - sprintf (ptr, "T%02x", sigval); - ptr += 3; - - sprintf (ptr, "%02x:", PC_REGNUM); - ptr = mem2hex (&frame->ExceptionPC, ptr + 3, 4, 0); - *ptr++ = ';'; - - sprintf (ptr, "%02x:", SP_REGNUM); - ptr = mem2hex (&frame->ExceptionState.CsavedRegs[SP_REGNUM], ptr + 3, 4, 0); - *ptr++ = ';'; - - sprintf (ptr, "%02x:", LR_REGNUM); - ptr = mem2hex (&frame->ExceptionState.CsavedRegs[LR_REGNUM], ptr + 3, 4, 0); - *ptr++ = ';'; - - *ptr = '\000'; -} diff --git a/gdb/nlm/ppc.h b/gdb/nlm/ppc.h deleted file mode 100644 index 84cee6b..0000000 --- a/gdb/nlm/ppc.h +++ /dev/null @@ -1,165 +0,0 @@ -typedef long Long; - -/* The following enum is used to access the special registers in - the saved machine state. */ - -typedef enum -{ - kDc_SavedPC = 0, /* really SRR0 */ - kDc_SavedMSR = 1, /* really SRR1 */ - kDc_SavedCR = 2, - kDc_SavedLR = 3, - kDc_SavedDSISR = 4, - kDc_SavedDAR = 5, - kDc_SavedXER = 6, - kDc_SavedCTR = 7, - kDc_SavedSDR1 = 8, - kDc_SavedRTCU = 9, - kDc_SavedRTCL = 10, - kDc_SavedDEC = 11, - kDc_SavedSR00 = 12, /* The Segement Registers are consecutive */ - kDc_SavedSR01 = 13, /* kDc_SavedSR00 + n is supported */ - kDc_SavedSR02 = 14, - kDc_SavedSR03 = 15, - kDc_SavedSR04 = 16, - kDc_SavedSR05 = 17, - kDc_SavedSR06 = 18, - kDc_SavedSR07 = 19, - kDc_SavedSR08 = 20, - kDc_SavedSR09 = 21, - kDc_SavedSR10 = 22, - kDc_SavedSR11 = 23, - kDc_SavedSR12 = 24, - kDc_SavedSR13 = 25, - kDc_SavedSR14 = 26, - kDc_SavedSR15 = 27, - kDc_SavedFPSCR = 29, - kDc_SavedMQ = 30, - kDc_SavedBAT0U = 31, - kDc_SavedBAT0L = 32, - kDc_SavedBAT1U = 33, - kDc_SavedBAT1L = 34, - kDc_SavedBAT2U = 35, - kDc_SavedBAT2L = 36, - kDc_SavedBAT3U = 37, - kDc_SavedBAT3L = 38, - - kNumberSpecialRegisters = 39 -} Dc_SavedRegisterName; - -/* Access to floating points is not very easy. This allows the number to be - accessed both as a floating number and as a pair of Longs. */ - -typedef union -{ - double asfloat; /* access the variable as a floating number */ - struct - { - Long high; - Long low; - } - asLONG; /* access the variable as two Longs */ -} FloatingPoints; - -/* The following is the standard record for Saving a machine state */ - -struct SavedMachineState -{ - FloatingPoints CSavedFPRegs[32]; /* The floating point registers [0->31] */ - /* ***32bit assumption*** */ - Long CsavedRegs[32]; /* space to save the General Registers */ - /* These are saved 0->31 */ - Long CexReason; - Long SavedDomainID; - union - { /* must be 8-byte aligned, so doubleFPSCR is 8-byte aligned */ - struct - { - Long CsavedSRR0; /* Index 0 - The saved PC */ - Long CsavedSRR1; /* 1 saved MSR */ - Long CsavedCR; /* 2 */ - Long CsavedLR; /* 3 */ - Long CsavedDSISR; /* 4 */ - Long CsavedDAR; /* 5 */ - - Long CsavedXER; /* 6 */ - Long CsavedCTR; /* 7 */ - Long CsavedSDR1; /* 8 */ - Long CsavedRTCU; /* 9 */ - Long CsavedRTCL; /* 10 */ - Long CsavedDEC; /* 11 */ - Long CsavedSR0; /* 12 */ - Long CsavedSR1; /* 13 */ - Long CsavedSR2; /* 14 */ - Long CsavedSR3; /* 15 */ - Long CsavedSR4; /* 16 */ - Long CsavedSR5; /* 17 */ - Long CsavedSR6; /* 18 */ - Long CsavedSR7; /* 19 */ - Long CsavedSR8; /* 20 */ - Long CsavedSR9; /* 21 */ - Long CsavedSR10; /* 22 */ - Long CsavedSR11; /* 23 */ - Long CsavedSR12; /* 24 */ - Long CsavedSR13; /* 25 */ - Long CsavedSR14; /* 26 */ - Long CsavedSR15; /* 27 */ - /* CdoubleFPSCR must be double word aligned */ - Long CdoubleFPSCR; /* 28 this is the upper part of the store and has - no meaning */ - Long CsavedFPSCR; /* 29 */ - Long CsavedMQ; /* 30 */ - Long CsavedBAT0U; /* 31 */ - Long CsavedBAT0L; /* 32 */ - Long CsavedBAT1U; /* 33 */ - Long CsavedBAT1L; /* 34 */ - Long CsavedBAT2U; /* 35 */ - Long CsavedBAT2L; /* 36 */ - Long CsavedBAT3U; /* 37 */ - Long CsavedBAT3L; /* 38 */ - } - SpecialRegistersEnumerated; - - Long SpecialRegistersIndexed[kNumberSpecialRegisters]; - } u; - - Long Padding[3]; /* Needed for quad-word alignment */ -}; - -struct StackFrame -{ - LONG *ExceptionDomainID; - /*ProcessorStructure*/ int *ExceptionProcessorID; - BYTE *ExceptionDescription; - LONG ExceptionFlags; - LONG ExceptionErrorCode; - LONG ExceptionNumber; - struct SavedMachineState ExceptionState; -}; - -/* Register values. All of these values *MUST* agree with tm.h */ -#define GP0_REGNUM 0 /* GPR register 0 */ -#define SP_REGNUM 1 /* Contains address of top of stack */ -#define FP0_REGNUM 32 /* FPR (Floating point) register 0 */ -#define PC_REGNUM 64 /* Contains program counter */ -#define PS_REGNUM 65 /* Processor (or machine) status (%msr) */ -#define CR_REGNUM 66 /* Condition register */ -#define LR_REGNUM 67 /* Link register */ -#define CTR_REGNUM 68 /* Count register */ -#define XER_REGNUM 69 /* Fixed point exception registers */ -#define MQ_REGNUM 70 /* Multiply/quotient register */ -#define NUM_REGS 71 /* Number of machine registers */ -#define REGISTER_BYTES (420) /* Total size of registers array */ - -#define ExceptionPC ExceptionState.u.SpecialRegistersEnumerated.CsavedSRR0 -#define DECR_PC_AFTER_BREAK 0 /* PPCs get this right! */ -#define BREAKPOINT {0x7d, 0x82, 0x10, 0x08} -extern unsigned char breakpoint_insn[]; -#define BREAKPOINT_SIZE 4 - -#if 0 -#define ALTERNATE_MEM_FUNCS /* We need our own get_char/set_char */ -#endif - -extern int get_char (char *addr); -extern void set_char (char *addr, int val); diff --git a/gdb/nlm/prelude.c b/gdb/nlm/prelude.c deleted file mode 100644 index 37e12c8..0000000 --- a/gdb/nlm/prelude.c +++ /dev/null @@ -1,67 +0,0 @@ -/*=========================================================================== -= Novell Standard C Library for NetWare Loadable Modules -= -= Unpublished Copyright (C) 1993 by Novell, Inc. All rights reserved. -= -= No part of this file may be duplicated, revised, translated, localized or -= modified in any manner or compiled, linked or uploaded or downloaded to or -= from any computer system without the prior written consent of Novell, Inc. -============================================================================== -= The object produced by compiling this file is for use by the client of this -= library and is not linked in; Prelude.Obj is therefore one of the files to -= be distributed with CLib.NLM and its headers. -============================================================================== -*/ - -#include -#if defined(__netware__) && defined(__i386__) -#define TERMINATE_BY_UNLOAD 5 -#else -#include -#endif -/*#include "libhooks.h"*/ - -extern int main (int, char **); - -static int NLMID; - - -void _Stop( void ) -{ - _TerminateNLM(NLMID, NULL, TERMINATE_BY_UNLOAD); -} - -int _cstart_( void ) -{ - return _SetupArgv(main); -} - -int _Prelude -( - int NLMHandle, - int initErrorScreenID, - char *commandLine, - char *loadDirectoryPath, - int uninitializedDataLength, - int NLMFileHandle, - int (*readRoutineP)(), - int customDataOffset, - int customDataSize -) -{ - int rc; - - rc = _StartNLM(NLMHandle, - initErrorScreenID, - commandLine, - loadDirectoryPath, - uninitializedDataLength, - NLMFileHandle, - readRoutineP, - customDataOffset, - customDataSize, - &NLMID, - _cstart_); - - return rc; -} diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c index d4f8c58..7697862 100644 --- a/gdb/ppc-linux-nat.c +++ b/gdb/ppc-linux-nat.c @@ -1037,5 +1037,5 @@ _initialize_ppc_linux_nat (void) t->to_stopped_data_address = ppc_linux_stopped_data_address; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/prologue-value.c b/gdb/prologue-value.c new file mode 100644 index 0000000..4ad4d6c --- /dev/null +++ b/gdb/prologue-value.c @@ -0,0 +1,591 @@ +/* Prologue value handling for GDB. + Copyright 2003, 2004, 2005 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 51 Franklin St - Fifth Floor + Boston, MA 02110-1301 + USA */ + +#include "defs.h" +#include "gdb_string.h" +#include "gdb_assert.h" +#include "prologue-value.h" +#include "regcache.h" + + +/* Constructors. */ + +pv_t +pv_unknown (void) +{ + pv_t v = { pvk_unknown, 0, 0 }; + + return v; +} + + +pv_t +pv_constant (CORE_ADDR k) +{ + pv_t v; + + v.kind = pvk_constant; + v.reg = -1; /* for debugging */ + v.k = k; + + return v; +} + + +pv_t +pv_register (int reg, CORE_ADDR k) +{ + pv_t v; + + v.kind = pvk_register; + v.reg = reg; + v.k = k; + + return v; +} + + + +/* Arithmetic operations. */ + +/* If one of *A and *B is a constant, and the other isn't, swap the + values as necessary to ensure that *B is the constant. This can + reduce the number of cases we need to analyze in the functions + below. */ +static void +constant_last (pv_t *a, pv_t *b) +{ + if (a->kind == pvk_constant + && b->kind != pvk_constant) + { + pv_t temp = *a; + *a = *b; + *b = temp; + } +} + + +pv_t +pv_add (pv_t a, pv_t b) +{ + constant_last (&a, &b); + + /* We can add a constant to a register. */ + if (a.kind == pvk_register + && b.kind == pvk_constant) + return pv_register (a.reg, a.k + b.k); + + /* We can add a constant to another constant. */ + else if (a.kind == pvk_constant + && b.kind == pvk_constant) + return pv_constant (a.k + b.k); + + /* Anything else we don't know how to add. We don't have a + representation for, say, the sum of two registers, or a multiple + of a register's value (adding a register to itself). */ + else + return pv_unknown (); +} + + +pv_t +pv_add_constant (pv_t v, CORE_ADDR k) +{ + /* Rather than thinking of all the cases we can and can't handle, + we'll just let pv_add take care of that for us. */ + return pv_add (v, pv_constant (k)); +} + + +pv_t +pv_subtract (pv_t a, pv_t b) +{ + /* This isn't quite the same as negating B and adding it to A, since + we don't have a representation for the negation of anything but a + constant. For example, we can't negate { pvk_register, R1, 10 }, + but we do know that { pvk_register, R1, 10 } minus { pvk_register, + R1, 5 } is { pvk_constant, , 5 }. + + This means, for example, that we could subtract two stack + addresses; they're both relative to the original SP. Since the + frame pointer is set based on the SP, its value will be the + original SP plus some constant (probably zero), so we can use its + value just fine, too. */ + + constant_last (&a, &b); + + /* We can subtract two constants. */ + if (a.kind == pvk_constant + && b.kind == pvk_constant) + return pv_constant (a.k - b.k); + + /* We can subtract a constant from a register. */ + else if (a.kind == pvk_register + && b.kind == pvk_constant) + return pv_register (a.reg, a.k - b.k); + + /* We can subtract a register from itself, yielding a constant. */ + else if (a.kind == pvk_register + && b.kind == pvk_register + && a.reg == b.reg) + return pv_constant (a.k - b.k); + + /* We don't know how to subtract anything else. */ + else + return pv_unknown (); +} + + +pv_t +pv_logical_and (pv_t a, pv_t b) +{ + constant_last (&a, &b); + + /* We can 'and' two constants. */ + if (a.kind == pvk_constant + && b.kind == pvk_constant) + return pv_constant (a.k & b.k); + + /* We can 'and' anything with the constant zero. */ + else if (b.kind == pvk_constant + && b.k == 0) + return pv_constant (0); + + /* We can 'and' anything with ~0. */ + else if (b.kind == pvk_constant + && b.k == ~ (CORE_ADDR) 0) + return a; + + /* We can 'and' a register with itself. */ + else if (a.kind == pvk_register + && b.kind == pvk_register + && a.reg == b.reg + && a.k == b.k) + return a; + + /* Otherwise, we don't know. */ + else + return pv_unknown (); +} + + + +/* Examining prologue values. */ + +int +pv_is_identical (pv_t a, pv_t b) +{ + if (a.kind != b.kind) + return 0; + + switch (a.kind) + { + case pvk_unknown: + return 1; + case pvk_constant: + return (a.k == b.k); + case pvk_register: + return (a.reg == b.reg && a.k == b.k); + default: + gdb_assert (0); + } +} + + +int +pv_is_constant (pv_t a) +{ + return (a.kind == pvk_constant); +} + + +int +pv_is_register (pv_t a, int r) +{ + return (a.kind == pvk_register + && a.reg == r); +} + + +int +pv_is_register_k (pv_t a, int r, CORE_ADDR k) +{ + return (a.kind == pvk_register + && a.reg == r + && a.k == k); +} + + +enum pv_boolean +pv_is_array_ref (pv_t addr, CORE_ADDR size, + pv_t array_addr, CORE_ADDR array_len, + CORE_ADDR elt_size, + int *i) +{ + /* Note that, since .k is a CORE_ADDR, and CORE_ADDR is unsigned, if + addr is *before* the start of the array, then this isn't going to + be negative... */ + pv_t offset = pv_subtract (addr, array_addr); + + if (offset.kind == pvk_constant) + { + /* This is a rather odd test. We want to know if the SIZE bytes + at ADDR don't overlap the array at all, so you'd expect it to + be an || expression: "if we're completely before || we're + completely after". But with unsigned arithmetic, things are + different: since it's a number circle, not a number line, the + right values for offset.k are actually one contiguous range. */ + if (offset.k <= -size + && offset.k >= array_len * elt_size) + return pv_definite_no; + else if (offset.k % elt_size != 0 + || size != elt_size) + return pv_maybe; + else + { + *i = offset.k / elt_size; + return pv_definite_yes; + } + } + else + return pv_maybe; +} + + + +/* Areas. */ + + +/* A particular value known to be stored in an area. + + Entries form a ring, sorted by unsigned offset from the area's base + register's value. Since entries can straddle the wrap-around point, + unsigned offsets form a circle, not a number line, so the list + itself is structured the same way --- there is no inherent head. + The entry with the lowest offset simply follows the entry with the + highest offset. Entries may abut, but never overlap. The area's + 'entry' pointer points to an arbitrary node in the ring. */ +struct area_entry +{ + /* Links in the doubly-linked ring. */ + struct area_entry *prev, *next; + + /* Offset of this entry's address from the value of the base + register. */ + CORE_ADDR offset; + + /* The size of this entry. Note that an entry may wrap around from + the end of the address space to the beginning. */ + CORE_ADDR size; + + /* The value stored here. */ + pv_t value; +}; + + +struct pv_area +{ + /* This area's base register. */ + int base_reg; + + /* The mask to apply to addresses, to make the wrap-around happen at + the right place. */ + CORE_ADDR addr_mask; + + /* An element of the doubly-linked ring of entries, or zero if we + have none. */ + struct area_entry *entry; +}; + + +struct pv_area * +make_pv_area (int base_reg) +{ + struct pv_area *a = (struct pv_area *) xmalloc (sizeof (*a)); + + memset (a, 0, sizeof (*a)); + + a->base_reg = base_reg; + a->entry = 0; + + /* Remember that shift amounts equal to the type's width are + undefined. */ + a->addr_mask = ((((CORE_ADDR) 1 << (TARGET_ADDR_BIT - 1)) - 1) << 1) | 1; + + return a; +} + + +/* Delete all entries from AREA. */ +static void +clear_entries (struct pv_area *area) +{ + struct area_entry *e = area->entry; + + if (e) + { + /* This needs to be a do-while loop, in order to actually + process the node being checked for in the terminating + condition. */ + do + { + struct area_entry *next = e->next; + xfree (e); + } + while (e != area->entry); + + area->entry = 0; + } +} + + +void +free_pv_area (struct pv_area *area) +{ + clear_entries (area); + xfree (area); +} + + +static void +do_free_pv_area_cleanup (void *arg) +{ + free_pv_area ((struct pv_area *) arg); +} + + +struct cleanup * +make_cleanup_free_pv_area (struct pv_area *area) +{ + return make_cleanup (do_free_pv_area_cleanup, (void *) area); +} + + +int +pv_area_store_would_trash (struct pv_area *area, pv_t addr) +{ + /* It may seem odd that pvk_constant appears here --- after all, + that's the case where we know the most about the address! But + pv_areas are always relative to a register, and we don't know the + value of the register, so we can't compare entry addresses to + constants. */ + return (addr.kind == pvk_unknown + || addr.kind == pvk_constant + || (addr.kind == pvk_register && addr.reg != area->base_reg)); +} + + +/* Return a pointer to the first entry we hit in AREA starting at + OFFSET and going forward. + + This may return zero, if AREA has no entries. + + And since the entries are a ring, this may return an entry that + entirely preceeds OFFSET. This is the correct behavior: depending + on the sizes involved, we could still overlap such an area, with + wrap-around. */ +static struct area_entry * +find_entry (struct pv_area *area, CORE_ADDR offset) +{ + struct area_entry *e = area->entry; + + if (! e) + return 0; + + /* If the next entry would be better than the current one, then scan + forward. Since we use '<' in this loop, it always terminates. + + Note that, even setting aside the addr_mask stuff, we must not + simplify this, in high school algebra fashion, to + (e->next->offset < e->offset), because of the way < interacts + with wrap-around. We have to subtract offset from both sides to + make sure both things we're comparing are on the same side of the + discontinuity. */ + while (((e->next->offset - offset) & area->addr_mask) + < ((e->offset - offset) & area->addr_mask)) + e = e->next; + + /* If the previous entry would be better than the current one, then + scan backwards. */ + while (((e->prev->offset - offset) & area->addr_mask) + < ((e->offset - offset) & area->addr_mask)) + e = e->prev; + + /* In case there's some locality to the searches, set the area's + pointer to the entry we've found. */ + area->entry = e; + + return e; +} + + +/* Return non-zero if the SIZE bytes at OFFSET would overlap ENTRY; + return zero otherwise. AREA is the area to which ENTRY belongs. */ +static int +overlaps (struct pv_area *area, + struct area_entry *entry, + CORE_ADDR offset, + CORE_ADDR size) +{ + /* Think carefully about wrap-around before simplifying this. */ + return (((entry->offset - offset) & area->addr_mask) < size + || ((offset - entry->offset) & area->addr_mask) < entry->size); +} + + +void +pv_area_store (struct pv_area *area, + pv_t addr, + CORE_ADDR size, + pv_t value) +{ + /* Remove any (potentially) overlapping entries. */ + if (pv_area_store_would_trash (area, addr)) + clear_entries (area); + else + { + CORE_ADDR offset = addr.k; + struct area_entry *e = find_entry (area, offset); + + /* Delete all entries that we would overlap. */ + while (e && overlaps (area, e, offset, size)) + { + struct area_entry *next = (e->next == e) ? 0 : e->next; + e->prev->next = e->next; + e->next->prev = e->prev; + + xfree (e); + e = next; + } + + /* Move the area's pointer to the next remaining entry. This + will also zero the pointer if we've deleted all the entries. */ + area->entry = e; + } + + /* Now, there are no entries overlapping us, and area->entry is + either zero or pointing at the closest entry after us. We can + just insert ourselves before that. + + But if we're storing an unknown value, don't bother --- that's + the default. */ + if (value.kind == pvk_unknown) + return; + else + { + CORE_ADDR offset = addr.k; + struct area_entry *e = (struct area_entry *) xmalloc (sizeof (*e)); + e->offset = offset; + e->size = size; + e->value = value; + + if (area->entry) + { + e->prev = area->entry->prev; + e->next = area->entry; + e->prev->next = e->next->prev = e; + } + else + { + e->prev = e->next = e; + area->entry = e; + } + } +} + + +pv_t +pv_area_fetch (struct pv_area *area, pv_t addr, CORE_ADDR size) +{ + /* If we have no entries, or we can't decide how ADDR relates to the + entries we do have, then the value is unknown. */ + if (! area->entry + || pv_area_store_would_trash (area, addr)) + return pv_unknown (); + else + { + CORE_ADDR offset = addr.k; + struct area_entry *e = find_entry (area, offset); + + /* If this entry exactly matches what we're looking for, then + we're set. Otherwise, say it's unknown. */ + if (e->offset == offset && e->size == size) + return e->value; + else + return pv_unknown (); + } +} + + +int +pv_area_find_reg (struct pv_area *area, + struct gdbarch *gdbarch, + int reg, + CORE_ADDR *offset_p) +{ + struct area_entry *e = area->entry; + + if (e) + do + { + if (e->value.kind == pvk_register + && e->value.reg == reg + && e->value.k == 0 + && e->size == register_size (gdbarch, reg)) + { + if (offset_p) + *offset_p = e->offset; + return 1; + } + + e = e->next; + } + while (e != area->entry); + + return 0; +} + + +void +pv_area_scan (struct pv_area *area, + void (*func) (void *closure, + pv_t addr, + CORE_ADDR size, + pv_t value), + void *closure) +{ + struct area_entry *e = area->entry; + pv_t addr; + + addr.kind = pvk_register; + addr.reg = area->base_reg; + + if (e) + do + { + addr.k = e->offset; + func (closure, addr, e->size, e->value); + e = e->next; + } + while (e != area->entry); +} diff --git a/gdb/prologue-value.h b/gdb/prologue-value.h new file mode 100644 index 0000000..ec44cad --- /dev/null +++ b/gdb/prologue-value.h @@ -0,0 +1,302 @@ +/* Interface to prologue value handling for GDB. + Copyright 2003, 2004, 2005 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 51 Franklin St - Fifth Floor + Boston, MA 02110-1301 + USA */ + +#ifndef PROLOGUE_VALUE_H +#define PROLOGUE_VALUE_H + +/* When we analyze a prologue, we're really doing 'abstract + interpretation' or 'pseudo-evaluation': running the function's code + in simulation, but using conservative approximations of the values + it would have when it actually runs. For example, if our function + starts with the instruction: + + addi r1, 42 # add 42 to r1 + + we don't know exactly what value will be in r1 after executing this + instruction, but we do know it'll be 42 greater than its original + value. + + If we then see an instruction like: + + addi r1, 22 # add 22 to r1 + + we still don't know what r1's value is, but again, we can say it is + now 64 greater than its original value. + + If the next instruction were: + + mov r2, r1 # set r2 to r1's value + + then we can say that r2's value is now the original value of r1 + plus 64. + + It's common for prologues to save registers on the stack, so we'll + need to track the values of stack frame slots, as well as the + registers. So after an instruction like this: + + mov (fp+4), r2 + + then we'd know that the stack slot four bytes above the frame + pointer holds the original value of r1 plus 64. + + And so on. + + Of course, this can only go so far before it gets unreasonable. If + we wanted to be able to say anything about the value of r1 after + the instruction: + + xor r1, r3 # exclusive-or r1 and r3, place result in r1 + + then things would get pretty complex. But remember, we're just + doing a conservative approximation; if exclusive-or instructions + aren't relevant to prologues, we can just say r1's value is now + 'unknown'. We can ignore things that are too complex, if that loss + of information is acceptable for our application. + + So when I say "conservative approximation" here, what I mean is an + approximation that is either accurate, or marked "unknown", but + never inaccurate. + + Once you've reached the current PC, or an instruction that you + don't know how to simulate, you stop. Now you can examine the + state of the registers and stack slots you've kept track of. + + - To see how large your stack frame is, just check the value of the + stack pointer register; if it's the original value of the SP + minus a constant, then that constant is the stack frame's size. + If the SP's value has been marked as 'unknown', then that means + the prologue has done something too complex for us to track, and + we don't know the frame size. + + - To see where we've saved the previous frame's registers, we just + search the values we've tracked --- stack slots, usually, but + registers, too, if you want --- for something equal to the + register's original value. If the ABI suggests a standard place + to save a given register, then we can check there first, but + really, anything that will get us back the original value will + probably work. + + Sure, this takes some work. But prologue analyzers aren't + quick-and-simple pattern patching to recognize a few fixed prologue + forms any more; they're big, hairy functions. Along with inferior + function calls, prologue analysis accounts for a substantial + portion of the time needed to stabilize a GDB port. So I think + it's worthwhile to look for an approach that will be easier to + understand and maintain. In the approach used here: + + - It's easier to see that the analyzer is correct: you just see + whether the analyzer properly (albiet conservatively) simulates + the effect of each instruction. + + - It's easier to extend the analyzer: you can add support for new + instructions, and know that you haven't broken anything that + wasn't already broken before. + + - It's orthogonal: to gather new information, you don't need to + complicate the code for each instruction. As long as your domain + of conservative values is already detailed enough to tell you + what you need, then all the existing instruction simulations are + already gathering the right data for you. + + A 'struct prologue_value' is a conservative approximation of the + real value the register or stack slot will have. */ + +struct prologue_value { + + /* What sort of value is this? This determines the interpretation + of subsequent fields. */ + enum { + + /* We don't know anything about the value. This is also used for + values we could have kept track of, when doing so would have + been too complex and we don't want to bother. The bottom of + our lattice. */ + pvk_unknown, + + /* A known constant. K is its value. */ + pvk_constant, + + /* The value that register REG originally had *UPON ENTRY TO THE + FUNCTION*, plus K. If K is zero, this means, obviously, just + the value REG had upon entry to the function. REG is a GDB + register number. Before we start interpreting, we initialize + every register R to { pvk_register, R, 0 }. */ + pvk_register, + + } kind; + + /* The meanings of the following fields depend on 'kind'; see the + comments for the specific 'kind' values. */ + int reg; + CORE_ADDR k; +}; + +typedef struct prologue_value pv_t; + + +/* Return the unknown prologue value --- { pvk_unknown, ?, ? }. */ +pv_t pv_unknown (void); + +/* Return the prologue value representing the constant K. */ +pv_t pv_constant (CORE_ADDR k); + +/* Return the prologue value representing the original value of + register REG, plus the constant K. */ +pv_t pv_register (int reg, CORE_ADDR k); + + +/* Return conservative approximations of the results of the following + operations. */ +pv_t pv_add (pv_t a, pv_t b); /* a + b */ +pv_t pv_add_constant (pv_t v, CORE_ADDR k); /* a + k */ +pv_t pv_subtract (pv_t a, pv_t b); /* a - b */ +pv_t pv_logical_and (pv_t a, pv_t b); /* a & b */ + + +/* Return non-zero iff A and B are identical expressions. + + This is not the same as asking if the two values are equal; the + result of such a comparison would have to be a pv_boolean, and + asking whether two 'unknown' values were equal would give you + pv_maybe. Same for comparing, say, { pvk_register, R1, 0 } and { + pvk_register, R2, 0}. + + Instead, this function asks whether the two representations are the + same. */ +int pv_is_identical (pv_t a, pv_t b); + + +/* Return non-zero if A is known to be a constant. */ +int pv_is_constant (pv_t a); + +/* Return non-zero if A is the original value of register number R + plus some constant, zero otherwise. */ +int pv_is_register (pv_t a, int r); + + +/* Return non-zero if A is the original value of register R plus the + constant K. */ +int pv_is_register_k (pv_t a, int r, CORE_ADDR k); + +/* A conservative boolean type, including "maybe", when we can't + figure out whether something is true or not. */ +enum pv_boolean { + pv_maybe, + pv_definite_yes, + pv_definite_no, +}; + + +/* Decide whether a reference to SIZE bytes at ADDR refers exactly to + an element of an array. The array starts at ARRAY_ADDR, and has + ARRAY_LEN values of ELT_SIZE bytes each. If ADDR definitely does + refer to an array element, set *I to the index of the referenced + element in the array, and return pv_definite_yes. If it definitely + doesn't, return pv_definite_no. If we can't tell, return pv_maybe. + + If the reference does touch the array, but doesn't fall exactly on + an element boundary, or doesn't refer to the whole element, return + pv_maybe. */ +enum pv_boolean pv_is_array_ref (pv_t addr, CORE_ADDR size, + pv_t array_addr, CORE_ADDR array_len, + CORE_ADDR elt_size, + int *i); + + +/* A 'struct pv_area' keeps track of values stored in a particular + region of memory. */ +struct pv_area; + +/* Create a new area, tracking stores relative to the original value + of BASE_REG. If BASE_REG is SP, then this effectively records the + contents of the stack frame: the original value of the SP is the + frame's CFA, or some constant offset from it. + + Stores to constant addresses, unknown addresses, or to addresses + relative to registers other than BASE_REG will trash this area; see + pv_area_store_would_trash. */ +struct pv_area *make_pv_area (int base_reg); + +/* Free AREA. */ +void free_pv_area (struct pv_area *area); + + +/* Register a cleanup to free AREA. */ +struct cleanup *make_cleanup_free_pv_area (struct pv_area *area); + + +/* Store the SIZE-byte value VALUE at ADDR in AREA. + + If ADDR is not relative to the same base register we used in + creating AREA, then we can't tell which values here the stored + value might overlap, and we'll have to mark everything as + unknown. */ +void pv_area_store (struct pv_area *area, + pv_t addr, + CORE_ADDR size, + pv_t value); + +/* Return the SIZE-byte value at ADDR in AREA. This may return + pv_unknown (). */ +pv_t pv_area_fetch (struct pv_area *area, pv_t addr, CORE_ADDR size); + +/* Return true if storing to address ADDR in AREA would force us to + mark the contents of the entire area as unknown. This could happen + if, say, ADDR is unknown, since we could be storing anywhere. Or, + it could happen if ADDR is relative to a different register than + the other stores base register, since we don't know the relative + values of the two registers. + + If you've reached such a store, it may be better to simply stop the + prologue analysis, and return the information you've gathered, + instead of losing all that information, most of which is probably + okay. */ +int pv_area_store_would_trash (struct pv_area *area, pv_t addr); + + +/* Search AREA for the original value of REGISTER. If we can't find + it, return zero; if we can find it, return a non-zero value, and if + OFFSET_P is non-zero, set *OFFSET_P to the register's offset within + AREA. GDBARCH is the architecture of which REGISTER is a member. + + In the worst case, this takes time proportional to the number of + items stored in AREA. If you plan to gather a lot of information + about registers saved in AREA, consider calling pv_area_scan + instead, and collecting all your information in one pass. */ +int pv_area_find_reg (struct pv_area *area, + struct gdbarch *gdbarch, + int register, + CORE_ADDR *offset_p); + + +/* For every part of AREA whose value we know, apply FUNC to CLOSURE, + the value's address, its size, and the value itself. */ +void pv_area_scan (struct pv_area *area, + void (*func) (void *closure, + pv_t addr, + CORE_ADDR size, + pv_t value), + void *closure); + + +#endif /* PROLOGUE_VALUE_H */ diff --git a/gdb/remote-rdp.c b/gdb/remote-rdp.c index 54eaf77..695156d 100644 --- a/gdb/remote-rdp.c +++ b/gdb/remote-rdp.c @@ -172,7 +172,7 @@ static int timeout = 2; static char *commandline = NULL; static int -remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, +remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target); @@ -1261,7 +1261,7 @@ remote_rdp_prepare_to_store (void) Returns the number of bytes transferred. */ static int -remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, char *myaddr, int len, +remote_rdp_xfer_inferior_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target) { diff --git a/gdb/remote.c b/gdb/remote.c index 5dc7ab4..582a6bf 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -323,10 +323,9 @@ packet_reg_from_pnum (struct remote_state *rs, LONGEST pnum) to stop for a watchpoint. */ static CORE_ADDR remote_watch_data_address; -/* This is non-zero if taregt stopped for a watchpoint. */ +/* This is non-zero if target stopped for a watchpoint. */ static int remote_stopped_by_watchpoint_p; - static struct target_ops remote_ops; static struct target_ops extended_remote_ops; diff --git a/gdb/s390-nat.c b/gdb/s390-nat.c index 24ff73f..8a38eb1 100644 --- a/gdb/s390-nat.c +++ b/gdb/s390-nat.c @@ -311,7 +311,7 @@ s390_fix_watch_points (void) } static int -s390_insert_watchpoint (CORE_ADDR addr, int len) +s390_insert_watchpoint (CORE_ADDR addr, int len, int type) { struct watch_area *area = xmalloc (sizeof (struct watch_area)); if (!area) @@ -328,7 +328,7 @@ s390_insert_watchpoint (CORE_ADDR addr, int len) } static int -s390_remove_watchpoint (CORE_ADDR addr, int len) +s390_remove_watchpoint (CORE_ADDR addr, int len, int type) { struct watch_area *area, **parea; @@ -388,5 +388,5 @@ _initialize_s390_nat (void) t->to_remove_watchpoint = s390_remove_watchpoint; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index a2fb0d4..e530893 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -2541,10 +2541,13 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) break; case bfd_mach_sh3: + case bfd_mach_sh3_nommu: + case bfd_mach_sh2a_nofpu_or_sh3_nommu: set_gdbarch_register_name (gdbarch, sh_sh3_register_name); break; case bfd_mach_sh3e: + case bfd_mach_sh2a_or_sh3e: /* doubles on sh2e and sh3e are actually 4 byte. */ set_gdbarch_double_bit (gdbarch, 4 * TARGET_CHAR_BIT); @@ -2574,6 +2577,9 @@ sh_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) case bfd_mach_sh4_nofpu: case bfd_mach_sh4a_nofpu: + case bfd_mach_sh4_nommu_nofpu: + case bfd_mach_sh2a_nofpu_or_sh4_nommu_nofpu: + case bfd_mach_sh2a_or_sh4: set_gdbarch_register_name (gdbarch, sh_sh4_nofpu_register_name); break; diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index abdef8f..128a543 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -421,6 +421,22 @@ frv_current_sos (void) struct so_list *sos_head = NULL; struct so_list **sos_next_ptr = &sos_head; + /* Make sure that the main executable has been relocated. This is + required in order to find the address of the global offset table, + which in turn is used to find the link map info. (See lm_base() + for details.) + + Note that the relocation of the main executable is also performed + by SOLIB_CREATE_INFERIOR_HOOK(), however, in the case of core + files, this hook is called too late in order to be of benefit to + SOLIB_ADD. SOLIB_ADD eventually calls this this function, + frv_current_sos, and also precedes the call to + SOLIB_CREATE_INFERIOR_HOOK(). (See post_create_inferior() in + infcmd.c.) */ + if (main_executable_lm_info == 0 && core_bfd != NULL) + frv_relocate_main_executable (); + + /* Fetch the GOT corresponding to the main executable. */ mgot = main_got (); /* Locate the address of the first link map struct. */ @@ -960,6 +976,14 @@ frv_clear_solib (void) enable_break1_done = 0; enable_break2_done = 0; main_lm_addr = 0; + if (main_executable_lm_info != 0) + { + xfree (main_executable_lm_info->map); + xfree (main_executable_lm_info->dyn_syms); + xfree (main_executable_lm_info->dyn_relocs); + xfree (main_executable_lm_info); + main_executable_lm_info = 0; + } } static void diff --git a/gdb/solib-som.c b/gdb/solib-som.c index 3d027cc..52c7367 100644 --- a/gdb/solib-som.c +++ b/gdb/solib-som.c @@ -520,7 +520,7 @@ link_map_start (void) read_memory (addr, buf, 4); addr = extract_unsigned_integer (buf, 4); if (addr == 0) - error (_("Debugging dynamic executables loaded via the hpux8 dld.sl is not supported.")); + return 0; read_memory (addr, buf, 4); return extract_unsigned_integer (buf, 4); diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 7d740a3..b0d12b3 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -704,6 +704,7 @@ svr4_current_sos (void) new->lm_info = xmalloc (sizeof (struct lm_info)); make_cleanup (xfree, new->lm_info); + new->lm_info->l_addr = (CORE_ADDR)-1; new->lm_info->lm = xzalloc (lmo->link_map_size); make_cleanup (xfree, new->lm_info->lm); @@ -744,8 +745,6 @@ svr4_current_sos (void) free_so (new); else { - new->lm_info->l_addr = (CORE_ADDR)-1; - new->next = 0; *link_ptr = new; link_ptr = &new->next; diff --git a/gdb/sparc-linux-nat.c b/gdb/sparc-linux-nat.c index 9ad30a8..a234402 100644 --- a/gdb/sparc-linux-nat.c +++ b/gdb/sparc-linux-nat.c @@ -1,5 +1,5 @@ /* Native-dependent code for GNU/Linux SPARC. - Copyright (C) 2005 + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -39,5 +39,5 @@ _initialize_sparc_linux_nat (void) t->to_store_registers = store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); } diff --git a/gdb/sparc64-linux-nat.c b/gdb/sparc64-linux-nat.c index 84ff739..730d4f9 100644 --- a/gdb/sparc64-linux-nat.c +++ b/gdb/sparc64-linux-nat.c @@ -1,6 +1,6 @@ /* Native-dependent code for GNU/Linux UltraSPARC. - Copyright (C) 2003, 2005 Free Software Foundation, Inc. + Copyright (C) 2003, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -57,7 +57,7 @@ _initialize_sparc64_linux_nat (void) t->to_store_registers = store_inferior_registers; /* Register the target. */ - add_target (t); + linux_nat_add_target (t); sparc_gregset = &sparc64_linux_ptrace_gregset; } diff --git a/gdb/symtab.h b/gdb/symtab.h index 840478a..bef9aaa 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -554,7 +554,7 @@ enum address_class LOC_INDIRECT, /* The variable's address is computed by a set of location - functions (see "struct location_funcs" below). */ + functions (see "struct symbol_ops" below). */ LOC_COMPUTED, /* Same as LOC_COMPUTED, but for function arguments. */ diff --git a/gdb/target.c b/gdb/target.c index 3da3e65..fbfc58a 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -675,7 +675,7 @@ push_target (struct target_ops *t) } /* If there's already targets at this stratum, remove them. */ - /* FIXME: cagney/2003-10-15: I think this should be poping all + /* FIXME: cagney/2003-10-15: I think this should be popping all targets to CUR, and not just those at this stratum level. */ while ((*cur) != NULL && t->to_stratum == (*cur)->to_stratum) { diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 888069a..16d66c7 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,91 @@ +2006-03-27 Nick Roberts + + * gdb.mi/mi-var-child-f.exp, gdb.mi/array.f: New files. + +2006-03-08 Alexandre Oliva + + * gdb.base/prelink.exp: Anchor tested-for regular expression + on gdb prompt. + +2006-03-07 Paul Brook + + * gdb.base/assign.exp: Correct fail message. + +2006-03-07 Paul Brook + + * lib/compiler.c: Extract armcc version number. + * lib/compiler.cc: Ditto. + +2006-03-07 Paul Brook + + * gdb.arch/altivec-abi.exp: Use nowarnings instead of + additional_flags=-w. + * gdb.arch/altivec-regs.exp: Ditto. + * gdb.arch/e500-abi.exp: Ditto. + * gdb.arch/e500-regs.exp: Ditto. + * gdb.base/all-bin.exp: Ditto. + * gdb.base/annota1.exp: Ditto. + * gdb.base/annota3.exp: Ditto. + * gdb.base/args.exp: Ditto. + * gdb.base/arithmet.exp: Ditto. + * gdb.base/assign.exp: Ditto. + * gdb.base/async.exp: Ditto. + * gdb.base/bang.exp: Ditto. + * gdb.base/break.exp: Ditto. + * gdb.base/call-rt-st.exp: Ditto. + * gdb.base/completion.exp: Ditto. + * gdb.base/cond-expr.exp: Ditto. + * gdb.base/condbreak.exp: Ditto. + * gdb.base/consecutive.exp: Ditto. + * gdb.base/define.exp: Ditto. + * gdb.base/display.exp: Ditto. + * gdb.base/ena-dis-br.exp: Ditto. + * gdb.base/environ.exp: Ditto. + * gdb.base/eval-skip.exp: Ditto. + * gdb.base/info-proc.exp: Ditto. + * gdb.base/jump.exp: Ditto. + * gdb.base/logical.exp: Ditto. + * gdb.base/long_long.exp: Ditto. + * gdb.base/maint.exp: Ditto. + * gdb.base/miscexprs.exp: Ditto. + * gdb.base/pc-fp.exp: Ditto. + * gdb.base/pointers.exp: Ditto. + * gdb.base/relational.exp: Ditto. + * gdb.base/reread.exp: Ditto. + * gdb.base/sect-cmd.exp: Ditto. + * gdb.base/sep.exp: Ditto. + * gdb.base/sepdebug.exp: Ditto. + * gdb.base/until.exp: Ditto. + * gdb.base/whatis-exp.exp: Ditto. + * gdb.cp/annota2.exp: Ditto. + * gdb.cp/annota3.exp: Ditto. + * gdb.trace/actions.exp: Ditto. + * gdb.trace/backtrace.exp: Ditto. + * gdb.trace/circ.exp: Ditto. + * gdb.trace/collection.exp: Ditto. + * gdb.trace/deltrace.exp: Ditto. + * gdb.trace/infotrace.exp: Ditto. + * gdb.trace/limits.exp: Ditto. + * gdb.trace/packetlen.exp: Ditto. + * gdb.trace/passc-dyn.exp: Ditto. + * gdb.trace/passcount.exp: Ditto. + * gdb.trace/report.exp: Ditto. + * gdb.trace/save-trace.exp: Ditto. + * gdb.trace/tfind.exp: Ditto. + * gdb.trace/tracecmd.exp: Ditto. + * gdb.trace/while-dyn.exp: Ditto. + * gdb.trace/while-stepping.exp: Ditto. + * lib/gdb.exp: Ditto. + (gdb_compile): Handle nowarning option. + +2006-03-07 Alexandre Oliva + + * gdb.base/prelink.c, gdb.base/prelink-lib.c: Update FSF address. + * gdb.base/prelink.exp: Likewise. Add -q to prelink runs. + Rename executable to prelinkt. Don't re-prelink if we didn't + get a core file. Test prelink -u exit status to tell whether + prelinking failed. Use gdb_test_multiple. + 2006-03-01 Daniel Jacobowitz * gdb.cp/inherit.exp (test_print_mi_member_types): New function. diff --git a/gdb/testsuite/gdb.arch/altivec-abi.exp b/gdb/testsuite/gdb.arch/altivec-abi.exp index 5c74d90..766af42 100644 --- a/gdb/testsuite/gdb.arch/altivec-abi.exp +++ b/gdb/testsuite/gdb.arch/altivec-abi.exp @@ -42,7 +42,7 @@ set testfile "altivec-abi" set binfile ${objdir}/${subdir}/${testfile} set srcfile ${testfile}.c -set compile_flags {debug additional_flags=-w} +set compile_flags {debug nowarnings} if [get_compiler_info $binfile] { warning "get_compiler failed" return -1 diff --git a/gdb/testsuite/gdb.arch/altivec-regs.exp b/gdb/testsuite/gdb.arch/altivec-regs.exp index 849fae8..e4f535d 100644 --- a/gdb/testsuite/gdb.arch/altivec-regs.exp +++ b/gdb/testsuite/gdb.arch/altivec-regs.exp @@ -42,7 +42,7 @@ set testfile "altivec-regs" set binfile ${objdir}/${subdir}/${testfile} set srcfile ${testfile}.c -set compile_flags {debug additional_flags=-w} +set compile_flags {debug nowarnings} if [get_compiler_info $binfile] { warning "get_compiler failed" return -1 diff --git a/gdb/testsuite/gdb.arch/e500-abi.exp b/gdb/testsuite/gdb.arch/e500-abi.exp index 0d11ad3..a634954 100644 --- a/gdb/testsuite/gdb.arch/e500-abi.exp +++ b/gdb/testsuite/gdb.arch/e500-abi.exp @@ -42,7 +42,7 @@ set binfile ${objdir}/${subdir}/${testfile} set src1 ${srcdir}/${subdir}/${testfile}.c -if { [gdb_compile ${src1} ${binfile} executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile ${src1} ${binfile} executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.arch/e500-regs.exp b/gdb/testsuite/gdb.arch/e500-regs.exp index 30dae0a..d17cdc6 100644 --- a/gdb/testsuite/gdb.arch/e500-regs.exp +++ b/gdb/testsuite/gdb.arch/e500-regs.exp @@ -41,7 +41,7 @@ set testfile "e500-regs" set binfile ${objdir}/${subdir}/${testfile} set src1 ${srcdir}/${subdir}/${testfile}.c -if { [gdb_compile ${src1} ${binfile} executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile ${src1} ${binfile} executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/all-bin.exp b/gdb/testsuite/gdb.base/all-bin.exp index fe6b755..bc71771 100644 --- a/gdb/testsuite/gdb.base/all-bin.exp +++ b/gdb/testsuite/gdb.base/all-bin.exp @@ -41,7 +41,7 @@ set testfile "all-types" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/annota1.exp b/gdb/testsuite/gdb.base/annota1.exp index 2fcd7b5..977108a 100644 --- a/gdb/testsuite/gdb.base/annota1.exp +++ b/gdb/testsuite/gdb.base/annota1.exp @@ -42,7 +42,7 @@ set testfile "annota1" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/annota3.exp b/gdb/testsuite/gdb.base/annota3.exp index 10eed26..5154390 100644 --- a/gdb/testsuite/gdb.base/annota3.exp +++ b/gdb/testsuite/gdb.base/annota3.exp @@ -41,7 +41,7 @@ set testfile "annota3" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/args.exp b/gdb/testsuite/gdb.base/args.exp index 4f50ef0..cdd729e 100644 --- a/gdb/testsuite/gdb.base/args.exp +++ b/gdb/testsuite/gdb.base/args.exp @@ -44,7 +44,7 @@ set testfile "args" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/arithmet.exp b/gdb/testsuite/gdb.base/arithmet.exp index 6e7e685..acce9d4 100644 --- a/gdb/testsuite/gdb.base/arithmet.exp +++ b/gdb/testsuite/gdb.base/arithmet.exp @@ -40,7 +40,7 @@ set testfile "int-type" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/assign.exp b/gdb/testsuite/gdb.base/assign.exp index 4bd15c3..77f06de 100644 --- a/gdb/testsuite/gdb.base/assign.exp +++ b/gdb/testsuite/gdb.base/assign.exp @@ -39,7 +39,7 @@ set testfile "all-types" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -439,7 +439,7 @@ gdb_expect { timeout { fail "(timeout) v_int+=v_double" } } } - -re ".*$gdb_prompt $" { fail "v_int+=v_signed_long" } + -re ".*$gdb_prompt $" { fail "v_int+=v_double" } timeout { fail "(timeout) v_int+=v_double" } } diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp index d135cfd..5872dc5 100644 --- a/gdb/testsuite/gdb.base/async.exp +++ b/gdb/testsuite/gdb.base/async.exp @@ -33,7 +33,7 @@ set testfile "async" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/bang.exp b/gdb/testsuite/gdb.base/bang.exp index 1e18328..d0cb7b5 100644 --- a/gdb/testsuite/gdb.base/bang.exp +++ b/gdb/testsuite/gdb.base/bang.exp @@ -25,7 +25,7 @@ set testfile "args" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/bang! -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/break.exp b/gdb/testsuite/gdb.base/break.exp index bcbdd1e..4a704fb 100644 --- a/gdb/testsuite/gdb.base/break.exp +++ b/gdb/testsuite/gdb.base/break.exp @@ -37,15 +37,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -858,15 +858,15 @@ test_next_with_recursion set binfileo2 ${objdir}/${subdir}/${testfile}o2 -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug "additional_flags=-w -O2"}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}O0.o" object {debug nowarnings optimize=-O2}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug "additional_flags=-w -O2"}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}O1.o" object {debug nowarnings optimize=-O2}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}O0.o ${binfile}O1.o" "${binfileo2}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/call-rt-st.exp b/gdb/testsuite/gdb.base/call-rt-st.exp index 7e94408..704a7ad 100644 --- a/gdb/testsuite/gdb.base/call-rt-st.exp +++ b/gdb/testsuite/gdb.base/call-rt-st.exp @@ -42,7 +42,7 @@ if { [istarget "sparclet-*-*"] } { return 0; } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { untested "couldn't compile ${srcdir}/${subdir}/${srcfile}" return -1 } diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 1698a30..2961cb5 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -67,15 +67,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/cond-expr.exp b/gdb/testsuite/gdb.base/cond-expr.exp index 746873c..ad0f3cc 100644 --- a/gdb/testsuite/gdb.base/cond-expr.exp +++ b/gdb/testsuite/gdb.base/cond-expr.exp @@ -42,7 +42,7 @@ if $tracelevel then { set testfile "int-type" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/condbreak.exp b/gdb/testsuite/gdb.base/condbreak.exp index dc4df21..742c2e5 100644 --- a/gdb/testsuite/gdb.base/condbreak.exp +++ b/gdb/testsuite/gdb.base/condbreak.exp @@ -38,15 +38,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/consecutive.exp b/gdb/testsuite/gdb.base/consecutive.exp index b04ae5a..6eeb73e 100644 --- a/gdb/testsuite/gdb.base/consecutive.exp +++ b/gdb/testsuite/gdb.base/consecutive.exp @@ -35,7 +35,7 @@ set testfile "consecutive" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/define.exp b/gdb/testsuite/gdb.base/define.exp index 74682fe..a13d886 100644 --- a/gdb/testsuite/gdb.base/define.exp +++ b/gdb/testsuite/gdb.base/define.exp @@ -37,15 +37,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/display.exp b/gdb/testsuite/gdb.base/display.exp index c39ee36..cc99cd4 100644 --- a/gdb/testsuite/gdb.base/display.exp +++ b/gdb/testsuite/gdb.base/display.exp @@ -31,7 +31,7 @@ set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } if [target_info exists gdb_stub] { diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp index 8d9ef60..bbf8c51 100644 --- a/gdb/testsuite/gdb.base/ena-dis-br.exp +++ b/gdb/testsuite/gdb.base/ena-dis-br.exp @@ -34,15 +34,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp index b00052b..5a7e007 100644 --- a/gdb/testsuite/gdb.base/environ.exp +++ b/gdb/testsuite/gdb.base/environ.exp @@ -41,15 +41,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/eval-skip.exp b/gdb/testsuite/gdb.base/eval-skip.exp index a2ab25c..91ae6b9 100644 --- a/gdb/testsuite/gdb.base/eval-skip.exp +++ b/gdb/testsuite/gdb.base/eval-skip.exp @@ -44,7 +44,7 @@ set testfile "int-type" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/info-proc.exp b/gdb/testsuite/gdb.base/info-proc.exp index fc68601..cc53f7d 100644 --- a/gdb/testsuite/gdb.base/info-proc.exp +++ b/gdb/testsuite/gdb.base/info-proc.exp @@ -34,15 +34,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/jump.exp b/gdb/testsuite/gdb.base/jump.exp index a2c53ee..6cf44ae 100644 --- a/gdb/testsuite/gdb.base/jump.exp +++ b/gdb/testsuite/gdb.base/jump.exp @@ -31,7 +31,7 @@ set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} # Build the test case -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/logical.exp b/gdb/testsuite/gdb.base/logical.exp index 231f8ae..9ef42e5 100644 --- a/gdb/testsuite/gdb.base/logical.exp +++ b/gdb/testsuite/gdb.base/logical.exp @@ -36,7 +36,7 @@ set testfile "int-type" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/long_long.exp b/gdb/testsuite/gdb.base/long_long.exp index fb39d96..e26d45a 100644 --- a/gdb/testsuite/gdb.base/long_long.exp +++ b/gdb/testsuite/gdb.base/long_long.exp @@ -44,7 +44,7 @@ if {$hp_cc_compiler} { set flag "" } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug "additional_flags=$flag -w"]] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [concat debug additional_flags=$flag nowarnings]] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/maint.exp b/gdb/testsuite/gdb.base/maint.exp index 679f90f..7bf9d0d 100644 --- a/gdb/testsuite/gdb.base/maint.exp +++ b/gdb/testsuite/gdb.base/maint.exp @@ -68,15 +68,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/miscexprs.exp b/gdb/testsuite/gdb.base/miscexprs.exp index ad8e11d..6fe071f 100644 --- a/gdb/testsuite/gdb.base/miscexprs.exp +++ b/gdb/testsuite/gdb.base/miscexprs.exp @@ -39,7 +39,7 @@ if [target_info exists gdb,small_stack_section] { set storage "-DSTORAGE=static" } -set additional_flags "additional_flags=-w ${storage}" +set additional_flags "additional_flags=${storage}" # # test running programs @@ -51,7 +51,7 @@ set testfile "miscexprs" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags}]] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ${additional_flags} nowarnings]] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/pc-fp.exp b/gdb/testsuite/gdb.base/pc-fp.exp index 174a8d9..f4c3cfc 100644 --- a/gdb/testsuite/gdb.base/pc-fp.exp +++ b/gdb/testsuite/gdb.base/pc-fp.exp @@ -38,7 +38,7 @@ set testfile "pc-fp" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/pointers.exp b/gdb/testsuite/gdb.base/pointers.exp index a10a7f3..b33590f 100644 --- a/gdb/testsuite/gdb.base/pointers.exp +++ b/gdb/testsuite/gdb.base/pointers.exp @@ -39,7 +39,7 @@ set testfile "pointers" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/prelink-lib.c b/gdb/testsuite/gdb.base/prelink-lib.c index 2a712ba..6b1092c 100644 --- a/gdb/testsuite/gdb.base/prelink-lib.c +++ b/gdb/testsuite/gdb.base/prelink-lib.c @@ -14,7 +14,7 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ int diff --git a/gdb/testsuite/gdb.base/prelink.c b/gdb/testsuite/gdb.base/prelink.c index c63d35b..07ba4b5 100644 --- a/gdb/testsuite/gdb.base/prelink.c +++ b/gdb/testsuite/gdb.base/prelink.c @@ -14,7 +14,7 @@ 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp index c26d20e..7dbf77e 100644 --- a/gdb/testsuite/gdb.base/prelink.exp +++ b/gdb/testsuite/gdb.base/prelink.exp @@ -12,10 +12,10 @@ # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # Please email any bugs, comments, and/or additions to this file to: -# bug-gdb@prep.ai.mit.edu +# bug-gdb@gnu.org # This file was written by Alexandre Oliva @@ -40,8 +40,6 @@ if {$gcc_compiled == 0} { } set testfile "prelink" -set srcfile ${testfile}.c -set binfile ${objdir}/${subdir}/${testfile} set libsrcfile ${testfile}-lib.c set libfile ${objdir}/${subdir}/${testfile}.so @@ -50,13 +48,13 @@ if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [l return -1 } -if {[catch "system \"prelink -NR ${libfile}\""] != 0} { +if {[catch "system \"prelink -qNR ${libfile}\""] != 0} { # Maybe we don't have prelink. return -1 } set srcfile ${testfile}.c -set binfile ${objdir}/${subdir}/${testfile} +set binfile ${objdir}/${subdir}/${testfile}t if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} { return -1; } @@ -82,9 +80,6 @@ if { $found == 0 } { } } -catch "system \"prelink -u ${libfile}\"" -catch "system \"prelink -NR ${libfile}\"" - # Try to clean up after ourselves. remote_file build delete [file join $coredir coremmap.data] remote_exec build "rmdir $coredir" @@ -94,6 +89,12 @@ if { $found == 0 } { return 0 } +if {[catch "system \"prelink -uN ${libfile}\""] != 0} { + untested "${libfile} was not prelinked, maybe system libraries are not prelinked?" + return 0 +} +catch "system \"prelink -qNR ${libfile}\"" + # Start with a fresh gdb gdb_exit @@ -101,26 +102,13 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -set oldtimeout $timeout -set timeout [expr "$timeout + 60"] -verbose "Timeout is now $timeout seconds" 2 -send_gdb "core-file $objdir/$subdir/prelink.core\n" -gdb_expect { - -re "warning: \.dynamic section.*not at the expected address" { - pass "changed base address" - } - -re ".*$gdb_prompt $" { fail "changed base address" } - timeout { fail "(timeout) changed base address" } -} -gdb_expect { - -re "warning: difference.*caused by prelink, adjusting" { - pass "prelink adjustment" +set test "prelink" +global gdb_prompt +gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" { + -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" { + pass "$test" } - -re ".*$gdb_prompt $" { fail "prelink adjustment" } - timeout { fail "(timeout) prelink adjustment" } } -set timeout $oldtimeout -verbose "Timeout is now $timeout seconds" 2 gdb_exit diff --git a/gdb/testsuite/gdb.base/relational.exp b/gdb/testsuite/gdb.base/relational.exp index 562a6fc..32ff8e0 100644 --- a/gdb/testsuite/gdb.base/relational.exp +++ b/gdb/testsuite/gdb.base/relational.exp @@ -38,7 +38,7 @@ set bug_id 0 set testfile "int-type" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp index 5e17e11..2d1167e 100644 --- a/gdb/testsuite/gdb.base/reread.exp +++ b/gdb/testsuite/gdb.base/reread.exp @@ -33,7 +33,7 @@ set srcfile1 ${testfile1}.c # Cygwin needs $EXEEXT. set binfile1 ${objdir}/${subdir}/${testfile1}$EXEEXT -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } @@ -43,7 +43,7 @@ set testfile2 "reread2" set srcfile2 ${testfile2}.c set binfile2 ${objdir}/${subdir}/${testfile2}$EXEEXT -if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/sect-cmd.exp b/gdb/testsuite/gdb.base/sect-cmd.exp index 0b86b79..01be44b 100644 --- a/gdb/testsuite/gdb.base/sect-cmd.exp +++ b/gdb/testsuite/gdb.base/sect-cmd.exp @@ -43,15 +43,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/sep.exp b/gdb/testsuite/gdb.base/sep.exp index 7a7c22a..7699ea2 100644 --- a/gdb/testsuite/gdb.base/sep.exp +++ b/gdb/testsuite/gdb.base/sep.exp @@ -25,7 +25,7 @@ set testfile "sep" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/sepdebug.exp b/gdb/testsuite/gdb.base/sepdebug.exp index 1028dab..2a38fad 100644 --- a/gdb/testsuite/gdb.base/sepdebug.exp +++ b/gdb/testsuite/gdb.base/sepdebug.exp @@ -42,7 +42,7 @@ set testfile "sepdebug" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/until.exp b/gdb/testsuite/gdb.base/until.exp index 033005d..a3a80f2 100644 --- a/gdb/testsuite/gdb.base/until.exp +++ b/gdb/testsuite/gdb.base/until.exp @@ -28,15 +28,15 @@ set srcfile ${testfile}.c set srcfile1 ${testfile}1.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}0.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile}1.o" object {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } -if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${binfile}0.o ${binfile}1.o" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.base/whatis-exp.exp b/gdb/testsuite/gdb.base/whatis-exp.exp index e36683e..f4a1966 100644 --- a/gdb/testsuite/gdb.base/whatis-exp.exp +++ b/gdb/testsuite/gdb.base/whatis-exp.exp @@ -42,7 +42,7 @@ set bug_id 0 set testfile "int-type" set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.cp/annota2.exp b/gdb/testsuite/gdb.cp/annota2.exp index 7710cc4..1a4f5d3 100644 --- a/gdb/testsuite/gdb.cp/annota2.exp +++ b/gdb/testsuite/gdb.cp/annota2.exp @@ -34,7 +34,7 @@ set testfile "annota2" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.cp/annota3.exp b/gdb/testsuite/gdb.cp/annota3.exp index edee7f2..63f68da 100644 --- a/gdb/testsuite/gdb.cp/annota3.exp +++ b/gdb/testsuite/gdb.cp/annota3.exp @@ -33,7 +33,7 @@ set testfile "annota3" set srcfile ${testfile}.cc set binfile ${objdir}/${subdir}/${testfile} -if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ additional_flags=-w}] != "" } { +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++ nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.mi/array.f b/gdb/testsuite/gdb.mi/array.f new file mode 100644 index 0000000..4cc7381 --- /dev/null +++ b/gdb/testsuite/gdb.mi/array.f @@ -0,0 +1,22 @@ +c Copyright 2006 Free Software Foundation, Inc. + +c This program is free software; you can redistribute it and/or modify +c it under the terms of the GNU General Public License as published by +c the Free Software Foundation; either version 2 of the License, or +c (at your option) any later version. +c +c This program is distributed in the hope that it will be useful, +c but WITHOUT ANY WARRANTY; without even the implied warranty of +c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +c GNU General Public License for more details. +c +c You should have received a copy of the GNU General Public License +c along with GNU Emacs; see the file COPYING. If not, write to the +c Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +c Boston, MA 02110-1301, USA. + + INTEGER array(1:2,-1:1) + DATA array/11,21,12,22,13,23/ + CONTINUE + STOP + END diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp new file mode 100644 index 0000000..82f4f0c --- /dev/null +++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp @@ -0,0 +1,51 @@ +# Copyright 2006 Free Software Foundation, Inc. + +# 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 +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Emacs; see the file COPYING. If not, write to the +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +# Test variable objects treat non-zero offsets in Fortran arrays correctly. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +gdb_exit +if [mi_gdb_start] { + continue +} + +set testfile "array" +set srcfile ${testfile}.f +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } { + untested "Couldn't compile ${srcfile}" + return -1 +} + +mi_gdb_reinitialize_dir $srcdir/$subdir +mi_gdb_load ${binfile} + +mi_runto MAIN__ + +mi_gdb_test "-var-create array * array" \ + "\\^done,name=\"array\",numchild=\"3\",type=\"integer \\(2,-1:1\\)\"" \ + "create local variable array" + +mi_gdb_test "-var-list-children --all-values array" \ + "\\^done,numchild=\"3\",children=\\\[child=\{name=\"array.-1\",exp=\"-1\",numchild=\"2\",value=\"\\\[2\\\]\",type=\"integer \\(2\\)\"\},child=\{name=\"array.0\",exp=\"0\",numchild=\"2\",value=\"\\\[2\\\]\",type=\"integer \\(2\\)\"\},child=\{name=\"array.1\",exp=\"1\",numchild=\"2\",value=\"\\\[2\\\]\",type=\"integer \\(2\\)\"\}\\\]" \ + "get children of array" + +mi_gdb_test "-var-list-children --all-values array.-1" \ + "\\^done,numchild=\"2\",children=\\\[child=\{name=\"array.-1.1\",exp=\"1\",numchild=\"0\",value=\"11\",type=\"integer\"\},child=\{name=\"array.-1.2\",exp=\"2\",numchild=\"0\",value=\"21\",type=\"integer\"\}\\\]" \ + "get grandchildren of array (children of first element of second index)" diff --git a/gdb/testsuite/gdb.trace/actions.exp b/gdb/testsuite/gdb.trace/actions.exp index 66d3d87..9be9f59 100644 --- a/gdb/testsuite/gdb.trace/actions.exp +++ b/gdb/testsuite/gdb.trace/actions.exp @@ -39,7 +39,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/gdb.trace/backtrace.exp b/gdb/testsuite/gdb.trace/backtrace.exp index e217f95..dde7795 100644 --- a/gdb/testsuite/gdb.trace/backtrace.exp +++ b/gdb/testsuite/gdb.trace/backtrace.exp @@ -54,7 +54,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_load $binfile diff --git a/gdb/testsuite/gdb.trace/circ.exp b/gdb/testsuite/gdb.trace/circ.exp index 2bfb7a6..4fe230b 100644 --- a/gdb/testsuite/gdb.trace/circ.exp +++ b/gdb/testsuite/gdb.trace/circ.exp @@ -36,7 +36,7 @@ set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.trace/collection.exp b/gdb/testsuite/gdb.trace/collection.exp index e62b694..1d499fd 100644 --- a/gdb/testsuite/gdb.trace/collection.exp +++ b/gdb/testsuite/gdb.trace/collection.exp @@ -36,7 +36,7 @@ set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.trace/deltrace.exp b/gdb/testsuite/gdb.trace/deltrace.exp index 58a69ba..a9adf7a 100644 --- a/gdb/testsuite/gdb.trace/deltrace.exp +++ b/gdb/testsuite/gdb.trace/deltrace.exp @@ -39,7 +39,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/gdb.trace/infotrace.exp b/gdb/testsuite/gdb.trace/infotrace.exp index 6a117d3..ae7d035 100644 --- a/gdb/testsuite/gdb.trace/infotrace.exp +++ b/gdb/testsuite/gdb.trace/infotrace.exp @@ -39,7 +39,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/gdb.trace/limits.exp b/gdb/testsuite/gdb.trace/limits.exp index eed1780..4022d6d 100644 --- a/gdb/testsuite/gdb.trace/limits.exp +++ b/gdb/testsuite/gdb.trace/limits.exp @@ -36,7 +36,7 @@ set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } diff --git a/gdb/testsuite/gdb.trace/packetlen.exp b/gdb/testsuite/gdb.trace/packetlen.exp index 458f732..54b22cc 100644 --- a/gdb/testsuite/gdb.trace/packetlen.exp +++ b/gdb/testsuite/gdb.trace/packetlen.exp @@ -54,7 +54,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_load $binfile diff --git a/gdb/testsuite/gdb.trace/passc-dyn.exp b/gdb/testsuite/gdb.trace/passc-dyn.exp index 8b2899e..f3c6848 100644 --- a/gdb/testsuite/gdb.trace/passc-dyn.exp +++ b/gdb/testsuite/gdb.trace/passc-dyn.exp @@ -53,7 +53,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_load $binfile diff --git a/gdb/testsuite/gdb.trace/passcount.exp b/gdb/testsuite/gdb.trace/passcount.exp index 1777693..881ead0 100644 --- a/gdb/testsuite/gdb.trace/passcount.exp +++ b/gdb/testsuite/gdb.trace/passcount.exp @@ -38,7 +38,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/gdb.trace/report.exp b/gdb/testsuite/gdb.trace/report.exp index 28449fa..1b772a3 100644 --- a/gdb/testsuite/gdb.trace/report.exp +++ b/gdb/testsuite/gdb.trace/report.exp @@ -54,7 +54,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_load $binfile diff --git a/gdb/testsuite/gdb.trace/save-trace.exp b/gdb/testsuite/gdb.trace/save-trace.exp index a5b7cf0..6ab52f0 100644 --- a/gdb/testsuite/gdb.trace/save-trace.exp +++ b/gdb/testsuite/gdb.trace/save-trace.exp @@ -39,7 +39,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/gdb.trace/tfind.exp b/gdb/testsuite/gdb.trace/tfind.exp index 9303820..aa15298 100644 --- a/gdb/testsuite/gdb.trace/tfind.exp +++ b/gdb/testsuite/gdb.trace/tfind.exp @@ -55,7 +55,7 @@ if [istarget "m68k-*-elf"] then { set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_load $binfile diff --git a/gdb/testsuite/gdb.trace/tracecmd.exp b/gdb/testsuite/gdb.trace/tracecmd.exp index d79c98e..dad64cf 100644 --- a/gdb/testsuite/gdb.trace/tracecmd.exp +++ b/gdb/testsuite/gdb.trace/tracecmd.exp @@ -38,7 +38,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/gdb.trace/while-dyn.exp b/gdb/testsuite/gdb.trace/while-dyn.exp index 84ab14b..03adf8c 100644 --- a/gdb/testsuite/gdb.trace/while-dyn.exp +++ b/gdb/testsuite/gdb.trace/while-dyn.exp @@ -55,7 +55,7 @@ if [istarget "m68k-*-elf"] then { set srcfile $testfile.c set binfile $objdir/$subdir/$testfile if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } gdb_load $binfile diff --git a/gdb/testsuite/gdb.trace/while-stepping.exp b/gdb/testsuite/gdb.trace/while-stepping.exp index 4c87d5c..0ea38f5 100644 --- a/gdb/testsuite/gdb.trace/while-stepping.exp +++ b/gdb/testsuite/gdb.trace/while-stepping.exp @@ -39,7 +39,7 @@ if [istarget "m68k-*-elf"] then { set srcfile ${testfile}.c set binfile ${objdir}/${subdir}/${testfile} if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" $binfile \ - executable {debug additional_flags=-w}] != "" } { + executable {debug nowarnings}] != "" } { gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." } } diff --git a/gdb/testsuite/lib/compiler.c b/gdb/testsuite/lib/compiler.c index 7160591..bfec521 100644 --- a/gdb/testsuite/lib/compiler.c +++ b/gdb/testsuite/lib/compiler.c @@ -70,3 +70,7 @@ set compiler_info [join {hpacc __HP_aCC} -] numbers seperated by '.'s: currently "7.0.0.0" */ set need_a_set [regsub -all {\.} [join {xlc __xlc__} -] - compiler_info] #endif + +#if defined (__ARMCC_VERSION) +set compiler_info [join {armcc __ARMCC_VERSION} -] +#endif diff --git a/gdb/testsuite/lib/compiler.cc b/gdb/testsuite/lib/compiler.cc index 6031900..444fb63 100644 --- a/gdb/testsuite/lib/compiler.cc +++ b/gdb/testsuite/lib/compiler.cc @@ -58,3 +58,7 @@ set compiler_info [join {hpacc __HP_aCC} -] numbers seperated by '.'s: currently "7.0.0.0" */ set need_a_set [regsub -all {\.} [join {xlc __xlc__} -] - compiler_info] #endif + +#if defined (__ARMCC_VERSION) +set compiler_info [join {armcc __ARMCC_VERSION} -] +#endif diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index cfddc99..4bb4b05 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -1183,7 +1183,7 @@ proc skip_altivec_tests {} { } # Make sure we have a compiler that understands altivec. - set compile_flags {debug additional_flags=-w} + set compile_flags {debug nowarnings} if [get_compiler_info not-used] { warning "Could not get compiler info" return 1 @@ -1497,6 +1497,18 @@ proc gdb_compile {source dest type options} { lappend options "ldflags=${gdb_wrapper_flags}" } + # Replace the "nowarnings" option with the appropriate additional_flags + # to disable compiler warnings. + set nowarnings [lsearch -exact $options nowarnings] + if {$nowarnings != -1} { + if [target_info exists gdb,nowarnings_flag] { + set flag "additional_flags=[target_info gdb,nowarnings_flag]" + } else { + set flag "additional_flags=-w" + } + set options [lreplace $options $nowarnings $nowarnings $flag] + } + set result [target_compile $source $dest $type $options]; regsub "\[\r\n\]*$" "$result" "" result; regsub "^\[\r\n\]*" "$result" "" result; diff --git a/gdb/top.c b/gdb/top.c index 61968af..e129722 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -112,6 +112,10 @@ Whether to confirm potentially dangerous operations is %s.\n"), FILE *instream; +/* Flag to indicate whether a user defined command is currently running. */ + +int in_user_command; + /* Current working directory. */ char *current_directory; @@ -909,11 +913,11 @@ command_line_input (char *prompt_arg, int repeat, char *annotation_suffix) } /* Don't use fancy stuff if not talking to stdin. */ - if (deprecated_readline_hook && instream == NULL) + if (deprecated_readline_hook && input_from_terminal_p ()) { rl = (*deprecated_readline_hook) (local_prompt); } - else if (command_editing_p && instream == stdin && ISATTY (instream)) + else if (command_editing_p && input_from_terminal_p ()) { rl = gdb_readline_wrapper (local_prompt); } @@ -1197,13 +1201,22 @@ quit_force (char *args, int from_tty) exit (exit_code); } -/* Returns whether GDB is running on a terminal and whether the user - desires that questions be asked of them on that terminal. */ +/* Returns whether GDB is running on a terminal and input is + currently coming from that terminal. */ int input_from_terminal_p (void) { - return gdb_has_a_terminal () && (instream == stdin) & caution; + if (gdb_has_a_terminal () && instream == stdin) + return 1; + + /* If INSTREAM is unset, and we are not in a user command, we + must be in Insight. That's like having a terminal, for our + purposes. */ + if (instream == NULL && !in_user_command) + return 1; + + return 0; } static void diff --git a/gdb/top.h b/gdb/top.h index e3f5d72..591bfa3 100644 --- a/gdb/top.h +++ b/gdb/top.h @@ -1,7 +1,7 @@ /* Top level stuff for GDB, the GNU debugger. Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, - 1996, 1997, 1998, 1999, 2000, 2005 Free Software Foundation, Inc. + 1996, 1997, 1998, 1999, 2000, 2005, 2006 Free Software Foundation, Inc. This file is part of GDB. @@ -27,6 +27,8 @@ extern char *line; extern int linesize; extern FILE *instream; +extern int in_user_command; +extern int caution; extern char gdb_dirbuf[1024]; extern int inhibit_gdbinit; extern int epoch_interface; diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index c40b120..4b91172 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2318,7 +2318,7 @@ tracepoint_save_command (char *args, int from_tty) char tmp[40]; if (args == 0 || *args == 0) - error (_("Argument required (file name in which to save tracepoints")); + error (_("Argument required (file name in which to save tracepoints)")); if (tracepoint_chain == 0) { diff --git a/gdb/tui/tui-hooks.c b/gdb/tui/tui-hooks.c index 2e4632e..7099dd7 100644 --- a/gdb/tui/tui-hooks.c +++ b/gdb/tui/tui-hooks.c @@ -1,6 +1,7 @@ /* GDB hooks for TUI. - Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This file is part of GDB. @@ -77,10 +78,6 @@ tui_query_hook (const char * msg, va_list argp) int ans2; int answer; - /* Automatically answer "yes" if input is not from a terminal. */ - if (!input_from_terminal_p ()) - return 1; - echo (); while (1) { diff --git a/gdb/utils.c b/gdb/utils.c index c1ed5b7..00a060b 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -54,6 +54,7 @@ #include "filenames.h" #include "symfile.h" #include "gdb_obstack.h" +#include "top.h" #include "inferior.h" /* for signed_pointer_to_address */ @@ -1141,16 +1142,17 @@ query (const char *ctlstr, ...) int ans2; int retval; + /* Automatically answer "yes" if input is not from the user + directly, or if the user did not want prompts. */ + if (!input_from_terminal_p () || !caution) + return 1; + if (deprecated_query_hook) { va_start (args, ctlstr); return deprecated_query_hook (ctlstr, args); } - /* Automatically answer "yes" if input is not from a terminal. */ - if (!input_from_terminal_p ()) - return 1; - while (1) { wrap_here (""); /* Flush any buffered output */ @@ -1244,15 +1246,16 @@ defaulted_query (const char *ctlstr, const char defchar, va_list args) n_string = "[n]"; } + /* Automatically answer the default value if input is not from the user + directly, or if the user did not want prompts. */ + if (!input_from_terminal_p () || !caution) + return def_value; + if (deprecated_query_hook) { return deprecated_query_hook (ctlstr, args); } - /* Automatically answer default value if input is not from a terminal. */ - if (!input_from_terminal_p ()) - return def_value; - while (1) { wrap_here (""); /* Flush any buffered output */ diff --git a/gdb/varobj.c b/gdb/varobj.c index 76ced13..c16e088 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -817,9 +817,7 @@ varobj_set_value (struct varobj *var, char *expression) int i; input_radix = 10; /* ALWAYS reset to decimal temporarily */ - if (!gdb_parse_exp_1 (&s, 0, 0, &exp)) - /* We cannot proceed without a well-formed expression. */ - return 0; + exp = parse_exp_1 (&s, 0, 0); if (!gdb_evaluate_expression (exp, &value)) { /* We cannot proceed without a valid expression. */ @@ -1833,7 +1831,8 @@ c_name_of_child (struct varobj *parent, int index) switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: - name = xstrprintf ("%d", index); + name = xstrprintf ("%d", index + + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type))); break; case TYPE_CODE_STRUCT: @@ -1931,6 +1930,7 @@ c_value_of_child (struct varobj *parent, int index) struct value *indval; struct type *type, *target; char *name; + int real_index; type = get_type (parent); target = get_target_type (type); @@ -1943,13 +1943,14 @@ c_value_of_child (struct varobj *parent, int index) switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: + real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)); #if 0 /* This breaks if the array lives in a (vector) register. */ - value = value_slice (temp, index, 1); + value = value_slice (temp, real_index, 1); temp = value_coerce_array (value); gdb_value_ind (temp, &value); #else - indval = value_from_longest (builtin_type_int, (LONGEST) index); + indval = value_from_longest (builtin_type_int, (LONGEST) real_index); gdb_value_subscript (temp, indval, &value); #endif break; diff --git a/gdb/version.in b/gdb/version.in index 562141b..04ba358 100644 --- a/gdb/version.in +++ b/gdb/version.in @@ -1 +1 @@ -6.4.50.20060303-cvs +6.4.50.20060330-cvs diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c index 172e12d..81b1669 100644 --- a/gdb/xstormy16-tdep.c +++ b/gdb/xstormy16-tdep.c @@ -202,7 +202,7 @@ xstormy16_store_return_value (struct type *type, struct regcache *regcache, static enum return_value_convention xstormy16_return_value (struct gdbarch *gdbarch, struct type *type, struct regcache *regcache, - void *readbuf, const void *writebuf) + gdb_byte *readbuf, const gdb_byte *writebuf) { if (xstormy16_use_struct_convention (type)) return RETURN_VALUE_STRUCT_CONVENTION; @@ -239,7 +239,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, int argreg = E_1ST_ARG_REGNUM; int i, j; int typelen, slacklen; - char *val; + const gdb_byte *val; char buf[xstormy16_pc_size]; /* If struct_return is true, then the struct return address will @@ -278,6 +278,8 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch, wordaligned. */ for (j = nargs - 1; j >= i; j--) { + char *val; + typelen = TYPE_LENGTH (value_enclosing_type (args[j])); slacklen = typelen & 1; val = alloca (typelen + slacklen); @@ -588,7 +590,7 @@ xstormy16_skip_trampoline_code (CORE_ADDR pc) and vice versa. */ static CORE_ADDR -xstormy16_pointer_to_address (struct type *type, const void *buf) +xstormy16_pointer_to_address (struct type *type, const gdb_byte *buf) { enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type)); CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type)); @@ -604,7 +606,7 @@ xstormy16_pointer_to_address (struct type *type, const void *buf) } static void -xstormy16_address_to_pointer (struct type *type, void *buf, CORE_ADDR addr) +xstormy16_address_to_pointer (struct type *type, gdb_byte *buf, CORE_ADDR addr) { enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type)); @@ -671,10 +673,11 @@ xstormy16_frame_cache (struct frame_info *next_frame, void **this_cache) } static void -xstormy16_frame_prev_register (struct frame_info *next_frame, void **this_cache, +xstormy16_frame_prev_register (struct frame_info *next_frame, + void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp, CORE_ADDR *addrp, - int *realnump, void *valuep) + int *realnump, gdb_byte *valuep) { struct xstormy16_frame_cache *cache = xstormy16_frame_cache (next_frame, this_cache); diff --git a/include/ChangeLog b/include/ChangeLog index 3c6907f..4af593f 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,13 @@ +2006-03-25 Bernd Schmidt + + * elf/bfin.h (R_BFIN_GOT17M4, R_BFIN_GOTHI, R_BFIN_GOTLO, + R_BFIN_FUNCDESC, R_BFIN_FUNCDESC_GOT17M4, R_BFIN_FUNCDESC_GOTHI, + R_BFIN_FUNCDESC_GOTLO, R_BFIN_FUNCDESC_VALUE, + R_BFIN_FUNCDESC_GOTOFF17M4, R_BFIN_FUNCDESC_GOTOFFHI, + R_BFIN_FUNCDESC_GOTOFFLO, R_BFIN_GOTOFF17M4, R_BFIN_GOTOFFHI, + R_BFIN_GOTOFFLO): New relocs. + (EF_BFIN_PIC, EF_BFIN_FDPIC, EF_BFIN_PIC_FLAGS): New macros. + 2006-02-17 Shrirang Khisti Anil Paranjape Shilin Shakti diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog index 2766585..48ce81c 100644 --- a/include/elf/ChangeLog +++ b/include/elf/ChangeLog @@ -1,3 +1,33 @@ +2006-03-22 Richard Sandiford + Daniel Jacobowitz + Phil Edwards + Zack Weinberg + Mark Mitchell + Nathan Sidwell + + * mips.h (R_MIPS_COPY, R_MIPS_JUMP_SLOT): New relocs. + +2006-03-19 John David Anglin + + * hppa.h (SHF_HP_TLS, SHF_HP_NEAR_SHARED, SHF_HP_FAR_SHARED, + SHF_HP_COMDAT, SHF_HP_CONST, SHN_TLS_COMMON, SHN_NS_COMMON, + SHN_NS_UNDEF, SHN_FS_UNDEF, SHN_HP_EXTERN, SHN_HP_EXTHINT, + SHN_HP_UNDEF_BIND_IMM, SHT_HP_OVLBITS, SHT_HP_DLKM, SHT_HP_COMDAT, + SHT_HP_OBJDICT, SHT_HP_ANNOT, STB_HP_ALIAS): Define. + +2006-03-10 Paul Brook + + * arm.h (EF_ARM_EABI_VER5): Define. + +2006-03-06 Nathan Sidwell + + * m68k.h (EF_M68K_ISA_MASK, EF_M68K_ISA_A, + EF_M68K_ISA_A_PLUS, EF_M68K_ISA_B, EF_M68K_ISA_C): Adjust. + (EF_M68K_ISA_A_NODIV, EF_M68K_ISA_B_NOUSP): New. + (EF_M68K_HW_DIV, EF_M68K_USP): Remove. + (EF_M68K_MAC, EF_M68K_EMAC, EF_M68K_FLOAT): Adjust. + (EF_M68K_EMAC_B): New. + 2006-03-03 Bjoern Haase * avr.h (R_AVR_MS8_LDI,R_AVR_MS8_LDI_NEG): Add. diff --git a/include/elf/arm.h b/include/elf/arm.h index 9ad0420..8311c13 100644 --- a/include/elf/arm.h +++ b/include/elf/arm.h @@ -56,6 +56,7 @@ #define EF_ARM_EABI_VER2 0x02000000 #define EF_ARM_EABI_VER3 0x03000000 #define EF_ARM_EABI_VER4 0x04000000 +#define EF_ARM_EABI_VER5 0x05000000 /* Local aliases for some flags to match names used by COFF port. */ #define F_INTERWORK EF_ARM_INTERWORK diff --git a/include/elf/bfin.h b/include/elf/bfin.h index 09faab6..3c07cd1 100644 --- a/include/elf/bfin.h +++ b/include/elf/bfin.h @@ -43,6 +43,21 @@ START_RELOC_NUMBERS (elf_bfin_reloc_type) RELOC_NUMBER (R_byte2_data, 0x11) /* 0x11, 0x00) .byte2 var = symbol */ RELOC_NUMBER (R_byte4_data, 0x12) /* 0x12, 0x00) .byte4 var = symbol and .var var=symbol */ RELOC_NUMBER (R_pcrel11, 0x13) /* 0x13, 0x00) lsetup part b */ + RELOC_NUMBER (R_BFIN_GOT17M4, 0x14) + RELOC_NUMBER (R_BFIN_GOTHI, 0x15) + RELOC_NUMBER (R_BFIN_GOTLO, 0x16) + RELOC_NUMBER (R_BFIN_FUNCDESC, 0x17) + RELOC_NUMBER (R_BFIN_FUNCDESC_GOT17M4, 0x18) + RELOC_NUMBER (R_BFIN_FUNCDESC_GOTHI, 0x19) + RELOC_NUMBER (R_BFIN_FUNCDESC_GOTLO, 0x1a) + RELOC_NUMBER (R_BFIN_FUNCDESC_VALUE, 0x1b) + RELOC_NUMBER (R_BFIN_FUNCDESC_GOTOFF17M4, 0x1c) + RELOC_NUMBER (R_BFIN_FUNCDESC_GOTOFFHI, 0x1d) + RELOC_NUMBER (R_BFIN_FUNCDESC_GOTOFFLO, 0x1e) + RELOC_NUMBER (R_BFIN_GOTOFF17M4, 0x1f) + RELOC_NUMBER (R_BFIN_GOTOFFHI, 0x20) + RELOC_NUMBER (R_BFIN_GOTOFFLO, 0x21) + RELOC_NUMBER (R_push, 0xE0) RELOC_NUMBER (R_const, 0xE1) RELOC_NUMBER (R_add, 0xE2) @@ -69,4 +84,9 @@ START_RELOC_NUMBERS (elf_bfin_reloc_type) RELOC_NUMBER (R_BFIN_GNU_VTENTRY, 0x43) /* C++, gnu only */ END_RELOC_NUMBERS (R_max) +/* Processor specific flags for the ELF header e_flags field. */ +#define EF_BFIN_PIC 0x00000001 /* -fpic */ +#define EF_BFIN_FDPIC 0x00000002 /* -mfdpic */ + +#define EF_BFIN_PIC_FLAGS (EF_BFIN_PIC | EF_BFIN_FDPIC) #endif /* _ELF_BFIN_H */ diff --git a/include/elf/hppa.h b/include/elf/hppa.h index 38a464e..15be2d5 100644 --- a/include/elf/hppa.h +++ b/include/elf/hppa.h @@ -490,6 +490,30 @@ typedef enum elf_hppa_reloc_type elf_hppa_reloc_type; #define PT_PARISC_UNWIND 0x70000001 #define PT_PARISC_WEAKORDER 0x70000002 +/* Flag bits in sh_flags of ElfXX_Shdr. */ +#define SHF_HP_TLS 0x01000000 +#define SHF_HP_NEAR_SHARED 0x02000000 +#define SHF_HP_FAR_SHARED 0x04000000 +#define SHF_HP_COMDAT 0x08000000 +#define SHF_HP_CONST 0x00800000 + +/* Reserved section header indices. */ +#define SHN_TLS_COMMON (SHN_LOOS + 0x0) +#define SHN_NS_COMMON (SHN_LOOS + 0x1) +#define SHN_FS_COMMON (SHN_LOOS + 0x2) +#define SHN_NS_UNDEF (SHN_LOOS + 0x3) +#define SHN_FS_UNDEF (SHN_LOOS + 0x4) +#define SHN_HP_EXTERN (SHN_LOOS + 0x5) +#define SHN_HP_EXTHINT (SHN_LOOS + 0x6) +#define SHN_HP_UNDEF_BIND_IMM (SHN_LOOS + 0x7) + +/* Values of sh_type in ElfXX_Shdr. */ +#define SHT_HP_OVLBITS (SHT_LOOS + 0x0) +#define SHT_HP_DLKM (SHT_LOOS + 0x1) +#define SHT_HP_COMDAT (SHT_LOOS + 0x2) +#define SHT_HP_OBJDICT (SHT_LOOS + 0x3) +#define SHT_HP_ANNOT (SHT_LOOS + 0x4) + /* Flag bits in p_flags of ElfXX_Phdr. */ #define PF_HP_CODE 0x00040000 #define PF_HP_MODIFY 0x00080000 @@ -571,6 +595,9 @@ typedef enum elf_hppa_reloc_type elf_hppa_reloc_type; #define PT_HP_STACK (PT_LOOS + 0x14) #define PT_HP_CORE_UTSNAME (PT_LOOS + 0x15) +/* Binding information. */ +#define STB_HP_ALIAS (STB_LOOS + 0x0) + /* Additional symbol types. */ #define STT_HP_OPAQUE (STT_LOOS + 0x1) #define STT_HP_STUB (STT_LOOS + 0x2) diff --git a/include/elf/m68k.h b/include/elf/m68k.h index 929cd60..08d0c44 100644 --- a/include/elf/m68k.h +++ b/include/elf/m68k.h @@ -58,16 +58,18 @@ END_RELOC_NUMBERS (R_68K_max) /* We use the bottom 8 bits to encode information about the coldfire variant. */ -#define EF_M68K_ISA_MASK 0x07 /* Which ISA */ -#define EF_M68K_ISA_A 0x01 -#define EF_M68K_ISA_A_PLUS 0x02 -#define EF_M68K_ISA_B 0x03 -#define EF_M68K_HW_DIV 0x08 /* Has HW divide */ +#define EF_M68K_ISA_MASK 0x0F /* Which ISA */ +#define EF_M68K_ISA_A_NODIV 0x01 /* ISA A except for div */ +#define EF_M68K_ISA_A 0x02 +#define EF_M68K_ISA_A_PLUS 0x03 +#define EF_M68K_ISA_B_NOUSP 0x04 /* ISA_B except for USP */ +#define EF_M68K_ISA_B 0x05 +#define EF_M68K_ISA_C 0x06 #define EF_M68K_MAC_MASK 0x30 -#define EF_M68K_MAC 0x10 /* Has MAC */ -#define EF_M68K_EMAC 0x20 /* Has EMAC */ -#define EF_M68K_USP 0x40 /* Has USP insns */ -#define EF_M68K_FLOAT 0x80 /* Has float insns */ +#define EF_M68K_MAC 0x10 /* MAC */ +#define EF_M68K_EMAC 0x20 /* EMAC */ +#define EF_M68K_EMAC_B 0x30 /* EMAC_B */ +#define EF_M68K_FLOAT 0x40 /* Has float insns */ #define EF_M68K_CF_MASK 0xFF #endif diff --git a/include/elf/mips.h b/include/elf/mips.h index 6afc12f..f22bd4d 100644 --- a/include/elf/mips.h +++ b/include/elf/mips.h @@ -97,6 +97,9 @@ START_RELOC_NUMBERS (elf_mips_reloc_type) RELOC_NUMBER (R_MIPS16_HI16, 104) RELOC_NUMBER (R_MIPS16_LO16, 105) FAKE_RELOC (R_MIPS16_max, 106) + /* These relocations are specific to VxWorks. */ + RELOC_NUMBER (R_MIPS_COPY, 126) + RELOC_NUMBER (R_MIPS_JUMP_SLOT, 127) /* This was a GNU extension used by embedded-PIC. It was co-opted by mips-linux for exception-handling data. It is no longer used, but should continue to be supported by the linker for backward diff --git a/include/elf/x86-64.h b/include/elf/x86-64.h index 74655fb..b09a558 100644 --- a/include/elf/x86-64.h +++ b/include/elf/x86-64.h @@ -54,7 +54,16 @@ START_RELOC_NUMBERS (elf_x86_64_reloc_type) RELOC_NUMBER (R_X86_64_GOTOFF64, 25) /* 64 bit offset to GOT */ RELOC_NUMBER (R_X86_64_GOTPC32, 26) /* 32 bit signed pc relative offset to GOT */ - /* 27 .. 33 */ + RELOC_NUMBER (R_X86_64_GOT64, 27) /* 64 bit GOT entry offset */ + RELOC_NUMBER (R_X86_64_GOTPCREL64, 28) /* 64 bit signed pc relative + offset to GOT entry */ + RELOC_NUMBER (R_X86_64_GOTPC64, 29) /* 64 bit signed pc relative + offset to GOT */ + RELOC_NUMBER (R_X86_64_GOTPLT64, 30) /* like GOT64, but indicates + that PLT entry is needed */ + RELOC_NUMBER (R_X86_64_PLTOFF64, 31) /* 64 bit GOT relative offset + to PLT entry */ + /* 32 .. 33 */ RELOC_NUMBER (R_X86_64_GOTPC32_TLSDESC, 34) /* 32 bit signed pc relative offset to TLS descriptor diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog index 9edfd3f..90bf23f 100644 --- a/include/opcode/ChangeLog +++ b/include/opcode/ChangeLog @@ -1,3 +1,20 @@ +2006-03-28 Nathan Sidwell + + * m68k.h (cpu_m68k, cpu_cf, cpu_m68000, cpu_m68008, cpu_m68010, + cpu_m68020, cpu_m68ec030, cpu_m68040, cpu_m68060, cpu_m68851, + cpu_m68881, cpu_m68882, cpu_cpu32, cpu_cf5200, cpu_cf5206e, + cpu_cf5208, cpu_cf521x, cpu_cf5213, cpu_cf5249, cpu_cf528x, + cpu_cf5307, cpu_cf5329, cpu_cf5407, cpu_cf547x, cpu_cf548x): Remove. + +2006-03-10 Paul Brook + + * arm.h (ARM_AEXT_V7_ARM): Include v6ZK extensions. + +2006-03-04 John David Anglin + + * hppa.h (pa_opcodes): Reorder bb opcodes so that pa10 opcodes come + first. Correct mask of bb "B" opcode. + 2006-02-27 H.J. Lu * i386.h (i386_optab): Support Intel Merom New Instructions. @@ -275,6 +292,14 @@ FloatMF to fldcw, fstcw, fnstcw, and the memory formas of fstsw and fnstsw. +2006-02-07 Nathan Sidwell + + * m68k.h (m68008, m68ec030, m68882): Remove. + (m68k_mask): New. + (cpu_m68k, cpu_cf): New. + (mcf5200, mcf5206e, mcf521x, mcf5249, mcf528x, mcf5307, mcf5407, + mcf5470, mcf5480): Rename to cpu_. Add m680x0 variants. + 2005-01-25 Alexandre Oliva 2004-11-10 Alexandre Oliva diff --git a/include/opcode/arm.h b/include/opcode/arm.h index 3260b2f..1d3aa5a 100644 --- a/include/opcode/arm.h +++ b/include/opcode/arm.h @@ -88,7 +88,7 @@ #define ARM_AEXT_V6KT2 (ARM_AEXT_V6T2 | ARM_EXT_V6K) #define ARM_AEXT_V6ZT2 (ARM_AEXT_V6T2 | ARM_EXT_V6Z) #define ARM_AEXT_V6ZKT2 (ARM_AEXT_V6T2 | ARM_EXT_V6K | ARM_EXT_V6Z) -#define ARM_AEXT_V7_ARM (ARM_AEXT_V6T2 | ARM_EXT_V7) +#define ARM_AEXT_V7_ARM (ARM_AEXT_V6ZKT2 | ARM_EXT_V7) #define ARM_AEXT_V7A (ARM_AEXT_V7_ARM | ARM_EXT_V7A) #define ARM_AEXT_V7R (ARM_AEXT_V7_ARM | ARM_EXT_V7R | ARM_EXT_DIV) #define ARM_AEXT_NOTM \ diff --git a/include/opcode/hppa.h b/include/opcode/hppa.h index 5b08b9d..d1c0e83 100644 --- a/include/opcode/hppa.h +++ b/include/opcode/hppa.h @@ -593,10 +593,10 @@ static const struct pa_opcode pa_opcodes[] = { "addbf", 0xa8000000, 0xfc000000, "?dnx,b,w", pa10, 0}, { "addibt", 0xa4000000, 0xfc000000, "?dn5,b,w", pa10, 0}, { "addibf", 0xac000000, 0xfc000000, "?dn5,b,w", pa10, 0}, +{ "bb", 0xc0004000, 0xffe06000, "?bnx,!,w", pa10, FLAG_STRICT}, { "bb", 0xc0006000, 0xffe06000, "?Bnx,!,w", pa20, FLAG_STRICT}, +{ "bb", 0xc4004000, 0xfc006000, "?bnx,Q,w", pa10, FLAG_STRICT}, { "bb", 0xc4004000, 0xfc004000, "?Bnx,B,w", pa20, FLAG_STRICT}, -{ "bb", 0xc0004000, 0xffe06000, "?bnx,!,w", pa10, FLAG_STRICT}, -{ "bb", 0xc4004000, 0xfc004000, "?bnx,Q,w", pa10, 0}, { "bvb", 0xc0004000, 0xffe04000, "?bnx,w", pa10, 0}, { "clrbts", 0xe8004005, 0xffffffff, "", pa20, FLAG_STRICT}, { "popbts", 0xe8004005, 0xfffff007, "$", pa20, FLAG_STRICT}, diff --git a/include/opcode/m68k.h b/include/opcode/m68k.h index 0d21658..d137d9d 100644 --- a/include/opcode/m68k.h +++ b/include/opcode/m68k.h @@ -53,44 +53,6 @@ #define mfloat (m68881 | m68040 | m68060) #define mmmu (m68851 | m68030 | m68040 | m68060) -/* CPU numbering. There are too many of these to use a bit vector. - These are a one-of-many selection. Choose a numbering scheme that - simply maps onto manufacturer's part numbers. */ - -/* All m68k cpus */ -#define cpu_m68k 0 -/* All coldfire cpus */ -#define cpu_cf 1000000 - -#define cpu_m68000 (cpu_m68k + 68000) -#define cpu_m68008 cpu_m68000 /* Synonym for -m68000. otherwise unused. */ -#define cpu_m68010 (cpu_m68k + 68010) -#define cpu_m68020 (cpu_m68k + 68020) -#define cpu_m68030 (cpu_m68k + 68030) -#define cpu_m68ec030 cpu_m68030 /* Similar enough to -m68030 to ignore - differences; gas will deal with the few - differences. */ -#define cpu_m68040 (cpu_m68k + 68040) -/* There is no 68050. */ -#define cpu_m68060 (cpu_m68k + 68060) -#define cpu_m68851 (cpu_m68k + 68851) -#define cpu_m68881 (cpu_m68k + 68881) -#define cpu_m68882 cpu_m68881 /* Synonym for -m68881. otherwise unused. */ -#define cpu_cpu32 (cpu_m68k + 32) - -#define cpu_cf5200 (cpu_cf + 5200) -#define cpu_cf5206e (cpu_cf + 5206) -#define cpu_cf5208 (cpu_cf + 5208) -#define cpu_cf521x (cpu_cf + 5210) -#define cpu_cf5213 (cpu_cf + 5213) -#define cpu_cf5249 (cpu_cf + 5249) -#define cpu_cf528x (cpu_cf + 5280) -#define cpu_cf5307 (cpu_cf + 5307) -#define cpu_cf5329 (cpu_cf + 5329) -#define cpu_cf5407 (cpu_cf + 5407) -#define cpu_cf547x (cpu_cf + 5470) -#define cpu_cf548x (cpu_cf + 5480) - /* The structure used to hold information for an opcode. */ struct m68k_opcode diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index acdfad0..5007a17 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,15 @@ +2006-03-24 Jim Blandy + + * pex-common.c (pex_run): Simplify output name handling. + +2006-03-12 Jim Blandy + + * pex-common.h (struct pex_obj): Doc fixes. + +2006-03-11 Jim Blandy + + * functions.texi: Regenerate. + 2006-02-21 Ben Elliston * pexecute.c (pwait): Syntax fix for previous change. diff --git a/libiberty/functions.texi b/libiberty/functions.texi index 8b4a50e..a09e207 100644 --- a/libiberty/functions.texi +++ b/libiberty/functions.texi @@ -214,6 +214,26 @@ symbolic name or message. @end deftypefn +@c argv.c:293 +@deftypefn Extension void expandargv (int *@var{argcp}, char ***@var{argvp}) + +The @var{argcp} and @code{argvp} arguments are pointers to the usual +@code{argc} and @code{argv} arguments to @code{main}. This function +looks for arguments that begin with the character @samp{@@}. Any such +arguments are interpreted as ``response files''. The contents of the +response file are interpreted as additional command line options. In +particular, the file is separated into whitespace-separated strings; +each such string is taken as a command-line option. The new options +are inserted in place of the option naming the response file, and +@code{*argcp} and @code{*argvp} will be updated. If the value of +@code{*argvp} is modified by this function, then the new value has +been dynamically allocated and can be deallocated by the caller with +@code{freeargv}. However, most callers will simply call +@code{expandargv} near the beginning of @code{main} and allow the +operating system to free the memory when the program exits. + +@end deftypefn + @c fdmatch.c:23 @deftypefn Extension int fdmatch (int @var{fd1}, int @var{fd2}) @@ -1194,7 +1214,7 @@ translation is found, returns 0. @end deftypefn -@c strverscmp.c:24 +@c strverscmp.c:25 @deftypefun int strverscmp (const char *@var{s1}, const char *@var{s2}) The @code{strverscmp} function compares the string @var{s1} against @var{s2}, considering them as holding indices/version numbers. Return diff --git a/libiberty/pex-common.c b/libiberty/pex-common.c index b2ca6e0..db842ae 100644 --- a/libiberty/pex-common.c +++ b/libiberty/pex-common.c @@ -211,17 +211,10 @@ pex_run (struct pex_obj *obj, int flags, const char *executable, outname_allocated = 0; } - if (!outname_allocated) - { - obj->next_input_name = outname; - obj->next_input_name_allocated = 0; - } - else - { - obj->next_input_name = outname; - outname_allocated = 0; - obj->next_input_name_allocated = 1; - } + /* Hand off ownership of outname to the next stage. */ + obj->next_input_name = outname; + obj->next_input_name_allocated = outname_allocated; + outname_allocated = 0; } else { diff --git a/libiberty/pex-common.h b/libiberty/pex-common.h index bd4f908..b70b38d 100644 --- a/libiberty/pex-common.h +++ b/libiberty/pex-common.h @@ -61,7 +61,7 @@ struct pex_obj int next_input_name_allocated; /* Number of child processes. */ int count; - /* PIDs of child processes; array allocated using maloc. */ + /* PIDs of child processes; array allocated using malloc. */ long *children; /* Exit statuses of child processes; array allocated using malloc. */ int *status; @@ -88,10 +88,11 @@ struct pex_funcs { /* Open file NAME for reading. If BINARY is non-zero, open in binary mode. Return >= 0 on success, -1 on error. */ - int (*open_read) (struct pex_obj *, const char *name, int binary); + int (*open_read) (struct pex_obj *, const char */* name */, int /* binary */); /* Open file NAME for writing. If BINARY is non-zero, open in binary mode. Return >= 0 on success, -1 on error. */ - int (*open_write) (struct pex_obj *, const char *name, int binary); + int (*open_write) (struct pex_obj *, const char */* name */, + int /* binary */); /* Execute a child process. FLAGS, EXECUTABLE, ARGV, ERR are from pex_run. IN, OUT, ERRDES are each a descriptor, from open_read, open_write, or pipe, or they are one of STDIN_FILE_NO, @@ -99,25 +100,27 @@ struct pex_funcs should be closed. The function should handle the PEX_STDERR_TO_STDOUT flag. Return >= 0 on success, or -1 on error and set *ERRMSG and *ERR. */ - long (*exec_child) (struct pex_obj *, int flags, const char *executable, - char * const * argv, int in, int out, int errdes, - const char **errmsg, int *err); + long (*exec_child) (struct pex_obj *, int /* flags */, + const char */* executable */, char * const * /* argv */, + int /* in */, int /* out */, int /* errdes */, + const char **/* errmsg */, int */* err */); /* Close a descriptor. Return 0 on success, -1 on error. */ int (*close) (struct pex_obj *, int); /* Wait for a child to complete, returning exit status in *STATUS and time in *TIME (if it is not null). CHILD is from fork. DONE is 1 if this is called via pex_free. ERRMSG and ERR are as in fork. Return 0 on success, -1 on error. */ - int (*wait) (struct pex_obj *, long, int *status, struct pex_time *time, - int done, const char **errmsg, int *err); + int (*wait) (struct pex_obj *, long /* child */, int * /* status */, + struct pex_time * /* time */, int /* done */, + const char ** /* errmsg */, int * /* err */); /* Create a pipe (only called if PEX_USE_PIPES is set) storing two - descriptin in *P. If BINARY is non-zero, open in binary mode. - Return 0 on success, -1 on error. */ - int (*pipe) (struct pex_obj *, int *p, int binary); + descriptors in P[0] and P[1]. If BINARY is non-zero, open in + binary mode. Return 0 on success, -1 on error. */ + int (*pipe) (struct pex_obj *, int * /* p */, int /* binary */); /* Get a FILE pointer to read from a file descriptor (only called if PEX_USE_PIPES is set). If BINARY is non-zero, open in binary mode. Return pointer on success, NULL on error. */ - FILE * (*fdopenr) (struct pex_obj *, int fd, int binary); + FILE * (*fdopenr) (struct pex_obj *, int /* fd */, int /* binary */); /* Free any system dependent data associated with OBJ. May be NULL if there is nothing to do. */ void (*cleanup) (struct pex_obj *); diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 8d9094a..ae0eb64 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,8 +1,68 @@ +2006-03-16 Bernd Schmidt + + * bfin-dis.c (decode_dsp32shiftimm_0): Simplify and correct the + logic to identify halfword shifts. + +2006-03-16 Paul Brook + + * arm-dis.c (arm_opcodes): Rename swi to svc. + (thumb_opcodes): Ditto. + +2006-03-13 DJ Delorie + + * m32c-asm.c: Regenerate. + * m32c-desc.c: Likewise. + * m32c-desc.h: Likewise. + * m32c-dis.c: Likewise. + * m32c-ibld.c: Likewise. + * m32c-opc.c: Likewise. + * m32c-opc.h: Likewise. + +2006-03-10 DJ Delorie + + * m32c-desc.c: Regenerate with mul.l, mulu.l. + * m32c-opc.c: Likewise. + * m32c-opc.h: Likewise. + + +2006-03-09 Nick Clifton + + * po/sv.po: Updated Swedish translation. + +2006-03-07 H.J. Lu + + PR binutils/2428 + * i386-dis.c (REP_Fixup): New function. + (AL): Remove duplicate. + (Xbr): New. + (Xvr): Likewise. + (Ybr): Likewise. + (Yvr): Likewise. + (indirDXr): Likewise. + (ALr): Likewise. + (eAXr): Likewise. + (dis386): Updated entries of ins, outs, movs, lods and stos. + +2006-03-05 Nick Clifton + + * cgen-ibld.in (insert_normal): Cope with attempts to insert a + signed 32-bit value into an unsigned 32-bit field when the host is + a 64-bit machine. + * fr30-ibld.c: Regenerate. + * frv-ibld.c: Regenerate. + * ip2k-ibld.c: Regenerate. + * iq2000-asm.c: Regenerate. + * iq2000-ibld.c: Regenerate. + * m32c-ibld.c: Regenerate. + * m32r-ibld.c: Regenerate. + * openrisc-ibld.c: Regenerate. + * xc16x-ibld.c: Regenerate. + * xstormy16-ibld.c: Regenerate. + 2006-03-03 Shrirang Khisti diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c index b5167e9..bc5b52c 100644 --- a/opcodes/arm-dis.c +++ b/opcodes/arm-dis.c @@ -659,7 +659,7 @@ static const struct opcode32 arm_opcodes[] = {ARM_EXT_V1, 0x08000000, 0x0e100000, "stm%c%23?id%24?ba\t%16-19r%21'!, %m%22'^"}, {ARM_EXT_V1, 0x08100000, 0x0e100000, "ldm%c%23?id%24?ba\t%16-19r%21'!, %m%22'^"}, {ARM_EXT_V1, 0x0a000000, 0x0e000000, "b%24'l%c\t%b"}, - {ARM_EXT_V1, 0x0f000000, 0x0f000000, "swi%c\t%0-23x"}, + {ARM_EXT_V1, 0x0f000000, 0x0f000000, "svc%c\t%0-23x"}, /* The rest. */ {ARM_EXT_V1, 0x00000000, 0x00000000, "undefined instruction %0-31x"}, @@ -798,7 +798,7 @@ static const struct opcode16 thumb_opcodes[] = {ARM_EXT_V4T, 0xC000, 0xF800, "stmia\t%8-10r!, %M"}, {ARM_EXT_V4T, 0xC800, 0xF800, "ldmia\t%8-10r!, %M"}, /* format 17 */ - {ARM_EXT_V4T, 0xDF00, 0xFF00, "swi\t%0-7d"}, + {ARM_EXT_V4T, 0xDF00, 0xFF00, "svc\t%0-7d"}, /* format 16 */ {ARM_EXT_V4T, 0xD000, 0xF000, "b%8-11c.n\t%0-7B"}, /* format 18 */ diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c index adeb7d0..0dc2922 100644 --- a/opcodes/bfin-dis.c +++ b/opcodes/bfin-dis.c @@ -4034,130 +4034,48 @@ decode_dsp32shiftimm_0 (TIword iw0, TIword iw1, disassemble_info *outf) int HLs = ((iw1 >> DSP32ShiftImm_HLs_bits) & DSP32ShiftImm_HLs_mask); - if (HLs == 0 && sop == 0 && sopcde == 0) - { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, ">>>"); - OUTS (outf, uimm4 (newimmag)); - } - else if (HLs == 1 && sop == 0 && sopcde == 0) + if (sop == 0 && sopcde == 0) { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, ">>>"); - OUTS (outf, uimm4 (newimmag)); - } - else if (HLs == 2 && sop == 0 && sopcde == 0) - { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, ">>>"); - OUTS (outf, uimm4 (newimmag)); - } - else if (HLs == 3 && sop == 0 && sopcde == 0) - { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, ">>>"); + OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0)); + OUTS (outf, " = "); + OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1)); + OUTS (outf, " >>> "); OUTS (outf, uimm4 (newimmag)); } - else if (HLs == 0 && sop == 1 && sopcde == 0) - { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, "<<"); - OUTS (outf, uimm4 (immag)); - OUTS (outf, "(S)"); - } - else if (HLs == 1 && sop == 1 && sopcde == 0) - { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, "<<"); - OUTS (outf, uimm4 (immag)); - OUTS (outf, "(S)"); - } - else if (HLs == 2 && sop == 1 && sopcde == 0) - { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, "<<"); - OUTS (outf, uimm4 (immag)); - OUTS (outf, "(S)"); - } - else if (HLs == 3 && sop == 1 && sopcde == 0) - { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, "<<"); - OUTS (outf, uimm4 (immag)); - OUTS (outf, "(S)"); - } - else if (HLs == 0 && sop == 2 && sopcde == 0 && bit8 == 0) + else if (sop == 1 && sopcde == 0 && bit8 == 0) { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, "<<"); + OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0)); + OUTS (outf, " = "); + OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1)); + OUTS (outf, " << "); OUTS (outf, uimm4 (immag)); + OUTS (outf, " (S)"); } - else if (HLs == 0 && sop == 2 && sopcde == 0 && bit8 == 1) - { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, ">>"); - OUTS (outf, uimm4 (newimmag)); - } - else if (HLs == 1 && sop == 2 && sopcde == 0) - { - OUTS (outf, dregs_lo (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, ">>"); - OUTS (outf, uimm4 (newimmag)); - } - else if (HLs == 2 && sop == 2 && sopcde == 0 && bit8 == 1) + else if (sop == 1 && sopcde == 0 && bit8 == 1) { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, ">>"); + OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0)); + OUTS (outf, " = "); + OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1)); + OUTS (outf, " >>> "); OUTS (outf, uimm4 (newimmag)); + OUTS (outf, " (S)"); } - else if (HLs == 2 && sop == 2 && sopcde == 0 && bit8 == 0) + else if (sop == 2 && sopcde == 0 && bit8 == 0) { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_lo (src1)); - OUTS (outf, "<<"); + OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0)); + OUTS (outf, " = "); + OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1)); + OUTS (outf, " << "); OUTS (outf, uimm4 (immag)); } - else if (HLs == 3 && sop == 2 && sopcde == 0 && bit8 == 1) + else if (sop == 2 && sopcde == 0 && bit8 == 1) { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, ">>"); + OUTS (outf, (HLs & 2) ? dregs_hi (dst0) : dregs_lo (dst0)); + OUTS (outf, " = "); + OUTS (outf, (HLs & 1) ? dregs_hi (src1) : dregs_lo (src1)); + OUTS (outf, " >> "); OUTS (outf, uimm4 (newimmag)); } - else if (HLs == 3 && sop == 2 && sopcde == 0 && bit8 == 0) - { - OUTS (outf, dregs_hi (dst0)); - OUTS (outf, "="); - OUTS (outf, dregs_hi (src1)); - OUTS (outf, "<<"); - OUTS (outf, uimm4 (immag)); - } else if (sop == 2 && sopcde == 3 && HLs == 1) { OUTS (outf, "A1= ROT A1 BY "); diff --git a/opcodes/cgen-ibld.in b/opcodes/cgen-ibld.in index 77deeed..626e655 100644 --- a/opcodes/cgen-ibld.in +++ b/opcodes/cgen-ibld.in @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } diff --git a/opcodes/fr30-ibld.c b/opcodes/fr30-ibld.c index 48dad67..15be3f3 100644 --- a/opcodes/fr30-ibld.c +++ b/opcodes/fr30-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/opcodes/frv-ibld.c b/opcodes/frv-ibld.c index 9fe2531..2283371 100644 --- a/opcodes/frv-ibld.c +++ b/opcodes/frv-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 06a842e..f73e883 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -101,6 +101,7 @@ static void INVLPG_Fixup (int, int); static void BadOp (void); static void SEG_Fixup (int, int); static void VMX_Fixup (int, int); +static void REP_Fixup (int, int); struct dis_private { /* Points to first byte not fetched. */ @@ -276,7 +277,6 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr) #define eSI OP_IMREG, eSI_reg #define eDI OP_IMREG, eDI_reg #define AL OP_IMREG, al_reg -#define AL OP_IMREG, al_reg #define CL OP_IMREG, cl_reg #define DL OP_IMREG, dl_reg #define BL OP_IMREG, bl_reg @@ -315,6 +315,15 @@ fetch_data (struct disassemble_info *info, bfd_byte *addr) #define OPSUF OP_3DNowSuffix, 0 #define OPSIMD OP_SIMD_Suffix, 0 +/* Used handle "rep" prefix for string instructions. */ +#define Xbr REP_Fixup, eSI_reg +#define Xvr REP_Fixup, eSI_reg +#define Ybr REP_Fixup, eDI_reg +#define Yvr REP_Fixup, eDI_reg +#define indirDXr REP_Fixup, indir_dx_reg +#define ALr REP_Fixup, al_reg +#define eAXr REP_Fixup, eAX_reg + #define cond_jump_flag NULL, cond_jump_mode #define loop_jcxz_flag NULL, loop_jcxz_mode @@ -629,10 +638,10 @@ static const struct dis386 dis386[] = { { "imulS", Gv, Ev, Iv }, { "pushT", sIb, XX, XX }, { "imulS", Gv, Ev, sIb }, - { "ins{b||b|}", Yb, indirDX, XX }, - { "ins{R||R|}", Yv, indirDX, XX }, - { "outs{b||b|}", indirDX, Xb, XX }, - { "outs{R||R|}", indirDX, Xv, XX }, + { "ins{b||b|}", Ybr, indirDX, XX }, + { "ins{R||R|}", Yvr, indirDX, XX }, + { "outs{b||b|}", indirDXr, Xb, XX }, + { "outs{R||R|}", indirDXr, Xv, XX }, /* 70 */ { "joH", Jb, XX, cond_jump_flag }, { "jnoH", Jb, XX, cond_jump_flag }, @@ -692,17 +701,17 @@ static const struct dis386 dis386[] = { { "movS", eAX, Ov, XX }, { "movB", Ob, AL, XX }, { "movS", Ov, eAX, XX }, - { "movs{b||b|}", Yb, Xb, XX }, - { "movs{R||R|}", Yv, Xv, XX }, + { "movs{b||b|}", Ybr, Xb, XX }, + { "movs{R||R|}", Yvr, Xv, XX }, { "cmps{b||b|}", Xb, Yb, XX }, { "cmps{R||R|}", Xv, Yv, XX }, /* a8 */ { "testB", AL, Ib, XX }, { "testS", eAX, Iv, XX }, - { "stosB", Yb, AL, XX }, - { "stosS", Yv, eAX, XX }, - { "lodsB", AL, Xb, XX }, - { "lodsS", eAX, Xv, XX }, + { "stosB", Ybr, AL, XX }, + { "stosS", Yvr, eAX, XX }, + { "lodsB", ALr, Xb, XX }, + { "lodsS", eAXr, Xv, XX }, { "scasB", AL, Yb, XX }, { "scasS", eAX, Yv, XX }, /* b0 */ @@ -4777,3 +4786,76 @@ OP_VMX (int bytemode, int sizeflag) strcpy (obuf, "vmptrld"); OP_E (bytemode, sizeflag); } + +static void +REP_Fixup (int bytemode, int sizeflag) +{ + /* The 0xf3 prefix should be displayed as "rep" for ins, outs, movs, + lods and stos. */ + size_t ilen = 0; + + if (prefixes & PREFIX_REPZ) + switch (*insn_codep) + { + case 0x6e: /* outsb */ + case 0x6f: /* outsw/outsl */ + case 0xa4: /* movsb */ + case 0xa5: /* movsw/movsl/movsq */ + if (!intel_syntax) + ilen = 5; + else + ilen = 4; + break; + case 0xaa: /* stosb */ + case 0xab: /* stosw/stosl/stosq */ + case 0xac: /* lodsb */ + case 0xad: /* lodsw/lodsl/lodsq */ + if (!intel_syntax && (sizeflag & SUFFIX_ALWAYS)) + ilen = 5; + else + ilen = 4; + break; + case 0x6c: /* insb */ + case 0x6d: /* insl/insw */ + if (!intel_syntax) + ilen = 4; + else + ilen = 3; + break; + default: + abort (); + break; + } + + if (ilen != 0) + { + size_t olen; + char *p; + + olen = strlen (obuf); + p = obuf + olen - ilen - 1 - 4; + /* Handle "repz [addr16|addr32]". */ + if ((prefixes & PREFIX_ADDR)) + p -= 1 + 6; + + memmove (p + 3, p + 4, olen - (p + 3 - obuf)); + } + + switch (bytemode) + { + case al_reg: + case eAX_reg: + case indir_dx_reg: + OP_IMREG (bytemode, sizeflag); + break; + case eDI_reg: + OP_ESreg (bytemode, sizeflag); + break; + case eSI_reg: + OP_DSreg (bytemode, sizeflag); + break; + default: + abort (); + break; + } +} diff --git a/opcodes/ip2k-ibld.c b/opcodes/ip2k-ibld.c index cd39392..fb08027 100644 --- a/opcodes/ip2k-ibld.c +++ b/opcodes/ip2k-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/opcodes/iq2000-asm.c b/opcodes/iq2000-asm.c index 0ec59ce..9259086 100644 --- a/opcodes/iq2000-asm.c +++ b/opcodes/iq2000-asm.c @@ -213,8 +213,8 @@ parse_hi16 (CGEN_CPU_DESC cd, 1 to the resultant %hi value. */ if (value & 0x8000) value += 0x10000; - value &= 0xffff; value >>= 16; + value &= 0xffff; } *valuep = value; diff --git a/opcodes/iq2000-ibld.c b/opcodes/iq2000-ibld.c index 9be3f0f..eadf0a3 100644 --- a/opcodes/iq2000-ibld.c +++ b/opcodes/iq2000-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/opcodes/m32c-asm.c b/opcodes/m32c-asm.c index e2d8c49..9407ed8 100644 --- a/opcodes/m32c-asm.c +++ b/opcodes/m32c-asm.c @@ -504,6 +504,24 @@ parse_imm3_S (CGEN_CPU_DESC cd, const char **strp, } static const char * +parse_bit3_S (CGEN_CPU_DESC cd, const char **strp, + int opindex, signed long *valuep) +{ + const char *errmsg = 0; + signed long value; + + errmsg = cgen_parse_signed_integer (cd, strp, opindex, & value); + if (errmsg) + return errmsg; + + if (value < 0 || value > 7) + return _("immediate is out of range 0-7"); + + *valuep = value; + return 0; +} + +static const char * parse_lab_5_3 (CGEN_CPU_DESC cd, const char **strp, int opindex ATTRIBUTE_UNUSED, @@ -933,6 +951,9 @@ m32c_cgen_parse_operand (CGEN_CPU_DESC cd, case M32C_OPERAND_BIT16RN : errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_gr_HI, & fields->f_dst16_rn); break; + case M32C_OPERAND_BIT3_S : + errmsg = parse_bit3_S (cd, strp, M32C_OPERAND_BIT3_S, (long *) (& fields->f_imm3_S)); + break; case M32C_OPERAND_BIT32ANPREFIXED : errmsg = cgen_parse_keyword (cd, strp, & m32c_cgen_opval_h_ar, & fields->f_dst32_an_prefixed); break; diff --git a/opcodes/m32c-desc.c b/opcodes/m32c-desc.c index 850c168..c87ddc7 100644 --- a/opcodes/m32c-desc.c +++ b/opcodes/m32c-desc.c @@ -1732,6 +1732,10 @@ const CGEN_OPERAND m32c_cgen_operand_table[] = { "Imm3-S", M32C_OPERAND_IMM3_S, HW_H_SINT, 2, 3, { 2, { (const PTR) &M32C_F_IMM3_S_MULTI_IFIELD[0] } }, { 0|A(VIRTUAL), { { { (1<f_dst16_rn, 0); break; + case M32C_OPERAND_BIT3_S : + print_normal (cd, info, fields->f_imm3_S, 0|(1<f_dst32_an_prefixed, 0); break; diff --git a/opcodes/m32c-ibld.c b/opcodes/m32c-ibld.c index 62c753b..31d5f9f 100644 --- a/opcodes/m32c-ibld.c +++ b/opcodes/m32c-ibld.c @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -570,6 +578,20 @@ m32c_cgen_insert_operand (CGEN_CPU_DESC cd, case M32C_OPERAND_BIT16RN : errmsg = insert_normal (cd, fields->f_dst16_rn, 0, 0, 14, 2, 32, total_length, buffer); break; + case M32C_OPERAND_BIT3_S : + { +{ + FLD (f_7_1) = ((((FLD (f_imm3_S)) - (1))) & (1)); + FLD (f_2_2) = ((((unsigned int) (((FLD (f_imm3_S)) - (1))) >> (1))) & (3)); +} + errmsg = insert_normal (cd, fields->f_2_2, 0, 0, 2, 2, 32, total_length, buffer); + if (errmsg) + break; + errmsg = insert_normal (cd, fields->f_7_1, 0, 0, 7, 1, 32, total_length, buffer); + if (errmsg) + break; + } + break; case M32C_OPERAND_BIT32ANPREFIXED : errmsg = insert_normal (cd, fields->f_dst32_an_prefixed, 0, 0, 17, 1, 32, total_length, buffer); break; @@ -1730,6 +1752,17 @@ m32c_cgen_extract_operand (CGEN_CPU_DESC cd, case M32C_OPERAND_BIT16RN : length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 2, 32, total_length, pc, & fields->f_dst16_rn); break; + case M32C_OPERAND_BIT3_S : + { + length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 2, 32, total_length, pc, & fields->f_2_2); + if (length <= 0) break; + length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 1, 32, total_length, pc, & fields->f_7_1); + if (length <= 0) break; +{ + FLD (f_imm3_S) = ((((((FLD (f_2_2)) << (1))) | (FLD (f_7_1)))) + (1)); +} + } + break; case M32C_OPERAND_BIT32ANPREFIXED : length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_dst32_an_prefixed); break; @@ -2853,6 +2886,9 @@ m32c_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, case M32C_OPERAND_BIT16RN : value = fields->f_dst16_rn; break; + case M32C_OPERAND_BIT3_S : + value = fields->f_imm3_S; + break; case M32C_OPERAND_BIT32ANPREFIXED : value = fields->f_dst32_an_prefixed; break; @@ -3443,6 +3479,9 @@ m32c_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, case M32C_OPERAND_BIT16RN : value = fields->f_dst16_rn; break; + case M32C_OPERAND_BIT3_S : + value = fields->f_imm3_S; + break; case M32C_OPERAND_BIT32ANPREFIXED : value = fields->f_dst32_an_prefixed; break; @@ -4038,6 +4077,9 @@ m32c_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, case M32C_OPERAND_BIT16RN : fields->f_dst16_rn = value; break; + case M32C_OPERAND_BIT3_S : + fields->f_imm3_S = value; + break; case M32C_OPERAND_BIT32ANPREFIXED : fields->f_dst32_an_prefixed = value; break; @@ -4606,6 +4648,9 @@ m32c_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, case M32C_OPERAND_BIT16RN : fields->f_dst16_rn = value; break; + case M32C_OPERAND_BIT3_S : + fields->f_imm3_S = value; + break; case M32C_OPERAND_BIT32ANPREFIXED : fields->f_dst32_an_prefixed = value; break; diff --git a/opcodes/m32c-opc.c b/opcodes/m32c-opc.c index ad4ab60..2d051cb 100644 --- a/opcodes/m32c-opc.c +++ b/opcodes/m32c-opc.c @@ -5625,6 +5625,22 @@ static const CGEN_IFMT ifmt_push16_b_s_rn_Rn16_push_S_derived ATTRIBUTE_UNUSED = 8, 8, 0xf7, { { F (F_0_4) }, { F (F_4_1) }, { F (F_5_3) }, { 0 } } }; +static const CGEN_IFMT ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived ATTRIBUTE_UNUSED = { + 8, 8, 0xfb, { { F (F_0_4) }, { F (F_6_2) }, { F (F_5_1) }, { F (F_4_1) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI ATTRIBUTE_UNUSED = { + 16, 16, 0xfb00, { { F (F_0_4) }, { F (F_6_2) }, { F (F_DSP_8_U8) }, { F (F_4_1) }, { F (F_DST16_RN_QI_S) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI ATTRIBUTE_UNUSED = { + 16, 16, 0xfb00, { { F (F_0_4) }, { F (F_6_2) }, { F (F_DSP_8_S8) }, { F (F_4_1) }, { F (F_DST16_RN_QI_S) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI ATTRIBUTE_UNUSED = { + 24, 24, 0xfb0000, { { F (F_0_4) }, { F (F_6_2) }, { F (F_DSP_8_U16) }, { F (F_4_1) }, { F (F_DST16_RN_QI_S) }, { 0 } } +}; + static const CGEN_IFMT ifmt_not16_b_s_dst16_3_S_R0l_direct_QI ATTRIBUTE_UNUSED = { 8, 8, 0xff, { { F (F_0_4) }, { F (F_5_3) }, { F (F_4_1) }, { 0 } } }; @@ -5649,6 +5665,54 @@ static const CGEN_IFMT ifmt_mulex_dst32_R3_direct_Unprefixed_HI ATTRIBUTE_UNUSED 16, 16, 0xffff, { { F (F_0_4) }, { F (F_4_3) }, { F (F_8_2) }, { F (F_7_1) }, { F (F_10_2) }, { F (F_12_4) }, { 0 } } }; +static const CGEN_IFMT ifmt_mulu_l_dst32_Rn_direct_Prefixed_SI ATTRIBUTE_UNUSED = { + 24, 24, 0xffff3f, { { F (F_0_4) }, { F (F_12_3) }, { F (F_DST32_RN_PREFIXED_SI) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_An_direct_Prefixed_SI ATTRIBUTE_UNUSED = { + 24, 24, 0xffffbf, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_An_indirect_Prefixed_SI ATTRIBUTE_UNUSED = { + 24, 24, 0xffffbf, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_8_An_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 32, 0xffffbf00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DSP_24_U8) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_16_An_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 40, 0xffffbf00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DSP_24_U16) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_24_An_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 48, 0xffffbf00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DSP_24_U24) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_8_SB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 32, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U8) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_16_SB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 40, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U16) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_8_FB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 32, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_S8) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_16_FB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 40, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_S16) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_16_absolute_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 40, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U16) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + +static const CGEN_IFMT ifmt_mulu_l_dst32_24_24_absolute_Prefixed_SI ATTRIBUTE_UNUSED = { + 32, 48, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U24) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } +}; + static const CGEN_IFMT ifmt_movhh32_src_r0l_dst32_Rn_direct_Prefixed_QI ATTRIBUTE_UNUSED = { 24, 24, 0xffff3f, { { F (F_0_4) }, { F (F_12_3) }, { F (F_DST32_RN_PREFIXED_QI) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } }; @@ -5949,22 +6013,6 @@ static const CGEN_IFMT ifmt_mov32_b_dst32_2_S_basic_r1l_dst32_2_S_R0l_direct_QI 8, 8, 0xff, { { F (F_0_2) }, { F (F_2_2) }, { F (F_4_3) }, { F (F_7_1) }, { 0 } } }; -static const CGEN_IFMT ifmt_mov16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived ATTRIBUTE_UNUSED = { - 8, 8, 0xfb, { { F (F_0_4) }, { F (F_6_2) }, { F (F_5_1) }, { F (F_4_1) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI ATTRIBUTE_UNUSED = { - 16, 16, 0xfb00, { { F (F_0_4) }, { F (F_6_2) }, { F (F_DSP_8_U8) }, { F (F_4_1) }, { F (F_DST16_RN_QI_S) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI ATTRIBUTE_UNUSED = { - 16, 16, 0xfb00, { { F (F_0_4) }, { F (F_6_2) }, { F (F_DSP_8_S8) }, { F (F_4_1) }, { F (F_DST16_RN_QI_S) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI ATTRIBUTE_UNUSED = { - 24, 24, 0xfb0000, { { F (F_0_4) }, { F (F_6_2) }, { F (F_DSP_8_U16) }, { F (F_4_1) }, { F (F_DST16_RN_QI_S) }, { 0 } } -}; - static const CGEN_IFMT ifmt_mov32_l_16_8_Unprefixed_24_Unprefixed_src32_16_8_An_relative_Unprefixed_SI_dst32_Rn_direct_Unprefixed_SI ATTRIBUTE_UNUSED = { 24, 24, 0xff2f00, { { F (F_0_1) }, { F (F_1_3) }, { F (F_10_1) }, { F (F_DSP_16_U8) }, { F (F_SRC32_AN_UNPREFIXED) }, { F (F_4_3) }, { F (F_DST32_RN_UNPREFIXED_SI) }, { F (F_7_1) }, { F (F_12_4) }, { 0 } } }; @@ -7057,54 +7105,6 @@ static const CGEN_IFMT ifmt_jsri16a_dst16_16_8_SI_dst16_16_8_FB_relative_SI ATTR 24, 24, 0xffff00, { { F (F_0_4) }, { F (F_12_4) }, { F (F_DSP_16_S8) }, { F (F_4_4) }, { F (F_8_4) }, { 0 } } }; -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_Rn_direct_Prefixed_SI ATTRIBUTE_UNUSED = { - 24, 24, 0xffff3f, { { F (F_0_4) }, { F (F_12_3) }, { F (F_DST32_RN_PREFIXED_SI) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_direct_Prefixed_SI ATTRIBUTE_UNUSED = { - 24, 24, 0xffffbf, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_indirect_Prefixed_SI ATTRIBUTE_UNUSED = { - 24, 24, 0xffffbf, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_An_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 32, 0xffffbf00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DSP_24_U8) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_An_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 40, 0xffffbf00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DSP_24_U16) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_An_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 48, 0xffffbf00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_1) }, { F (F_DSP_24_U24) }, { F (F_DST32_AN_PREFIXED) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_SB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 32, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U8) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_SB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 40, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U16) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_FB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 32, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_S8) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_FB_relative_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 40, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_S16) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_absolute_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 40, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U16) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - -static const CGEN_IFMT ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_absolute_Prefixed_SI ATTRIBUTE_UNUSED = { - 32, 48, 0xffffff00, { { F (F_0_4) }, { F (F_12_3) }, { F (F_16_2) }, { F (F_DSP_24_U24) }, { F (F_4_4) }, { F (F_8_4) }, { F (F_15_1) }, { F (F_18_2) }, { F (F_20_4) }, { 0 } } -}; - static const CGEN_IFMT ifmt_cmp32_w_S_src2_r0_HI_src32_2_S_8_SB_relative_HI ATTRIBUTE_UNUSED = { 16, 16, 0xff00, { { F (F_0_2) }, { F (F_2_2) }, { F (F_DSP_8_U8) }, { F (F_4_3) }, { F (F_7_1) }, { 0 } } }; @@ -7709,6 +7709,10 @@ static const CGEN_IFMT ifmt_brk16 ATTRIBUTE_UNUSED = { 8, 8, 0xff, { { F (F_0_4) }, { F (F_4_4) }, { 0 } } }; +static const CGEN_IFMT ifmt_btst_s ATTRIBUTE_UNUSED = { + 24, 24, 0xce0000, { { F (F_0_2) }, { F (F_IMM3_S) }, { F (F_4_3) }, { F (F_DSP_8_U16) }, { 0 } } +}; + static const CGEN_IFMT ifmt_dec16_w ATTRIBUTE_UNUSED = { 8, 8, 0xf7, { { F (F_0_4) }, { F (F_DST16_AN_S) }, { F (F_5_3) }, { 0 } } }; @@ -24650,114 +24654,138 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, ' ', OP (DSP_16_U24), 0 } }, & ifmt_shl32_b_dst_dst32_16_24_absolute_Unprefixed_QI, { 0xb6af0000 } }, -/* pop.w $Dst16RnHI */ +/* pop.w${G} $Dst16RnHI */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DST16RNHI), 0 } }, + { { MNEM, OP (G), ' ', OP (DST16RNHI), 0 } }, & ifmt_rorc16_w_16_dst16_Rn_direct_HI, { 0x75d0 } }, -/* pop.w $Dst16AnHI */ +/* pop.w${G} $Dst16AnHI */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DST16ANHI), 0 } }, + { { MNEM, OP (G), ' ', OP (DST16ANHI), 0 } }, & ifmt_rorc16_w_16_dst16_An_direct_HI, { 0x75d4 } }, -/* pop.w [$Dst16An] */ +/* pop.w${G} [$Dst16An] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '[', OP (DST16AN), ']', 0 } }, + { { MNEM, OP (G), ' ', '[', OP (DST16AN), ']', 0 } }, & ifmt_rorc16_w_16_dst16_An_indirect_HI, { 0x75d6 } }, -/* pop.w ${Dsp-16-u8}[$Dst16An] */ +/* pop.w${G} ${Dsp-16-u8}[$Dst16An] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U8), '[', OP (DST16AN), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U8), '[', OP (DST16AN), ']', 0 } }, & ifmt_rorc16_w_16_dst16_16_8_An_relative_HI, { 0x75d800 } }, -/* pop.w ${Dsp-16-u16}[$Dst16An] */ +/* pop.w${G} ${Dsp-16-u16}[$Dst16An] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U16), '[', OP (DST16AN), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U16), '[', OP (DST16AN), ']', 0 } }, & ifmt_rorc16_w_16_dst16_16_16_An_relative_HI, { 0x75dc0000 } }, -/* pop.w ${Dsp-16-u8}[sb] */ +/* pop.w${G} ${Dsp-16-u8}[sb] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U8), '[', 's', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U8), '[', 's', 'b', ']', 0 } }, & ifmt_rorc16_w_16_dst16_16_8_SB_relative_HI, { 0x75da00 } }, -/* pop.w ${Dsp-16-u16}[sb] */ +/* pop.w${G} ${Dsp-16-u16}[sb] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U16), '[', 's', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U16), '[', 's', 'b', ']', 0 } }, & ifmt_rorc16_w_16_dst16_16_16_SB_relative_HI, { 0x75de0000 } }, -/* pop.w ${Dsp-16-s8}[fb] */ +/* pop.w${G} ${Dsp-16-s8}[fb] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_S8), '[', 'f', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_S8), '[', 'f', 'b', ']', 0 } }, & ifmt_rorc16_w_16_dst16_16_8_FB_relative_HI, { 0x75db00 } }, -/* pop.w ${Dsp-16-u16} */ +/* pop.w${G} ${Dsp-16-u16} */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U16), 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U16), 0 } }, & ifmt_rorc16_w_16_dst16_16_16_absolute_HI, { 0x75df0000 } }, -/* pop.b $Dst16RnQI */ +/* pop.b${G} $Dst16RnQI */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DST16RNQI), 0 } }, + { { MNEM, OP (G), ' ', OP (DST16RNQI), 0 } }, & ifmt_rorc16_b_16_dst16_Rn_direct_QI, { 0x74d0 } }, -/* pop.b $Dst16AnQI */ +/* pop.b${G} $Dst16AnQI */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DST16ANQI), 0 } }, + { { MNEM, OP (G), ' ', OP (DST16ANQI), 0 } }, & ifmt_rorc16_b_16_dst16_An_direct_QI, { 0x74d4 } }, -/* pop.b [$Dst16An] */ +/* pop.b${G} [$Dst16An] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '[', OP (DST16AN), ']', 0 } }, + { { MNEM, OP (G), ' ', '[', OP (DST16AN), ']', 0 } }, & ifmt_rorc16_b_16_dst16_An_indirect_QI, { 0x74d6 } }, -/* pop.b ${Dsp-16-u8}[$Dst16An] */ +/* pop.b${G} ${Dsp-16-u8}[$Dst16An] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U8), '[', OP (DST16AN), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U8), '[', OP (DST16AN), ']', 0 } }, & ifmt_rorc16_b_16_dst16_16_8_An_relative_QI, { 0x74d800 } }, -/* pop.b ${Dsp-16-u16}[$Dst16An] */ +/* pop.b${G} ${Dsp-16-u16}[$Dst16An] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U16), '[', OP (DST16AN), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U16), '[', OP (DST16AN), ']', 0 } }, & ifmt_rorc16_b_16_dst16_16_16_An_relative_QI, { 0x74dc0000 } }, -/* pop.b ${Dsp-16-u8}[sb] */ +/* pop.b${G} ${Dsp-16-u8}[sb] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U8), '[', 's', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U8), '[', 's', 'b', ']', 0 } }, & ifmt_rorc16_b_16_dst16_16_8_SB_relative_QI, { 0x74da00 } }, -/* pop.b ${Dsp-16-u16}[sb] */ +/* pop.b${G} ${Dsp-16-u16}[sb] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U16), '[', 's', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U16), '[', 's', 'b', ']', 0 } }, & ifmt_rorc16_b_16_dst16_16_16_SB_relative_QI, { 0x74de0000 } }, -/* pop.b ${Dsp-16-s8}[fb] */ +/* pop.b${G} ${Dsp-16-s8}[fb] */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_S8), '[', 'f', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_S8), '[', 'f', 'b', ']', 0 } }, & ifmt_rorc16_b_16_dst16_16_8_FB_relative_QI, { 0x74db00 } }, -/* pop.b ${Dsp-16-u16} */ +/* pop.b${G} ${Dsp-16-u16} */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', OP (DSP_16_U16), 0 } }, + { { MNEM, OP (G), ' ', OP (DSP_16_U16), 0 } }, & ifmt_rorc16_b_16_dst16_16_16_absolute_QI, { 0x74df0000 } }, +/* or.b${S} ${SrcDst16-r0l-r0h-S-normal} */ + { + { 0, 0, 0, 0 }, + { { MNEM, OP (S), ' ', OP (SRCDST16_R0L_R0H_S_NORMAL), 0 } }, + & ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x18 } + }, +/* or.b${S} ${Dsp-8-u8}[sb],${Dst16RnQI-S} */ + { + { 0, 0, 0, 0 }, + { { MNEM, OP (S), ' ', OP (DSP_8_U8), '[', 's', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x1900 } + }, +/* or.b${S} ${Dsp-8-s8}[fb],${Dst16RnQI-S} */ + { + { 0, 0, 0, 0 }, + { { MNEM, OP (S), ' ', OP (DSP_8_S8), '[', 'f', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x1a00 } + }, +/* or.b${S} ${Dsp-8-u16},${Dst16RnQI-S} */ + { + { 0, 0, 0, 0 }, + { { MNEM, OP (S), ' ', OP (DSP_8_U16), ',', OP (DST16RNQI_S), 0 } }, + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0x1b0000 } + }, /* or.w${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedHI */ { { 0, 0, 0, 0 }, @@ -31346,6 +31374,150 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, ' ', OP (DSP_16_U24), 0 } }, & ifmt_shl32_w_dst_dst32_16_24_absolute_Unprefixed_HI, { 0xc7be0000 } }, +/* mulu.l $Dst32RnPrefixedSI,r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DST32RNPREFIXEDSI), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_Rn_direct_Prefixed_SI, { 0x1890f } + }, +/* mulu.l $Dst32AnPrefixedSI,r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DST32ANPREFIXEDSI), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_An_direct_Prefixed_SI, { 0x1818f } + }, +/* mulu.l [$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_An_indirect_Prefixed_SI, { 0x1810f } + }, +/* mulu.l ${Dsp-24-u8}[$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U8), '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_8_An_relative_Prefixed_SI, { 0x1830f00 } + }, +/* mulu.l ${Dsp-24-u16}[$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U16), '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_An_relative_Prefixed_SI, { 0x1850f00 } + }, +/* mulu.l ${Dsp-24-u24}[$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U24), '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_24_An_relative_Prefixed_SI, { 0x1870f00 } + }, +/* mulu.l ${Dsp-24-u8}[sb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U8), '[', 's', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_8_SB_relative_Prefixed_SI, { 0x1838f00 } + }, +/* mulu.l ${Dsp-24-u16}[sb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U16), '[', 's', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_SB_relative_Prefixed_SI, { 0x1858f00 } + }, +/* mulu.l ${Dsp-24-s8}[fb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_S8), '[', 'f', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_8_FB_relative_Prefixed_SI, { 0x183cf00 } + }, +/* mulu.l ${Dsp-24-s16}[fb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_S16), '[', 'f', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_FB_relative_Prefixed_SI, { 0x185cf00 } + }, +/* mulu.l ${Dsp-24-u16},r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U16), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_absolute_Prefixed_SI, { 0x187cf00 } + }, +/* mulu.l ${Dsp-24-u24},r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U24), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_24_absolute_Prefixed_SI, { 0x1878f00 } + }, +/* mul.l $Dst32RnPrefixedSI,r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DST32RNPREFIXEDSI), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_Rn_direct_Prefixed_SI, { 0x1891f } + }, +/* mul.l $Dst32AnPrefixedSI,r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DST32ANPREFIXEDSI), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_An_direct_Prefixed_SI, { 0x1819f } + }, +/* mul.l [$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_An_indirect_Prefixed_SI, { 0x1811f } + }, +/* mul.l ${Dsp-24-u8}[$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U8), '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_8_An_relative_Prefixed_SI, { 0x1831f00 } + }, +/* mul.l ${Dsp-24-u16}[$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U16), '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_An_relative_Prefixed_SI, { 0x1851f00 } + }, +/* mul.l ${Dsp-24-u24}[$Dst32AnPrefixed],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U24), '[', OP (DST32ANPREFIXED), ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_24_An_relative_Prefixed_SI, { 0x1871f00 } + }, +/* mul.l ${Dsp-24-u8}[sb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U8), '[', 's', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_8_SB_relative_Prefixed_SI, { 0x1839f00 } + }, +/* mul.l ${Dsp-24-u16}[sb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U16), '[', 's', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_SB_relative_Prefixed_SI, { 0x1859f00 } + }, +/* mul.l ${Dsp-24-s8}[fb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_S8), '[', 'f', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_8_FB_relative_Prefixed_SI, { 0x183df00 } + }, +/* mul.l ${Dsp-24-s16}[fb],r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_S16), '[', 'f', 'b', ']', ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_FB_relative_Prefixed_SI, { 0x185df00 } + }, +/* mul.l ${Dsp-24-u16},r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U16), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_16_absolute_Prefixed_SI, { 0x187df00 } + }, +/* mul.l ${Dsp-24-u24},r2r0 */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (DSP_24_U24), ',', 'r', '2', 'r', '0', 0 } }, + & ifmt_mulu_l_dst32_24_24_absolute_Prefixed_SI, { 0x1879f00 } + }, /* mul.w${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedHI */ { { 0, 0, 0, 0 }, @@ -36534,43 +36706,43 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (SRCDST16_R0L_R0H_S_NORMAL), 0 } }, - & ifmt_mov16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x8 } + & ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x8 } }, /* mov.b${S} ${Dsp-8-u8}[sb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U8), '[', 's', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x900 } + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x900 } }, /* mov.b${S} ${Dsp-8-s8}[fb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_S8), '[', 'f', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0xa00 } + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0xa00 } }, /* mov.b${S} ${Dsp-8-u16},${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U16), ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI, { 0xb0000 } + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0xb0000 } }, /* mov.b${S} ${Dst16RnQI-S},${Dsp-8-u8}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DST16RNQI_S), ',', OP (DSP_8_U8), '[', 's', 'b', ']', 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x100 } + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x100 } }, /* mov.b${S} ${Dst16RnQI-S},${Dsp-8-s8}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DST16RNQI_S), ',', OP (DSP_8_S8), '[', 'f', 'b', ']', 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x200 } + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x200 } }, /* mov.b${S} ${Dst16RnQI-S},${Dsp-8-u16} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DST16RNQI_S), ',', OP (DSP_8_U16), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI, { 0x30000 } + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0x30000 } }, /* mov.l${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedSI */ { @@ -48834,25 +49006,25 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (SRCDST16_R0L_R0H_S_NORMAL), 0 } }, - & ifmt_mov16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x28 } + & ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x28 } }, /* sub.b${S} ${Dsp-8-u8}[sb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U8), '[', 's', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x2900 } + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x2900 } }, /* sub.b${S} ${Dsp-8-s8}[fb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_S8), '[', 'f', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x2a00 } + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x2a00 } }, /* sub.b${S} ${Dsp-8-u16},${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U16), ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI, { 0x2b0000 } + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0x2b0000 } }, /* sub.w${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedHI */ { @@ -55584,217 +55756,217 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DST32RNPREFIXEDSI), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_Rn_direct_Prefixed_SI, { 0x1a92f } + & ifmt_mulu_l_dst32_Rn_direct_Prefixed_SI, { 0x1a92f } }, /* divx.l $Dst32AnPrefixedSI */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DST32ANPREFIXEDSI), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_direct_Prefixed_SI, { 0x1a1af } + & ifmt_mulu_l_dst32_An_direct_Prefixed_SI, { 0x1a1af } }, /* divx.l [$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_indirect_Prefixed_SI, { 0x1a12f } + & ifmt_mulu_l_dst32_An_indirect_Prefixed_SI, { 0x1a12f } }, /* divx.l ${Dsp-24-u8}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U8), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_An_relative_Prefixed_SI, { 0x1a32f00 } + & ifmt_mulu_l_dst32_24_8_An_relative_Prefixed_SI, { 0x1a32f00 } }, /* divx.l ${Dsp-24-u16}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_An_relative_Prefixed_SI, { 0x1a52f00 } + & ifmt_mulu_l_dst32_24_16_An_relative_Prefixed_SI, { 0x1a52f00 } }, /* divx.l ${Dsp-24-u24}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U24), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_An_relative_Prefixed_SI, { 0x1a72f00 } + & ifmt_mulu_l_dst32_24_24_An_relative_Prefixed_SI, { 0x1a72f00 } }, /* divx.l ${Dsp-24-u8}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U8), '[', 's', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_SB_relative_Prefixed_SI, { 0x1a3af00 } + & ifmt_mulu_l_dst32_24_8_SB_relative_Prefixed_SI, { 0x1a3af00 } }, /* divx.l ${Dsp-24-u16}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), '[', 's', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_SB_relative_Prefixed_SI, { 0x1a5af00 } + & ifmt_mulu_l_dst32_24_16_SB_relative_Prefixed_SI, { 0x1a5af00 } }, /* divx.l ${Dsp-24-s8}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_S8), '[', 'f', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_FB_relative_Prefixed_SI, { 0x1a3ef00 } + & ifmt_mulu_l_dst32_24_8_FB_relative_Prefixed_SI, { 0x1a3ef00 } }, /* divx.l ${Dsp-24-s16}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_S16), '[', 'f', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_FB_relative_Prefixed_SI, { 0x1a5ef00 } + & ifmt_mulu_l_dst32_24_16_FB_relative_Prefixed_SI, { 0x1a5ef00 } }, /* divx.l ${Dsp-24-u16} */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_absolute_Prefixed_SI, { 0x1a7ef00 } + & ifmt_mulu_l_dst32_24_16_absolute_Prefixed_SI, { 0x1a7ef00 } }, /* divx.l ${Dsp-24-u24} */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U24), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_absolute_Prefixed_SI, { 0x1a7af00 } + & ifmt_mulu_l_dst32_24_24_absolute_Prefixed_SI, { 0x1a7af00 } }, /* divu.l $Dst32RnPrefixedSI */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DST32RNPREFIXEDSI), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_Rn_direct_Prefixed_SI, { 0x1a90f } + & ifmt_mulu_l_dst32_Rn_direct_Prefixed_SI, { 0x1a90f } }, /* divu.l $Dst32AnPrefixedSI */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DST32ANPREFIXEDSI), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_direct_Prefixed_SI, { 0x1a18f } + & ifmt_mulu_l_dst32_An_direct_Prefixed_SI, { 0x1a18f } }, /* divu.l [$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_indirect_Prefixed_SI, { 0x1a10f } + & ifmt_mulu_l_dst32_An_indirect_Prefixed_SI, { 0x1a10f } }, /* divu.l ${Dsp-24-u8}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U8), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_An_relative_Prefixed_SI, { 0x1a30f00 } + & ifmt_mulu_l_dst32_24_8_An_relative_Prefixed_SI, { 0x1a30f00 } }, /* divu.l ${Dsp-24-u16}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_An_relative_Prefixed_SI, { 0x1a50f00 } + & ifmt_mulu_l_dst32_24_16_An_relative_Prefixed_SI, { 0x1a50f00 } }, /* divu.l ${Dsp-24-u24}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U24), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_An_relative_Prefixed_SI, { 0x1a70f00 } + & ifmt_mulu_l_dst32_24_24_An_relative_Prefixed_SI, { 0x1a70f00 } }, /* divu.l ${Dsp-24-u8}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U8), '[', 's', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_SB_relative_Prefixed_SI, { 0x1a38f00 } + & ifmt_mulu_l_dst32_24_8_SB_relative_Prefixed_SI, { 0x1a38f00 } }, /* divu.l ${Dsp-24-u16}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), '[', 's', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_SB_relative_Prefixed_SI, { 0x1a58f00 } + & ifmt_mulu_l_dst32_24_16_SB_relative_Prefixed_SI, { 0x1a58f00 } }, /* divu.l ${Dsp-24-s8}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_S8), '[', 'f', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_FB_relative_Prefixed_SI, { 0x1a3cf00 } + & ifmt_mulu_l_dst32_24_8_FB_relative_Prefixed_SI, { 0x1a3cf00 } }, /* divu.l ${Dsp-24-s16}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_S16), '[', 'f', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_FB_relative_Prefixed_SI, { 0x1a5cf00 } + & ifmt_mulu_l_dst32_24_16_FB_relative_Prefixed_SI, { 0x1a5cf00 } }, /* divu.l ${Dsp-24-u16} */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_absolute_Prefixed_SI, { 0x1a7cf00 } + & ifmt_mulu_l_dst32_24_16_absolute_Prefixed_SI, { 0x1a7cf00 } }, /* divu.l ${Dsp-24-u24} */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U24), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_absolute_Prefixed_SI, { 0x1a78f00 } + & ifmt_mulu_l_dst32_24_24_absolute_Prefixed_SI, { 0x1a78f00 } }, /* div.l $Dst32RnPrefixedSI */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DST32RNPREFIXEDSI), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_Rn_direct_Prefixed_SI, { 0x1a91f } + & ifmt_mulu_l_dst32_Rn_direct_Prefixed_SI, { 0x1a91f } }, /* div.l $Dst32AnPrefixedSI */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DST32ANPREFIXEDSI), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_direct_Prefixed_SI, { 0x1a19f } + & ifmt_mulu_l_dst32_An_direct_Prefixed_SI, { 0x1a19f } }, /* div.l [$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_An_indirect_Prefixed_SI, { 0x1a11f } + & ifmt_mulu_l_dst32_An_indirect_Prefixed_SI, { 0x1a11f } }, /* div.l ${Dsp-24-u8}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U8), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_An_relative_Prefixed_SI, { 0x1a31f00 } + & ifmt_mulu_l_dst32_24_8_An_relative_Prefixed_SI, { 0x1a31f00 } }, /* div.l ${Dsp-24-u16}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_An_relative_Prefixed_SI, { 0x1a51f00 } + & ifmt_mulu_l_dst32_24_16_An_relative_Prefixed_SI, { 0x1a51f00 } }, /* div.l ${Dsp-24-u24}[$Dst32AnPrefixed] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U24), '[', OP (DST32ANPREFIXED), ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_An_relative_Prefixed_SI, { 0x1a71f00 } + & ifmt_mulu_l_dst32_24_24_An_relative_Prefixed_SI, { 0x1a71f00 } }, /* div.l ${Dsp-24-u8}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U8), '[', 's', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_SB_relative_Prefixed_SI, { 0x1a39f00 } + & ifmt_mulu_l_dst32_24_8_SB_relative_Prefixed_SI, { 0x1a39f00 } }, /* div.l ${Dsp-24-u16}[sb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), '[', 's', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_SB_relative_Prefixed_SI, { 0x1a59f00 } + & ifmt_mulu_l_dst32_24_16_SB_relative_Prefixed_SI, { 0x1a59f00 } }, /* div.l ${Dsp-24-s8}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_S8), '[', 'f', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_8_FB_relative_Prefixed_SI, { 0x1a3df00 } + & ifmt_mulu_l_dst32_24_8_FB_relative_Prefixed_SI, { 0x1a3df00 } }, /* div.l ${Dsp-24-s16}[fb] */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_S16), '[', 'f', 'b', ']', 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_FB_relative_Prefixed_SI, { 0x1a5df00 } + & ifmt_mulu_l_dst32_24_16_FB_relative_Prefixed_SI, { 0x1a5df00 } }, /* div.l ${Dsp-24-u16} */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U16), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_16_absolute_Prefixed_SI, { 0x1a7df00 } + & ifmt_mulu_l_dst32_24_16_absolute_Prefixed_SI, { 0x1a7df00 } }, /* div.l ${Dsp-24-u24} */ { { 0, 0, 0, 0 }, { { MNEM, ' ', OP (DSP_24_U24), 0 } }, - & ifmt_divx32_l_dst32_24_Prefixed_SI_dst32_24_24_absolute_Prefixed_SI, { 0x1a79f00 } + & ifmt_mulu_l_dst32_24_24_absolute_Prefixed_SI, { 0x1a79f00 } }, /* divx.w $Dst32RnUnprefixedHI */ { @@ -57750,25 +57922,25 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (SRCDST16_R0L_R0H_S_NORMAL), 0 } }, - & ifmt_mov16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x38 } + & ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x38 } }, /* cmp.b${S} ${Dsp-8-u8}[sb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U8), '[', 's', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x3900 } + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x3900 } }, /* cmp.b${S} ${Dsp-8-s8}[fb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_S8), '[', 'f', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x3a00 } + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x3a00 } }, /* cmp.b${S} ${Dsp-8-u16},${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U16), ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI, { 0x3b0000 } + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0x3b0000 } }, /* cmp.w${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedHI */ { @@ -61598,76 +61770,76 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, OP (X), ' ', OP (BITBASE16_16_U16), 0 } }, & ifmt_bxor16_X_bit16_16_bit16_16_16_absolute, { 0x7e0f0000 } }, -/* btst${X} $Bitno32Unprefixed,$Bit32RnUnprefixed */ +/* btst${G} $Bitno32Unprefixed,$Bit32RnUnprefixed */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITNO32UNPREFIXED), ',', OP (BIT32RNUNPREFIXED), 0 } }, + { { MNEM, OP (G), ' ', OP (BITNO32UNPREFIXED), ',', OP (BIT32RNUNPREFIXED), 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_Rn_direct_Unprefixed, { 0xd800 } }, -/* btst${X} $Bitno32Unprefixed,$Bit32AnUnprefixed */ +/* btst${G} $Bitno32Unprefixed,$Bit32AnUnprefixed */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITNO32UNPREFIXED), ',', OP (BIT32ANUNPREFIXED), 0 } }, + { { MNEM, OP (G), ' ', OP (BITNO32UNPREFIXED), ',', OP (BIT32ANUNPREFIXED), 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_An_direct_Unprefixed, { 0xd080 } }, -/* btst${X} $Bitno32Unprefixed,[$Bit32AnUnprefixed] */ +/* btst${G} $Bitno32Unprefixed,[$Bit32AnUnprefixed] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITNO32UNPREFIXED), ',', '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITNO32UNPREFIXED), ',', '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_An_indirect_Unprefixed, { 0xd000 } }, -/* btst${X} ${BitBase32-16-u11-Unprefixed}[$Bit32AnUnprefixed] */ +/* btst${G} ${BitBase32-16-u11-Unprefixed}[$Bit32AnUnprefixed] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U11_UNPREFIXED), '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U11_UNPREFIXED), '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_11_An_relative_Unprefixed, { 0xd20000 } }, -/* btst${X} ${BitBase32-16-u19-Unprefixed}[$Bit32AnUnprefixed] */ +/* btst${G} ${BitBase32-16-u19-Unprefixed}[$Bit32AnUnprefixed] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U19_UNPREFIXED), '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U19_UNPREFIXED), '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_19_An_relative_Unprefixed, { 0xd4000000 } }, -/* btst${X} ${BitBase32-16-u27-Unprefixed}[$Bit32AnUnprefixed] */ +/* btst${G} ${BitBase32-16-u27-Unprefixed}[$Bit32AnUnprefixed] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U27_UNPREFIXED), '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U27_UNPREFIXED), '[', OP (BIT32ANUNPREFIXED), ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_27_An_relative_Unprefixed, { 0xd6000000 } }, -/* btst${X} ${BitBase32-16-u11-Unprefixed}[sb] */ +/* btst${G} ${BitBase32-16-u11-Unprefixed}[sb] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U11_UNPREFIXED), '[', 's', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U11_UNPREFIXED), '[', 's', 'b', ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_11_SB_relative_Unprefixed, { 0xd28000 } }, -/* btst${X} ${BitBase32-16-u19-Unprefixed}[sb] */ +/* btst${G} ${BitBase32-16-u19-Unprefixed}[sb] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U19_UNPREFIXED), '[', 's', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U19_UNPREFIXED), '[', 's', 'b', ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_19_SB_relative_Unprefixed, { 0xd4800000 } }, -/* btst${X} ${BitBase32-16-s11-Unprefixed}[fb] */ +/* btst${G} ${BitBase32-16-s11-Unprefixed}[fb] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_S11_UNPREFIXED), '[', 'f', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_S11_UNPREFIXED), '[', 'f', 'b', ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_11_FB_relative_Unprefixed, { 0xd2c000 } }, -/* btst${X} ${BitBase32-16-s19-Unprefixed}[fb] */ +/* btst${G} ${BitBase32-16-s19-Unprefixed}[fb] */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_S19_UNPREFIXED), '[', 'f', 'b', ']', 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_S19_UNPREFIXED), '[', 'f', 'b', ']', 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_19_FB_relative_Unprefixed, { 0xd4c00000 } }, -/* btst${X} ${BitBase32-16-u19-Unprefixed} */ +/* btst${G} ${BitBase32-16-u19-Unprefixed} */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U19_UNPREFIXED), 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U19_UNPREFIXED), 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_19_absolute_Unprefixed, { 0xd6c00000 } }, -/* btst${X} ${BitBase32-16-u27-Unprefixed} */ +/* btst${G} ${BitBase32-16-u27-Unprefixed} */ { { 0, 0, 0, 0 }, - { { MNEM, OP (X), ' ', OP (BITBASE32_16_U27_UNPREFIXED), 0 } }, + { { MNEM, OP (G), ' ', OP (BITBASE32_16_U27_UNPREFIXED), 0 } }, & ifmt_btsts32_X_bit32_16_Unprefixed_bit32_16_27_absolute_Unprefixed, { 0xd6800000 } }, /* btst${G} $Bitno16R,$Bit16Rn */ @@ -63204,25 +63376,25 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (SRCDST16_R0L_R0H_S_NORMAL), 0 } }, - & ifmt_mov16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x10 } + & ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x10 } }, /* and.b${S} ${Dsp-8-u8}[sb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U8), '[', 's', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x1100 } + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x1100 } }, /* and.b${S} ${Dsp-8-s8}[fb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_S8), '[', 'f', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x1200 } + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x1200 } }, /* and.b${S} ${Dsp-8-u16},${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U16), ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI, { 0x130000 } + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0x130000 } }, /* and.w${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedHI */ { @@ -75018,25 +75190,25 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (SRCDST16_R0L_R0H_S_NORMAL), 0 } }, - & ifmt_mov16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x20 } + & ifmt_or16_b_S_r0l_r0h_srcdst16_r0l_r0h_S_derived, { 0x20 } }, /* add.b${S} ${Dsp-8-u8}[sb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U8), '[', 's', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x2100 } + & ifmt_or16_b_S_src2_src16_2_S_8_SB_relative_QI, { 0x2100 } }, /* add.b${S} ${Dsp-8-s8}[fb],${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_S8), '[', 'f', 'b', ']', ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x2200 } + & ifmt_or16_b_S_src2_src16_2_S_8_FB_relative_QI, { 0x2200 } }, /* add.b${S} ${Dsp-8-u16},${Dst16RnQI-S} */ { { 0, 0, 0, 0 }, { { MNEM, OP (S), ' ', OP (DSP_8_U16), ',', OP (DST16RNQI_S), 0 } }, - & ifmt_mov16_b_S_src2_src16_2_S_16_absolute_QI, { 0x230000 } + & ifmt_or16_b_S_src2_src16_2_S_16_absolute_QI, { 0x230000 } }, /* add.w${G} ${Dsp-16-u8}[$Src32AnUnprefixed],$Dst32RnUnprefixedHI */ { @@ -78956,16 +79128,16 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, OP (G), ' ', '#', OP (IMM_16_HI), ',', 's', 'p', 0 } }, & ifmt_add32_l_imm16_G, { 0xb6130000 } }, -/* dadc.b #${Imm-16-QI} */ +/* dadc.b #${Imm-16-QI},r0l */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_QI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_QI), ',', 'r', '0', 'l', 0 } }, & ifmt_add32_l_imm8_S, { 0x7cee00 } }, -/* dadc.w #${Imm-16-HI} */ +/* dadc.w #${Imm-16-HI},r0 */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_HI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_HI), ',', 'r', '0', 0 } }, & ifmt_add32_l_imm16_G, { 0x7dee0000 } }, /* dadc.b r0h,r0l */ @@ -78980,16 +79152,16 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, ' ', 'r', '1', ',', 'r', '0', 0 } }, & ifmt_dadc16_b_r0h_r0l, { 0x7de6 } }, -/* dadd.b #${Imm-16-QI} */ +/* dadd.b #${Imm-16-QI},r0l */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_QI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_QI), ',', 'r', '0', 'l', 0 } }, & ifmt_add32_l_imm8_S, { 0x7cec00 } }, -/* dadd.w #${Imm-16-HI} */ +/* dadd.w #${Imm-16-HI},r0 */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_HI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_HI), ',', 'r', '0', 0 } }, & ifmt_add32_l_imm16_G, { 0x7dec0000 } }, /* dadd.b r0h,r0l */ @@ -79034,6 +79206,12 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, 0 } }, & ifmt_brk16, { 0x8 } }, +/* btst:s ${Bit3-S},${Dsp-8-u16} */ + { + { 0, 0, 0, 0 }, + { { MNEM, ' ', OP (BIT3_S), ',', OP (DSP_8_U16), 0 } }, + & ifmt_btst_s, { 0xa0000 } + }, /* dec.w ${Dst16An-S} */ { { 0, 0, 0, 0 }, @@ -79112,16 +79290,16 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, ' ', '#', OP (IMM_16_HI), 0 } }, & ifmt_div32_w_Imm_16_HI, { 0xb2530000 } }, -/* dsbb.b #${Imm-16-QI} */ +/* dsbb.b #${Imm-16-QI},r0l */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_QI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_QI), ',', 'r', '0', 'l', 0 } }, & ifmt_add32_l_imm8_S, { 0x7cef00 } }, -/* dsbb.w #${Imm-16-HI} */ +/* dsbb.w #${Imm-16-HI},r0 */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_HI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_HI), ',', 'r', '0', 0 } }, & ifmt_add32_l_imm16_G, { 0x7def0000 } }, /* dsbb.b r0h,r0l */ @@ -79136,16 +79314,16 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, ' ', 'r', '1', ',', 'r', '0', 0 } }, & ifmt_dadc16_b_r0h_r0l, { 0x7de7 } }, -/* dsub.b #${Imm-16-QI} */ +/* dsub.b #${Imm-16-QI},r0l */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_QI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_QI), ',', 'r', '0', 'l', 0 } }, & ifmt_add32_l_imm8_S, { 0x7ced00 } }, -/* dsub.w #${Imm-16-HI} */ +/* dsub.w #${Imm-16-HI},r0 */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', OP (IMM_16_HI), 0 } }, + { { MNEM, ' ', '#', OP (IMM_16_HI), ',', 'r', '0', 0 } }, & ifmt_add32_l_imm16_G, { 0x7ded0000 } }, /* dsub.b r0h,r0l */ @@ -79562,10 +79740,10 @@ static const CGEN_OPCODE m32c_cgen_insn_opcode_table[MAX_INSNS] = { { MNEM, OP (G), ' ', '#', OP (IMM_16_HI), 0 } }, & ifmt_add32_l_imm16_G, { 0x7de20000 } }, -/* push.b #Imm-8-QI */ +/* push.b #${Imm-8-QI} */ { { 0, 0, 0, 0 }, - { { MNEM, ' ', '#', 'I', 'm', 'm', '-', '8', '-', 'Q', 'I', 0 } }, + { { MNEM, ' ', '#', OP (IMM_8_QI), 0 } }, & ifmt_jmps16, { 0xae00 } }, /* push.w #${Imm-8-HI} */ diff --git a/opcodes/m32c-opc.h b/opcodes/m32c-opc.h index 23cc23e..7f0e6e5 100644 --- a/opcodes/m32c-opc.h +++ b/opcodes/m32c-opc.h @@ -749,7 +749,8 @@ typedef enum cgen_insn_type { , M32C_INSN_POP16_W_16_DST16_16_16_AN_RELATIVE_HI, M32C_INSN_POP16_W_16_DST16_16_8_SB_RELATIVE_HI, M32C_INSN_POP16_W_16_DST16_16_16_SB_RELATIVE_HI, M32C_INSN_POP16_W_16_DST16_16_8_FB_RELATIVE_HI , M32C_INSN_POP16_W_16_DST16_16_16_ABSOLUTE_HI, M32C_INSN_POP16_B_16_DST16_RN_DIRECT_QI, M32C_INSN_POP16_B_16_DST16_AN_DIRECT_QI, M32C_INSN_POP16_B_16_DST16_AN_INDIRECT_QI , M32C_INSN_POP16_B_16_DST16_16_8_AN_RELATIVE_QI, M32C_INSN_POP16_B_16_DST16_16_16_AN_RELATIVE_QI, M32C_INSN_POP16_B_16_DST16_16_8_SB_RELATIVE_QI, M32C_INSN_POP16_B_16_DST16_16_16_SB_RELATIVE_QI - , M32C_INSN_POP16_B_16_DST16_16_8_FB_RELATIVE_QI, M32C_INSN_POP16_B_16_DST16_16_16_ABSOLUTE_QI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI + , M32C_INSN_POP16_B_16_DST16_16_8_FB_RELATIVE_QI, M32C_INSN_POP16_B_16_DST16_16_16_ABSOLUTE_QI, M32C_INSN_OR16_B_S_R0L_R0H_SRCDST16_R0L_R0H_S_DERIVED, M32C_INSN_OR16_B_S_SRC2_SRC16_2_S_8_SB_RELATIVE_QI + , M32C_INSN_OR16_B_S_SRC2_SRC16_2_S_8_FB_RELATIVE_QI, M32C_INSN_OR16_B_S_SRC2_SRC16_2_S_16_ABSOLUTE_QI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI , M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_AN_DIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_AN_DIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_AN_DIRECT_UNPREFIXED_HI , M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_AN_INDIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_AN_INDIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_AN_INDIRECT_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_24_8_AN_RELATIVE_UNPREFIXED_HI , M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_24_8_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_24_8_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_24_16_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_OR32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_24_16_AN_RELATIVE_UNPREFIXED_HI @@ -1024,6 +1025,12 @@ typedef enum cgen_insn_type { , M32C_INSN_MULEX_DST32_R3_DIRECT_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_AN_DIRECT_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_AN_INDIRECT_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_8_AN_RELATIVE_UNPREFIXED_HI , M32C_INSN_MULEX_DST32_16_16_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_24_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_8_SB_RELATIVE_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_16_SB_RELATIVE_UNPREFIXED_HI , M32C_INSN_MULEX_DST32_16_8_FB_RELATIVE_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_16_FB_RELATIVE_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_16_ABSOLUTE_UNPREFIXED_HI, M32C_INSN_MULEX_DST32_16_24_ABSOLUTE_UNPREFIXED_HI + , M32C_INSN_MULU_L_DST32_RN_DIRECT_PREFIXED_SI, M32C_INSN_MULU_L_DST32_AN_DIRECT_PREFIXED_SI, M32C_INSN_MULU_L_DST32_AN_INDIRECT_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_8_AN_RELATIVE_PREFIXED_SI + , M32C_INSN_MULU_L_DST32_24_16_AN_RELATIVE_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_24_AN_RELATIVE_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_8_SB_RELATIVE_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_16_SB_RELATIVE_PREFIXED_SI + , M32C_INSN_MULU_L_DST32_24_8_FB_RELATIVE_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_16_FB_RELATIVE_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_16_ABSOLUTE_PREFIXED_SI, M32C_INSN_MULU_L_DST32_24_24_ABSOLUTE_PREFIXED_SI + , M32C_INSN_MUL_L_DST32_RN_DIRECT_PREFIXED_SI, M32C_INSN_MUL_L_DST32_AN_DIRECT_PREFIXED_SI, M32C_INSN_MUL_L_DST32_AN_INDIRECT_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_8_AN_RELATIVE_PREFIXED_SI + , M32C_INSN_MUL_L_DST32_24_16_AN_RELATIVE_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_24_AN_RELATIVE_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_8_SB_RELATIVE_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_16_SB_RELATIVE_PREFIXED_SI + , M32C_INSN_MUL_L_DST32_24_8_FB_RELATIVE_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_16_FB_RELATIVE_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_16_ABSOLUTE_PREFIXED_SI, M32C_INSN_MUL_L_DST32_24_24_ABSOLUTE_PREFIXED_SI , M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_RN_DIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_AN_DIRECT_UNPREFIXED_HI , M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_AN_DIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_AN_DIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_AN_INDIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_AN_INDIRECT_UNPREFIXED_HI , M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_AN_INDIRECT_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_AN_RELATIVE_UNPREFIXED_HI_DST32_24_8_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_SB_RELATIVE_UNPREFIXED_HI_DST32_24_8_AN_RELATIVE_UNPREFIXED_HI, M32C_INSN_MUL32_W_16_8_UNPREFIXED_24_UNPREFIXED_SRC32_16_8_FB_RELATIVE_UNPREFIXED_HI_DST32_24_8_AN_RELATIVE_UNPREFIXED_HI @@ -2284,10 +2291,10 @@ typedef enum cgen_insn_type { , M32C_INSN_BTSTC32_X_BIT32_16_UNPREFIXED_BIT32_16_19_SB_RELATIVE_UNPREFIXED, M32C_INSN_BTSTC32_X_BIT32_16_UNPREFIXED_BIT32_16_11_FB_RELATIVE_UNPREFIXED, M32C_INSN_BTSTC32_X_BIT32_16_UNPREFIXED_BIT32_16_19_FB_RELATIVE_UNPREFIXED, M32C_INSN_BTSTC32_X_BIT32_16_UNPREFIXED_BIT32_16_19_ABSOLUTE_UNPREFIXED , M32C_INSN_BTSTC32_X_BIT32_16_UNPREFIXED_BIT32_16_27_ABSOLUTE_UNPREFIXED, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_RN_DIRECT, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_AN_DIRECT, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_AN_INDIRECT , M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_8_AN_RELATIVE, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_16_AN_RELATIVE, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_8_SB_RELATIVE, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_16_SB_RELATIVE - , M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_8_FB_RELATIVE, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_16_ABSOLUTE, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_RN_DIRECT_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_AN_DIRECT_UNPREFIXED - , M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_AN_INDIRECT_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_11_AN_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_19_AN_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_27_AN_RELATIVE_UNPREFIXED - , M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_11_SB_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_19_SB_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_11_FB_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_19_FB_RELATIVE_UNPREFIXED - , M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_19_ABSOLUTE_UNPREFIXED, M32C_INSN_BTST32_X_BIT32_16_UNPREFIXED_BIT32_16_27_ABSOLUTE_UNPREFIXED, M32C_INSN_BTST16_G_BIT16_16_8_BIT16_RN_DIRECT, M32C_INSN_BTST16_G_BIT16_16_8_BIT16_AN_DIRECT + , M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_8_FB_RELATIVE, M32C_INSN_BTSTC16_X_BIT16_16_BIT16_16_16_ABSOLUTE, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_RN_DIRECT_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_AN_DIRECT_UNPREFIXED + , M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_AN_INDIRECT_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_11_AN_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_19_AN_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_27_AN_RELATIVE_UNPREFIXED + , M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_11_SB_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_19_SB_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_11_FB_RELATIVE_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_19_FB_RELATIVE_UNPREFIXED + , M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_19_ABSOLUTE_UNPREFIXED, M32C_INSN_BTST32_G_BIT32_16_UNPREFIXED_BIT32_16_27_ABSOLUTE_UNPREFIXED, M32C_INSN_BTST16_G_BIT16_16_8_BIT16_RN_DIRECT, M32C_INSN_BTST16_G_BIT16_16_8_BIT16_AN_DIRECT , M32C_INSN_BTST16_G_BIT16_16_8_BIT16_16_8_AN_RELATIVE, M32C_INSN_BTST16_G_BIT16_16_8_BIT16_16_8_SB_RELATIVE, M32C_INSN_BTST16_G_BIT16_16_8_BIT16_16_8_FB_RELATIVE, M32C_INSN_BTST16_S_BIT16_11_S_BIT16_11_SB_RELATIVE_S , M32C_INSN_BTST16_G_BIT16_16_16_BIT16_16_16_AN_RELATIVE, M32C_INSN_BTST16_G_BIT16_16_16_BIT16_16_16_SB_RELATIVE, M32C_INSN_BTST16_G_BIT16_16_16_BIT16_16_16_ABSOLUTE, M32C_INSN_BTST16_G_BIT16_16_BASIC_BIT16_AN_INDIRECT , M32C_INSN_BSET32_X_BIT32_16_UNPREFIXED_BIT32_RN_DIRECT_UNPREFIXED, M32C_INSN_BSET32_X_BIT32_16_UNPREFIXED_BIT32_AN_DIRECT_UNPREFIXED, M32C_INSN_BSET32_X_BIT32_16_UNPREFIXED_BIT32_AN_INDIRECT_UNPREFIXED, M32C_INSN_BSET32_X_BIT32_16_UNPREFIXED_BIT32_16_11_AN_RELATIVE_UNPREFIXED @@ -3011,41 +3018,42 @@ typedef enum cgen_insn_type { , M32C_INSN_DADC16_W_IMM16, M32C_INSN_DADC16_B_R0H_R0L, M32C_INSN_DADC16_W_R1_R0, M32C_INSN_DADD16_B_IMM8 , M32C_INSN_DADD16_W_IMM16, M32C_INSN_DADD16_B_R0H_R0L, M32C_INSN_DADD16_W_R1_R0, M32C_INSN_BM16_C , M32C_INSN_BM32_C, M32C_INSN_BRK16, M32C_INSN_BRK32, M32C_INSN_BRK232 - , M32C_INSN_DEC16_W, M32C_INSN_DIV16_B_IMM_16_QI, M32C_INSN_DIV16_W_IMM_16_HI, M32C_INSN_DIV32_B_IMM_16_QI - , M32C_INSN_DIV32_W_IMM_16_HI, M32C_INSN_DIVU16_B_IMM_16_QI, M32C_INSN_DIVU16_W_IMM_16_HI, M32C_INSN_DIVU32_B_IMM_16_QI - , M32C_INSN_DIVU32_W_IMM_16_HI, M32C_INSN_DIVX16_B_IMM_16_QI, M32C_INSN_DIVX16_W_IMM_16_HI, M32C_INSN_DIVX32_B_IMM_16_QI - , M32C_INSN_DIVX32_W_IMM_16_HI, M32C_INSN_DSBB16_B_IMM8, M32C_INSN_DSBB16_W_IMM16, M32C_INSN_DSBB16_B_R0H_R0L - , M32C_INSN_DSBB16_W_R1_R0, M32C_INSN_DSUB16_B_IMM8, M32C_INSN_DSUB16_W_IMM16, M32C_INSN_DSUB16_B_R0H_R0L - , M32C_INSN_DSUB16_W_R1_R0, M32C_INSN_ENTER16, M32C_INSN_EXITD16, M32C_INSN_ENTER32 - , M32C_INSN_EXITD32, M32C_INSN_FCLR16, M32C_INSN_FSET16, M32C_INSN_FCLR - , M32C_INSN_FSET, M32C_INSN_INC16_W, M32C_INSN_FREIT32, M32C_INSN_INT16 - , M32C_INSN_INTO16, M32C_INSN_INT32, M32C_INSN_INTO32, M32C_INSN_JCND16_5 - , M32C_INSN_JCND16, M32C_INSN_JCND32, M32C_INSN_JMP16_S, M32C_INSN_JMP16_B - , M32C_INSN_JMP16_W, M32C_INSN_JMP16_A, M32C_INSN_JMPS16, M32C_INSN_JMP32_S - , M32C_INSN_JMP32_B, M32C_INSN_JMP32_W, M32C_INSN_JMP32_A, M32C_INSN_JMPS32 - , M32C_INSN_JSR16_W, M32C_INSN_JSR16_A, M32C_INSN_JSR32_W, M32C_INSN_JSR32_A - , M32C_INSN_JSRS16, M32C_INSN_JSRS, M32C_INSN_LDC16_IMM16, M32C_INSN_LDC32_IMM16_CR1 - , M32C_INSN_LDC32_IMM16_CR2, M32C_INSN_LDC32_IMM16_CR3, M32C_INSN_LDCTX16, M32C_INSN_LDCTX32 - , M32C_INSN_STCTX16, M32C_INSN_STCTX32, M32C_INSN_LDIPL16_IMM, M32C_INSN_LDIPL32_IMM - , M32C_INSN_MOV16_B_S_IMM_A0, M32C_INSN_MOV16_B_S_IMM_A1, M32C_INSN_MOV16_W_S_IMM_A0, M32C_INSN_MOV16_W_S_IMM_A1 - , M32C_INSN_MOV32_W_A0, M32C_INSN_MOV32_W_A1, M32C_INSN_MOV32_L_A0, M32C_INSN_MOV32_L_A1 - , M32C_INSN_MOV16_B_S_R0L_A1, M32C_INSN_MOV16_B_S_R0H_A0, M32C_INSN_NOP16, M32C_INSN_NOP32 - , M32C_INSN_POPC16_IMM16, M32C_INSN_POPC32_IMM16_CR1, M32C_INSN_POPC32_IMM16_CR2, M32C_INSN_PUSHC16_IMM16 - , M32C_INSN_PUSHC32_IMM16_CR1, M32C_INSN_PUSHC32_IMM16_CR2, M32C_INSN_POPM16, M32C_INSN_PUSHM16 - , M32C_INSN_POPM, M32C_INSN_PUSHM, M32C_INSN_PUSH16_B_G_IMM, M32C_INSN_PUSH16_W_G_IMM - , M32C_INSN_PUSH32_B_IMM, M32C_INSN_PUSH32_W_IMM, M32C_INSN_PUSH32_L_IMM, M32C_INSN_REIT16 - , M32C_INSN_REIT32, M32C_INSN_RMPA16_B, M32C_INSN_RMPA16_W, M32C_INSN_RMPA32_B - , M32C_INSN_RMPA32_W, M32C_INSN_RTS16, M32C_INSN_RTS32, M32C_INSN_SCMPU_B - , M32C_INSN_SCMPU_W, M32C_INSN_SHA16_L_IMM_R2R0, M32C_INSN_SHA16_L_IMM_R3R1, M32C_INSN_SHA16_L_R1H_R2R0 - , M32C_INSN_SHA16_L_R1H_R3R1, M32C_INSN_SHL16_L_IMM_R2R0, M32C_INSN_SHL16_L_IMM_R3R1, M32C_INSN_SHL16_L_R1H_R2R0 - , M32C_INSN_SHL16_L_R1H_R3R1, M32C_INSN_SIN32_B, M32C_INSN_SIN32_W, M32C_INSN_SMOVB16_B - , M32C_INSN_SMOVB16_W, M32C_INSN_SMOVB32_B, M32C_INSN_SMOVB32_W, M32C_INSN_SMOVF16_B - , M32C_INSN_SMOVF16_W, M32C_INSN_SMOVF32_B, M32C_INSN_SMOVF32_W, M32C_INSN_SMOVU_B - , M32C_INSN_SMOVU_W, M32C_INSN_SOUT_B, M32C_INSN_SOUT_W, M32C_INSN_SSTR16_B - , M32C_INSN_SSTR16_W, M32C_INSN_SSTR_B, M32C_INSN_SSTR_W, M32C_INSN_STZX16_IMM8_IMM8_R0H - , M32C_INSN_STZX16_IMM8_IMM8_R0L, M32C_INSN_STZX16_IMM8_IMM8_DSP8SB, M32C_INSN_STZX16_IMM8_IMM8_DSP8FB, M32C_INSN_STZX16_IMM8_IMM8_ABS16 - , M32C_INSN_UND16, M32C_INSN_UND32, M32C_INSN_WAIT16, M32C_INSN_WAIT - , M32C_INSN_EXTS16_W_R0, M32C_INSN_SRCIND, M32C_INSN_DESTIND, M32C_INSN_SRCDESTIND + , M32C_INSN_BTST_S, M32C_INSN_DEC16_W, M32C_INSN_DIV16_B_IMM_16_QI, M32C_INSN_DIV16_W_IMM_16_HI + , M32C_INSN_DIV32_B_IMM_16_QI, M32C_INSN_DIV32_W_IMM_16_HI, M32C_INSN_DIVU16_B_IMM_16_QI, M32C_INSN_DIVU16_W_IMM_16_HI + , M32C_INSN_DIVU32_B_IMM_16_QI, M32C_INSN_DIVU32_W_IMM_16_HI, M32C_INSN_DIVX16_B_IMM_16_QI, M32C_INSN_DIVX16_W_IMM_16_HI + , M32C_INSN_DIVX32_B_IMM_16_QI, M32C_INSN_DIVX32_W_IMM_16_HI, M32C_INSN_DSBB16_B_IMM8, M32C_INSN_DSBB16_W_IMM16 + , M32C_INSN_DSBB16_B_R0H_R0L, M32C_INSN_DSBB16_W_R1_R0, M32C_INSN_DSUB16_B_IMM8, M32C_INSN_DSUB16_W_IMM16 + , M32C_INSN_DSUB16_B_R0H_R0L, M32C_INSN_DSUB16_W_R1_R0, M32C_INSN_ENTER16, M32C_INSN_EXITD16 + , M32C_INSN_ENTER32, M32C_INSN_EXITD32, M32C_INSN_FCLR16, M32C_INSN_FSET16 + , M32C_INSN_FCLR, M32C_INSN_FSET, M32C_INSN_INC16_W, M32C_INSN_FREIT32 + , M32C_INSN_INT16, M32C_INSN_INTO16, M32C_INSN_INT32, M32C_INSN_INTO32 + , M32C_INSN_JCND16_5, M32C_INSN_JCND16, M32C_INSN_JCND32, M32C_INSN_JMP16_S + , M32C_INSN_JMP16_B, M32C_INSN_JMP16_W, M32C_INSN_JMP16_A, M32C_INSN_JMPS16 + , M32C_INSN_JMP32_S, M32C_INSN_JMP32_B, M32C_INSN_JMP32_W, M32C_INSN_JMP32_A + , M32C_INSN_JMPS32, M32C_INSN_JSR16_W, M32C_INSN_JSR16_A, M32C_INSN_JSR32_W + , M32C_INSN_JSR32_A, M32C_INSN_JSRS16, M32C_INSN_JSRS, M32C_INSN_LDC16_IMM16 + , M32C_INSN_LDC32_IMM16_CR1, M32C_INSN_LDC32_IMM16_CR2, M32C_INSN_LDC32_IMM16_CR3, M32C_INSN_LDCTX16 + , M32C_INSN_LDCTX32, M32C_INSN_STCTX16, M32C_INSN_STCTX32, M32C_INSN_LDIPL16_IMM + , M32C_INSN_LDIPL32_IMM, M32C_INSN_MOV16_B_S_IMM_A0, M32C_INSN_MOV16_B_S_IMM_A1, M32C_INSN_MOV16_W_S_IMM_A0 + , M32C_INSN_MOV16_W_S_IMM_A1, M32C_INSN_MOV32_W_A0, M32C_INSN_MOV32_W_A1, M32C_INSN_MOV32_L_A0 + , M32C_INSN_MOV32_L_A1, M32C_INSN_MOV16_B_S_R0L_A1, M32C_INSN_MOV16_B_S_R0H_A0, M32C_INSN_NOP16 + , M32C_INSN_NOP32, M32C_INSN_POPC16_IMM16, M32C_INSN_POPC32_IMM16_CR1, M32C_INSN_POPC32_IMM16_CR2 + , M32C_INSN_PUSHC16_IMM16, M32C_INSN_PUSHC32_IMM16_CR1, M32C_INSN_PUSHC32_IMM16_CR2, M32C_INSN_POPM16 + , M32C_INSN_PUSHM16, M32C_INSN_POPM, M32C_INSN_PUSHM, M32C_INSN_PUSH16_B_G_IMM + , M32C_INSN_PUSH16_W_G_IMM, M32C_INSN_PUSH32_B_IMM, M32C_INSN_PUSH32_W_IMM, M32C_INSN_PUSH32_L_IMM + , M32C_INSN_REIT16, M32C_INSN_REIT32, M32C_INSN_RMPA16_B, M32C_INSN_RMPA16_W + , M32C_INSN_RMPA32_B, M32C_INSN_RMPA32_W, M32C_INSN_RTS16, M32C_INSN_RTS32 + , M32C_INSN_SCMPU_B, M32C_INSN_SCMPU_W, M32C_INSN_SHA16_L_IMM_R2R0, M32C_INSN_SHA16_L_IMM_R3R1 + , M32C_INSN_SHA16_L_R1H_R2R0, M32C_INSN_SHA16_L_R1H_R3R1, M32C_INSN_SHL16_L_IMM_R2R0, M32C_INSN_SHL16_L_IMM_R3R1 + , M32C_INSN_SHL16_L_R1H_R2R0, M32C_INSN_SHL16_L_R1H_R3R1, M32C_INSN_SIN32_B, M32C_INSN_SIN32_W + , M32C_INSN_SMOVB16_B, M32C_INSN_SMOVB16_W, M32C_INSN_SMOVB32_B, M32C_INSN_SMOVB32_W + , M32C_INSN_SMOVF16_B, M32C_INSN_SMOVF16_W, M32C_INSN_SMOVF32_B, M32C_INSN_SMOVF32_W + , M32C_INSN_SMOVU_B, M32C_INSN_SMOVU_W, M32C_INSN_SOUT_B, M32C_INSN_SOUT_W + , M32C_INSN_SSTR16_B, M32C_INSN_SSTR16_W, M32C_INSN_SSTR_B, M32C_INSN_SSTR_W + , M32C_INSN_STZX16_IMM8_IMM8_R0H, M32C_INSN_STZX16_IMM8_IMM8_R0L, M32C_INSN_STZX16_IMM8_IMM8_DSP8SB, M32C_INSN_STZX16_IMM8_IMM8_DSP8FB + , M32C_INSN_STZX16_IMM8_IMM8_ABS16, M32C_INSN_UND16, M32C_INSN_UND32, M32C_INSN_WAIT16 + , M32C_INSN_WAIT, M32C_INSN_EXTS16_W_R0, M32C_INSN_SRCIND, M32C_INSN_DESTIND + , M32C_INSN_SRCDESTIND } CGEN_INSN_TYPE; /* Index of `invalid' insn place holder. */ diff --git a/opcodes/m32r-ibld.c b/opcodes/m32r-ibld.c index ffd47dd..fee130d 100644 --- a/opcodes/m32r-ibld.c +++ b/opcodes/m32r-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/opcodes/openrisc-ibld.c b/opcodes/openrisc-ibld.c index 035f438..1225ad4 100644 --- a/opcodes/openrisc-ibld.c +++ b/opcodes/openrisc-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/opcodes/po/sv.po b/opcodes/po/sv.po index ae55351..c0533d4 100644 --- a/opcodes/po/sv.po +++ b/opcodes/po/sv.po @@ -1,45 +1,50 @@ # Swedish messages for opcodes. -# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. +# Copyright (C) 2006 Free Software Foundation, Inc. # Christian Rose , 2001, 2002, 2003. +# Daniel Nylander , 2006. # msgid "" msgstr "" -"Project-Id-Version: opcodes 2.14rel030712\n" -"POT-Creation-Date: 2003-07-11 13:56+0930\n" -"PO-Revision-Date: 2003-07-16 14:36+0200\n" -"Last-Translator: Christian Rose \n" -"Language-Team: Swedish \n" +"Project-Id-Version: opcodes 2.15.96\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2005-03-05 20:32+1030\n" +"PO-Revision-Date: 2006-02-13 22:58+0100\n" +"Last-Translator: Daniel Nylander \n" +"Language-Team: Swedish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" -#: alpha-opc.c:335 +#: alpha-opc.c:331 msgid "branch operand unaligned" msgstr "grenoperanden ligger inte p� j�mn gr�ns" -#: alpha-opc.c:358 alpha-opc.c:380 +#: alpha-opc.c:353 alpha-opc.c:374 msgid "jump hint unaligned" msgstr "hopptipset ligger inte p� j�mn gr�ns" -#: arc-dis.c:52 +#: arc-dis.c:76 msgid "Illegal limm reference in last instruction!\n" msgstr "Otill�ten limm-referens i sista instruktionen!\n" -#: arm-dis.c:554 +#: arm-dis.c:1267 msgid "" msgstr "" -#: arm-dis.c:1162 +#. XXX - should break 'option' at following delimiter. +#: arm-dis.c:1912 #, c-format msgid "Unrecognised register name set: %s\n" msgstr "Ok�nt registernamn �r angivet: %s\n" -#: arm-dis.c:1169 +#. XXX - should break 'option' at following delimiter. +#: arm-dis.c:1920 #, c-format msgid "Unrecognised disassembler option: %s\n" msgstr "Ok�nt disassembleralternativ: %s\n" -#: arm-dis.c:1343 +#: arm-dis.c:2093 +#, c-format msgid "" "\n" "The following ARM specific disassembler options are supported for use with\n" @@ -49,11 +54,13 @@ msgstr "" "F�ljande ARM-specifika disassembleralternativ st�ds f�r anv�ndning\n" "tillsammans med flaggan -M:\n" -#: avr-dis.c:117 avr-dis.c:127 +#: avr-dis.c:112 avr-dis.c:122 +#, c-format msgid "undefined" msgstr "odefinierad" #: avr-dis.c:179 +#, c-format msgid "Internal disassembler error" msgstr "Internt fel i disassembleraren" @@ -62,13 +69,13 @@ msgstr "Internt fel i disassembleraren" msgid "unknown constraint `%c'" msgstr "ok�nd begr�nsning \"%c\"" -#: cgen-asm.c:348 fr30-ibld.c:195 frv-ibld.c:195 ip2k-ibld.c:195 -#: iq2000-ibld.c:195 m32r-ibld.c:195 openrisc-ibld.c:195 xstormy16-ibld.c:195 +#: cgen-asm.c:336 fr30-ibld.c:197 frv-ibld.c:197 ip2k-ibld.c:197 +#: iq2000-ibld.c:197 m32r-ibld.c:197 openrisc-ibld.c:197 xstormy16-ibld.c:197 #, c-format msgid "operand out of range (%ld not between %ld and %ld)" msgstr "operanden �r utanf�r intervallet (%ld �r inte mellan %ld och %ld)" -#: cgen-asm.c:369 +#: cgen-asm.c:358 #, c-format msgid "operand out of range (%lu not between %lu and %lu)" msgstr "operanden �r utanf�r intervallet (%lu �r inte mellan %lu och %lu)" @@ -84,63 +91,63 @@ msgstr "" msgid "Unknown error %d\n" msgstr "Ok�nt fel %d\n" -#: dis-buf.c:62 +#: dis-buf.c:66 #, c-format -msgid "Address 0x%x is out of bounds.\n" -msgstr "Adressen 0x%x ligger utanf�r till�tna gr�nser.\n" +msgid "Address 0x%s is out of bounds.\n" +msgstr "Adressen 0x%s ligger utanf�r till�tna gr�nser.\n" -#: fr30-asm.c:323 frv-asm.c:626 ip2k-asm.c:574 iq2000-asm.c:460 m32r-asm.c:325 -#: openrisc-asm.c:261 xstormy16-asm.c:284 +#: fr30-asm.c:323 frv-asm.c:1298 ip2k-asm.c:530 iq2000-asm.c:465 +#: m32r-asm.c:338 openrisc-asm.c:252 xstormy16-asm.c:284 #, c-format msgid "Unrecognized field %d while parsing.\n" msgstr "Ok�nt f�lt %d vid tolkning.\n" -#: fr30-asm.c:373 frv-asm.c:676 ip2k-asm.c:624 iq2000-asm.c:510 m32r-asm.c:375 -#: openrisc-asm.c:311 xstormy16-asm.c:334 +#: fr30-asm.c:372 frv-asm.c:1347 ip2k-asm.c:579 iq2000-asm.c:514 +#: m32r-asm.c:387 openrisc-asm.c:301 xstormy16-asm.c:333 msgid "missing mnemonic in syntax string" msgstr "instruktion saknas i syntaxstr�ng" #. We couldn't parse it. -#: fr30-asm.c:509 fr30-asm.c:513 fr30-asm.c:600 fr30-asm.c:702 frv-asm.c:812 -#: frv-asm.c:816 frv-asm.c:903 frv-asm.c:1005 ip2k-asm.c:760 ip2k-asm.c:764 -#: ip2k-asm.c:851 ip2k-asm.c:953 iq2000-asm.c:646 iq2000-asm.c:650 -#: iq2000-asm.c:737 iq2000-asm.c:839 m32r-asm.c:511 m32r-asm.c:515 -#: m32r-asm.c:602 m32r-asm.c:704 openrisc-asm.c:447 openrisc-asm.c:451 -#: openrisc-asm.c:538 openrisc-asm.c:640 xstormy16-asm.c:470 -#: xstormy16-asm.c:474 xstormy16-asm.c:561 xstormy16-asm.c:663 +#: fr30-asm.c:507 fr30-asm.c:511 fr30-asm.c:598 fr30-asm.c:699 frv-asm.c:1482 +#: frv-asm.c:1486 frv-asm.c:1573 frv-asm.c:1674 ip2k-asm.c:714 ip2k-asm.c:718 +#: ip2k-asm.c:805 ip2k-asm.c:906 iq2000-asm.c:649 iq2000-asm.c:653 +#: iq2000-asm.c:740 iq2000-asm.c:841 m32r-asm.c:522 m32r-asm.c:526 +#: m32r-asm.c:613 m32r-asm.c:714 openrisc-asm.c:436 openrisc-asm.c:440 +#: openrisc-asm.c:527 openrisc-asm.c:628 xstormy16-asm.c:468 +#: xstormy16-asm.c:472 xstormy16-asm.c:559 xstormy16-asm.c:660 msgid "unrecognized instruction" msgstr "ok�nd instruktion" -#: fr30-asm.c:556 frv-asm.c:859 ip2k-asm.c:807 iq2000-asm.c:693 m32r-asm.c:558 -#: openrisc-asm.c:494 xstormy16-asm.c:517 +#: fr30-asm.c:554 frv-asm.c:1529 ip2k-asm.c:761 iq2000-asm.c:696 +#: m32r-asm.c:569 openrisc-asm.c:483 xstormy16-asm.c:515 #, c-format msgid "syntax error (expected char `%c', found `%c')" msgstr "syntaxfel (tecknet \"%c\" f�rv�ntades, hittade \"%c\")" -#: fr30-asm.c:566 frv-asm.c:869 ip2k-asm.c:817 iq2000-asm.c:703 m32r-asm.c:568 -#: openrisc-asm.c:504 xstormy16-asm.c:527 +#: fr30-asm.c:564 frv-asm.c:1539 ip2k-asm.c:771 iq2000-asm.c:706 +#: m32r-asm.c:579 openrisc-asm.c:493 xstormy16-asm.c:525 #, c-format msgid "syntax error (expected char `%c', found end of instruction)" msgstr "syntaxfel (tecknet \"%c\" f�rv�ntades, hittade slutet p� instruktion)" -#: fr30-asm.c:594 frv-asm.c:897 ip2k-asm.c:845 iq2000-asm.c:731 m32r-asm.c:596 -#: openrisc-asm.c:532 xstormy16-asm.c:555 +#: fr30-asm.c:592 frv-asm.c:1567 ip2k-asm.c:799 iq2000-asm.c:734 +#: m32r-asm.c:607 openrisc-asm.c:521 xstormy16-asm.c:553 msgid "junk at end of line" msgstr "skr�p vid slutet p� raden" -#: fr30-asm.c:701 frv-asm.c:1004 ip2k-asm.c:952 iq2000-asm.c:838 -#: m32r-asm.c:703 openrisc-asm.c:639 xstormy16-asm.c:662 +#: fr30-asm.c:698 frv-asm.c:1673 ip2k-asm.c:905 iq2000-asm.c:840 +#: m32r-asm.c:713 openrisc-asm.c:627 xstormy16-asm.c:659 msgid "unrecognized form of instruction" msgstr "ok�nd instruktionsform" -#: fr30-asm.c:713 frv-asm.c:1016 ip2k-asm.c:964 iq2000-asm.c:850 -#: m32r-asm.c:715 openrisc-asm.c:651 xstormy16-asm.c:674 +#: fr30-asm.c:710 frv-asm.c:1685 ip2k-asm.c:917 iq2000-asm.c:852 +#: m32r-asm.c:725 openrisc-asm.c:639 xstormy16-asm.c:671 #, c-format msgid "bad instruction `%.50s...'" msgstr "felaktig instruktion \"%.50s...\"" -#: fr30-asm.c:716 frv-asm.c:1019 ip2k-asm.c:967 iq2000-asm.c:853 -#: m32r-asm.c:718 openrisc-asm.c:654 xstormy16-asm.c:677 +#: fr30-asm.c:713 frv-asm.c:1688 ip2k-asm.c:920 iq2000-asm.c:855 +#: m32r-asm.c:728 openrisc-asm.c:642 xstormy16-asm.c:674 #, c-format msgid "bad instruction `%.50s'" msgstr "felaktig instruktion \"%.50s\"" @@ -151,70 +158,70 @@ msgstr "felaktig instruktion \"%.50s\"" msgid "*unknown*" msgstr "*ok�nd*" -#: fr30-dis.c:320 frv-dis.c:371 ip2k-dis.c:329 iq2000-dis.c:192 m32r-dis.c:251 -#: openrisc-dis.c:138 xstormy16-dis.c:171 +#: fr30-dis.c:319 frv-dis.c:410 ip2k-dis.c:313 iq2000-dis.c:191 m32r-dis.c:262 +#: openrisc-dis.c:137 xstormy16-dis.c:170 #, c-format msgid "Unrecognized field %d while printing insn.\n" msgstr "Ok�nt f�lt %d vid utskrift av instruktion.\n" -#: fr30-ibld.c:166 frv-ibld.c:166 ip2k-ibld.c:166 iq2000-ibld.c:166 -#: m32r-ibld.c:166 openrisc-ibld.c:166 xstormy16-ibld.c:166 +#: fr30-ibld.c:168 frv-ibld.c:168 ip2k-ibld.c:168 iq2000-ibld.c:168 +#: m32r-ibld.c:168 openrisc-ibld.c:168 xstormy16-ibld.c:168 #, c-format msgid "operand out of range (%ld not between %ld and %lu)" msgstr "operanden �r utanf�r intervallet (%ld �r inte mellan %ld och %lu)" -#: fr30-ibld.c:179 frv-ibld.c:179 ip2k-ibld.c:179 iq2000-ibld.c:179 -#: m32r-ibld.c:179 openrisc-ibld.c:179 xstormy16-ibld.c:179 +#: fr30-ibld.c:181 frv-ibld.c:181 ip2k-ibld.c:181 iq2000-ibld.c:181 +#: m32r-ibld.c:181 openrisc-ibld.c:181 xstormy16-ibld.c:181 #, c-format msgid "operand out of range (%lu not between 0 and %lu)" msgstr "operanden utanf�r intervallet (%lu inte mellan 0 och %lu)" -#: fr30-ibld.c:730 frv-ibld.c:829 ip2k-ibld.c:607 iq2000-ibld.c:713 -#: m32r-ibld.c:659 openrisc-ibld.c:633 xstormy16-ibld.c:678 +#: fr30-ibld.c:732 frv-ibld.c:858 ip2k-ibld.c:609 iq2000-ibld.c:715 +#: m32r-ibld.c:667 openrisc-ibld.c:635 xstormy16-ibld.c:680 #, c-format msgid "Unrecognized field %d while building insn.\n" msgstr "Ok�nt f�lt %d vid konstruktion av instruktion.\n" -#: fr30-ibld.c:937 frv-ibld.c:1121 ip2k-ibld.c:684 iq2000-ibld.c:890 -#: m32r-ibld.c:792 openrisc-ibld.c:735 xstormy16-ibld.c:826 +#: fr30-ibld.c:939 frv-ibld.c:1177 ip2k-ibld.c:686 iq2000-ibld.c:892 +#: m32r-ibld.c:806 openrisc-ibld.c:737 xstormy16-ibld.c:828 #, c-format msgid "Unrecognized field %d while decoding insn.\n" msgstr "Ok�nt f�lt %d vid avkodning av instruktion.\n" -#: fr30-ibld.c:1086 frv-ibld.c:1375 ip2k-ibld.c:761 iq2000-ibld.c:1024 -#: m32r-ibld.c:902 openrisc-ibld.c:815 xstormy16-ibld.c:939 +#: fr30-ibld.c:1088 frv-ibld.c:1458 ip2k-ibld.c:763 iq2000-ibld.c:1026 +#: m32r-ibld.c:922 openrisc-ibld.c:817 xstormy16-ibld.c:941 #, c-format msgid "Unrecognized field %d while getting int operand.\n" msgstr "Ok�nt f�lt %d vid h�mtning av heltalsoperand.\n" -#: fr30-ibld.c:1215 frv-ibld.c:1609 ip2k-ibld.c:818 iq2000-ibld.c:1138 -#: m32r-ibld.c:992 openrisc-ibld.c:875 xstormy16-ibld.c:1032 +#: fr30-ibld.c:1217 frv-ibld.c:1719 ip2k-ibld.c:820 iq2000-ibld.c:1140 +#: m32r-ibld.c:1018 openrisc-ibld.c:877 xstormy16-ibld.c:1034 #, c-format msgid "Unrecognized field %d while getting vma operand.\n" msgstr "Ok�nt f�lt %d vid h�mtning av vma-operand.\n" -#: fr30-ibld.c:1349 frv-ibld.c:1852 ip2k-ibld.c:880 iq2000-ibld.c:1261 -#: m32r-ibld.c:1090 openrisc-ibld.c:944 xstormy16-ibld.c:1134 +#: fr30-ibld.c:1351 frv-ibld.c:1989 ip2k-ibld.c:882 iq2000-ibld.c:1263 +#: m32r-ibld.c:1122 openrisc-ibld.c:946 xstormy16-ibld.c:1136 #, c-format msgid "Unrecognized field %d while setting int operand.\n" msgstr "Ok�nt f�lt %d vid inst�llning av heltalsoperand.\n" -#: fr30-ibld.c:1471 frv-ibld.c:2083 ip2k-ibld.c:930 iq2000-ibld.c:1372 -#: m32r-ibld.c:1176 openrisc-ibld.c:1001 xstormy16-ibld.c:1224 +#: fr30-ibld.c:1473 frv-ibld.c:2247 ip2k-ibld.c:932 iq2000-ibld.c:1374 +#: m32r-ibld.c:1214 openrisc-ibld.c:1003 xstormy16-ibld.c:1226 #, c-format msgid "Unrecognized field %d while setting vma operand.\n" msgstr "Ok�nt f�lt %d vid inst�llning av vma-operand.\n" -#: frv-asm.c:365 +#: frv-asm.c:978 msgid "register number must be even" msgstr "registernumret m�ste vara j�mnt" -#: h8300-dis.c:377 +#: h8300-dis.c:358 #, c-format msgid "Hmmmm 0x%x" msgstr "Hmmmm 0x%x" -#: h8300-dis.c:760 +#: h8300-dis.c:744 #, c-format msgid "Don't understand 0x%x \n" msgstr "F�rst�r inte 0x%x \n" @@ -225,40 +232,40 @@ msgid "can't cope with insert %d\n" msgstr "kan inte s�tta in %d\n" #. Couldn't understand anything. -#: h8500-dis.c:350 +#: h8500-dis.c:342 #, c-format msgid "%02x\t\t*unknown*" msgstr "%02x\t\t*ok�nd*" -#: i386-dis.c:1699 +#: i386-dis.c:1733 msgid "" msgstr "" -#: ia64-gen.c:295 +#: ia64-gen.c:297 #, c-format msgid "%s: Error: " msgstr "%s: Fel: " -#: ia64-gen.c:308 +#: ia64-gen.c:310 #, c-format msgid "%s: Warning: " msgstr "%s: Varning: " -#: ia64-gen.c:494 ia64-gen.c:728 +#: ia64-gen.c:496 ia64-gen.c:730 #, c-format msgid "multiple note %s not handled\n" msgstr "multipel anteckning %s hanteras inte\n" -#: ia64-gen.c:605 +#: ia64-gen.c:607 msgid "can't find ia64-ic.tbl for reading\n" msgstr "kan inte hitta ia64-ic.tbl f�r l�sning\n" -#: ia64-gen.c:810 +#: ia64-gen.c:812 #, c-format msgid "can't find %s for reading\n" msgstr "kan inte hitta %s f�r l�sning\n" -#: ia64-gen.c:1034 +#: ia64-gen.c:1036 #, c-format msgid "" "most recent format '%s'\n" @@ -267,82 +274,82 @@ msgstr "" "allra senaste formatet \"%s\"\n" "verkar mer restriktivt �n \"%s\"\n" -#: ia64-gen.c:1045 +#: ia64-gen.c:1047 #, c-format msgid "overlapping field %s->%s\n" msgstr "�verlappande f�lt %s->%s\n" -#: ia64-gen.c:1236 +#: ia64-gen.c:1244 #, c-format msgid "overwriting note %d with note %d (IC:%s)\n" msgstr "skriver �ver anteckning %d med anteckning %d (IC:%s)\n" -#: ia64-gen.c:1435 +#: ia64-gen.c:1443 #, c-format msgid "don't know how to specify %% dependency %s\n" msgstr "vet inte hur %%-beroende %s ska anges\n" -#: ia64-gen.c:1457 +#: ia64-gen.c:1465 #, c-format msgid "Don't know how to specify # dependency %s\n" msgstr "Vet inte hur #-beroende %s ska anges\n" -#: ia64-gen.c:1496 +#: ia64-gen.c:1504 #, c-format msgid "IC:%s [%s] has no terminals or sub-classes\n" msgstr "IC:%s [%s] har inga terminaler eller underklasser\n" -#: ia64-gen.c:1499 +#: ia64-gen.c:1507 #, c-format msgid "IC:%s has no terminals or sub-classes\n" msgstr "IC:%s har inga terminaler eller underklasser\n" -#: ia64-gen.c:1508 +#: ia64-gen.c:1516 #, c-format msgid "no insns mapped directly to terminal IC %s [%s]" msgstr "inga instruktioner mappade direkt till terminal-IC %s [%s]" -#: ia64-gen.c:1511 +#: ia64-gen.c:1519 #, c-format msgid "no insns mapped directly to terminal IC %s\n" msgstr "inga instruktioner mappade direkt till terminal-IC %s\n" -#: ia64-gen.c:1522 +#: ia64-gen.c:1530 #, c-format msgid "class %s is defined but not used\n" msgstr "klassen %s �r definierad men inte anv�nd\n" # Misst�nkt pluralhack! -#: ia64-gen.c:1533 +#: ia64-gen.c:1541 #, c-format msgid "Warning: rsrc %s (%s) has no chks%s\n" msgstr "Varning: rsrc %s (%s) har inga kontroller%s\n" -#: ia64-gen.c:1537 +#: ia64-gen.c:1545 #, c-format msgid "rsrc %s (%s) has no regs\n" msgstr "rsrc %s (%s) har inga register\n" -#: ia64-gen.c:2436 +#: ia64-gen.c:2444 #, c-format msgid "IC note %d in opcode %s (IC:%s) conflicts with resource %s note %d\n" msgstr "" "IC-anteckning %d i instruktion %s (IC:%s) st�r i konflikt med resurs %s\n" "anteckning %d\n" -#: ia64-gen.c:2464 +#: ia64-gen.c:2472 #, c-format msgid "IC note %d for opcode %s (IC:%s) conflicts with resource %s note %d\n" msgstr "" "IC-anteckning %d f�r instruktion %s (IC:%s) st�r i konflikt med resurs %s\n" "anteckning %d\n" -#: ia64-gen.c:2478 +#: ia64-gen.c:2486 #, c-format msgid "opcode %s has no class (ops %d %d %d)\n" msgstr "instruktion %s har ingen klass (operationer %d %d %d)\n" -#: ia64-gen.c:2789 +#: ia64-gen.c:2816 #, c-format msgid "unable to change directory to \"%s\", errno = %s\n" msgstr "kan inte byta katalog till \"%s\", felnummer = %s\n" @@ -354,66 +361,66 @@ msgid "W keyword invalid in FR operand slot." msgstr "W-nyckelord ogiltigt i FR-operandlucka." #. Invalid offset present. -#: ip2k-asm.c:122 +#: ip2k-asm.c:117 msgid "offset(IP) is not a valid form" msgstr "avst�ndet(IP) �r inte en giltig form" #. Found something there in front of (DP) but it's out #. of range. -#: ip2k-asm.c:175 +#: ip2k-asm.c:165 msgid "(DP) offset out of range." msgstr "(DP) avst�ndet �r utanf�r intervallet." #. Found something there in front of (SP) but it's out #. of range. -#: ip2k-asm.c:221 +#: ip2k-asm.c:206 msgid "(SP) offset out of range." msgstr "(SP) avst�ndet �r utanf�r intervallet." -#: ip2k-asm.c:241 +#: ip2k-asm.c:222 msgid "illegal use of parentheses" msgstr "otill�ten anv�ndning av parenteser" -#: ip2k-asm.c:248 +#: ip2k-asm.c:229 msgid "operand out of range (not between 1 and 255)" msgstr "operanden utanf�r intervallet (inte mellan 1 och 255)" #. Something is very wrong. opindex has to be one of the above. -#: ip2k-asm.c:273 +#: ip2k-asm.c:254 msgid "parse_addr16: invalid opindex." msgstr "parse_addr16: ogiltigt opindex." -#: ip2k-asm.c:353 +#: ip2k-asm.c:309 msgid "Byte address required. - must be even." msgstr "Byteadress kr�vs - m�ste vara j�mn." -#: ip2k-asm.c:362 +#: ip2k-asm.c:318 msgid "cgen_parse_address returned a symbol. Literal required." msgstr "cgen_parse_address returnerade en symbol. Literal kr�vs." -#: ip2k-asm.c:420 +#: ip2k-asm.c:376 #, c-format msgid "%operator operand is not a symbol" msgstr "%operator-operand �r inte en symbol" -#: ip2k-asm.c:474 +#: ip2k-asm.c:430 msgid "Attempt to find bit index of 0" msgstr "F�rs�k att hitta 0-bitindex" -#: iq2000-asm.c:110 iq2000-asm.c:141 +#: iq2000-asm.c:115 iq2000-asm.c:146 msgid "immediate value cannot be register" msgstr "omedelbart v�rde kan inte vara register" -#: iq2000-asm.c:120 iq2000-asm.c:151 +#: iq2000-asm.c:126 iq2000-asm.c:156 msgid "immediate value out of range" msgstr "omedelbart v�rde �r utanf�r intervallet" -#: iq2000-asm.c:180 +#: iq2000-asm.c:185 msgid "21-bit offset out of range" msgstr "21-bitars avst�nd utanf�r intervallet" -#: iq2000-asm.c:205 iq2000-asm.c:235 iq2000-asm.c:272 iq2000-asm.c:305 -#: openrisc-asm.c:96 openrisc-asm.c:155 +#: iq2000-asm.c:210 iq2000-asm.c:240 iq2000-asm.c:277 iq2000-asm.c:310 +#: openrisc-asm.c:90 openrisc-asm.c:144 msgid "missing `)'" msgstr "\")\" saknas" @@ -427,17 +434,17 @@ msgstr "ok�nd\t0x%02x" msgid "unknown\t0x%04lx" msgstr "ok�nd\t0x%04lx" -#: m10300-dis.c:766 +#: m10300-dis.c:767 #, c-format msgid "unknown\t0x%04x" msgstr "ok�nd\t0x%04x" -#: m68k-dis.c:429 +#: m68k-dis.c:295 #, c-format msgid "\n" msgstr "\n" -#: m68k-dis.c:1007 +#: m68k-dis.c:1089 #, c-format msgid "" msgstr "" @@ -447,26 +454,27 @@ msgstr "" msgid "# " msgstr "# " -#: mips-dis.c:699 +#: mips-dis.c:720 msgid "# internal error, incomplete extension sequence (+)" msgstr "# internt fel, ofullst�ndig �ndelsesekvens (+)" -#: mips-dis.c:742 +#: mips-dis.c:779 #, c-format msgid "# internal error, undefined extension sequence (+%c)" msgstr "# internt fel, odefinierad �ndelsesekvens (+%c)" -#: mips-dis.c:1000 +#: mips-dis.c:1037 #, c-format msgid "# internal error, undefined modifier(%c)" msgstr "# internt fel, ok�nd modifierare(%c)" -#: mips-dis.c:1751 +#: mips-dis.c:1793 #, c-format msgid "# internal disassembler error, unrecognised modifier (%c)" msgstr "# internt disassemblerfel, ok�nd modifierare (%c)" -#: mips-dis.c:1763 +#: mips-dis.c:1805 +#, c-format msgid "" "\n" "The following MIPS specific disassembler options are supported for use\n" @@ -476,7 +484,8 @@ msgstr "" "F�ljande MIPS-specifika disassembleralternativ st�ds f�r anv�ndning\n" "tillsammans med flaggan -M (flera alternativ kan skiljas �t med komman):\n" -#: mips-dis.c:1767 +#: mips-dis.c:1809 +#, c-format msgid "" "\n" " gpr-names=ABI Print GPR names according to specified ABI.\n" @@ -487,7 +496,8 @@ msgstr "" " Standard: baserat p� den bin�rfil som\n" " disassembleras.\n" -#: mips-dis.c:1771 +#: mips-dis.c:1813 +#, c-format msgid "" "\n" " fpr-names=ABI Print FPR names according to specified ABI.\n" @@ -497,7 +507,8 @@ msgstr "" " fpr-names=ABI Skriv ut FPR-namn enligt det angivna ABI:t.\n" " Standard: numeriskt.\n" -#: mips-dis.c:1775 +#: mips-dis.c:1817 +#, c-format msgid "" "\n" " cp0-names=ARCH Print CP0 register names according to\n" @@ -510,7 +521,8 @@ msgstr "" " Standard: baserat p� den bin�rfil som\n" " disassembleras.\n" -#: mips-dis.c:1780 +#: mips-dis.c:1822 +#, c-format msgid "" "\n" " hwr-names=ARCH Print HWR names according to specified \n" @@ -523,7 +535,8 @@ msgstr "" " Standard: baserat p� den bin�rfil som\n" " disassembleras.\n" -#: mips-dis.c:1785 +#: mips-dis.c:1827 +#, c-format msgid "" "\n" " reg-names=ABI Print GPR and FPR names according to\n" @@ -533,7 +546,8 @@ msgstr "" " reg-names=ABI Skriv ut GPR- och FPR-namn enligt det angivna\n" " ABI:t.\n" -#: mips-dis.c:1789 +#: mips-dis.c:1831 +#, c-format msgid "" "\n" " reg-names=ARCH Print CP0 register and HWR names according to\n" @@ -543,7 +557,8 @@ msgstr "" " reg-names=ARK Skriv ut CP0-register med HWR-namn enligt\n" " angiven arkitektur.\n" -#: mips-dis.c:1793 +#: mips-dis.c:1835 +#, c-format msgid "" "\n" " For the options above, the following values are supported for \"ABI\":\n" @@ -553,11 +568,13 @@ msgstr "" " F�r flaggorna ovan st�ds f�ljande v�rden p� \"ABI\":\n" " " -#: mips-dis.c:1798 mips-dis.c:1806 mips-dis.c:1808 +#: mips-dis.c:1840 mips-dis.c:1848 mips-dis.c:1850 +#, c-format msgid "\n" msgstr "\n" -#: mips-dis.c:1800 +#: mips-dis.c:1842 +#, c-format msgid "" "\n" " For the options above, The following values are supported for \"ARCH\":\n" @@ -593,86 +610,91 @@ msgstr "*ok�nd operandtyp: %d*" #. * anyway! #. #: ns32k-dis.c:631 +#, c-format msgid "$" msgstr "$" -#: ppc-opc.c:781 ppc-opc.c:809 +#: ppc-opc.c:794 ppc-opc.c:822 msgid "invalid conditional option" msgstr "ogiltig villkorlig flagga" -#: ppc-opc.c:811 +#: ppc-opc.c:824 msgid "attempt to set y bit when using + or - modifier" msgstr "f�rs�k att st�lla in y-biten d� modifieraren + eller - anv�ndes" -#: ppc-opc.c:840 +#: ppc-opc.c:852 msgid "offset not a multiple of 16" msgstr "avst�ndet �r inte en multipel av 16" -#: ppc-opc.c:860 +#: ppc-opc.c:871 msgid "offset not a multiple of 2" msgstr "avst�ndet �r inte en multipel av 2" -#: ppc-opc.c:862 +#: ppc-opc.c:873 msgid "offset greater than 62" msgstr "avst�ndet �r st�rre �n 62" -#: ppc-opc.c:881 ppc-opc.c:927 ppc-opc.c:975 +#: ppc-opc.c:892 ppc-opc.c:937 ppc-opc.c:981 msgid "offset not a multiple of 4" msgstr "avst�ndet �r inte en multipel av 4" -#: ppc-opc.c:883 +#: ppc-opc.c:894 msgid "offset greater than 124" msgstr "avst�ndet �r st�rre �n 124" -#: ppc-opc.c:902 +#: ppc-opc.c:913 msgid "offset not a multiple of 8" msgstr "avst�ndet �r inte en multipel av 8" -#: ppc-opc.c:904 +#: ppc-opc.c:915 msgid "offset greater than 248" msgstr "avst�ndet �r st�rre �n 248" -#: ppc-opc.c:950 +#: ppc-opc.c:958 msgid "offset not between -2048 and 2047" msgstr "avst�ndet �r inte mellan -2048 och 2047" -#: ppc-opc.c:973 +#: ppc-opc.c:979 msgid "offset not between -8192 and 8191" msgstr "avst�ndet �r inte mellan -8192 och 8191" -#: ppc-opc.c:1011 +#: ppc-opc.c:1007 +msgid "invalid mask field" +msgstr "ogiltigt maskf�lt" + +#: ppc-opc.c:1033 msgid "ignoring invalid mfcr mask" msgstr "ignorerar ogiltig mfcr-mask" -#: ppc-opc.c:1059 +#: ppc-opc.c:1075 msgid "ignoring least significant bits in branch offset" msgstr "ignorerar minst signifikanta bitarna i grenavst�nd" -#: ppc-opc.c:1090 ppc-opc.c:1125 +#: ppc-opc.c:1105 ppc-opc.c:1140 msgid "illegal bitmask" msgstr "otill�ten bitmask" -#: ppc-opc.c:1192 +#: ppc-opc.c:1205 msgid "value out of range" msgstr "v�rdet �r utanf�r intervallet" -#: ppc-opc.c:1262 +#: ppc-opc.c:1273 msgid "index register in load range" msgstr "indexregistret �r i inl�sningsintervallet" -#: ppc-opc.c:1279 +#: ppc-opc.c:1289 msgid "source and target register operands must be different" msgstr "k�ll- och m�lregisteroperander m�ste vara olika" -#: ppc-opc.c:1294 +#: ppc-opc.c:1304 msgid "invalid register operand when updating" msgstr "ogiltig registeroperand vid uppdatering" -#: ppc-opc.c:1335 +#: ppc-opc.c:1343 msgid "target register operand must be even" msgstr "m�lregisteroperand m�ste vara j�mn" -#: ppc-opc.c:1350 +#: ppc-opc.c:1357 msgid "source register operand must be even" msgstr "k�llregisteroperand m�ste vara j�mn" @@ -696,12 +718,12 @@ msgstr "Internt fel: felaktig sparc-opcode.h: \"%s\", %#.8lx, %#.8lx\n" msgid "Internal error: bad sparc-opcode.h: \"%s\" == \"%s\"\n" msgstr "Internt fel: felaktig sparc-opcode.h: \"%s\" == \"%s\"\n" -#: v850-dis.c:221 +#: v850-dis.c:225 #, c-format msgid "unknown operand shift: %x\n" msgstr "ok�nt operandskifte: %x\n" -#: v850-dis.c:233 +#: v850-dis.c:237 #, c-format msgid "unknown pop reg: %d\n" msgstr "ok�nt pop-register: %d\n" @@ -711,47 +733,47 @@ msgstr "ok�nt pop-register: %d\n" #. v850_insert_operand() in gas/config/tc-v850.c. Error messages #. containing the string 'out of range' will be ignored unless a #. specific command line option is given to GAS. -#: v850-opc.c:68 +#: v850-opc.c:69 msgid "displacement value is not in range and is not aligned" msgstr "f�rskjutningsv�rdet �r inte inom intervallet och ligger inte p� j�mn gr�ns" -#: v850-opc.c:69 +#: v850-opc.c:70 msgid "displacement value is out of range" msgstr "f�rskjutningsv�rdet �r utanf�r intervallet" -#: v850-opc.c:70 +#: v850-opc.c:71 msgid "displacement value is not aligned" msgstr "f�rskjutningsv�rdet ligger inte p� j�mn gr�ns" -#: v850-opc.c:72 +#: v850-opc.c:73 msgid "immediate value is out of range" msgstr "omedelbara v�rdet �r utanf�r intervallet" -#: v850-opc.c:83 +#: v850-opc.c:84 msgid "branch value not in range and to odd offset" msgstr "grenv�rdet �r inte inom intervallet och till ett udda avst�nd" -#: v850-opc.c:85 v850-opc.c:117 +#: v850-opc.c:86 v850-opc.c:118 msgid "branch value out of range" msgstr "grenv�rdet �r utanf�r intervallet" -#: v850-opc.c:88 v850-opc.c:120 +#: v850-opc.c:89 v850-opc.c:121 msgid "branch to odd offset" msgstr "grening till udda avst�nd" -#: v850-opc.c:115 +#: v850-opc.c:116 msgid "branch value not in range and to an odd offset" msgstr "grenv�rdet �r inte inom intervallet och till ett udda avst�nd" -#: v850-opc.c:346 +#: v850-opc.c:347 msgid "invalid register for stack adjustment" msgstr "ogiltigt register f�r stackjustering" -#: v850-opc.c:370 +#: v850-opc.c:371 msgid "immediate value not in range and not even" msgstr "omedelbara v�rdet �r inte inom intervallet och inte j�mnt" -#: v850-opc.c:375 +#: v850-opc.c:376 msgid "immediate value must be even" msgstr "omedelbara v�rdet m�ste vara j�mnt" diff --git a/opcodes/xc16x-ibld.c b/opcodes/xc16x-ibld.c index 97e6bbc..de82f3f 100644 --- a/opcodes/xc16x-ibld.c +++ b/opcodes/xc16x-ibld.c @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } diff --git a/opcodes/xstormy16-ibld.c b/opcodes/xstormy16-ibld.c index 57ef85c..51aee9d 100644 --- a/opcodes/xstormy16-ibld.c +++ b/opcodes/xstormy16-ibld.c @@ -3,7 +3,7 @@ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. - the resultant file is machine generated, cgen-ibld.in isn't - Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005 + Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006 Free Software Foundation, Inc. This file is part of the GNU Binutils and GDB, the GNU debugger. @@ -168,13 +168,21 @@ insert_normal (CGEN_CPU_DESC cd, else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) { unsigned long maxval = mask; - - if ((unsigned long) value > maxval) + unsigned long val = (unsigned long) value; + + /* For hosts with a word size > 32 check to see if value has been sign + extended beyond 32 bits. If so then ignore these higher sign bits + as the user is attempting to store a 32-bit signed value into an + unsigned 32-bit field which is allowed. */ + if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) + val &= 0xFFFFFFFF; + + if (val > maxval) { /* xgettext:c-format */ sprintf (errbuf, - _("operand out of range (%lu not between 0 and %lu)"), - value, maxval); + _("operand out of range (0x%lx not between 0 and 0x%lx)"), + val, maxval); return errbuf; } } @@ -440,9 +448,8 @@ extract_normal (CGEN_CPU_DESC cd, word_length may be too big. */ if (cd->min_insn_bitsize < cd->base_insn_bitsize) { - if (word_offset == 0 - && word_length > total_length) - word_length = total_length; + if (word_offset + word_length > total_length) + word_length = total_length - word_offset; } /* Does the value reside in INSN_VALUE, and at the right alignment? */ diff --git a/readline/ChangeLog.gdb b/readline/ChangeLog.gdb index 28cb1f2..863beca 100644 --- a/readline/ChangeLog.gdb +++ b/readline/ChangeLog.gdb @@ -1,3 +1,8 @@ +2006-03-21 Denis Pilat + + * histfile.c (read_history_range): Remove '\r' character from + history lines. + 2005-02-10 Denis Pilat * readline/terminal.c (_rl_get_screen_size): Get console size from diff --git a/readline/histfile.c b/readline/histfile.c index 60a9125..c19630d 100644 --- a/readline/histfile.c +++ b/readline/histfile.c @@ -228,7 +228,10 @@ read_history_range (filename, from, to) for (line_end = line_start; line_end < bufend; line_end++) if (*line_end == '\n') { - *line_end = '\0'; + if (line_end - 1 >= line_start && *(line_end - 1) == '\r') + *(line_end - 1) = '\0'; + else + *line_end = '\0'; if (*line_start) add_history (line_start); diff --git a/sim/ChangeLog b/sim/ChangeLog index a7e59e0..83e6dcc 100644 --- a/sim/ChangeLog +++ b/sim/ChangeLog @@ -1,3 +1,7 @@ +2006-03-13 DJ Delorie + + * MAINTAINERS: Add self as m32c sim maintainer. + 2006-02-23 Hans-Peter Nilsson * cris/traps.c (syscall_map): Remove CB_SYS_time / TARGET_SYS_time diff --git a/sim/MAINTAINERS b/sim/MAINTAINERS index 897539a..395a88f 100644 --- a/sim/MAINTAINERS +++ b/sim/MAINTAINERS @@ -15,6 +15,7 @@ igen (igen simulators) ppc Andrew Cagney m68hc11 Stephane Carrez sh (global maintainers) +m32c DJ Delorie common Ben Elliston common Frank Ch. Eigler * (target, then global maintainers) diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog index df88ef1..c4ea3bd 100644 --- a/sim/arm/ChangeLog +++ b/sim/arm/ChangeLog @@ -1,3 +1,7 @@ +2006-03-07 Paul Brook + + * elfos.c (ARMul_OSHandleSWI): Call correct function for IsTTY. + 2006-02-01 Shaun Jackman * armos.c (ARMul_OSHandleSWI): Handle the RedBoot system diff --git a/sim/arm/armos.c b/sim/arm/armos.c index 8e346c7..7739052 100644 --- a/sim/arm/armos.c +++ b/sim/arm/armos.c @@ -747,8 +747,8 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number) break; case AngelSWI_Reason_IsTTY: - state->Reg[0] = sim_callback->close (sim_callback, - ARMul_ReadWord (state, addr)); + state->Reg[0] = sim_callback->isatty (sim_callback, + ARMul_ReadWord (state, addr)); OSptr->ErrorNo = sim_callback->get_errno (sim_callback); break; diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index 2db4937..dcadcd6 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,8 @@ +2006-03-29 Hans-Peter Nilsson + + * aclocal.m4 (SIM_AC_OPTION_HARDWARE): Correct duplicate- + option-contents test. + 2005-11-28 Mark Mitchell * sim-signal.c (sim_signal_to_target): Fix typos. diff --git a/sim/common/aclocal.m4 b/sim/common/aclocal.m4 index 056beba..d94b1e6 100644 --- a/sim/common/aclocal.m4 +++ b/sim/common/aclocal.m4 @@ -593,9 +593,8 @@ else # remove duplicates sim_hw="" sim_hw_objs="\$(SIM_COMMON_HW_OBJS)" - for i in x $hardware ; do - case " $f " in - x) ;; + for i in $hardware ; do + case " $sim_hw " in *" $i "*) ;; *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";; esac diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog index 0e44c07..9c3cae1 100644 --- a/sim/m32c/ChangeLog +++ b/sim/m32c/ChangeLog @@ -1,3 +1,15 @@ +2006-03-13 DJ Delorie + + * mem.c (mem_put_byte): Hook simulated UART to stdout. + (mem_put_hi): Hook in simulated trace port. + (mem_get_byte): Hook in simulated uart control port. + * opc2c: Be more picky about matching special comments. + * r8c.opc (shift_op): Limit shift counts to -16..16. + (BMcnd): Map conditional codes. + * reg.c (condition_true): Mask condition code to 4 bits. + * syscalls.c: Include local syscall.h. + * syscall.h: New, copied from libgloss. + 2005-10-06 Jim Blandy Simulator for Renesas M32C and M16C, by DJ Delorie , diff --git a/sim/m32c/mem.c b/sim/m32c/mem.c index d7623a4..258c295 100644 --- a/sim/m32c/mem.c +++ b/sim/m32c/mem.c @@ -202,6 +202,23 @@ mem_put_byte (int address, unsigned char value) } break; + case 0x3aa: /* uart1tx */ + { + static int pending_exit = 0; + if (value == 0) + { + if (pending_exit) + { + step_result = M32C_MAKE_EXITED(value); + return; + } + pending_exit = 1; + } + else + putchar(value); + } + break; + case 0x400: m32c_syscall (value); break; @@ -232,6 +249,11 @@ mem_put_qi (int address, unsigned char value) void mem_put_hi (int address, unsigned short value) { + if (address == 0x402) + { + printf ("SimTrace: %06lx %04x\n", regs.r_pc, value); + return; + } S ("<="); mem_put_byte (address, value & 0xff); mem_put_byte (address + 1, value >> 8); @@ -288,16 +310,16 @@ mem_get_byte (int address) address &= membus_mask; S ("=>"); m = mem_ptr (address); - if (trace) + switch (address) { - if (tpr) + case 0x3ad: /* uart1c1 */ + E(); + return 2; /* transmitter empty */ + break; + default: + if (trace) printf (" %02x", *m); - else - { - S ("=>"); - printf (" %02x", *m); - E (); - } + break; } E (); return *m; diff --git a/sim/m32c/r8c.opc b/sim/m32c/r8c.opc index 4a6ba51..4db0bda 100644 --- a/sim/m32c/r8c.opc +++ b/sim/m32c/r8c.opc @@ -240,6 +240,15 @@ shift_op (srcdest sd, int arith, int count) { mask = 0xffffffffU; msb = 0x80000000U; + if (count > 16 || count < -16) + { + fprintf(stderr, "Error: SI shift of %d undefined\n", count); + exit(1); + } + if (count > 16) + count = (count - 1) % 16 + 1; + if (count < -16) + count = -((-count - 1) % 16 + 1); } tprintf("%s %x by %d\n", arith ? "sha" : "shl", v, count); @@ -292,6 +301,12 @@ shift_op (srcdest sd, int arith, int count) tprintf ("b=%d, carry=%d, %s = %d\n", b, carry, #expr, v); \ set_c (v); +/* The "BMcnd dest" opcode uses a different encoding for the */ +/* condition than other opcodes. */ +static int bmcnd_cond_map[] = { + 0, 1, 2, 3, 8, 9, 10, 11, 4, 5, 6, 7, 12, 13, 14, 15 +}; + int decode_r8c() { @@ -448,7 +463,7 @@ decode_r8c() /** 0111 1110 0010 dest BMcnd dest */ dc = decode_bit (dest); - if (condition_true (IMM (0))) + if (condition_true (bmcnd_cond_map [IMM (0) & 15])) put_bit (dc, 1); else put_bit (dc, 0); diff --git a/sim/m32c/reg.c b/sim/m32c/reg.c index 40cb11c..8c01675 100644 --- a/sim/m32c/reg.c +++ b/sim/m32c/reg.c @@ -347,7 +347,7 @@ condition_true (int cond_id) "(S^O)|Z", "O", "!(S^O)", "unk", "!((S^O)|Z)", "!O", "S^O", "unk" }; - switch (cond_id) + switch (cond_id & 15) { case 0: f = FLAG_C; @@ -409,7 +409,7 @@ condition_true (int cond_id) "C", "GTU", "Z", "N", "O", "LE", "LT", "!?" }; - switch (cond_id) + switch (cond_id & 15) { case 0: f = !FLAG_C; diff --git a/sim/m32c/syscall.h b/sim/m32c/syscall.h new file mode 100644 index 0000000..0194e03 --- /dev/null +++ b/sim/m32c/syscall.h @@ -0,0 +1,50 @@ +/* Copied from libgloss */ +/* General use syscall.h file. + The more ports that use this file, the simpler sim/common/nltvals.def + remains. */ + +#ifndef LIBGLOSS_SYSCALL_H +#define LIBGLOSS_SYSCALL_H + +/* Note: This file may be included by assembler source. */ + +/* These should be as small as possible to allow a port to use a trap type + instruction, which the system call # as the trap (the d10v for instance + supports traps 0..31). An alternative would be to define one trap for doing + system calls, and put the system call number in a register that is not used + for the normal calling sequence (so that you don't have to shift down the + arguments to add the system call number). Obviously, if these system call + numbers are ever changed, all of the simulators and potentially user code + will need to be updated. */ + +/* There is no current need for the following: SYS_execv, SYS_creat, SYS_wait, + etc. etc. Don't add them. */ + +/* These are required by the ANSI C part of newlib (excluding system() of + course). */ +#define SYS_exit 1 +#define SYS_open 2 +#define SYS_close 3 +#define SYS_read 4 +#define SYS_write 5 +#define SYS_lseek 6 +#define SYS_unlink 7 +#define SYS_getpid 8 +#define SYS_kill 9 +#define SYS_fstat 10 +/*#define SYS_sbrk 11 - not currently a system call, but reserved. */ + +/* ARGV support. */ +#define SYS_argvlen 12 +#define SYS_argv 13 + +/* These are extras added for one reason or another. */ +#define SYS_chdir 14 +#define SYS_stat 15 +#define SYS_chmod 16 +#define SYS_utime 17 +#define SYS_time 18 +#define SYS_gettimeofday 19 +#define SYS_times 20 +#define SYS_link 21 +#endif diff --git a/sim/m32c/syscalls.c b/sim/m32c/syscalls.c index bf33c1d..0a1c249 100644 --- a/sim/m32c/syscalls.c +++ b/sim/m32c/syscalls.c @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA #include "mem.h" #include "syscalls.h" -#include "../../libgloss/syscall.h" +#include "syscall.h" /* The current syscall callbacks we're using. */ static struct host_callback_struct *callbacks; diff --git a/sim/m68hc11/ChangeLog b/sim/m68hc11/ChangeLog index 78daebc..edfb2ac 100644 --- a/sim/m68hc11/ChangeLog +++ b/sim/m68hc11/ChangeLog @@ -1,3 +1,7 @@ +2006-03-29 Hans-Peter Nilsson + + * configure: Regenerate. + 2005-03-23 Mark Kettenis * configure: Regenerate. diff --git a/sim/m68hc11/configure b/sim/m68hc11/configure index 12bf1c6..cc32d65 100755 --- a/sim/m68hc11/configure +++ b/sim/m68hc11/configure @@ -7557,9 +7557,8 @@ else # remove duplicates sim_hw="" sim_hw_objs="\$(SIM_COMMON_HW_OBJS)" - for i in x $hardware ; do - case " $f " in - x) ;; + for i in $hardware ; do + case " $sim_hw " in *" $i "*) ;; *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";; esac diff --git a/sim/mips/ChangeLog b/sim/mips/ChangeLog index 9457544..65b8fae 100644 --- a/sim/mips/ChangeLog +++ b/sim/mips/ChangeLog @@ -1,3 +1,7 @@ +2006-03-29 Hans-Peter Nilsson + + * configure: Regenerate. + 2005-12-14 Chao-ying Fu * Makefile.in (SIM_OBJS): Add dsp.o. diff --git a/sim/mips/configure b/sim/mips/configure index b458181..d0d47eb 100755 --- a/sim/mips/configure +++ b/sim/mips/configure @@ -8130,9 +8130,8 @@ else # remove duplicates sim_hw="" sim_hw_objs="\$(SIM_COMMON_HW_OBJS)" - for i in x $hardware ; do - case " $f " in - x) ;; + for i in $hardware ; do + case " $sim_hw " in *" $i "*) ;; *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";; esac diff --git a/sim/mn10300/ChangeLog b/sim/mn10300/ChangeLog index 0a31acc..7862bb3 100644 --- a/sim/mn10300/ChangeLog +++ b/sim/mn10300/ChangeLog @@ -1,3 +1,7 @@ +2006-03-29 Hans-Peter Nilsson + + * configure: Regenerate. + 2005-03-23 Mark Kettenis * configure: Regenerate. diff --git a/sim/mn10300/configure b/sim/mn10300/configure index 5ca10af..6cee4fc 100755 --- a/sim/mn10300/configure +++ b/sim/mn10300/configure @@ -7674,9 +7674,8 @@ else # remove duplicates sim_hw="" sim_hw_objs="\$(SIM_COMMON_HW_OBJS)" - for i in x $hardware ; do - case " $f " in - x) ;; + for i in $hardware ; do + case " $sim_hw " in *" $i "*) ;; *) sim_hw="$sim_hw $i" ; sim_hw_objs="$sim_hw_objs dv-$i.o";; esac