From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11559 invoked by alias); 18 Dec 2003 11:43:04 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 11337 invoked from network); 18 Dec 2003 11:42:58 -0000 Received: from unknown (HELO mail04.idc.renesas.com) (202.234.163.13) by sources.redhat.com with SMTP; 18 Dec 2003 11:42:58 -0000 Received: (from root@localhost) by guardian01.idc.renesas.com with id hBIBgl98018460; Thu, 18 Dec 2003 20:42:47 +0900 (JST) Received: from unknown [172.20.8.73] by guardian01.idc.renesas.com with SMTP id WAA18459 ; Thu, 18 Dec 2003 20:42:46 +0900 Received: from dnma02 (dnma02.rso.renesas.com [10.15.11.200]) by dnma01.rso.renesas.com (iPlanet Messaging Server 5.2 HotFix 1.12 (built Feb 13 2003)) with ESMTP id <0HQ300KGG9V7CW@dnma01.rso.renesas.com>; Thu, 18 Dec 2003 20:42:44 +0900 (JST) Received: from t1pcapricot.tool.maec.co.jp ([10.145.105.37]) by dnma02.rso.renesas.com (iPlanet Messaging Server 5.2 HotFix 1.12 (built Feb 13 2003)) with SMTP id <0HQ300DJO9V3HY@dnma02.rso.renesas.com>; Thu, 18 Dec 2003 20:42:43 +0900 (JST) Date: Thu, 18 Dec 2003 11:43:00 -0000 From: Kazuhiro Inaoka Subject: [PATCH] New port m32r-linux target. To: Nick Clifton Cc: binutils@sources.redhat.com, gdb-patches@sources.redhat.com Message-id: <007901c3c55c$cc9229e0$2569910a@tool.maec.co.jp> MIME-version: 1.0 Content-type: multipart/mixed; boundary="Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw)" X-SW-Source: 2003-12/txt/msg00431.txt.bz2 This is a multi-part message in MIME format. --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: text/plain; charset=iso-2022-jp Content-transfer-encoding: 7BIT Content-length: 4859 Hello, This patch is .. Support PIC and m32r-linux target. m32r-*-as generates objects with RELA relocations instead of REL relocations. m32r-*-ld can link both of RELA and REL relocations. Please commit it. Kazuhiro Inaoka bfd/ChangLog 2003-12-18 Kazuhiro Inaoka m32r-linux and PIC support. Add new ABI of USE_RELA. * config.bfd (m32r*-*-linux*, m32r*le-*-linux*, m32r*le-*-*): Added. * configure.in (bfd_elf32_m32rlin_vec, bfd_elf32_m32rlelin_vec, bfd_elf32_m32rle_vec): Added * elf32-m32r.c (m32r_info_to_howto, m32r_elf_adjust_dynamic_symbol, m32r_elf_size_dynamic_sections, m32r_elf_create_dynamic_sections, m32r_elf_finish_dynamic_sections, m32r_elf_finish_dynamic_symbol, allocate_dynrelocs, readonly_dynrelocs, m32r_elf_reloc_type_class, m32r_elf_fake_sections): Added. (m32r_elf_howto_table): Added R_M32R_16_RELA, R_M32R_32_RELA, R_M32R_24_RELA, R_M32R_10_PCREL_RELA, R_M32R_18_PCREL_RELA, R_M32R_26_PCREL_RELA, R_M32R_HI16_ULO_RELA, R_M32R_HI16_SLO_RELA, R_M32R_LO16_RELA, R_M32R_SDA16_RELA, R_M32R_RELA_GNU_VTINHERIT, R_M32R_RELA_GNU_VTENTRY, R_M32R_GOT24, R_M32R_26_PLTREL, R_M32R_COPY, R_M32R_GLOB_DAT, R_M32R_JMP_SLOT, R_M32R_RELATIVE, R_M32R_GOTOFF, R_M32R_GOTPC24, R_M32R_GOT16_HI_ULO, R_M32R_GOT16_HI_SLO, R_M32R_GOT16_LO, R_M32R_GOTPC_HI_ULO, R_M32R_GOTPC_HI_SLO, R_M32R_GOTPC_LO. (m32r_elf_relocate_section, m32r_elf_check_relocs): Changed for New ABI. * reloc.c: Added BFD_RELOC_M32R_GOT24, BFD_RELOC_M32R_26_PLTREL, BFD_RELOC_M32R_COPY, BFD_RELOC_M32R_GLOB_DAT, BFD_RELOC_M32R_JMP_SLOT, BFD_RELOC_M32R_RELATIVE, BFD_RELOC_M32R_GOTOFF, BFD_RELOC_M32R_GOTPC24, BFD_RELOC_M32R_GOT16_HI_ULO, BFD_RELOC_M32R_GOT16_HI_SLO, BFD_RELOC_M32R_GOT16_LO, BFD_RELOC_M32R_GOTPC_HI_ULO, BFD_RELOC_M32R_GOTPC_HI_SLO, BFD_RELOC_M32R_GOTPC_LO. * targets.c (bfd_elf32_m32rlin_vec, bfd_elf32_m32rlelin_vec, bfd_elf32_m32rle_vec): Added gas/ChangeLog 2003-12-18 Kazuhiro Inaoka m32r-linux and PIC support. Add new ABI of USE_RELA. * configure.in: Add m32r-linux targets. * config/tc-m32r.c (md_parse_option): Add -KPIC option. (tc_gen_reloc): Added. (debug_sym, md_estimate_size_before_relax, md_convert_frag, md_pcrel_from_section, m32r_fix_adjustable): Changed for PIC. * config/tc-m32r.h (tc_gen_reloc, EXTERN_FORCE_RELOC): Undefined. (TC_HANDLES_FX_DONE, TC_FIX_ADJUSTABLE, TC_RELOC_RTSYM_LOC_FIXUP, ): Defined. gdb/configure.host 2003-12-18 Kazuhiro Inaoka m32r-linux and PIC support. Add new ABI of USE_RELA. * configure.host: Add m32r-linux targets. include/ChangeLog 2003-12-18 Kazuhiro Inaoka m32r-linux and PIC support. Add new ABI of USE_RELA. * elf/m32r.h : Added R_M32R_16_RELA, R_M32R_32_RELA, R_M32R_24_RELA, R_M32R_10_PCREL_RELA, R_M32R_18_PCREL_RELA, R_M32R_26_PCREL_RELA, R_M32R_HI16_ULO_RELA, R_M32R_HI16_SLO_RELA, R_M32R_LO16_RELA, R_M32R_SDA16_RELA, R_M32R_RELA_GNU_VTINHERIT, R_M32R_RELA_GNU_VTENTRY, R_M32R_GOT24, R_M32R_26_PLTREL, R_M32R_COPY, R_M32R_GLOB_DAT, R_M32R_JMP_SLOT, R_M32R_RELATIVE, R_M32R_GOTOFF, R_M32R_GOTPC24, R_M32R_GOT16_HI_ULO, R_M32R_GOT16_HI_SLO, R_M32R_GOT16_LO, R_M32R_GOTPC_HI_ULO, R_M32R_GOTPC_HI_SLO, R_M32R_GOTPC_LO. ld/ChangeLog 2003-12-18 Kazuhiro Inaoka m32r-linux and PIC support. Add new ABI of USE_RELA. * Makefile.am: Added em32rlelf.c, em32relf_linux.c, em32rlelf_linux.c. * configure.tgt (m32r*-*-linux*, m32r*le-*-linux*, m32r*le-*-*): Added. * emulparams/m32relf_linux.sh: Added. * emulparams/m32rlelf.sh: Ditto. * emulparams/m32rlelf_linux.sh: Ditto. sim/ChangeLog 2003-12-18 Kazuhiro Inaoka * common/sim-core.c (sim_core_trans_addr): Added for m32r-linux-run. sim/m32r/ChangeLog 2003-12-18 Kazuhiro Inaoka * configure.in: Changed for dummy simulator of m32r-linux. * Makefile.in: Added traps-linux.o for dummy simulator of m32r-linux. * traps-linux.c: Added for dummy simulator of m32r-linux. * syscall.h: Ditto. * sim-if.c (sim_create_inferior): Changed to setup SP for dummy simulator for m32r-linux. * sim-main.h (M32R_DEFAULT_MEM_SIZE): Changed for dummy simulator of m32r-linux. --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: application/octet-stream; name=newreloc.patch Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=newreloc.patch Content-length: 193076 Index: bfd/config.bfd=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/bfd/config.bfd,v=0A= retrieving revision 1.149=0A= diff -c -r1.149 config.bfd=0A= *** bfd/config.bfd 3 Dec 2003 15:07:15 -0000 1.149=0A= --- bfd/config.bfd 18 Dec 2003 10:04:31 -0000=0A= ***************=0A= *** 597,602 ****=0A= --- 597,617 ----=0A= targ_defvec=3Dbfd_elf32_iq2000_vec=0A= ;;=0A= =20=20=0A= + m32r*le-*-linux*)=0A= + targ_defvec=3Dbfd_elf32_m32rlelin_vec=0A= + targ_selvecs=3D"bfd_elf32_m32rlin_vec bfd_elf32_m32rlelin_vec"=0A= + ;;=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= + m32r*-*-linux*)=0A= + targ_defvec=3Dbfd_elf32_m32rlin_vec=0A= + targ_selvecs=3D"bfd_elf32_m32rlin_vec bfd_elf32_m32rlelin_vec"=0A= + ;;=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= + m32r*le-*-*)=0A= + targ_defvec=3Dbfd_elf32_m32rle_vec=0A= + targ_selvecs=3D"bfd_elf32_m32r_vec bfd_elf32_m32rle_vec"=0A= + ;;=0A= +=20=0A= m32r-*-*)=0A= targ_defvec=3Dbfd_elf32_m32r_vec=0A= ;;=0A= Index: bfd/configure.in=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/bfd/configure.in,v=0A= retrieving revision 1.141=0A= diff -c -r1.141 configure.in=0A= *** bfd/configure.in 3 Dec 2003 15:07:15 -0000 1.141=0A= --- bfd/configure.in 18 Dec 2003 10:04:32 -0000=0A= ***************=0A= *** 631,636 ****=0A= --- 631,639 ----=0A= bfd_elf32_littlearm_vec) tb=3D"$tb elfarm-nabi.lo elf32.lo $elf" ;;= =0A= bfd_elf32_littlemips_vec) tb=3D"$tb elf32-mips.lo elfxx-mips.lo elf3= 2.lo $elf ecofflink.lo" ;;=0A= bfd_elf32_m32r_vec) tb=3D"$tb elf32-m32r.lo elf32.lo $elf" ;;=0A= + bfd_elf32_m32rle_vec) tb=3D"$tb elf32-m32r.lo elf32.lo $elf" ;;= =0A= + bfd_elf32_m32rlin_vec) tb=3D"$tb elf32-m32r.lo elf32.lo $elf" ;;= =0A= + bfd_elf32_m32rlelin_vec) tb=3D"$tb elf32-m32r.lo elf32.lo $elf" ;;= =0A= bfd_elf32_m68hc11_vec) tb=3D"$tb elf32-m68hc11.lo elf32-m68hc1x.lo el= f32.lo $elf" ;;=0A= bfd_elf32_m68hc12_vec) tb=3D"$tb elf32-m68hc12.lo elf32-m68hc1x.lo el= f32.lo $elf" ;;=0A= bfd_elf32_m68k_vec) tb=3D"$tb elf32-m68k.lo elf32.lo $elf" ;;=0A= Index: bfd/elf32-m32r.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/bfd/elf32-m32r.c,v=0A= retrieving revision 1.38=0A= diff -c -r1.38 elf32-m32r.c=0A= *** bfd/elf32-m32r.c 3 Dec 2003 17:38:48 -0000 1.38=0A= --- bfd/elf32-m32r.c 18 Dec 2003 10:04:33 -0000=0A= ***************=0A= *** 44,49 ****=0A= --- 44,51 ----=0A= PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));=0A= static void m32r_info_to_howto_rel=0A= PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));=0A= + static void m32r_info_to_howto=0A= + PARAMS ((bfd *, arelent *, Elf_Internal_Rela *));=0A= bfd_boolean _bfd_m32r_elf_section_from_bfd_section=0A= PARAMS ((bfd *, asection *, int *));=0A= void _bfd_m32r_elf_symbol_processing=0A= ***************=0A= *** 77,86 ****=0A= --- 79,112 ----=0A= PARAMS ((bfd *, struct bfd_link_info *, asection *,=0A= const Elf_Internal_Rela *));=0A= =20=20=0A= + static bfd_boolean m32r_elf_adjust_dynamic_symbol=0A= + PARAMS ((struct bfd_link_info *, struct elf_link_hash_entry *));=0A= + static bfd_boolean m32r_elf_size_dynamic_sections=0A= + PARAMS ((bfd *, struct bfd_link_info *));=0A= +=20=0A= asection * m32r_elf_gc_mark_hook=0A= PARAMS ((asection *, struct bfd_link_info *, Elf_Internal_Rela *,=0A= struct elf_link_hash_entry *, Elf_Internal_Sym *));=0A= =20=20=0A= + static bfd_boolean m32r_elf_create_dynamic_sections=0A= + PARAMS ((bfd *, struct bfd_link_info *));=0A= +=20=0A= + static bfd_boolean m32r_elf_finish_dynamic_sections=0A= + PARAMS ((bfd *, struct bfd_link_info *));=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= + static bfd_boolean m32r_elf_finish_dynamic_symbol=0A= + PARAMS ((bfd *, struct bfd_link_info *, struct elf_link_hash_entry *,= =0A= + Elf_Internal_Sym *));=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= + static bfd_boolean allocate_dynrelocs=0A= + PARAMS ((struct elf_link_hash_entry *, PTR));=0A= + static bfd_boolean readonly_dynrelocs=0A= + PARAMS ((struct elf_link_hash_entry *, PTR));=0A= + static enum elf_reloc_type_class m32r_elf_reloc_type_class=0A= + PARAMS ((const Elf_Internal_Rela *));=0A= + static bfd_boolean m32r_elf_fake_sections=0A= + PARAMS ((bfd *, Elf_Internal_Shdr *, asection *));=0A= +=20=0A= #define NOP_INSN 0x7000=0A= #define MAKE_PARALLEL(insn) ((insn) | 0x8000)=0A= =20=20=0A= ***************=0A= *** 88,98 ****=0A= This only saves space in libraries and object files, but perhaps=0A= relocs will be put in ROM? All in all though, REL relocs are a pain= =0A= to work with. */=0A= ! #define USE_REL 1=0A= =20=20=0A= #ifndef USE_REL=0A= #define USE_REL 0=0A= ! #endif=0A= =20=20=0A= static reloc_howto_type m32r_elf_howto_table[] =3D=0A= {=0A= --- 114,168 ----=0A= This only saves space in libraries and object files, but perhaps=0A= relocs will be put in ROM? All in all though, REL relocs are a pain= =0A= to work with. */=0A= ! /* #define USE_REL 1=0A= =20=20=0A= #ifndef USE_REL=0A= #define USE_REL 0=0A= ! #endif */=0A= ! /* Use RELA. But use REL to link old objects for backwords compatibility.= */=0A= !=20=0A= ! /* Functions for the M32R ELF linker. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! /* The name of the dynamic interpreter. This is put in the .interp=0A= ! section. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! #define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1"=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! /* The nop opcode we use. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! #define M32R_NOP 0x7000f000=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! #define PLT_EMPTY 0x10101010 /* RIE -> RIE */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! /* The size in bytes of an entry in the procedure linkage table. */=0A= !=20=0A= ! #define PLT_ENTRY_SIZE 20=0A= ! #define PLT_HEADER_SIZE 20=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! /* The first one entries in a procedure linkage table are reserved,=0A= ! and the initial contents are unimportant (we zero them out).=0A= ! Subsequent entries look like this. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! #define PLT0_ENTRY_WORD0 0xd6c00000 /* seth r6, #high(.got+4) = */=0A= ! #define PLT0_ENTRY_WORD1 0x86e60000 /* or3 r6, r6, #low(.got)+4) = */=0A= ! #define PLT0_ENTRY_WORD2 0x24e626c6 /* ld r4, @r6+ -> ld r6, @r6= */=0A= ! #define PLT0_ENTRY_WORD3 0x1fc6f000 /* jmp r6 || pnop = */=0A= ! #define PLT0_ENTRY_WORD4 PLT_EMPTY /* RIE -> RIE = */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! #define PLT0_PIC_ENTRY_WORD0 0xa4cc0004 /* ld r4, @(4,r12) = */=0A= ! #define PLT0_PIC_ENTRY_WORD1 0xa6cc0008 /* ld r6, @(8,r12) = */=0A= ! #define PLT0_PIC_ENTRY_WORD2 0x1fc6f000 /* jmp r6 || nop = */=0A= ! #define PLT0_PIC_ENTRY_WORD3 PLT_EMPTY /* RIE -> RIE = */=0A= ! #define PLT0_PIC_ENTRY_WORD4 PLT_EMPTY /* RIE -> RIE = */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! #define PLT_ENTRY_WORD0 0xe6000000 /* ld24 r6, .name_in_GOT = */=0A= ! #define PLT_ENTRY_WORD1 0x06acf000 /* add r6, r12 || nop = */=0A= ! #define PLT_ENTRY_WORD0b 0xd6c00000 /* seth r6, #high(.name_in_GOT) = */=0A= ! #define PLT_ENTRY_WORD1b 0x86e60000 /* or3 r6, r6, #low(.name_in_GOT) = */=0A= ! #define PLT_ENTRY_WORD2 0x26c61fc6 /* ld r6, @r6 -> jmp r6 = */=0A= ! #define PLT_ENTRY_WORD3 0xe5000000 /* ld24 r5, $offset = */=0A= ! #define PLT_ENTRY_WORD4 0xff000000 /* bra .plt0. = */=0A= !=20=0A= =20=20=0A= static reloc_howto_type m32r_elf_howto_table[] =3D=0A= {=0A= ***************=0A= *** 302,420 ****=0A= 0, /* dst_mask */=0A= FALSE), /* pcrel_offset */=0A= =20=20=0A= ! };=0A= ! =0C=0A= ! /* Handle the R_M32R_10_PCREL reloc. */=0A= !=20=0A= ! static bfd_reloc_status_type=0A= ! m32r_elf_10_pcrel_reloc (abfd, reloc_entry, symbol, data,=0A= ! input_section, output_bfd, error_message)=0A= ! bfd * abfd;=0A= ! arelent * reloc_entry;=0A= ! asymbol * symbol;=0A= ! PTR data;=0A= ! asection * input_section;=0A= ! bfd * output_bfd;=0A= ! char ** error_message ATTRIBUTE_UNUSED;=0A= ! {=0A= ! /* This part is from bfd_elf_generic_reloc. */=0A= ! if (output_bfd !=3D (bfd *) NULL=0A= ! && (symbol->flags & BSF_SECTION_SYM) =3D=3D 0=0A= ! && (! reloc_entry->howto->partial_inplace=0A= ! || reloc_entry->addend =3D=3D 0))=0A= ! {=0A= ! reloc_entry->address +=3D input_section->output_offset;=0A= ! return bfd_reloc_ok;=0A= ! }=0A= =20=20=0A= ! if (output_bfd !=3D NULL)=0A= ! {=0A= ! /* FIXME: See bfd_perform_relocation. Is this right? */=0A= ! return bfd_reloc_continue;=0A= ! }=0A= =20=20=0A= ! return m32r_elf_do_10_pcrel_reloc (abfd, reloc_entry->howto,=0A= ! input_section,=0A= ! data, reloc_entry->address,=0A= ! symbol->section,=0A= ! (symbol->value=0A= ! + symbol->section->output_section->vma=0A= ! + symbol->section->output_offset),=0A= ! reloc_entry->addend);=0A= ! }=0A= =20=20=0A= ! /* Utility to actually perform an R_M32R_10_PCREL reloc. */=0A= =20=20=0A= ! static bfd_reloc_status_type=0A= ! m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset,=0A= ! symbol_section, symbol_value, addend)=0A= ! bfd *abfd;=0A= ! reloc_howto_type *howto;=0A= ! asection *input_section;=0A= ! bfd_byte *data;=0A= ! bfd_vma offset;=0A= ! asection *symbol_section ATTRIBUTE_UNUSED;=0A= ! bfd_vma symbol_value;=0A= ! bfd_vma addend;=0A= ! {=0A= ! bfd_signed_vma relocation;=0A= ! unsigned long x;=0A= ! bfd_reloc_status_type status;=0A= =20=20=0A= ! /* Sanity check the address (offset in section). */=0A= ! if (offset > input_section->_cooked_size)=0A= ! return bfd_reloc_outofrange;=0A= =20=20=0A= ! relocation =3D symbol_value + addend;=0A= ! /* Make it pc relative. */=0A= ! relocation -=3D (input_section->output_section->vma=0A= ! + input_section->output_offset);=0A= ! /* These jumps mask off the lower two bits of the current address=0A= ! before doing pcrel calculations. */=0A= ! relocation -=3D (offset & -(bfd_vma) 4);=0A= =20=20=0A= ! if (relocation < -0x200 || relocation > 0x1ff)=0A= ! status =3D bfd_reloc_overflow;=0A= ! else=0A= ! status =3D bfd_reloc_ok;=0A= =20=20=0A= ! x =3D bfd_get_16 (abfd, data + offset);=0A= ! relocation >>=3D howto->rightshift;=0A= ! relocation <<=3D howto->bitpos;=0A= ! x =3D (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & = howto->dst_mask);=0A= ! bfd_put_16 (abfd, (bfd_vma) x, data + offset);=0A= =20=20=0A= ! return status;=0A= ! }=0A= =20=20=0A= ! /* Handle the R_M32R_HI16_[SU]LO relocs.=0A= ! HI16_SLO is for the add3 and load/store with displacement instructions= .=0A= ! HI16_ULO is for the or3 instruction.=0A= ! For R_M32R_HI16_SLO, the lower 16 bits are sign extended when added to= =0A= ! the high 16 bytes so if the lower 16 bits are negative (bit 15 =3D=3D = 1) then=0A= ! we must add one to the high 16 bytes (which will get subtracted off wh= en=0A= ! the low 16 bits are added).=0A= ! These relocs have to be done in combination with an R_M32R_LO16 reloc= =0A= ! because there is a carry from the LO16 to the HI16. Here we just save= =0A= ! the information we need; we do the actual relocation when we see the L= O16.=0A= ! This code is copied from the elf32-mips.c. We also support an arbitra= ry=0A= ! number of HI16 relocs to be associated with a single LO16 reloc. The= =0A= ! assembler sorts the relocs to ensure each HI16 immediately precedes it= s=0A= ! LO16. However if there are multiple copies, the assembler may not fin= d=0A= ! the real LO16 so it picks the first one it finds. */=0A= =20=20=0A= ! struct m32r_hi16=0A= ! {=0A= ! struct m32r_hi16 *next;=0A= ! bfd_byte *addr;=0A= ! bfd_vma addend;=0A= ! };=0A= =20=20=0A= ! /* FIXME: This should not be a static variable. */=0A= =20=20=0A= ! static struct m32r_hi16 *m32r_hi16_list;=0A= =20=20=0A= ! static bfd_reloc_status_type=0A= m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data,=0A= input_section, output_bfd, error_message)=0A= bfd *abfd ATTRIBUTE_UNUSED;=0A= --- 372,921 ----=0A= 0, /* dst_mask */=0A= FALSE), /* pcrel_offset */=0A= =20=20=0A= ! EMPTY_HOWTO (13),=0A= ! EMPTY_HOWTO (14),=0A= ! EMPTY_HOWTO (15),=0A= ! EMPTY_HOWTO (16),=0A= ! EMPTY_HOWTO (17),=0A= ! EMPTY_HOWTO (18),=0A= ! EMPTY_HOWTO (19),=0A= ! EMPTY_HOWTO (20),=0A= ! EMPTY_HOWTO (21),=0A= ! EMPTY_HOWTO (22),=0A= ! EMPTY_HOWTO (23),=0A= ! EMPTY_HOWTO (24),=0A= ! EMPTY_HOWTO (25),=0A= ! EMPTY_HOWTO (26),=0A= ! EMPTY_HOWTO (27),=0A= ! EMPTY_HOWTO (28),=0A= ! EMPTY_HOWTO (29),=0A= ! EMPTY_HOWTO (30),=0A= ! EMPTY_HOWTO (31),=0A= ! EMPTY_HOWTO (32),=0A= =20=20=0A= ! /* A 16 bit absolute relocation. */=0A= ! HOWTO (R_M32R_16_RELA, /* type */=0A= ! 0, /* rightshift */=0A= ! 1, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_16_RELA", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffff, /* src_mask */=0A= ! 0xffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* A 32 bit absolute relocation. */=0A= ! HOWTO (R_M32R_32_RELA, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 32, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc,/* special_function */=0A= ! "R_M32R_32_RELA", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffffff, /* src_mask */=0A= ! 0xffffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* A 24 bit address. */=0A= ! HOWTO (R_M32R_24_RELA, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 24, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_unsigned, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc,/* special_function */=0A= ! "R_M32R_24_RELA", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffff, /* src_mask */=0A= ! 0xffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! HOWTO (R_M32R_10_PCREL_RELA, /* type */=0A= ! 2, /* rightshift */=0A= ! 1, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 10, /* bitsize */=0A= ! TRUE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_signed, /* complain_on_overflow */=0A= ! m32r_elf_10_pcrel_reloc, /* special_function */=0A= ! "R_M32R_10_PCREL_RELA",/* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xff, /* src_mask */=0A= ! 0xff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= =20=20=0A= ! /* A relative 18 bit relocation, right shifted by 2. */=0A= ! HOWTO (R_M32R_18_PCREL_RELA, /* type */=0A= ! 2, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! TRUE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_signed, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_18_PCREL_RELA",/* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffff, /* src_mask */=0A= ! 0xffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= =20=20=0A= ! /* A relative 26 bit relocation, right shifted by 2. */=0A= ! HOWTO (R_M32R_26_PCREL_RELA, /* type */=0A= ! 2, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 26, /* bitsize */=0A= ! TRUE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_signed, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_26_PCREL_RELA",/* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffff, /* src_mask */=0A= ! 0xffffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= =20=20=0A= ! /* High 16 bits of address when lower 16 is or'd in. */=0A= ! HOWTO (R_M32R_HI16_ULO_RELA, /* type */=0A= ! 16, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_HI16_ULO_RELA",/* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* High 16 bits of address when lower 16 is added in. */=0A= ! HOWTO (R_M32R_HI16_SLO_RELA, /* type */=0A= ! 16, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_HI16_SLO_RELA",/* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* Lower 16 bits of address. */=0A= ! HOWTO (R_M32R_LO16_RELA, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_LO16_RELA", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* Small data area 16 bits offset. */=0A= ! HOWTO (R_M32R_SDA16_RELA, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_signed, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_SDA16_RELA", /* name */=0A= ! TRUE, /* partial_inplace */ /* FIXME: correct? */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* GNU extension to record C++ vtable hierarchy */=0A= ! HOWTO (R_M32R_RELA_GNU_VTINHERIT, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D l= ong) */=0A= ! 0, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! NULL, /* special_function */=0A= ! "R_M32R_RELA_GNU_VTINHERIT", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0, /* src_mask */=0A= ! 0, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* GNU extension to record C++ vtable member usage */=0A= ! HOWTO (R_M32R_RELA_GNU_VTENTRY, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D l= ong) */=0A= ! 0, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! _bfd_elf_rel_vtable_reloc_fn, /* special_function */=0A= ! "R_M32R_RELA_GNU_VTENTRY", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0, /* src_mask */=0A= ! 0, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! EMPTY_HOWTO (45),=0A= ! EMPTY_HOWTO (46),=0A= ! EMPTY_HOWTO (47),=0A= !=20=0A= ! /* Like R_M32R_24, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOT24, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 24, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_unsigned, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOT24", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffff, /* src_mask */=0A= ! 0xffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= =20=20=0A= ! /* Like R_M32R_PCREL, but referring to the procedure linkage table=0A= ! entry for the symbol. */=0A= ! HOWTO (R_M32R_26_PLTREL, /* type */=0A= ! 2, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 24, /* bitsize */=0A= ! TRUE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_signed, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_26_PLTREL", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffff, /* src_mask */=0A= ! 0xffffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= !=20=0A= ! /* This is used only by the dynamic linker. The symbol should exist=0A= ! both in the object being run and in some shared library. The=0A= ! dynamic linker copies the data addressed by the symbol from the=0A= ! shared library into the object, because the object being=0A= ! run has to have the data at some particular address. */=0A= ! HOWTO (R_M32R_COPY, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 32, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_COPY", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffffff, /* src_mask */=0A= ! 0xffffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* Like R_M32R_24, but used when setting global offset table=0A= ! entries. */=0A= ! HOWTO (R_M32R_GLOB_DAT, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 32, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GLOB_DAT", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffffff, /* src_mask */=0A= ! 0xffffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* Marks a procedure linkage table entry for a symbol. */=0A= ! HOWTO (R_M32R_JMP_SLOT, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 32, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_JMP_SLOT", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffffff, /* src_mask */=0A= ! 0xffffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* Used only by the dynamic linker. When the object is run, this=0A= ! longword is set to the load address of the object, plus the=0A= ! addend. */=0A= ! HOWTO (R_M32R_RELATIVE, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 32, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_RELATIVE", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffffff, /* src_mask */=0A= ! 0xffffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! HOWTO (R_M32R_GOTOFF, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 32, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_bitfield, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOTOFF", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffffff, /* src_mask */=0A= ! 0xffffffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* An PC Relative 24-bit relocation used when setting PIC offset=0A= ! table register. */=0A= ! HOWTO (R_M32R_GOTPC24, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 24, /* bitsize */=0A= ! TRUE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_unsigned, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOTPC24", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0xffffff, /* src_mask */=0A= ! 0xffffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= !=20=0A= ! /* Like R_M32R_HI16_ULO, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOT16_HI_ULO, /* type */=0A= ! 16, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOT16_HI_ULO", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* Like R_M32R_HI16_SLO, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOT16_HI_SLO, /* type */=0A= ! 16, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOT16_HI_SLO", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* Like R_M32R_LO16, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOT16_LO, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOT16_LO", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! FALSE), /* pcrel_offset */=0A= !=20=0A= ! /* An PC Relative relocation used when setting PIC offset table registe= r.=0A= ! Like R_M32R_HI16_ULO, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOTPC_HI_ULO, /* type */=0A= ! 16, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOTPC_HI_ULO", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= !=20=0A= ! /* An PC Relative relocation used when setting PIC offset table registe= r.=0A= ! Like R_M32R_HI16_SLO, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOTPC_HI_SLO, /* type */=0A= ! 16, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOTPC_HI_SLO", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= !=20=0A= ! /* An PC Relative relocation used when setting PIC offset table registe= r.=0A= ! Like R_M32R_LO16, but referring to the GOT table entry for=0A= ! the symbol. */=0A= ! HOWTO (R_M32R_GOTPC_LO, /* type */=0A= ! 0, /* rightshift */=0A= ! 2, /* size (0 =3D byte, 1 =3D short, 2 =3D long) */=0A= ! 16, /* bitsize */=0A= ! FALSE, /* pc_relative */=0A= ! 0, /* bitpos */=0A= ! complain_overflow_dont, /* complain_on_overflow */=0A= ! bfd_elf_generic_reloc, /* special_function */=0A= ! "R_M32R_GOTPC_LO", /* name */=0A= ! FALSE, /* partial_inplace */=0A= ! 0x0000ffff, /* src_mask */=0A= ! 0x0000ffff, /* dst_mask */=0A= ! TRUE), /* pcrel_offset */=0A= ! };=0A= ! =0C=0A= ! /* Handle the R_M32R_10_PCREL reloc. */=0A= !=20=0A= ! static bfd_reloc_status_type=0A= ! m32r_elf_10_pcrel_reloc (abfd, reloc_entry, symbol, data,=0A= ! input_section, output_bfd, error_message)=0A= ! bfd * abfd;=0A= ! arelent * reloc_entry;=0A= ! asymbol * symbol;=0A= ! PTR data;=0A= ! asection * input_section;=0A= ! bfd * output_bfd;=0A= ! char ** error_message ATTRIBUTE_UNUSED;=0A= ! {=0A= ! /* This part is from bfd_elf_generic_reloc. */=0A= ! if (output_bfd !=3D (bfd *) NULL=0A= ! && (symbol->flags & BSF_SECTION_SYM) =3D=3D 0=0A= ! && (! reloc_entry->howto->partial_inplace=0A= ! || reloc_entry->addend =3D=3D 0))=0A= ! {=0A= ! reloc_entry->address +=3D input_section->output_offset;=0A= ! return bfd_reloc_ok;=0A= ! }=0A= !=20=0A= ! if (output_bfd !=3D NULL)=0A= ! {=0A= ! /* FIXME: See bfd_perform_relocation. Is this right? */=0A= ! return bfd_reloc_continue;=0A= ! }=0A= !=20=0A= ! return m32r_elf_do_10_pcrel_reloc (abfd, reloc_entry->howto,=0A= ! input_section,=0A= ! data, reloc_entry->address,=0A= ! symbol->section,=0A= ! (symbol->value=0A= ! + symbol->section->output_section->vma=0A= ! + symbol->section->output_offset),=0A= ! reloc_entry->addend);=0A= ! }=0A= !=20=0A= ! /* Utility to actually perform an R_M32R_10_PCREL reloc. */=0A= !=20=0A= ! static bfd_reloc_status_type=0A= ! m32r_elf_do_10_pcrel_reloc (abfd, howto, input_section, data, offset,=0A= ! symbol_section, symbol_value, addend)=0A= ! bfd *abfd;=0A= ! reloc_howto_type *howto;=0A= ! asection *input_section;=0A= ! bfd_byte *data;=0A= ! bfd_vma offset;=0A= ! asection *symbol_section ATTRIBUTE_UNUSED;=0A= ! bfd_vma symbol_value;=0A= ! bfd_vma addend;=0A= ! {=0A= ! bfd_signed_vma relocation;=0A= ! unsigned long x;=0A= ! bfd_reloc_status_type status;=0A= !=20=0A= ! /* Sanity check the address (offset in section). */=0A= ! if (offset > input_section->_cooked_size)=0A= ! return bfd_reloc_outofrange;=0A= !=20=0A= ! relocation =3D symbol_value + addend;=0A= ! /* Make it pc relative. */=0A= ! relocation -=3D (input_section->output_section->vma=0A= ! + input_section->output_offset);=0A= ! /* These jumps mask off the lower two bits of the current address=0A= ! before doing pcrel calculations. */=0A= ! relocation -=3D (offset & -(bfd_vma) 4);=0A= !=20=0A= ! if (relocation < -0x200 || relocation > 0x1ff)=0A= ! status =3D bfd_reloc_overflow;=0A= ! else=0A= ! status =3D bfd_reloc_ok;=0A= !=20=0A= ! x =3D bfd_get_16 (abfd, data + offset);=0A= ! relocation >>=3D howto->rightshift;=0A= ! relocation <<=3D howto->bitpos;=0A= ! x =3D (x & ~howto->dst_mask) | (((x & howto->src_mask) + relocation) & = howto->dst_mask);=0A= ! bfd_put_16 (abfd, (bfd_vma) x, data + offset);=0A= !=20=0A= ! return status;=0A= ! }=0A= !=20=0A= ! /* Handle the R_M32R_HI16_[SU]LO relocs.=0A= ! HI16_SLO is for the add3 and load/store with displacement instructions= .=0A= ! HI16_ULO is for the or3 instruction.=0A= ! For R_M32R_HI16_SLO, the lower 16 bits are sign extended when added to= =0A= ! the high 16 bytes so if the lower 16 bits are negative (bit 15 =3D=3D = 1) then=0A= ! we must add one to the high 16 bytes (which will get subtracted off wh= en=0A= ! the low 16 bits are added).=0A= ! These relocs have to be done in combination with an R_M32R_LO16 reloc= =0A= ! because there is a carry from the LO16 to the HI16. Here we just save= =0A= ! the information we need; we do the actual relocation when we see the L= O16.=0A= ! This code is copied from the elf32-mips.c. We also support an arbitra= ry=0A= ! number of HI16 relocs to be associated with a single LO16 reloc. The= =0A= ! assembler sorts the relocs to ensure each HI16 immediately precedes it= s=0A= ! LO16. However if there are multiple copies, the assembler may not fin= d=0A= ! the real LO16 so it picks the first one it finds. */=0A= !=20=0A= ! struct m32r_hi16=0A= ! {=0A= ! struct m32r_hi16 *next;=0A= ! bfd_byte *addr;=0A= ! bfd_vma addend;=0A= ! };=0A= !=20=0A= ! /* FIXME: This should not be a static variable. */=0A= !=20=0A= ! static struct m32r_hi16 *m32r_hi16_list;=0A= !=20=0A= ! static bfd_reloc_status_type=0A= m32r_elf_hi16_reloc (abfd, reloc_entry, symbol, data,=0A= input_section, output_bfd, error_message)=0A= bfd *abfd ATTRIBUTE_UNUSED;=0A= ***************=0A= *** 715,721 ****=0A= unsigned char elf_reloc_val;=0A= };=0A= =20=20=0A= ! static const struct m32r_reloc_map m32r_reloc_map[] =3D=0A= {=0A= { BFD_RELOC_NONE, R_M32R_NONE },=0A= { BFD_RELOC_16, R_M32R_16 },=0A= --- 1216,1222 ----=0A= unsigned char elf_reloc_val;=0A= };=0A= =20=20=0A= ! static const struct m32r_reloc_map m32r_reloc_map_old[] =3D=0A= {=0A= { BFD_RELOC_NONE, R_M32R_NONE },=0A= { BFD_RELOC_16, R_M32R_16 },=0A= ***************=0A= *** 732,737 ****=0A= --- 1233,1270 ----=0A= { BFD_RELOC_VTABLE_ENTRY, R_M32R_GNU_VTENTRY },=0A= };=0A= =20=20=0A= + static const struct m32r_reloc_map m32r_reloc_map[] =3D=0A= + {=0A= + { BFD_RELOC_NONE, R_M32R_NONE },=0A= + { BFD_RELOC_16, R_M32R_16_RELA },=0A= + { BFD_RELOC_32, R_M32R_32_RELA },=0A= + { BFD_RELOC_M32R_24, R_M32R_24_RELA },=0A= + { BFD_RELOC_M32R_10_PCREL, R_M32R_10_PCREL_RELA },=0A= + { BFD_RELOC_M32R_18_PCREL, R_M32R_18_PCREL_RELA },=0A= + { BFD_RELOC_M32R_26_PCREL, R_M32R_26_PCREL_RELA },=0A= + { BFD_RELOC_M32R_HI16_ULO, R_M32R_HI16_ULO_RELA },=0A= + { BFD_RELOC_M32R_HI16_SLO, R_M32R_HI16_SLO_RELA },=0A= + { BFD_RELOC_M32R_LO16, R_M32R_LO16_RELA },=0A= + { BFD_RELOC_M32R_SDA16, R_M32R_SDA16_RELA },=0A= + { BFD_RELOC_VTABLE_INHERIT, R_M32R_RELA_GNU_VTINHERIT },=0A= + { BFD_RELOC_VTABLE_ENTRY, R_M32R_RELA_GNU_VTENTRY },=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= + { BFD_RELOC_M32R_GOT24, R_M32R_GOT24 },=0A= + { BFD_RELOC_M32R_26_PLTREL, R_M32R_26_PLTREL },=0A= + { BFD_RELOC_M32R_COPY, R_M32R_COPY },=0A= + { BFD_RELOC_M32R_GLOB_DAT, R_M32R_GLOB_DAT },=0A= + { BFD_RELOC_M32R_JMP_SLOT, R_M32R_JMP_SLOT },=0A= + { BFD_RELOC_M32R_RELATIVE, R_M32R_RELATIVE },=0A= + { BFD_RELOC_M32R_GOTOFF, R_M32R_GOTOFF },=0A= + { BFD_RELOC_M32R_GOTPC24, R_M32R_GOTPC24 },=0A= + { BFD_RELOC_M32R_GOT16_HI_ULO, R_M32R_GOT16_HI_ULO },=0A= + { BFD_RELOC_M32R_GOT16_HI_SLO, R_M32R_GOT16_HI_SLO },=0A= + { BFD_RELOC_M32R_GOT16_LO, R_M32R_GOT16_LO },=0A= + { BFD_RELOC_M32R_GOTPC_HI_ULO, R_M32R_GOTPC_HI_ULO },=0A= + { BFD_RELOC_M32R_GOTPC_HI_SLO, R_M32R_GOTPC_HI_SLO },=0A= + { BFD_RELOC_M32R_GOTPC_LO, R_M32R_GOTPC_LO },=0A= + };=0A= +=20=0A= static reloc_howto_type *=0A= bfd_elf32_bfd_reloc_type_lookup (abfd, code)=0A= bfd *abfd ATTRIBUTE_UNUSED;=0A= ***************=0A= *** 739,744 ****=0A= --- 1272,1287 ----=0A= {=0A= unsigned int i;=0A= =20=20=0A= + #ifdef USE_M32R_OLD_RELOC=0A= + for (i =3D 0;=0A= + i < sizeof (m32r_reloc_map_old) / sizeof (struct m32r_reloc_map);= =0A= + i++)=0A= + {=0A= + if (m32r_reloc_map_old[i].bfd_reloc_val =3D=3D code)=0A= + return &m32r_elf_howto_table[m32r_reloc_map_old[i].elf_reloc_val];=0A= + }=0A= + #else /* ! USE_M32R_OLD_RELOC */=0A= +=20=0A= for (i =3D 0;=0A= i < sizeof (m32r_reloc_map) / sizeof (struct m32r_reloc_map);=0A= i++)=0A= ***************=0A= *** 746,751 ****=0A= --- 1289,1295 ----=0A= if (m32r_reloc_map[i].bfd_reloc_val =3D=3D code)=0A= return &m32r_elf_howto_table[m32r_reloc_map[i].elf_reloc_val];=0A= }=0A= + #endif=0A= =20=20=0A= return NULL;=0A= }=0A= ***************=0A= *** 753,769 ****=0A= /* Set the howto pointer for an M32R ELF reloc. */=0A= =20=20=0A= static void=0A= ! m32r_info_to_howto_rel (abfd, cache_ptr, dst)=0A= bfd *abfd ATTRIBUTE_UNUSED;=0A= arelent *cache_ptr;=0A= Elf_Internal_Rela *dst;=0A= {=0A= ! unsigned int r_type;=0A= !=20=0A= ! r_type =3D ELF32_R_TYPE (dst->r_info);=0A= ! BFD_ASSERT (r_type < (unsigned int) R_M32R_max);=0A= ! cache_ptr->howto =3D &m32r_elf_howto_table[r_type];=0A= }=0A= =0C=0A= /* Given a BFD section, try to locate the corresponding ELF section=0A= index. */=0A= --- 1297,1326 ----=0A= /* Set the howto pointer for an M32R ELF reloc. */=0A= =20=20=0A= static void=0A= ! m32r_info_to_howto_rel (abfd, cache_ptr, dst)=0A= ! bfd *abfd ATTRIBUTE_UNUSED;=0A= ! arelent *cache_ptr;=0A= ! Elf_Internal_Rela *dst;=0A= ! {=0A= ! unsigned int r_type;=0A= !=20=0A= ! r_type =3D ELF32_R_TYPE (dst->r_info);=0A= ! BFD_ASSERT (ELF32_R_TYPE(dst->r_info) <=3D (unsigned int) R_M32R_GNU_VT= ENTRY)=0A= ! cache_ptr->howto =3D &m32r_elf_howto_table[r_type];=0A= ! }=0A= !=20=0A= ! static void=0A= ! m32r_info_to_howto (abfd, cache_ptr, dst)=0A= bfd *abfd ATTRIBUTE_UNUSED;=0A= arelent *cache_ptr;=0A= Elf_Internal_Rela *dst;=0A= {=0A= ! BFD_ASSERT ((ELF32_R_TYPE(dst->r_info) =3D=3D (unsigned int) R_M32R_NON= E)=0A= ! || ((ELF32_R_TYPE(dst->r_info) > (unsigned int) R_M32R_GNU_= VTENTRY)=0A= ! && (ELF32_R_TYPE(dst->r_info) < (unsigned int) R_M32R_m= ax)));=0A= ! cache_ptr->howto =3D &m32r_elf_howto_table[ELF32_R_TYPE(dst->r_info)];= =0A= }=0A= +=20=0A= =0C=0A= /* Given a BFD section, try to locate the corresponding ELF section=0A= index. */=0A= ***************=0A= *** 854,940 ****=0A= struct bfd_link_hash_entry *bh;=0A= asection *s =3D bfd_get_section_by_name (abfd, ".sdata");=0A= =20=20=0A= ! /* The following code was cobbled from elf32-ppc.c and elflink.c. = */=0A= =20=20=0A= ! if (s =3D=3D NULL)=0A= ! {=0A= ! flagword flags =3D (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS=0A= ! | SEC_IN_MEMORY | SEC_LINKER_CREATED);=0A= =20=20=0A= ! s =3D bfd_make_section_anyway (abfd, ".sdata");=0A= ! if (s =3D=3D NULL)=0A= ! return FALSE;=0A= ! bfd_set_section_flags (abfd, s, flags);=0A= ! bfd_set_section_alignment (abfd, s, 2);=0A= ! }=0A= =20=20=0A= ! bh =3D bfd_link_hash_lookup (info->hash, "_SDA_BASE_",=0A= ! FALSE, FALSE, FALSE);=0A= =20=20=0A= ! if ((bh =3D=3D NULL || bh->type =3D=3D bfd_link_hash_undefined)=0A= ! && !(_bfd_generic_link_add_one_symbol (info,=0A= ! abfd,=0A= ! "_SDA_BASE_",=0A= ! BSF_GLOBAL,=0A= ! s,=0A= ! (bfd_vma) 32768,=0A= ! (const char *) NULL,=0A= ! FALSE,=0A= ! get_elf_backend_data (abfd)->collect,=0A= ! &bh)))=0A= ! return FALSE;=0A= ! h =3D (struct elf_link_hash_entry *) bh;=0A= ! h->type =3D STT_OBJECT;=0A= ! }=0A= =20=20=0A= ! switch (sym->st_shndx)=0A= {=0A= ! case SHN_M32R_SCOMMON:=0A= ! *secp =3D bfd_make_section_old_way (abfd, ".scommon");=0A= ! (*secp)->flags |=3D SEC_IS_COMMON;=0A= ! *valp =3D sym->st_size;=0A= ! break;=0A= }=0A= =20=20=0A= ! return TRUE;=0A= ! }=0A= =20=20=0A= ! /* We have to figure out the SDA_BASE value, so that we can adjust the=0A= ! symbol value correctly. We look up the symbol _SDA_BASE_ in the outpu= t=0A= ! BFD. If we can't find it, we're stuck. We cache it in the ELF=0A= ! target data. We don't need to adjust the symbol value for an=0A= ! external symbol if we are producing relocatable output. */=0A= =20=20=0A= ! static bfd_reloc_status_type=0A= ! m32r_elf_final_sda_base (output_bfd, info, error_message, psb)=0A= ! bfd *output_bfd;=0A= ! struct bfd_link_info *info;=0A= ! const char **error_message;=0A= ! bfd_vma *psb;=0A= ! {=0A= ! if (elf_gp (output_bfd) =3D=3D 0)=0A= {=0A= ! struct bfd_link_hash_entry *h;=0A= =20=20=0A= ! h =3D bfd_link_hash_lookup (info->hash, "_SDA_BASE_", FALSE, FALSE,= TRUE);=0A= ! if (h !=3D (struct bfd_link_hash_entry *) NULL=0A= ! && h->type =3D=3D bfd_link_hash_defined)=0A= ! elf_gp (output_bfd) =3D (h->u.def.value=0A= ! + h->u.def.section->output_section->vma=0A= ! + h->u.def.section->output_offset);=0A= else=0A= {=0A= ! /* Only get the error once. */=0A= ! *psb =3D elf_gp (output_bfd) =3D 4;=0A= ! *error_message =3D=0A= ! (const char *) _("SDA relocation when _SDA_BASE_ not defined");=0A= ! return bfd_reloc_dangerous;=0A= }=0A= }=0A= ! *psb =3D elf_gp (output_bfd);=0A= ! return bfd_reloc_ok;=0A= }=0A= - =0C=0A= /* Relocate an M32R/D ELF section.=0A= There is some attempt to make this function usable for many architectu= res,=0A= both for RELA and REL type relocs, if only to serve as a learning tool= .=0A= --- 1411,2488 ----=0A= struct bfd_link_hash_entry *bh;=0A= asection *s =3D bfd_get_section_by_name (abfd, ".sdata");=0A= =20=20=0A= ! /* The following code was cobbled from elf32-ppc.c and elflink.c. = */=0A= !=20=0A= ! if (s =3D=3D NULL)=0A= ! {=0A= ! flagword flags =3D (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS=0A= ! | SEC_IN_MEMORY | SEC_LINKER_CREATED);=0A= !=20=0A= ! s =3D bfd_make_section_anyway (abfd, ".sdata");=0A= ! if (s =3D=3D NULL)=0A= ! return FALSE;=0A= ! bfd_set_section_flags (abfd, s, flags);=0A= ! bfd_set_section_alignment (abfd, s, 2);=0A= ! }=0A= !=20=0A= ! bh =3D bfd_link_hash_lookup (info->hash, "_SDA_BASE_",=0A= ! FALSE, FALSE, FALSE);=0A= !=20=0A= ! if ((bh =3D=3D NULL || bh->type =3D=3D bfd_link_hash_undefined)=0A= ! && !(_bfd_generic_link_add_one_symbol (info,=0A= ! abfd,=0A= ! "_SDA_BASE_",=0A= ! BSF_GLOBAL,=0A= ! s,=0A= ! (bfd_vma) 32768,=0A= ! (const char *) NULL,=0A= ! FALSE,=0A= ! get_elf_backend_data (abfd)->collect,=0A= ! &bh)))=0A= ! return FALSE;=0A= ! h =3D (struct elf_link_hash_entry *) bh;=0A= ! h->type =3D STT_OBJECT;=0A= ! }=0A= !=20=0A= ! switch (sym->st_shndx)=0A= ! {=0A= ! case SHN_M32R_SCOMMON:=0A= ! *secp =3D bfd_make_section_old_way (abfd, ".scommon");=0A= ! (*secp)->flags |=3D SEC_IS_COMMON;=0A= ! *valp =3D sym->st_size;=0A= ! break;=0A= ! }=0A= !=20=0A= ! return TRUE;=0A= ! }=0A= !=20=0A= ! /* We have to figure out the SDA_BASE value, so that we can adjust the=0A= ! symbol value correctly. We look up the symbol _SDA_BASE_ in the outpu= t=0A= ! BFD. If we can't find it, we're stuck. We cache it in the ELF=0A= ! target data. We don't need to adjust the symbol value for an=0A= ! external symbol if we are producing relocatable output. */=0A= !=20=0A= ! static bfd_reloc_status_type=0A= ! m32r_elf_final_sda_base (output_bfd, info, error_message, psb)=0A= ! bfd *output_bfd;=0A= ! struct bfd_link_info *info;=0A= ! const char **error_message;=0A= ! bfd_vma *psb;=0A= ! {=0A= ! if (elf_gp (output_bfd) =3D=3D 0)=0A= ! {=0A= ! struct bfd_link_hash_entry *h;=0A= !=20=0A= ! h =3D bfd_link_hash_lookup (info->hash, "_SDA_BASE_", FALSE, FALSE,= TRUE);=0A= ! if (h !=3D (struct bfd_link_hash_entry *) NULL=0A= ! && h->type =3D=3D bfd_link_hash_defined)=0A= ! elf_gp (output_bfd) =3D (h->u.def.value=0A= ! + h->u.def.section->output_section->vma=0A= ! + h->u.def.section->output_offset);=0A= ! else=0A= ! {=0A= ! /* Only get the error once. */=0A= ! *psb =3D elf_gp (output_bfd) =3D 4;=0A= ! *error_message =3D=0A= ! (const char *) _("SDA relocation when _SDA_BASE_ not defined");=0A= ! return bfd_reloc_dangerous;=0A= ! }=0A= ! }=0A= ! *psb =3D elf_gp (output_bfd);=0A= ! return bfd_reloc_ok;=0A= ! }=0A= ! =0C=0A= ! /* Return size of a PLT entry. */=0A= ! #define elf_m32r_sizeof_plt(info) PLT_ENTRY_SIZE=0A= !=20=0A= ! /* The m32r linker needs to keep track of the number of relocs that it=0A= ! decides to copy in check_relocs for each symbol. This is so that=0A= ! it can discard PC relative relocs if it doesn't need them when=0A= ! linking with -Bsymbolic. We store the information in a field=0A= ! extending the regular ELF linker hash table. */=0A= !=20=0A= ! /* This structure keeps track of the number of PC relative relocs we=0A= ! have copied for a given symbol. */=0A= !=20=0A= ! struct elf_m32r_pcrel_relocs_copied=0A= ! {=0A= ! /* Next section. */=0A= ! struct elf_m32r_pcrel_relocs_copied *next;=0A= ! /* A section in dynobj. */=0A= ! asection *section;=0A= ! /* Number of relocs copied in this section. */=0A= ! bfd_size_type count;=0A= ! };=0A= !=20=0A= ! /* The sh linker needs to keep track of the number of relocs that it=0A= ! decides to copy as dynamic relocs in check_relocs for each symbol.=0A= ! This is so that it can later discard them if they are found to be=0A= ! unnecessary. We store the information in a field extending the=0A= ! regular ELF linker hash table. */=0A= !=20=0A= ! struct elf_m32r_dyn_relocs=0A= ! {=0A= ! struct elf_m32r_dyn_relocs *next;=0A= !=20=0A= ! /* The input section of the reloc. */=0A= ! asection *sec;=0A= !=20=0A= ! /* Total number of relocs copied for the input section. */=0A= ! bfd_size_type count;=0A= !=20=0A= ! /* Number of pc-relative relocs copied for the input section. */=0A= ! bfd_size_type pc_count;=0A= ! };=0A= !=20=0A= !=20=0A= ! /* m32r ELF linker hash entry. */=0A= !=20=0A= ! struct elf_m32r_link_hash_entry=0A= ! {=0A= ! struct elf_link_hash_entry root;=0A= !=20=0A= ! /* Track dynamic relocs copied for this symbol. */=0A= ! struct elf_m32r_dyn_relocs *dyn_relocs;=0A= !=20=0A= ! // bfd_signed_vma gotplt_refcount;=0A= !=20=0A= ! /* Number of PC relative relocs copied for this symbol. */=0A= ! /* struct elf_m32r_pcrel_relocs_copied *pcrel_relocs_copied; FIXME */= =0A= ! };=0A= !=20=0A= ! /* m32r ELF linker hash table. */=0A= !=20=0A= ! struct elf_m32r_link_hash_table=0A= ! {=0A= ! struct elf_link_hash_table root;=0A= !=20=0A= ! /* Short-cuts to get to dynamic linker sections. */=0A= ! asection *sgot;=0A= ! asection *sgotplt;=0A= ! asection *srelgot;=0A= ! asection *splt;=0A= ! asection *srelplt;=0A= ! asection *sdynbss;=0A= ! asection *srelbss;=0A= !=20=0A= ! /* Small local sym to section mapping cache. */=0A= ! struct sym_sec_cache sym_sec;=0A= ! };=0A= !=20=0A= ! /* Traverse an m32r ELF linker hash table. */=0A= !=20=0A= ! #define m32r_elf_link_hash_traverse(table, func, info) \=0A= ! (elf_link_hash_traverse \=0A= ! (&(table)->root, \=0A= ! (bfd_boolean (*) PARAMS ((struct elf_link_hash_entry *, PTR))) (func)= , \=0A= ! (info)))=0A= !=20=0A= ! /* Get the m32r ELF linker hash table from a link_info structure. */=0A= !=20=0A= !=20=0A= ! #define m32r_elf_hash_table(p) \=0A= ! ((struct elf_m32r_link_hash_table *) ((p)->hash))=0A= !=20=0A= ! /* Create an entry in an m32r ELF linker hash table. */=0A= ! static struct bfd_hash_entry *=0A= ! m32r_elf_link_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_tabl= e *,=0A= ! const char * );=0A= !=20=0A= ! static struct bfd_hash_entry *=0A= ! m32r_elf_link_hash_newfunc (entry, table, string)=0A= ! struct bfd_hash_entry *entry;=0A= ! struct bfd_hash_table *table;=0A= ! const char *string;=0A= ! {=0A= ! struct elf_m32r_link_hash_entry *ret =3D=0A= ! (struct elf_m32r_link_hash_entry *) entry;=0A= !=20=20=20=20=20=0A= ! /* Allocate the structure if it has not already been allocated by a=0A= ! subclass. */=0A= ! if (ret =3D=3D (struct elf_m32r_link_hash_entry *) NULL)=0A= ! ret =3D ((struct elf_m32r_link_hash_entry *)=0A= ! bfd_hash_allocate (table,=0A= ! sizeof (struct elf_m32r_link_hash_entry)));= =0A= ! if (ret =3D=3D (struct elf_m32r_link_hash_entry *) NULL)=0A= ! return (struct bfd_hash_entry *) ret;=0A= !=20=20=20=20=0A= ! /* Call the allocation method of the superclass. */=0A= ! ret =3D ((struct elf_m32r_link_hash_entry *)=0A= ! _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret,=0A= ! table, string));=0A= ! if (ret !=3D (struct elf_m32r_link_hash_entry *) NULL)=0A= ! {=0A= ! struct elf_m32r_link_hash_entry *eh;=0A= !=20=20=20=0A= ! eh =3D (struct elf_m32r_link_hash_entry *) ret;=0A= ! eh->dyn_relocs =3D NULL;=0A= ! // eh->gotplt_refcount =3D 0;=0A= ! /* eh->pcrel_relocs_copied =3D NULL; FIXME */=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! return (struct bfd_hash_entry *) ret;=0A= ! }=0A= !=20=0A= ! /* Create an m32r ELF linker hash table. */=0A= ! static struct bfd_link_hash_table *m32r_elf_link_hash_table_create (bfd *= );=0A= !=20=0A= ! static struct bfd_link_hash_table *=0A= ! m32r_elf_link_hash_table_create (abfd)=0A= ! bfd *abfd;=0A= ! {=0A= ! struct elf_m32r_link_hash_table *ret;=0A= ! bfd_size_type amt =3D sizeof (struct elf_m32r_link_hash_table);=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! ret =3D (struct elf_m32r_link_hash_table *) bfd_malloc (amt);=0A= ! if (ret =3D=3D (struct elf_m32r_link_hash_table *) NULL)=0A= ! return NULL;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! if (! _bfd_elf_link_hash_table_init (&ret->root, abfd,=0A= ! m32r_elf_link_hash_newfunc))=0A= ! {=0A= ! free (ret);=0A= ! return NULL;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! ret->sgot =3D NULL;=0A= ! ret->sgotplt =3D NULL;=0A= ! ret->srelgot =3D NULL;=0A= ! ret->splt =3D NULL;=0A= ! ret->srelplt =3D NULL;=0A= ! ret->sdynbss =3D NULL;=0A= ! ret->srelbss =3D NULL;=0A= ! ret->sym_sec.abfd =3D NULL;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! return &ret->root.root;=0A= ! }=0A= !=20=0A= ! /* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up=0A= ! shortcuts to them in our hash table. */=0A= ! static bfd_boolean create_got_section (bfd *, struct bfd_link_info *);=0A= !=20=0A= ! static bfd_boolean=0A= ! create_got_section (dynobj, info)=0A= ! bfd *dynobj;=0A= ! struct bfd_link_info *info;=0A= ! {=0A= ! struct elf_m32r_link_hash_table *htab;=0A= !=20=0A= ! if (! _bfd_elf_create_got_section (dynobj, info))=0A= ! return FALSE;=0A= !=20=0A= ! htab =3D m32r_elf_hash_table (info);=0A= ! htab->sgot =3D bfd_get_section_by_name (dynobj, ".got");=0A= ! htab->sgotplt =3D bfd_get_section_by_name (dynobj, ".got.plt");=0A= ! if (! htab->sgot || ! htab->sgotplt)=0A= ! abort ();=0A= !=20=0A= ! htab->srelgot =3D bfd_make_section (dynobj, ".rela.got");=0A= ! if (htab->srelgot =3D=3D NULL=0A= ! || ! bfd_set_section_flags (dynobj, htab->srelgot,=0A= ! (SEC_ALLOC=0A= ! | SEC_LOAD=0A= ! | SEC_HAS_CONTENTS=0A= ! | SEC_IN_MEMORY=0A= ! | SEC_LINKER_CREATED=0A= ! | SEC_READONLY))=0A= ! || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2))=0A= ! return FALSE;=0A= !=20=0A= ! return TRUE;=0A= ! }=0A= !=20=0A= ! /* Create dynamic sections when linking against a dynamic object. */=0A= !=20=0A= ! static bfd_boolean=0A= ! m32r_elf_create_dynamic_sections (abfd, info)=0A= ! bfd *abfd;=0A= ! struct bfd_link_info *info;=0A= ! {=0A= ! struct elf_m32r_link_hash_table *htab;=0A= ! flagword flags, pltflags;=0A= ! register asection *s;=0A= ! const struct elf_backend_data *bed =3D get_elf_backend_data (abfd);=0A= ! int ptralign =3D 2; /* 32bit */=0A= !=20=0A= ! htab =3D m32r_elf_hash_table (info);=0A= !=20=0A= ! /* We need to create .plt, .rel[a].plt, .got, .got.plt, .dynbss, and=0A= ! .rel[a].bss sections. */=0A= !=20=0A= ! flags =3D (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY=0A= ! | SEC_LINKER_CREATED);=0A= !=20=0A= ! pltflags =3D flags;=0A= ! pltflags |=3D SEC_CODE;=0A= ! if (bed->plt_not_loaded)=0A= ! pltflags &=3D ~ (SEC_LOAD | SEC_HAS_CONTENTS);=0A= ! if (bed->plt_readonly)=0A= ! pltflags |=3D SEC_READONLY;=0A= !=20=0A= ! s =3D bfd_make_section (abfd, ".plt");=0A= ! htab->splt =3D s;=0A= ! if (s =3D=3D NULL=0A= ! || ! bfd_set_section_flags (abfd, s, pltflags)=0A= ! || ! bfd_set_section_alignment (abfd, s, bed->plt_alignment))=0A= ! return FALSE;=0A= !=20=0A= ! if (bed->want_plt_sym)=0A= ! {=0A= ! /* Define the symbol _PROCEDURE_LINKAGE_TABLE_ at the start of the= =0A= ! .plt section. */=0A= ! struct elf_link_hash_entry *h =3D NULL;=0A= ! if (! (_bfd_generic_link_add_one_symbol=0A= ! (info, abfd, "_PROCEDURE_LINKAGE_TABLE_", BSF_GLOBAL, s,=0A= ! (bfd_vma) 0, (const char *) NULL, FALSE,=0A= ! get_elf_backend_data (abfd)->collect,=0A= ! (struct bfd_link_hash_entry **) &h)))=0A= ! return FALSE;=0A= ! h->elf_link_hash_flags |=3D ELF_LINK_HASH_DEF_REGULAR;=0A= ! h->type =3D STT_OBJECT;=0A= !=20=0A= ! if (info->shared=0A= ! && ! _bfd_elf_link_record_dynamic_symbol (info, h))=0A= ! return FALSE;=0A= ! }=0A= !=20=0A= ! s =3D bfd_make_section (abfd,=0A= ! bed->default_use_rela_p ? ".rela.plt" : ".rel.plt= ");=0A= ! htab->srelplt =3D s;=0A= ! if (s =3D=3D NULL=0A= ! || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)=0A= ! || ! bfd_set_section_alignment (abfd, s, ptralign))=0A= ! return FALSE;=0A= !=20=0A= ! if (htab->sgot =3D=3D NULL=0A= ! && ! create_got_section (abfd, info))=0A= ! return FALSE;=0A= !=20=0A= ! {=0A= ! const char *secname;=0A= ! char *relname;=0A= ! flagword secflags;=0A= ! asection *sec;=0A= !=20=0A= ! for (sec =3D abfd->sections; sec; sec =3D sec->next)=0A= ! {=0A= ! secflags =3D bfd_get_section_flags (abfd, sec);=0A= ! if ((secflags & (SEC_DATA | SEC_LINKER_CREATED))=0A= ! || ((secflags & SEC_HAS_CONTENTS) !=3D SEC_HAS_CONTENTS))=0A= ! continue;=0A= ! secname =3D bfd_get_section_name (abfd, sec);=0A= ! relname =3D (char *) bfd_malloc ((bfd_size_type) strlen (secname)= + 6);=0A= ! strcpy (relname, ".rela");=0A= ! strcat (relname, secname);=0A= ! if (bfd_get_section_by_name (abfd, secname))=0A= ! continue;=0A= ! s =3D bfd_make_section (abfd, relname);=0A= ! if (s =3D=3D NULL=0A= ! || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)=0A= ! || ! bfd_set_section_alignment (abfd, s, ptralign))=0A= ! return FALSE;=0A= ! }=0A= ! }=0A= !=20=0A= ! if (bed->want_dynbss)=0A= ! {=0A= ! /* The .dynbss section is a place to put symbols which are defined= =0A= ! by dynamic objects, are referenced by regular objects, and are= =0A= ! not functions. We must allocate space for them in the process= =0A= ! image and use a R_*_COPY reloc to tell the dynamic linker to=0A= ! initialize them at run time. The linker script puts the .dynbss= =0A= ! section into the .bss section of the final image. */=0A= ! s =3D bfd_make_section (abfd, ".dynbss");=0A= ! htab->sdynbss =3D s;=0A= ! if (s =3D=3D NULL=0A= ! || ! bfd_set_section_flags (abfd, s, SEC_ALLOC))=0A= ! return FALSE;=0A= ! /* The .rel[a].bss section holds copy relocs. This section is not= =0A= ! normally needed. We need to create it here, though, so that the= =0A= ! linker will map it to an output section. We can't just create i= t=0A= ! only if we need it, because we will not know whether we need it= =0A= ! until we have seen all the input files, and the first time the= =0A= ! main linker code calls BFD after examining all the input files= =0A= ! (size_dynamic_sections) the input sections have already been=0A= ! mapped to the output sections. If the section turns out not to= =0A= ! be needed, we can discard it later. We will never need this=0A= ! section when generating a shared object, since they do not use= =0A= ! copy relocs. */=0A= ! if (! info->shared)=0A= ! {=0A= ! s =3D bfd_make_section (abfd,=0A= ! (bed->default_use_rela_p=0A= ! ? ".rela.bss" : ".rel.bss"));=0A= ! htab->srelbss =3D s;=0A= ! if (s =3D=3D NULL=0A= ! || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY)= =0A= ! || ! bfd_set_section_alignment (abfd, s, ptralign))=0A= ! return FALSE;=0A= ! }=0A= ! }=0A= !=20=0A= ! return TRUE;=0A= ! }=0A= !=20=0A= ! /* Copy the extra info we tack onto an elf_link_hash_entry. */=0A= ! static void m32r_elf_copy_indirect_symbol (const struct elf_backend_data = *,=0A= ! struct elf_link_hash_entry *,= =0A= ! struct elf_link_hash_entry *);= =0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! static void=0A= ! m32r_elf_copy_indirect_symbol (const struct elf_backend_data *bed,=0A= ! struct elf_link_hash_entry *dir,=0A= ! struct elf_link_hash_entry *ind)=0A= ! {=0A= ! struct elf_m32r_link_hash_entry *edir, *eind;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! edir =3D (struct elf_m32r_link_hash_entry *) dir;=0A= ! eind =3D (struct elf_m32r_link_hash_entry *) ind;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! if (eind->dyn_relocs !=3D NULL)=0A= ! {=0A= ! if (edir->dyn_relocs !=3D NULL)=0A= ! {=0A= ! struct elf_m32r_dyn_relocs **pp;=0A= ! struct elf_m32r_dyn_relocs *p;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! if (ind->root.type =3D=3D bfd_link_hash_indirect)=0A= ! abort ();=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! /* Add reloc counts against the weak sym to the strong sym=0A= ! list. Merge any entries against the same section. */=0A= ! for (pp =3D &eind->dyn_relocs; (p =3D *pp) !=3D NULL; )=0A= ! {=0A= ! struct elf_m32r_dyn_relocs *q;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! for (q =3D edir->dyn_relocs; q !=3D NULL; q =3D q->next)=0A= ! if (q->sec =3D=3D p->sec)=0A= ! {=0A= ! q->pc_count +=3D p->pc_count;=0A= ! q->count +=3D p->count;=0A= ! *pp =3D p->next;=0A= ! break;=0A= ! }=0A= ! if (q =3D=3D NULL)=0A= ! pp =3D &p->next;=0A= ! }=0A= ! *pp =3D edir->dyn_relocs;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! edir->dyn_relocs =3D eind->dyn_relocs;=0A= ! eind->dyn_relocs =3D NULL;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! // if (ind->root.type =3D=3D bfd_link_hash_indirect=0A= ! // && dir->got.refcount <=3D 0)=0A= ! // {=0A= ! // edir->tls_type =3D eind->tls_type;=0A= ! // eind->tls_type =3D GOT_UNKNOWN;=0A= ! // }=0A= ! _bfd_elf_link_hash_copy_indirect (bed, dir, ind);=0A= ! }=0A= !=20=0A= ! =0C=0A= ! /* Adjust a symbol defined by a dynamic object and referenced by a=0A= ! regular object. The current definition is in some section of the=0A= ! dynamic object, but we're not including those sections. We have to=0A= ! change the definition to something the rest of the link can=0A= ! understand. */=0A= !=20=20=0A= ! static bfd_boolean=0A= ! m32r_elf_adjust_dynamic_symbol (info, h)=0A= ! struct bfd_link_info *info;=0A= ! struct elf_link_hash_entry *h;=0A= ! {=0A= ! struct elf_m32r_link_hash_table *htab;=0A= ! struct elf_m32r_link_hash_entry *eh;=0A= ! struct elf_m32r_dyn_relocs *p;=0A= ! bfd *dynobj;=0A= ! asection *s;=0A= ! unsigned int power_of_two;=0A= !=20=0A= ! #ifdef DEBUG_PIC=0A= ! printf("m32r_elf_adjust_dynamic_symbol()\n");=0A= ! #endif=0A= !=20=20=0A= ! dynobj =3D elf_hash_table (info)->dynobj;=0A= !=20=20=0A= ! /* Make sure we know what is going on here. */=0A= ! BFD_ASSERT (dynobj !=3D NULL=0A= ! && ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT)=0A= ! || h->weakdef !=3D NULL=0A= ! || ((h->elf_link_hash_flags=0A= ! & ELF_LINK_HASH_DEF_DYNAMIC) !=3D 0=0A= ! && (h->elf_link_hash_flags=0A= ! & ELF_LINK_HASH_REF_REGULAR) !=3D 0=0A= ! && (h->elf_link_hash_flags=0A= ! & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0)));=0A= !=20=0A= !=20=20=0A= ! /* If this is a function, put it in the procedure linkage table. We=0A= ! will fill in the contents of the procedure linkage table later,=0A= ! when we know the address of the .got section. */=0A= ! if (h->type =3D=3D STT_FUNC=0A= ! || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_PLT) !=3D 0)=0A= ! {=0A= ! if (! info->shared=0A= ! && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) =3D=3D = 0=0A= ! && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) =3D=3D = 0=0A= ! && h->root.type !=3D bfd_link_hash_undefweak=0A= ! && h->root.type !=3D bfd_link_hash_undefined)=0A= ! {=0A= ! /* This case can occur if we saw a PLT reloc in an input=0A= ! file, but the symbol was never referred to by a dynamic=0A= ! object. In such a case, we don't actually need to build=0A= ! a procedure linkage table, and we can just do a PCREL=0A= ! reloc instead. */=0A= ! h->plt.offset =3D (bfd_vma) -1;=0A= ! h->elf_link_hash_flags &=3D ~ELF_LINK_HASH_NEEDS_PLT;=0A= ! }=0A= !=20=0A= ! return TRUE;=0A= ! }=0A= ! else=0A= ! h->plt.offset =3D (bfd_vma) -1;=0A= !=20=20=0A= ! /* If this is a weak symbol, and there is a real definition, the=0A= ! processor independent code will have arranged for us to see the=0A= ! real definition first, and we can just use the same value. */=0A= ! if (h->weakdef !=3D NULL)=0A= ! {=0A= ! BFD_ASSERT (h->weakdef->root.type =3D=3D bfd_link_hash_defined=0A= ! || h->weakdef->root.type =3D=3D bfd_link_hash_defweak);= =0A= ! h->root.u.def.section =3D h->weakdef->root.u.def.section;=0A= ! h->root.u.def.value =3D h->weakdef->root.u.def.value;=0A= ! return TRUE;=0A= ! }=0A= !=20=20=0A= ! /* This is a reference to a symbol defined by a dynamic object which=0A= ! is not a function. */=0A= !=20=20=0A= ! /* If we are creating a shared library, we must presume that the=0A= ! only references to the symbol are via the global offset table.=0A= ! For such cases we need not do anything here; the relocations will=0A= ! be handled correctly by relocate_section. */=0A= ! if (info->shared)=0A= ! return TRUE;=0A= !=20=20=0A= ! /* If there are no references to this symbol that do not use the=0A= ! GOT, we don't need to generate a copy reloc. */=0A= ! if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) =3D=3D 0)=0A= ! return TRUE;=0A= !=20=0A= ! /* If -z nocopyreloc was given, we won't generate them either. */=0A= ! if (info->nocopyreloc)=0A= ! {=0A= ! h->elf_link_hash_flags &=3D ~ELF_LINK_NON_GOT_REF;=0A= ! return TRUE;=0A= ! }=0A= !=20=0A= ! eh =3D (struct elf_m32r_link_hash_entry *) h;=0A= ! for (p =3D eh->dyn_relocs; p !=3D NULL; p =3D p->next)=0A= ! {=0A= ! s =3D p->sec->output_section;=0A= ! if (s !=3D NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != =3D 0)=0A= ! break;=0A= ! }=0A= !=20=0A= ! /* If we didn't find any dynamic relocs in sections which needs the=0A= ! copy reloc, then we'll be keeping the dynamic relocs and avoiding=0A= ! the copy reloc. */=0A= ! if (p =3D=3D NULL)=0A= ! {=0A= ! h->elf_link_hash_flags &=3D ~ELF_LINK_NON_GOT_REF;=0A= ! return TRUE;=0A= ! }=0A= !=20=0A= ! /* We must allocate the symbol in our .dynbss section, which will=0A= ! become part of the .bss section of the executable. There will be=0A= ! an entry for this symbol in the .dynsym section. The dynamic=0A= ! object will contain position independent code, so all references=0A= ! from the dynamic object to this symbol will go through the global=0A= ! offset table. The dynamic linker will use the .dynsym entry to=0A= ! determine the address it must put in the global offset table, so=0A= ! both the dynamic object and the regular object will refer to the=0A= ! same memory location for the variable. */=0A= !=20=20=0A= ! htab =3D m32r_elf_hash_table (info);=0A= ! s =3D htab->sdynbss;=0A= ! BFD_ASSERT (s !=3D NULL);=0A= !=20=20=0A= ! /* We must generate a R_M32R_COPY reloc to tell the dynamic linker=0A= ! to copy the initial value out of the dynamic object and into the=0A= ! runtime process image. We need to remember the offset into the=0A= ! .rela.bss section we are going to use. */=0A= ! if ((h->root.u.def.section->flags & SEC_ALLOC) !=3D 0)=0A= ! {=0A= ! asection *srel;=0A= !=20=20=0A= ! srel =3D htab->srelbss;=0A= ! BFD_ASSERT (srel !=3D NULL);=0A= ! srel->_raw_size +=3D sizeof (Elf32_External_Rela);=0A= ! h->elf_link_hash_flags |=3D ELF_LINK_HASH_NEEDS_COPY;=0A= ! }=0A= !=20=20=0A= ! /* We need to figure out the alignment required for this symbol. I=0A= ! have no idea how ELF linkers handle this. */=0A= ! power_of_two =3D bfd_log2 (h->size);=0A= ! if (power_of_two > 3)=0A= ! power_of_two =3D 3;=0A= !=20=20=0A= ! /* Apply the required alignment. */=0A= ! s->_raw_size =3D BFD_ALIGN (s->_raw_size,=0A= ! (bfd_size_type) (1 << power_of_two));=0A= ! if (power_of_two > bfd_get_section_alignment (dynobj, s))=0A= ! {=0A= ! if (! bfd_set_section_alignment (dynobj, s, power_of_two))=0A= ! return FALSE;=0A= ! }=0A= !=20=20=0A= ! /* Define the symbol as being at this point in the section. */=0A= ! h->root.u.def.section =3D s;=0A= ! h->root.u.def.value =3D s->_raw_size;=0A= !=20=20=0A= ! /* Increment the section size to make room for the symbol. */=0A= ! s->_raw_size +=3D h->size;=0A= !=20=20=0A= ! return TRUE;=0A= ! }=0A= !=20=0A= ! /* This is the condition under which finish_dynamic_symbol will be called= =0A= ! from elflink.h. If elflink.h doesn't call our finish_dynamic_symbol= =0A= ! routine, we'll need to do something about initializing any .plt and .g= ot=0A= ! entries in relocate_section. */=0A= ! #define WILL_CALL_FINISH_DYNAMIC_SYMBOL(DYN, INFO, H) \=0A= ! ((DYN) \=0A= ! && ((INFO)->shared \=0A= ! || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) =3D=3D 0) \= =0A= ! && ((H)->dynindx !=3D -1 \=0A= ! || ((H)->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) !=3D 0))=0A= !=20=0A= ! /* Allocate space in .plt, .got and associated reloc sections for=0A= ! dynamic relocs. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! static bfd_boolean=0A= ! allocate_dynrelocs (h, inf)=0A= ! struct elf_link_hash_entry *h;=0A= ! PTR inf;=0A= ! {=0A= ! struct bfd_link_info *info;=0A= ! struct elf_m32r_link_hash_table *htab;=0A= ! struct elf_m32r_link_hash_entry *eh;=0A= ! struct elf_m32r_dyn_relocs *p;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! if (h->root.type =3D=3D bfd_link_hash_indirect)=0A= ! return TRUE;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! if (h->root.type =3D=3D bfd_link_hash_warning)=0A= ! /* When warning symbols are created, they **replace** the "real"=0A= ! entry in the hash table, thus we never get to see the real=0A= ! symbol in a hash traversal. So look at it now. */=0A= ! h =3D (struct elf_link_hash_entry *) h->root.u.i.link;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! info =3D (struct bfd_link_info *) inf;=0A= ! htab =3D m32r_elf_hash_table (info);=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! eh =3D (struct elf_m32r_link_hash_entry *) h;=0A= ! // if ((h->got.refcount > 0=0A= ! // || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))=0A= ! // && eh->gotplt_refcount > 0)=0A= ! // {=0A= ! // /* The symbol has been forced local, or we have some direct got r= efs,=0A= ! // so treat all the gotplt refs as got refs. */=0A= ! // h->got.refcount +=3D eh->gotplt_refcount;=0A= ! // if (h->plt.refcount >=3D eh->gotplt_refcount)=0A= ! // h->plt.refcount -=3D eh->gotplt_refcount;=0A= ! // }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! if (htab->root.dynamic_sections_created=0A= ! && h->plt.refcount > 0)=0A= ! {=0A= ! /* Make sure this symbol is output as a dynamic symbol.=0A= ! Undefined weak syms won't yet be marked as dynamic. */=0A= ! if (h->dynindx =3D=3D -1=0A= ! && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) =3D=3D 0)= =0A= ! {=0A= ! if (! bfd_elf32_link_record_dynamic_symbol (info, h))=0A= ! return FALSE;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info, h))=0A= ! {=0A= ! asection *s =3D htab->splt;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! /* If this is the first .plt entry, make room for the special= =0A= ! first entry. */=0A= ! if (s->_raw_size =3D=3D 0)=0A= ! s->_raw_size +=3D PLT_ENTRY_SIZE;=0A= !=20=20=20=20=20=20=20=20=20=20=20=0A= ! h->plt.offset =3D s->_raw_size;=0A= !=20=20=20=20=20=20=20=20=20=20=0A= ! /* If this symbol is not defined in a regular file, and we are= =0A= ! not generating a shared library, then set the symbol to this= =0A= ! location in the .plt. This is required to make function=0A= ! pointers compare as equal between the normal executable and= =0A= ! the shared library. */=0A= ! if (! info->shared=0A= ! && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) =3D= =3D 0)=0A= ! {=0A= ! h->root.u.def.section =3D s;=0A= ! h->root.u.def.value =3D h->plt.offset;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=0A= ! /* Make room for this entry. */=0A= ! s->_raw_size +=3D PLT_ENTRY_SIZE;=0A= !=20=20=20=20=20=20=20=20=0A= ! /* We also need to make an entry in the .got.plt section, which= =0A= ! will be placed in the .got section by the linker script. */= =0A= ! htab->sgotplt->_raw_size +=3D 4;=0A= !=20=20=20=20=20=20=20=0A= ! /* We also need to make an entry in the .rel.plt section. */= =0A= ! htab->srelplt->_raw_size +=3D sizeof (Elf32_External_Rela);=0A= ! }=0A= ! else=0A= ! {=0A= ! h->plt.offset =3D (bfd_vma) -1;=0A= ! h->elf_link_hash_flags &=3D ~ELF_LINK_HASH_NEEDS_PLT;=0A= ! }=0A= ! }=0A= ! else=0A= ! {=0A= ! h->plt.offset =3D (bfd_vma) -1;=0A= ! h->elf_link_hash_flags &=3D ~ELF_LINK_HASH_NEEDS_PLT;=0A= ! }=0A= !=20=20=20=20=20=20=0A= ! if (h->got.refcount > 0)=0A= ! {=0A= ! asection *s;=0A= ! bfd_boolean dyn;=0A= !=20=20=20=20=20=0A= ! /* Make sure this symbol is output as a dynamic symbol.=0A= ! Undefined weak syms won't yet be marked as dynamic. */=0A= ! if (h->dynindx =3D=3D -1=0A= ! && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) =3D=3D 0)= =0A= ! {=0A= ! if (! bfd_elf32_link_record_dynamic_symbol (info, h))=0A= ! return FALSE;=0A= ! }=0A= !=20=20=20=20=0A= ! s =3D htab->sgot;=0A= !=20=0A= ! h->got.offset =3D s->_raw_size;=0A= ! s->_raw_size +=3D 4;=0A= ! dyn =3D htab->root.dynamic_sections_created;=0A= ! if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h))=0A= ! htab->srelgot->_raw_size +=3D sizeof (Elf32_External_Rela);=0A= ! }=0A= ! else=0A= ! h->got.offset =3D (bfd_vma) -1;=0A= !=20=20=20=0A= ! if (eh->dyn_relocs =3D=3D NULL)=0A= ! return TRUE;=0A= !=20=20=0A= ! /* In the shared -Bsymbolic case, discard space allocated for=0A= ! dynamic pc-relative relocs against symbols which turn out to be=0A= ! defined in regular objects. For the normal shared case, discard=0A= ! space for pc-relative relocs that have become local due to symbol=0A= ! visibility changes. */=0A= !=20=0A= ! if (info->shared)=0A= ! {=0A= ! if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) !=3D 0=0A= ! && ((h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) !=3D 0=0A= ! || info->symbolic))=0A= ! {=0A= ! struct elf_m32r_dyn_relocs **pp;=0A= ! for (pp =3D &eh->dyn_relocs; (p =3D *pp) !=3D NULL; )=0A= ! {=0A= ! p->count -=3D p->pc_count;=0A= ! p->pc_count =3D 0;=0A= ! if (p->count =3D=3D 0)=0A= ! *pp =3D p->next;=0A= ! else=0A= ! pp =3D &p->next;=0A= ! }=0A= ! }=0A= ! }=0A= ! else=0A= ! {=0A= ! /* For the non-shared case, discard space for relocs against=0A= ! symbols which turn out to need copy relocs or are not=0A= ! dynamic. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! if ((h->elf_link_hash_flags & ELF_LINK_NON_GOT_REF) =3D=3D 0=0A= ! && (((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) !=3D = 0=0A= ! && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) = =3D=3D 0)=0A= ! || (htab->root.dynamic_sections_created=0A= ! && (h->root.type =3D=3D bfd_link_hash_undefweak=0A= ! || h->root.type =3D=3D bfd_link_hash_undefined))))= =0A= ! {=0A= ! /* Make sure this symbol is output as a dynamic symbol.=0A= ! Undefined weak syms won't yet be marked as dynamic. */=0A= ! if (h->dynindx =3D=3D -1=0A= ! && (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL) =3D=3D = 0)=0A= ! {=0A= ! if (! bfd_elf32_link_record_dynamic_symbol (info, h))=0A= ! return FALSE;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! /* If that succeeded, we know we'll be keeping all the=0A= ! relocs. */=0A= ! if (h->dynindx !=3D -1)=0A= ! goto keep;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ! eh->dyn_relocs =3D NULL;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =0A= ! keep: ;=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=0A= ! /* Finally, allocate space. */=0A= ! for (p =3D eh->dyn_relocs; p !=3D NULL; p =3D p->next)=0A= ! {=0A= ! asection *sreloc =3D elf_section_data (p->sec)->sreloc;=0A= ! sreloc->_raw_size +=3D p->count * sizeof (Elf32_External_Rela);=0A= ! }=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=0A= ! return TRUE;=0A= ! }=0A= ! /* Find any dynamic relocs that apply to read-only sections. */=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=0A= ! static bfd_boolean=0A= ! readonly_dynrelocs (h, inf)=0A= ! struct elf_link_hash_entry *h;=0A= ! PTR inf;=0A= ! {=0A= ! struct elf_m32r_link_hash_entry *eh;=0A= ! struct elf_m32r_dyn_relocs *p;=0A= !=20=0A= ! if (h->root.type =3D=3D bfd_link_hash_warning)=0A= ! h =3D (struct elf_link_hash_entry *) h->root.u.i.link;=0A= !=20=0A= ! eh =3D (struct elf_m32r_link_hash_entry *) h;=0A= ! for (p =3D eh->dyn_relocs; p !=3D NULL; p =3D p->next)=0A= ! {=0A= ! asection *s =3D p->sec->output_section;=0A= !=20=0A= ! if (s !=3D NULL && (s->flags & SEC_READONLY) !=3D 0)=0A= ! {=0A= ! struct bfd_link_info *info =3D (struct bfd_link_info *) inf;=0A= !=20=0A= ! info->flags |=3D DF_TEXTREL;=0A= =20=20=0A= ! /* Not an error, just cut short the traversal. */=0A= ! return FALSE;=0A= ! }=0A= ! }=0A= ! return TRUE;=0A= ! }=0A= =20=20=0A= ! /* Set the sizes of the dynamic sections. */=0A= !=20=20=0A= ! static bfd_boolean=0A= ! m32r_elf_size_dynamic_sections (output_bfd, info)=0A= ! bfd *output_bfd ATTRIBUTE_UNUSED;=0A= ! struct bfd_link_info *info;=0A= ! {=0A= ! struct elf_m32r_link_hash_table *htab;=0A= ! bfd *dynobj;=0A= ! asection *s;=0A= ! bfd_boolean relocs;=0A= ! bfd *ibfd;=0A= =20=20=0A= ! #ifdef DEBUG_PIC=0A= ! printf("m32r_elf_size_dynamic_sections()\n");=0A= ! #endif=0A= =20=20=0A= ! htab =3D m32r_elf_hash_table (info);=0A= ! dynobj =3D htab->root.dynobj;=0A= ! BFD_ASSERT (dynobj !=3D NULL);=0A= =20=20=0A= ! if (htab->root.dynamic_sections_created)=0A= {=0A= ! /* Set the contents of the .interp section to the interpreter. */= =0A= ! if (! info->shared)=0A= ! {=0A= ! s =3D bfd_get_section_by_name (dynobj, ".interp");=0A= ! BFD_ASSERT (s !=3D NULL);=0A= ! s->_raw_size =3D sizeof ELF_DYNAMIC_INTERPRETER;=0A= ! s->contents =3D (unsigned char *) ELF_DYNAMIC_INTERPRETER;=0A= ! }=0A= }=0A= =20=20=0A= ! /* Set up .got offsets for local syms, and space for local dynamic=0A= ! relocs. */=0A= ! for (ibfd =3D info->input_bfds; ibfd !=3D NULL; ibfd =3D ibfd->link_nex= t)=0A= ! {=0A= ! bfd_signed_vma *local_got;=0A= ! bfd_signed_vma *end_local_got;=0A= ! bfd_size_type locsymcount;=0A= ! Elf_Internal_Shdr *symtab_hdr;=0A= ! asection *srel;=0A= =20=20=0A= ! if (bfd_get_flavour (ibfd) !=3D bfd_target_elf_flavour)=0A= ! continue;=0A= =20=20=0A= ! for (s =3D ibfd->sections; s !=3D NULL; s =3D s->next)=0A= ! {=0A= ! struct elf_m32r_dyn_relocs *p;=0A= !=20=0A= ! for (p =3D ((struct elf_m32r_dyn_relocs *)=0A= ! elf_section_data (s)->local_dynrel);=0A= ! p !=3D NULL;=0A= ! p =3D p->next)=0A= ! {=0A= ! if (! bfd_is_abs_section (p->sec)=0A= ! && bfd_is_abs_section (p->sec->output_section))=0A= ! {=0A= ! /* Input section has been discarded, either because=0A= ! it is a copy of a linkonce section or due to=0A= ! linker script /DISCARD/, so we'll be discarding=0A= ! the relocs too. */=0A= ! }=0A= ! else if (p->count !=3D 0)=0A= ! {=0A= ! srel =3D elf_section_data (p->sec)->sreloc;=0A= ! srel->_raw_size +=3D p->count * sizeof (Elf32_External_= Rela);=0A= ! if ((p->sec->output_section->flags & SEC_READONLY) !=3D= 0)=0A= ! info->flags |=3D DF_TEXTREL;=0A= ! }=0A= ! }=0A= ! }=0A= !=20=0A= ! local_got =3D elf_local_got_refcounts (ibfd);=0A= ! if (!local_got)=0A= ! continue;=0A= !=20=0A= ! symtab_hdr =3D &elf_tdata (ibfd)->symtab_hdr;=0A= ! locsymcount =3D symtab_hdr->sh_info;=0A= ! end_local_got =3D local_got + locsymcount;=0A= ! s =3D htab->sgot;=0A= ! srel =3D htab->srelgot;=0A= ! for (; local_got < end_local_got; ++local_got)=0A= ! {=0A= ! if (*local_got > 0)=0A= ! {=0A= ! *local_got =3D s->_raw_size;=0A= ! s->_raw_size +=3D 4;=0A= ! if (info->shared)=0A= ! srel->_raw_size +=3D sizeof (Elf32_External_Rela);=0A= ! }=0A= ! else=0A= ! *local_got =3D (bfd_vma) -1;=0A= ! }=0A= ! }=0A= !=20=0A= ! /* Allocate global sym .plt and .got entries, and space for global=0A= ! sym dynamic relocs. */=0A= ! elf_link_hash_traverse (&htab->root, allocate_dynrelocs, (PTR) info);= =0A= !=20=0A= ! /* We now have determined the sizes of the various dynamic sections.=0A= ! Allocate memory for them. */=0A= ! relocs =3D FALSE;=0A= ! for (s =3D dynobj->sections; s !=3D NULL; s =3D s->next)=0A= {=0A= ! if ((s->flags & SEC_LINKER_CREATED) =3D=3D 0)=0A= ! continue;=0A= =20=20=0A= ! if (s =3D=3D htab->splt=0A= ! || s =3D=3D htab->sgot=0A= ! || s =3D=3D htab->sgotplt)=0A= ! {=0A= ! /* Strip this section if we don't need it; see the=0A= ! comment below. */=0A= ! }=0A= ! else if (strncmp (bfd_get_section_name (dynobj, s), ".rela", 5) =3D= =3D 0)=0A= ! {=0A= ! if (s->_raw_size !=3D 0 && s !=3D htab->srelplt)=0A= ! relocs =3D TRUE;=0A= !=20=0A= ! /* We use the reloc_count field as a counter if we need=0A= ! to copy relocs into the output file. */=0A= ! s->reloc_count =3D 0;=0A= ! }=0A= else=0A= + {=0A= + /* It's not one of our sections, so don't allocate space. */= =0A= + continue;=0A= + }=0A= +=20=0A= + if (s->_raw_size =3D=3D 0)=0A= + {=0A= + /* If we don't need this section, strip it from the=0A= + output file. This is mostly to handle .rela.bss and=0A= + .rela.plt. We must create both sections in=0A= + create_dynamic_sections, because they must be created=0A= + before the linker maps input sections to output=0A= + sections. The linker does that before=0A= + adjust_dynamic_symbol is called, and it is that=0A= + function which decides whether anything needs to go=0A= + into these sections. */=0A= + _bfd_strip_section_from_output (info, s);=0A= + continue;=0A= + }=0A= +=20=0A= + /* Allocate memory for the section contents. We use bfd_zalloc=0A= + here in case unused entries are not reclaimed before the=0A= + section's contents are written out. This should not happen,=0A= + but this way if it does, we get a R_M32R_NONE reloc instead=0A= + of garbage. */=0A= + s->contents =3D (bfd_byte *) bfd_zalloc (dynobj, s->_raw_size);=0A= + if (s->contents =3D=3D NULL)=0A= + return FALSE;=0A= + }=0A= +=20=0A= + if (htab->root.dynamic_sections_created)=0A= + {=0A= + /* Add some entries to the .dynamic section. We fill in the=0A= + values later, in m32r_elf_finish_dynamic_sections, but we=0A= + must add the entries now so that we get the correct size for=0A= + the .dynamic section. The DT_DEBUG entry is filled in by the=0A= + dynamic linker and used by the debugger. */=0A= + #define add_dynamic_entry(TAG, VAL) \=0A= + bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL))=0A= +=20=0A= + if (! info->shared)=0A= {=0A= ! if (! add_dynamic_entry (DT_DEBUG, 0))=0A= ! return FALSE;=0A= }=0A= +=20=0A= + if (htab->splt->_raw_size !=3D 0)=0A= + {=0A= + if (! add_dynamic_entry (DT_PLTGOT, 0)=0A= + || ! add_dynamic_entry (DT_PLTRELSZ, 0)=0A= + || ! add_dynamic_entry (DT_PLTREL, DT_RELA)=0A= + || ! add_dynamic_entry (DT_JMPREL, 0))=0A= + return FALSE;=0A= + }=0A= +=20=0A= + if (relocs)=0A= + {=0A= + if (! add_dynamic_entry (DT_RELA, 0)=0A= + || ! add_dynamic_entry (DT_RELASZ, 0)=0A= + || ! add_dynamic_entry (DT_RELAENT,=0A= + sizeof (Elf32_External_Rela)))=0A= + return FALSE;=0A= +=20=0A= + /* If any dynamic relocs apply to a read-only section,=0A= + then we need a DT_TEXTREL entry. */=0A= + if ((info->flags & DF_TEXTREL) =3D=3D 0)=0A= + elf_link_hash_traverse (&htab->root, readonly_dynrelocs,=0A= + (PTR) info);=0A= +=20=0A= + if ((info->flags & DF_TEXTREL) !=3D 0)=0A= + {=0A= + if (! add_dynamic_entry (DT_TEXTREL, 0))=0A= + return FALSE;=0A= + }=0A= + }=0A= }=0A= ! #undef add_dynamic_entry=0A= !=20=0A= ! return TRUE;=0A= }=0A= /* Relocate an M32R/D ELF section.=0A= There is some attempt to make this function usable for many architectu= res,=0A= both for RELA and REL type relocs, if only to serve as a learning tool= .=0A= ***************=0A= *** 986,995 ****=0A= /* Assume success. */=0A= bfd_boolean ret =3D TRUE;=0A= =20=20=0A= ! #if !USE_REL=0A= ! if (info->relocatable)=0A= ! return TRUE;=0A= ! #endif=0A= =20=20=0A= rel =3D relocs;=0A= relend =3D relocs + input_section->reloc_count;=0A= --- 2534,2550 ----=0A= /* Assume success. */=0A= bfd_boolean ret =3D TRUE;=0A= =20=20=0A= ! struct elf_m32r_link_hash_table *htab =3D m32r_elf_hash_table (info);= =0A= ! bfd *dynobj;=0A= ! bfd_vma *local_got_offsets;=0A= ! asection *sgot, *splt, *sreloc;=0A= !=20=0A= ! dynobj =3D htab->root.dynobj;=0A= ! local_got_offsets =3D elf_local_got_offsets (input_bfd);=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! sgot =3D htab->sgot;=0A= ! splt =3D htab->splt;=0A= ! sreloc =3D NULL;=0A= =20=20=0A= rel =3D relocs;=0A= relend =3D relocs + input_section->reloc_count;=0A= ***************=0A= *** 998,1015 ****=0A= int r_type;=0A= reloc_howto_type *howto;=0A= unsigned long r_symndx;=0A= /* We can't modify r_addend here as elf_link_input_bfd has an asser= t to=0A= ! ensure it's zero (we use REL relocs, not RELA). Therefore this=0A= ! should be assigning zero to `addend', but for clarity we use=0A= ! `r_addend'. */=0A= bfd_vma addend =3D rel->r_addend;=0A= bfd_vma offset =3D rel->r_offset;=0A= - struct elf_link_hash_entry *h;=0A= Elf_Internal_Sym *sym;=0A= asection *sec;=0A= const char *sym_name;=0A= bfd_reloc_status_type r;=0A= const char *errmsg =3D NULL;=0A= =20=20=0A= h =3D NULL;=0A= r_type =3D ELF32_R_TYPE (rel->r_info);=0A= --- 2553,2571 ----=0A= int r_type;=0A= reloc_howto_type *howto;=0A= unsigned long r_symndx;=0A= + struct elf_link_hash_entry *h;=0A= /* We can't modify r_addend here as elf_link_input_bfd has an asser= t to=0A= ! ensure it's zero (we use REL relocs, not RELA). Therefore this= =0A= ! should be assigning zero to `addend', but for clarity we use=0A= ! `r_addend'. */=0A= bfd_vma addend =3D rel->r_addend;=0A= bfd_vma offset =3D rel->r_offset;=0A= Elf_Internal_Sym *sym;=0A= asection *sec;=0A= const char *sym_name;=0A= bfd_reloc_status_type r;=0A= const char *errmsg =3D NULL;=0A= + bfd_boolean use_rel =3D FALSE;=0A= =20=20=0A= h =3D NULL;=0A= r_type =3D ELF32_R_TYPE (rel->r_info);=0A= ***************=0A= *** 1024,1037 ****=0A= }=0A= =20=20=0A= if (r_type =3D=3D R_M32R_GNU_VTENTRY=0A= ! || r_type =3D=3D R_M32R_GNU_VTINHERIT)=0A= continue;=0A= =20=20=0A= howto =3D m32r_elf_howto_table + r_type;=0A= r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= =20=20=0A= ! #if USE_REL=0A= ! if (info->relocatable)=0A= {=0A= /* This is a relocatable link. We don't have to change=0A= anything, unless the reloc is against a section symbol,=0A= --- 2580,2598 ----=0A= }=0A= =20=20=0A= if (r_type =3D=3D R_M32R_GNU_VTENTRY=0A= ! || r_type =3D=3D R_M32R_GNU_VTINHERIT=0A= ! || r_type =3D=3D R_M32R_NONE=0A= ! || r_type =3D=3D R_M32R_RELA_GNU_VTENTRY=0A= ! || r_type =3D=3D R_M32R_RELA_GNU_VTINHERIT)=0A= continue;=0A= =20=20=0A= + if (r_type <=3D R_M32R_GNU_VTENTRY)=0A= + use_rel =3D TRUE;=0A= +=20=0A= howto =3D m32r_elf_howto_table + r_type;=0A= r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= =20=20=0A= ! if (info->relocatable && (use_rel =3D=3D TRUE))=0A= {=0A= /* This is a relocatable link. We don't have to change=0A= anything, unless the reloc is against a section symbol,=0A= ***************=0A= *** 1092,1104 ****=0A= }=0A= }=0A= else=0A= - #endif /* USE_REL */=0A= {=0A= bfd_vma relocation;=0A= =20=20=0A= /* This is a final link. */=0A= sym =3D NULL;=0A= sec =3D NULL;=0A= =20=20=0A= if (r_symndx < symtab_hdr->sh_info)=0A= {=0A= --- 2653,2665 ----=0A= }=0A= }=0A= else=0A= {=0A= bfd_vma relocation;=0A= =20=20=0A= /* This is a final link. */=0A= sym =3D NULL;=0A= sec =3D NULL;=0A= + h =3D NULL;=0A= =20=20=0A= if (r_symndx < symtab_hdr->sh_info)=0A= {=0A= ***************=0A= *** 1106,1125 ****=0A= sym =3D local_syms + r_symndx;=0A= sec =3D local_sections[r_symndx];=0A= sym_name =3D "";=0A= ! #if !USE_REL=0A= ! relocation =3D _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel= );=0A= ! addend =3D rel->r_addend;=0A= ! #else=0A= ! /* FIXME: This won't handle local relocations against SEC_MERGE=0A= ! symbols. See elf32-i386.c for how to do this. */=0A= ! relocation =3D (sec->output_section->vma=0A= ! + sec->output_offset=0A= ! + sym->st_value);=0A= ! #endif=0A= }=0A= else=0A= {=0A= /* External symbol. */=0A= h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= while (h->root.type =3D=3D bfd_link_hash_indirect=0A= || h->root.type =3D=3D bfd_link_hash_warning)=0A= --- 2667,2703 ----=0A= sym =3D local_syms + r_symndx;=0A= sec =3D local_sections[r_symndx];=0A= sym_name =3D "";=0A= !=20=0A= ! if (use_rel =3D=3D FALSE)=0A= ! {=0A= ! relocation =3D _bfd_elf_rela_local_sym (output_bfd, sym, &sec,= rel);=0A= ! addend =3D rel->r_addend;=0A= !=20=0A= ! if (info->relocatable)=0A= ! {=0A= ! /* This is a relocatable link. We don't have to ch= ange=0A= ! anything, unless the reloc is against a section = symbol,=0A= ! in which case we have to adjust according to whe= re the=0A= ! section symbol winds up in the output section. = */=0A= ! if (ELF_ST_TYPE (sym->st_info) =3D=3D STT_SECTION)= =0A= ! rel->r_addend +=3D sec->output_offset + sym->st_v= alue;=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! continue;=0A= ! }=0A= ! }=0A= ! else=0A= ! {=0A= ! relocation =3D (sec->output_section->vma=0A= ! + sec->output_offset=0A= ! + sym->st_value);=0A= ! }=0A= }=0A= else=0A= {=0A= /* External symbol. */=0A= + if (info->relocatable && (use_rel =3D=3D FALSE))=0A= + continue;=0A= +=20=0A= h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= while (h->root.type =3D=3D bfd_link_hash_indirect=0A= || h->root.type =3D=3D bfd_link_hash_warning)=0A= ***************=0A= *** 1129,1137 ****=0A= if (h->root.type =3D=3D bfd_link_hash_defined=0A= || h->root.type =3D=3D bfd_link_hash_defweak)=0A= {=0A= sec =3D h->root.u.def.section;=0A= ! if (sec->output_section =3D=3D NULL)=0A= ! relocation =3D 0;=0A= else=0A= relocation =3D (h->root.u.def.value=0A= + sec->output_section->vma=0A= --- 2707,2770 ----=0A= if (h->root.type =3D=3D bfd_link_hash_defined=0A= || h->root.type =3D=3D bfd_link_hash_defweak)=0A= {=0A= + bfd_boolean dyn;=0A= sec =3D h->root.u.def.section;=0A= !=20=0A= ! dyn =3D htab->root.dynamic_sections_created;=0A= ! sec =3D h->root.u.def.section;=0A= ! if (r_type =3D=3D R_M32R_GOTPC24=0A= ! || (r_type =3D=3D R_M32R_GOTPC_HI_ULO=0A= ! || r_type =3D=3D R_M32R_GOTPC_HI_SLO=0A= ! || r_type =3D=3D R_M32R_GOTPC_LO)=0A= ! || (r_type =3D=3D R_M32R_26_PLTREL=0A= ! && h->plt.offset !=3D (bfd_vma) -1)=0A= ! || ((r_type =3D=3D R_M32R_GOT24=0A= ! || r_type =3D=3D R_M32R_GOT16_HI_ULO=0A= ! || r_type =3D=3D R_M32R_GOT16_HI_SLO=0A= ! || r_type =3D=3D R_M32R_GOT16_LO)=0A= ! && WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, = h)=0A= ! && (! info->shared=0A= ! || (! info->symbolic && h->dynindx !=3D -1)= =0A= ! || (h->elf_link_hash_flags=0A= ! & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0))= =0A= ! || (info->shared=0A= ! && ((! info->symbolic && h->dynindx !=3D -1)=0A= ! || (h->elf_link_hash_flags=0A= ! & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0)= =0A= ! && (((r_type =3D=3D R_M32R_16_RELA=0A= ! || r_type =3D=3D R_M32R_32_RELA=0A= ! || r_type =3D=3D R_M32R_24_RELA=0A= ! || r_type =3D=3D R_M32R_HI16_ULO_RELA=0A= ! || r_type =3D=3D R_M32R_HI16_SLO_RELA=0A= ! || r_type =3D=3D R_M32R_LO16_RELA)=0A= ! && (h->elf_link_hash_flags=0A= ! & ELF_LINK_FORCED_LOCAL) =3D=3D 0)=0A= ! || r_type =3D=3D R_M32R_10_PCREL_RELA=0A= ! || r_type =3D=3D R_M32R_18_PCREL_RELA=0A= ! || r_type =3D=3D R_M32R_26_PCREL_RELA)=0A= ! && ((input_section->flags & SEC_ALLOC) !=3D 0= =0A= ! /* DWARF will emit R_M32R_16(24,32) relocat= ions=0A= ! in its sections against symbols defined= =20=0A= ! externally in shared libraries. We can'= t do=0A= ! anything with them here. */=0A= ! || ((input_section->flags & SEC_DEBUGGING) = !=3D 0=0A= ! && (h->elf_link_hash_flags=0A= ! & ELF_LINK_HASH_DEF_DYNAMIC) !=3D 0= ))))=0A= ! {=0A= ! /* In these cases, we don't need the relocation=0A= ! value. We check specially because in some=0A= ! obscure cases sec->output_section will be NULL. = */=0A= ! relocation =3D 0;=0A= ! }=0A= ! else if (sec->output_section =3D=3D NULL)=0A= ! {=0A= ! (*_bfd_error_handler)=0A= ! (_("%s: warning: unresolvable relocation against = symbol `%s' from %s section"),=0A= ! bfd_get_filename (input_bfd), h->root.root.strin= g,=0A= ! bfd_get_section_name (input_bfd, input_section))= ;=0A= !=20=0A= ! relocation =3D 0;=0A= ! }=0A= else=0A= relocation =3D (h->root.u.def.value=0A= + sec->output_section->vma=0A= ***************=0A= *** 1139,1149 ****=0A= }=0A= else if (h->root.type =3D=3D bfd_link_hash_undefweak)=0A= relocation =3D 0;=0A= else=0A= {=0A= if (! ((*info->callbacks->undefined_symbol)=0A= (info, h->root.root.string, input_bfd,=0A= ! input_section, offset, TRUE)))=0A= return FALSE;=0A= relocation =3D 0;=0A= }=0A= --- 2772,2788 ----=0A= }=0A= else if (h->root.type =3D=3D bfd_link_hash_undefweak)=0A= relocation =3D 0;=0A= + else if (info->shared=0A= + && (!info->symbolic)=0A= + && ELF_ST_VISIBILITY (h->other) =3D=3D STV_DEFAULT= )=0A= + relocation =3D 0;=0A= else=0A= {=0A= if (! ((*info->callbacks->undefined_symbol)=0A= (info, h->root.root.string, input_bfd,=0A= ! input_section, offset,=0A= ! (!info->shared=20=0A= ! || ELF_ST_VISIBILITY (h->other)))))=0A= return FALSE;=0A= relocation =3D 0;=0A= }=0A= ***************=0A= *** 1158,1168 ****=0A= =20=20=0A= switch ((int) r_type)=0A= {=0A= case (int) R_M32R_10_PCREL :=0A= r =3D m32r_elf_do_10_pcrel_reloc (input_bfd, howto, input_section,= =0A= contents, offset,=0A= sec, relocation, addend);=0A= ! break;=0A= =20=20=0A= case (int) R_M32R_HI16_SLO :=0A= case (int) R_M32R_HI16_ULO :=0A= --- 2797,3079 ----=0A= =20=20=0A= switch ((int) r_type)=0A= {=0A= + case R_M32R_GOTPC24:=0A= + /* .got(_GLOBAL_OFFSET_TABLE_) - pc relocation=0A= + ld24 rx,#_GLOBAL_OFFSET_TABLE_=0A= + */=0A= + relocation =3D sgot->output_section->vma;=0A= + break;=0A= +=20=0A= + case R_M32R_GOTPC_HI_ULO:=0A= + case R_M32R_GOTPC_HI_SLO:=0A= + case R_M32R_GOTPC_LO:=20=0A= + {=0A= + /* .got(_GLOBAL_OFFSET_TABLE_) - pc relocation=0A= + bl .+4=0A= + seth rx,#high(_GLOBAL_OFFSET_TABLE_)=0A= + or3 rx,rx,#low(_GLOBAL_OFFSET_TABLE_ +4)=0A= + or=0A= + bl .+4=0A= + seth rx,#shigh(_GLOBAL_OFFSET_TABLE_)=0A= + add3 rx,rx,#low(_GLOBAL_OFFSET_TABLE_ +4)=0A= + */=0A= + relocation =3D sgot->output_section->vma;=0A= + relocation -=3D (input_section->output_section->vma=0A= + + input_section->output_offset=0A= + + rel->r_offset);=0A= + if ((r_type =3D=3D R_M32R_GOTPC_HI_SLO)=20=0A= + && ((relocation + rel->r_addend) & 0x8000))=0A= + rel->r_addend +=3D 0x10000;=0A= +=20=0A= + break;=0A= + }=0A= + case R_M32R_GOT16_HI_ULO:=0A= + case R_M32R_GOT16_HI_SLO:=0A= + case R_M32R_GOT16_LO:=20=0A= + /* Fall through. */=0A= + case R_M32R_GOT24:=0A= + /* Relocation is to the entry for this symbol in the global= =0A= + offset table. */=0A= + BFD_ASSERT (sgot !=3D NULL);=0A= +=20=20=0A= + if (h !=3D NULL)=0A= + {=0A= + bfd_boolean dyn;=0A= + bfd_vma off;=0A= +=20=20=0A= + off =3D h->got.offset;=0A= + BFD_ASSERT (off !=3D (bfd_vma) -1);=0A= +=20=0A= + dyn =3D htab->root.dynamic_sections_created;=0A= + if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info, h)=0A= + || (info->shared=0A= + && (info->symbolic=0A= + || h->dynindx =3D=3D -1=0A= + || (h->elf_link_hash_flags & ELF_LINK_FORCE= D_LOCAL))=0A= + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_= REGULAR)))=0A= + {=0A= + /* This is actually a static link, or it is a=0A= + -Bsymbolic link and the symbol is defined=0A= + locally, or the symbol was forced to be local=0A= + because of a version file. We must initialize= =0A= + this entry in the global offset table. Since th= e=0A= + offset must always be a multiple of 4, we use th= e=0A= + least significant bit to record whether we have= =0A= + initialized it already.=0A= +=20=20=0A= + When doing a dynamic link, we create a .rela.got= =0A= + relocation entry to initialize the value. This= =0A= + is done in the finish_dynamic_symbol routine. *= /=0A= + if ((off & 1) !=3D 0)=0A= + off &=3D ~1;=0A= + else=0A= + {=0A= + bfd_put_32 (output_bfd, relocation,=0A= + sgot->contents + off);=0A= + h->got.offset |=3D 1;=0A= + }=0A= + }=0A= +=20=20=0A= + relocation =3D sgot->output_offset + off;=0A= + }=0A= + else=0A= + {=0A= + bfd_vma off;=0A= + bfd_byte *loc;=0A= +=20=20=0A= + BFD_ASSERT (local_got_offsets !=3D NULL=0A= + && local_got_offsets[r_symndx] !=3D (bfd_vm= a) -1);=0A= +=20=20=0A= + off =3D local_got_offsets[r_symndx];=0A= +=20=20=0A= + /* The offset must always be a multiple of 4. We use= =0A= + the least significant bit to record whether we have= =0A= + already processed this entry. */=0A= + if ((off & 1) !=3D 0)=0A= + off &=3D ~1;=0A= + else=0A= + {=0A= + bfd_put_32 (output_bfd, relocation, sgot->contents = + off);=0A= +=20=20=0A= + if (info->shared)=0A= + {=0A= + asection *srelgot;=0A= + Elf_Internal_Rela outrel;=0A= +=20=20=0A= + /* We need to generate a R_M32R_RELATIVE reloc= =0A= + for the dynamic linker. */=0A= + srelgot =3D bfd_get_section_by_name (dynobj, ".= rela.got");=0A= + BFD_ASSERT (srelgot !=3D NULL);=0A= +=20=20=0A= + outrel.r_offset =3D (sgot->output_section->vma= =0A= + + sgot->output_offset=0A= + + off);=0A= + outrel.r_info =3D ELF32_R_INFO (0, R_M32R_RELAT= IVE);=0A= + outrel.r_addend =3D relocation;=0A= + loc =3D srelgot->contents;=0A= + loc +=3D srelgot->reloc_count * sizeof(Elf32_Ex= ternal_Rela);=0A= + bfd_elf32_swap_reloca_out (output_bfd, &outrel,= loc);=0A= + ++srelgot->reloc_count;=0A= + }=0A= +=20=20=0A= + local_got_offsets[r_symndx] |=3D 1;=0A= + }=0A= +=20=20=0A= + relocation =3D sgot->output_offset + off;=0A= + }=0A= + if ((r_type =3D=3D R_M32R_GOT16_HI_SLO)=0A= + && ((relocation + rel->r_addend) & 0x8000))=0A= + rel->r_addend +=3D 0x10000;=0A= +=20=0A= + break;=0A= +=20=20=0A= + case R_M32R_26_PLTREL:=0A= + /* Relocation is to the entry for this symbol in the=0A= + procedure linkage table. */=0A= +=20=20=0A= + /* The native assembler will generate a 26_PLTREL reloc=0A= + for a local symbol if you assemble a call from one=0A= + section to another when using -K pic. */=0A= + if (h =3D=3D NULL)=0A= + break;=0A= +=20=0A= + //if (ELF_ST_VISIBILITY (h->other) =3D=3D STV_INTERNAL=0A= + // || ELF_ST_VISIBILITY (h->other) =3D=3D STV_HIDDEN)=0A= + // break;=0A= + if (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)=0A= + break;=0A= +=20=0A= + if (h->plt.offset =3D=3D (bfd_vma) -1)=0A= + {=0A= + /* We didn't make a PLT entry for this symbol. This=0A= + happens when statically linking PIC code, or when=0A= + using -Bsymbolic. */=0A= + break;=0A= + }=0A= +=20=20=0A= + relocation =3D (splt->output_section->vma=0A= + + splt->output_offset=0A= + + h->plt.offset);=0A= + break;=0A= +=20=20=0A= + case R_M32R_HI16_SLO_RELA:=0A= + {=0A= + if ((relocation + rel->r_addend) & 0x8000)=0A= + {=0A= + rel->r_addend +=3D 0x10000;=0A= + }=0A= + }=0A= + /* Fall through. */=0A= + case R_M32R_16_RELA:=0A= + case R_M32R_24_RELA:=0A= + case R_M32R_32_RELA:=0A= + case R_M32R_18_PCREL_RELA:=0A= + case R_M32R_26_PCREL_RELA:=0A= + case R_M32R_HI16_ULO_RELA:=0A= + case R_M32R_LO16_RELA:=0A= + case R_M32R_SDA16_RELA:=0A= + if (info->shared=0A= + && r_symndx !=3D 0=0A= + && (input_section->flags & SEC_ALLOC) !=3D 0=0A= + && ((r_type !=3D R_M32R_18_PCREL_RELA=0A= + && r_type !=3D R_M32R_26_PCREL_RELA)=0A= + || (h !=3D NULL=0A= + && h->dynindx !=3D -1=0A= + && (! info->symbolic=0A= + || (h->elf_link_hash_flags=0A= + & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0))= ))=0A= + {=0A= + Elf_Internal_Rela outrel;=0A= + bfd_boolean skip, relocate;=0A= + bfd_byte *loc;=0A= +=20=20=0A= + /* When generating a shared object, these relocations= =0A= + are copied into the output file to be resolved at ru= n=0A= + time. */=0A= +=20=20=0A= + if (sreloc =3D=3D NULL)=0A= + {=0A= + const char *name;=0A= +=20=20=0A= + name =3D (bfd_elf_string_from_elf_section=0A= + (input_bfd,=0A= + elf_elfheader (input_bfd)->e_shstrndx,=0A= + elf_section_data (input_section)->rel_hdr.= sh_name));=0A= + if (name =3D=3D NULL)=0A= + return FALSE;=0A= +=20=20=0A= + BFD_ASSERT (strncmp (name, ".rela", 5) =3D=3D 0=0A= + && strcmp (bfd_get_section_name (input_= bfd,=0A= + input_= section),=0A= + name + 5) =3D=3D 0);=0A= +=20=20=0A= + sreloc =3D bfd_get_section_by_name (dynobj, name);= =0A= + BFD_ASSERT (sreloc !=3D NULL);=0A= + }=0A= +=20=20=0A= + skip =3D FALSE;=0A= + relocate =3D FALSE;=0A= +=20=20=0A= + outrel.r_offset =3D _bfd_elf_section_offset (output_bfd= ,=0A= + info,=0A= + input_sectio= n,=0A= + rel->r_offse= t);=0A= + if (outrel.r_offset =3D=3D (bfd_vma) -1)=0A= + skip =3D TRUE;=0A= + else if (outrel.r_offset =3D=3D (bfd_vma) -2)=0A= + skip =3D TRUE, relocate =3D TRUE;=0A= + outrel.r_offset +=3D (input_section->output_section->vm= a=0A= + + input_section->output_offset);=0A= +=20=20=0A= + if (skip)=0A= + memset (&outrel, 0, sizeof outrel);=0A= + else if (r_type =3D=3D R_M32R_18_PCREL_RELA=0A= + || r_type =3D=3D R_M32R_26_PCREL_RELA)=0A= + {=0A= + BFD_ASSERT (h !=3D NULL && h->dynindx !=3D -1);=0A= + outrel.r_info =3D ELF32_R_INFO (h->dynindx, r_type)= ;=0A= + outrel.r_addend =3D rel->r_addend;=0A= + }=0A= + else=0A= + {=0A= + /* h->dynindx may be -1 if this symbol was marked to= =0A= + become local. */=0A= + if (h =3D=3D NULL=0A= + || ((info->symbolic || h->dynindx =3D=3D -1)=0A= + && (h->elf_link_hash_flags=0A= + & ELF_LINK_HASH_DEF_REGULAR) !=3D 0))=0A= + {=0A= + relocate =3D TRUE;=0A= + outrel.r_info =3D ELF32_R_INFO (0, R_M32R_RELATIV= E);=0A= + outrel.r_addend =3D relocation + rel->r_addend;= =0A= + }=0A= + else=0A= + {=0A= + BFD_ASSERT (h->dynindx !=3D -1);=0A= + outrel.r_info =3D ELF32_R_INFO (h->dynindx, r_typ= e);=0A= + outrel.r_addend =3D relocation + rel->r_addend;= =0A= + }=0A= + }=0A= +=20=0A= + loc =3D sreloc->contents;=0A= + loc +=3D sreloc->reloc_count * sizeof(Elf32_External_Re= la);=0A= + bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc);=0A= + ++sreloc->reloc_count;=0A= +=20=0A= + /* If this reloc is against an external symbol, we do= =0A= + not want to fiddle with the addend. Otherwise, we= =0A= + need to include the symbol value so that it becomes= =0A= + an addend for the dynamic reloc. */=0A= + if (! relocate)=0A= + continue;=0A= + }=0A= + break;=0A= +=20=20=0A= case (int) R_M32R_10_PCREL :=0A= r =3D m32r_elf_do_10_pcrel_reloc (input_bfd, howto, input_section,= =0A= contents, offset,=0A= sec, relocation, addend);=0A= ! goto check_reloc;=0A= =20=20=0A= case (int) R_M32R_HI16_SLO :=0A= case (int) R_M32R_HI16_ULO :=0A= ***************=0A= *** 1190,1196 ****=0A= contents, offset,=0A= relocation, addend);=0A= }=0A= ! break;=0A= =20=20=0A= case (int) R_M32R_SDA16 :=0A= {=0A= --- 3101,3108 ----=0A= contents, offset,=0A= relocation, addend);=0A= }=0A= !=20=0A= ! goto check_reloc;=0A= =20=20=0A= case (int) R_M32R_SDA16 :=0A= {=0A= ***************=0A= *** 1233,1246 ****=0A= continue;=0A= }=0A= }=0A= ! /* fall through */=0A= =20=20=0A= - default :=0A= r =3D _bfd_final_link_relocate (howto, input_bfd, input_section,= =0A= contents, offset,=0A= relocation, addend);=0A= ! break;=0A= }=0A= }=0A= =20=20=0A= check_reloc:=0A= --- 3145,3164 ----=0A= continue;=0A= }=0A= }=0A= ! /* fall through */=0A= !=20=0A= ! default : /* OLD_M32R_RELOC */=0A= =20=20=0A= r =3D _bfd_final_link_relocate (howto, input_bfd, input_section,= =0A= contents, offset,=0A= relocation, addend);=0A= ! goto check_reloc;=0A= }=0A= +=20=0A= + r =3D _bfd_final_link_relocate (howto, input_bfd, input_section= ,=0A= + contents, rel->r_offset,=0A= + relocation, rel->r_addend);=0A= +=20=0A= }=0A= =20=20=0A= check_reloc:=0A= ***************=0A= *** 1307,1312 ****=0A= --- 3225,3577 ----=0A= =20=20=0A= return ret;=0A= }=0A= +=20=0A= + /* Finish up dynamic symbol handling. We set the contents of various=0A= + dynamic sections here. */=0A= + static bfd_boolean=0A= + m32r_elf_finish_dynamic_symbol (output_bfd, info, h, sym)=0A= + bfd *output_bfd;=0A= + struct bfd_link_info *info;=0A= + struct elf_link_hash_entry *h;=0A= + Elf_Internal_Sym *sym;=0A= + {=0A= + struct elf_m32r_link_hash_table *htab;=0A= + bfd *dynobj;=0A= + bfd_byte *loc;=0A= +=20=20=0A= + #ifdef DEBUG_PIC=0A= + printf("m32r_elf_finish_dynamic_symbol()\n");=0A= + #endif=0A= +=20=20=20=0A= + htab =3D m32r_elf_hash_table (info);=0A= + dynobj =3D htab->root.dynobj;=0A= +=20=0A= + if (h->plt.offset !=3D (bfd_vma) -1)=0A= + {=0A= + asection *splt;=0A= + asection *sgot;=0A= + asection *srela;=0A= +=20=0A= + bfd_vma plt_index;=0A= + bfd_vma got_offset;=0A= + Elf_Internal_Rela rela;=0A= +=20=20=0A= + /* This symbol has an entry in the procedure linkage table. Set=0A= + it up. */=0A= +=20=20=0A= + BFD_ASSERT (h->dynindx !=3D -1);=0A= +=20=20=0A= + splt =3D htab->splt;=0A= + sgot =3D htab->sgotplt;=0A= + srela =3D htab->srelplt;=0A= + BFD_ASSERT (splt !=3D NULL && sgot !=3D NULL && srela !=3D NULL);= =0A= +=20=0A= + /* Get the index in the procedure linkage table which=0A= + corresponds to this symbol. This is the index of this symbol=0A= + in all the symbols for which we are making plt entries. The=0A= + first entry in the procedure linkage table is reserved. */=0A= + plt_index =3D h->plt.offset / PLT_ENTRY_SIZE - 1;=0A= +=20=0A= + /* Get the offset into the .got table of the entry that=0A= + corresponds to this function. Each .got entry is 4 bytes.=0A= + The first three are reserved. */=0A= + got_offset =3D (plt_index + 3) * 4;=0A= +=20=0A= + /* Fill in the entry in the procedure linkage table. */=0A= + if (! info->shared)=0A= + {=0A= + bfd_put_32 (output_bfd,=0A= + (PLT_ENTRY_WORD0b=0A= + + (((sgot->output_section->vma=0A= + + sgot->output_offset=0A= + + got_offset) >> 16) & 0xffff)),=0A= + splt->contents + h->plt.offset);=0A= + bfd_put_32 (output_bfd,=0A= + (PLT_ENTRY_WORD1b=0A= + + ((sgot->output_section->vma=0A= + + sgot->output_offset=0A= + + got_offset) & 0xffff)),=0A= + splt->contents + h->plt.offset + 4);=0A= + bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,=0A= + splt->contents + h->plt.offset + 8);=0A= + bfd_put_32 (output_bfd,=0A= + (PLT_ENTRY_WORD3=0A= + + plt_index * sizeof (Elf32_External_Rela)),=0A= + splt->contents + h->plt.offset + 12);=0A= + bfd_put_32 (output_bfd,=0A= + (PLT_ENTRY_WORD4=0A= + + (((unsigned int) ((- (h->plt.offset + 16)) >> 2)) & 0xff= ffff)),=0A= + splt->contents + h->plt.offset + 16);=0A= + }=0A= + else=0A= + {=0A= + bfd_put_32 (output_bfd,=0A= + PLT_ENTRY_WORD0 + got_offset,=0A= + splt->contents + h->plt.offset);=0A= + bfd_put_32 (output_bfd, PLT_ENTRY_WORD1,=0A= + splt->contents + h->plt.offset + 4);=0A= + bfd_put_32 (output_bfd, PLT_ENTRY_WORD2,=0A= + splt->contents + h->plt.offset + 8);=0A= + bfd_put_32 (output_bfd,=0A= + (PLT_ENTRY_WORD3=0A= + + plt_index * sizeof (Elf32_External_Rela)),=0A= + splt->contents + h->plt.offset + 12);=0A= + bfd_put_32 (output_bfd,=0A= + (PLT_ENTRY_WORD4=0A= + + (((unsigned int) ((- (h->plt.offset + 16)) >> 2)) & 0xff= ffff)),=0A= + splt->contents + h->plt.offset + 16);=0A= + }=0A= +=20=20=0A= + /* Fill in the entry in the global offset table. */=0A= + bfd_put_32 (output_bfd,=0A= + (splt->output_section->vma=0A= + + splt->output_offset=0A= + + h->plt.offset=0A= + + 12), /* same offset */=0A= + sgot->contents + got_offset);=0A= +=20=0A= + /* Fill in the entry in the .rela.plt section. */=0A= + rela.r_offset =3D (sgot->output_section->vma=0A= + + sgot->output_offset=0A= + + got_offset);=0A= + rela.r_info =3D ELF32_R_INFO (h->dynindx, R_M32R_JMP_SLOT);=0A= + rela.r_addend =3D 0;=0A= + loc =3D srela->contents;=0A= + loc +=3D plt_index * sizeof(Elf32_External_Rela);=0A= + bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);=0A= +=20=20=0A= + if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0)= =0A= + {=0A= + /* Mark the symbol as undefined, rather than as defined in=0A= + the .plt section. Leave the value alone. */=0A= + sym->st_shndx =3D SHN_UNDEF;=0A= + }=0A= + }=0A= +=20=0A= + if (h->got.offset !=3D (bfd_vma) -1)=0A= + {=0A= + asection *sgot;=0A= + asection *srela;=0A= + Elf_Internal_Rela rela;=0A= +=20=20=0A= + /* This symbol has an entry in the global offset table. Set it=0A= + up. */=0A= +=20=20=0A= + sgot =3D htab->sgot;=0A= + srela =3D htab->srelgot;=0A= + BFD_ASSERT (sgot !=3D NULL && srela !=3D NULL);=0A= +=20=20=0A= + rela.r_offset =3D (sgot->output_section->vma=0A= + + sgot->output_offset=0A= + + (h->got.offset &~ 1));=0A= +=20=20=0A= + /* If this is a -Bsymbolic link, and the symbol is defined=0A= + locally, we just want to emit a RELATIVE reloc. Likewise if=0A= + the symbol was forced to be local because of a version file.=0A= + The entry in the global offset table will already have been=0A= + initialized in the relocate_section function. */=0A= + if (info->shared=0A= + && (info->symbolic=0A= + || h->dynindx =3D=3D -1=0A= + || (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL))=0A= + && (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))=0A= + {=0A= + rela.r_info =3D ELF32_R_INFO (0, R_M32R_RELATIVE);=0A= + rela.r_addend =3D (h->root.u.def.value=0A= + + h->root.u.def.section->output_section->vma= =0A= + + h->root.u.def.section->output_offset);=0A= + }=0A= + else=0A= + {=0A= + BFD_ASSERT((h->got.offset & 1) =3D=3D 0);=0A= + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.of= fset);=0A= + rela.r_info =3D ELF32_R_INFO (h->dynindx, R_M32R_GLOB_DAT);=0A= + rela.r_addend =3D 0;=0A= + }=0A= +=20=20=0A= + loc =3D srela->contents;=0A= + loc +=3D srela->reloc_count * sizeof(Elf32_External_Rela);=0A= + bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);=0A= + ++srela->reloc_count;=0A= + }=0A= +=20=20=0A= + if ((h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) !=3D 0)=0A= + {=0A= + asection *s;=0A= + Elf_Internal_Rela rela;=0A= +=20=20=0A= + /* This symbols needs a copy reloc. Set it up. */=0A= +=20=20=0A= + BFD_ASSERT (h->dynindx !=3D -1=0A= + && (h->root.type =3D=3D bfd_link_hash_defined=0A= + || h->root.type =3D=3D bfd_link_hash_defweak));=0A= +=20=20=0A= + s =3D bfd_get_section_by_name (h->root.u.def.section->owner,=0A= + ".rela.bss");=0A= + BFD_ASSERT (s !=3D NULL);=0A= +=20=20=0A= + rela.r_offset =3D (h->root.u.def.value=0A= + + h->root.u.def.section->output_section->vma=0A= + + h->root.u.def.section->output_offset);=0A= + rela.r_info =3D ELF32_R_INFO (h->dynindx, R_M32R_COPY);=0A= + rela.r_addend =3D 0;=0A= + loc =3D s->contents;=0A= + loc +=3D s->reloc_count * sizeof(Elf32_External_Rela);=0A= + bfd_elf32_swap_reloca_out (output_bfd, &rela, loc);=0A= + ++s->reloc_count;=0A= + }=0A= +=20=20=0A= + /* Mark some specially defined symbols as absolute. */=0A= + if (strcmp (h->root.root.string, "_DYNAMIC") =3D=3D 0=0A= + || strcmp (h->root.root.string, "_GLOBAL_OFFSET_TABLE_") =3D=3D 0)= =0A= + sym->st_shndx =3D SHN_ABS;=0A= +=20=20=0A= + return TRUE;=0A= + }=0A= +=20=0A= +=20=0A= + /* Finish up the dynamic sections. */=0A= +=20=20=0A= + static bfd_boolean=0A= + m32r_elf_finish_dynamic_sections (output_bfd, info)=0A= + bfd *output_bfd;=0A= + struct bfd_link_info *info;=0A= + {=0A= + struct elf_m32r_link_hash_table *htab;=0A= + bfd *dynobj;=0A= + asection *sdyn;=0A= + asection *sgot;=0A= +=20=0A= + #ifdef DEBUG_PIC=0A= + printf("m32r_elf_finish_dynamic_sections()\n");=0A= + #endif=0A= +=20=20=0A= + htab =3D m32r_elf_hash_table (info);=0A= + dynobj =3D htab->root.dynobj;=0A= +=20=0A= + sgot =3D htab->sgotplt;=0A= + sdyn =3D bfd_get_section_by_name (dynobj, ".dynamic");=0A= +=20=20=0A= + if (htab->root.dynamic_sections_created)=0A= + {=0A= + asection *splt;=0A= + Elf32_External_Dyn *dyncon, *dynconend;=0A= +=20=20=0A= + BFD_ASSERT (sgot !=3D NULL && sdyn !=3D NULL);=0A= +=20=20=0A= + dyncon =3D (Elf32_External_Dyn *) sdyn->contents;=0A= + dynconend =3D (Elf32_External_Dyn *) (sdyn->contents + sdyn->_raw_s= ize);=0A= +=20=0A= + for (; dyncon < dynconend; dyncon++)=0A= + {=0A= + Elf_Internal_Dyn dyn;=0A= + const char *name;=0A= + asection *s;=0A= +=20=20=0A= + bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn);=0A= +=20=20=0A= + switch (dyn.d_tag)=0A= + {=0A= + default:=0A= + break;=0A= +=20=0A= + case DT_PLTGOT:=0A= + name =3D ".got";=0A= + s =3D htab->sgot->output_section;=20=0A= + goto get_vma;=0A= + case DT_JMPREL:=0A= + name =3D ".rela.plt";=0A= + s =3D htab->srelplt->output_section;=0A= + get_vma:=0A= + BFD_ASSERT (s !=3D NULL);=0A= + dyn.d_un.d_ptr =3D s->vma;=0A= + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);=0A= + break;=0A= +=20=0A= + case DT_PLTRELSZ:=0A= + s =3D htab->srelplt->output_section;=0A= + BFD_ASSERT (s !=3D NULL);=0A= + if (s->_cooked_size !=3D 0)=0A= + dyn.d_un.d_val =3D s->_cooked_size;=0A= + else=0A= + dyn.d_un.d_val =3D s->_raw_size;=0A= + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);=0A= + break;=0A= +=20=0A= + case DT_RELASZ:=0A= + /* My reading of the SVR4 ABI indicates that the=0A= + procedure linkage table relocs (DT_JMPREL) should be=0A= + included in the overall relocs (DT_RELA). This is=0A= + what Solaris does. However, UnixWare can not handle=0A= + that case. Therefore, we override the DT_RELASZ entry= =0A= + here to make it not include the JMPREL relocs. Since=0A= + the linker script arranges for .rela.plt to follow all= =0A= + other relocation sections, we don't have to worry=0A= + about changing the DT_RELA entry. */=0A= + if (htab->srelplt !=3D NULL)=0A= + {=0A= + s =3D htab->srelplt->output_section;=0A= + if (s->_cooked_size !=3D 0)=0A= + dyn.d_un.d_val -=3D s->_cooked_size;=0A= + else=0A= + dyn.d_un.d_val -=3D s->_raw_size;=0A= + }=0A= + bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);=0A= + break;=0A= + }=0A= + }=0A= +=20=20=0A= + /* Fill in the first entry in the procedure linkage table. */=0A= + splt =3D htab->splt;=0A= + if (splt && splt->_raw_size > 0)=0A= + {=0A= + if (info->shared)=0A= + {=0A= + bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD0, splt->content= s);=0A= + bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD1, splt->content= s + 4);=0A= + bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD2, splt->content= s + 8);=0A= + bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD3, splt->content= s + 12);=0A= + bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD4, splt->content= s + 16);=0A= + }=0A= + else=0A= + {=0A= + unsigned long addr;=0A= + /* addr =3D .got + 4 */=0A= + addr =3D sgot->output_section->vma + sgot->output_offset + = 4;=0A= + bfd_put_32 (output_bfd,=0A= + PLT0_ENTRY_WORD0 | ((addr >> 16) & 0xffff),=0A= + splt->contents);=0A= + bfd_put_32 (output_bfd,=20=0A= + PLT0_ENTRY_WORD1 | (addr & 0xffff),=0A= + splt->contents + 4);=0A= + bfd_put_32 (output_bfd, PLT0_ENTRY_WORD2, splt->contents + = 8);=0A= + bfd_put_32 (output_bfd, PLT0_ENTRY_WORD3, splt->contents + = 12);=0A= + bfd_put_32 (output_bfd, PLT0_ENTRY_WORD4, splt->contents + = 16);=0A= + }=0A= +=20=0A= + elf_section_data (splt->output_section)->this_hdr.sh_entsize = =3D=0A= + PLT_ENTRY_SIZE;=0A= + }=0A= + }=0A= +=20=0A= + /* Fill in the first three entries in the global offset table. */=0A= + if (sgot && sgot->_raw_size > 0)=0A= + {=0A= + if (sdyn =3D=3D NULL)=0A= + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents);=0A= + else=0A= + bfd_put_32 (output_bfd,=0A= + sdyn->output_section->vma + sdyn->output_offset,=0A= + sgot->contents);=0A= + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 4);=0A= + bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + 8);=0A= +=20=0A= + elf_section_data (sgot->output_section)->this_hdr.sh_entsize =3D 4;= =0A= + }=0A= +=20=20=0A= + return TRUE;=0A= + }=0A= +=20=0A= =0C=0A= #if 0 /* relaxing not supported yet */=0A= =20=20=0A= ***************=0A= *** 2005,2010 ****=0A= --- 4270,4277 ----=0A= {=0A= case R_M32R_GNU_VTINHERIT:=0A= case R_M32R_GNU_VTENTRY:=0A= + case R_M32R_RELA_GNU_VTINHERIT:=0A= + case R_M32R_RELA_GNU_VTENTRY:=0A= break;=0A= =20=20=0A= default:=0A= ***************=0A= *** 2035,2041 ****=0A= asection *sec ATTRIBUTE_UNUSED;=0A= const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;=0A= {=0A= ! /* we don't use got and plt entries for m32r */=0A= return TRUE;=0A= }=0A= =20=20=0A= --- 4302,4398 ----=0A= asection *sec ATTRIBUTE_UNUSED;=0A= const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED;=0A= {=0A= ! /* Update the got entry reference counts for the section being removed.= */=0A= ! Elf_Internal_Shdr *symtab_hdr;=0A= ! struct elf_link_hash_entry **sym_hashes;=0A= ! bfd_signed_vma *local_got_refcounts;=0A= ! const Elf_Internal_Rela *rel, *relend;=0A= ! unsigned long r_symndx;=0A= ! struct elf_link_hash_entry *h;=0A= !=20=0A= ! elf_section_data (sec)->local_dynrel =3D NULL;=0A= !=20=0A= ! symtab_hdr =3D &elf_tdata (abfd)->symtab_hdr;=0A= ! sym_hashes =3D elf_sym_hashes (abfd);=0A= ! local_got_refcounts =3D elf_local_got_refcounts (abfd);=0A= !=20=0A= ! relend =3D relocs + sec->reloc_count;=0A= ! for (rel =3D relocs; rel < relend; rel++)=0A= ! switch (ELF32_R_TYPE (rel->r_info))=0A= ! {=0A= ! case R_M32R_GOT16_HI_ULO:=0A= ! case R_M32R_GOT16_HI_SLO:=0A= ! case R_M32R_GOT16_LO:=0A= ! case R_M32R_GOT24:=0A= ! case R_M32R_GOTPC_HI_ULO:=0A= ! case R_M32R_GOTPC_HI_SLO:=0A= ! case R_M32R_GOTPC_LO:=0A= ! case R_M32R_GOTPC24:=0A= ! r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= ! if (r_symndx >=3D symtab_hdr->sh_info)=0A= ! {=0A= ! h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= ! if (h->got.refcount > 0)=0A= ! h->got.refcount--;=0A= ! }=0A= ! else=0A= ! {=0A= ! if (local_got_refcounts && local_got_refcounts[r_symndx] > 0)=0A= ! local_got_refcounts[r_symndx]--;=0A= ! }=0A= ! break;=0A= !=20=0A= ! case R_M32R_16_RELA:=0A= ! case R_M32R_24_RELA:=0A= ! case R_M32R_32_RELA:=0A= ! case R_M32R_HI16_ULO_RELA:=0A= ! case R_M32R_HI16_SLO_RELA:=0A= ! case R_M32R_LO16_RELA:=0A= ! case R_M32R_SDA16_RELA:=0A= ! case R_M32R_18_PCREL_RELA:=0A= ! case R_M32R_26_PCREL_RELA:=0A= ! r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= ! if (r_symndx >=3D symtab_hdr->sh_info)=0A= ! {=0A= ! struct elf_m32r_link_hash_entry *eh;=0A= ! struct elf_m32r_dyn_relocs **pp;=0A= ! struct elf_m32r_dyn_relocs *p;=0A= !=20=0A= ! h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= !=20=0A= ! if (!info->shared && h->plt.refcount > 0)=0A= ! h->plt.refcount -=3D 1;=0A= !=20=0A= ! eh =3D (struct elf_m32r_link_hash_entry *) h;=0A= !=20=0A= ! for (pp =3D &eh->dyn_relocs; (p =3D *pp) !=3D NULL; pp =3D &p= ->next)=0A= ! if (p->sec =3D=3D sec)=0A= ! {=0A= ! if (ELF32_R_TYPE (rel->r_info) =3D=3D R_M32R_26_PCREL_R= ELA=0A= ! || ELF32_R_TYPE (rel->r_info) =3D=3D R_M32R_26_PCRE= L_RELA)=0A= ! p->pc_count -=3D 1;=0A= ! p->count -=3D 1;=0A= ! if (p->count =3D=3D 0)=0A= ! *pp =3D p->next;=0A= ! break;=0A= ! }=0A= ! }=0A= ! break;=0A= !=20=0A= ! case R_M32R_26_PLTREL:=0A= ! r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= ! if (r_symndx >=3D symtab_hdr->sh_info)=0A= ! {=0A= ! h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= ! if (h->plt.refcount > 0)=0A= ! h->plt.refcount--;=0A= ! }=0A= ! break;=0A= !=20=0A= ! default:=0A= ! break;=0A= ! }=0A= !=20=0A= return TRUE;=0A= }=0A= =20=20=0A= ***************=0A= *** 2054,2085 ****=0A= struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;=0A= const Elf_Internal_Rela *rel;=0A= const Elf_Internal_Rela *rel_end;=0A= =20=20=0A= if (info->relocatable)=0A= return TRUE;=0A= =20=20=0A= symtab_hdr =3D &elf_tdata (abfd)->symtab_hdr;=0A= sym_hashes =3D elf_sym_hashes (abfd);=0A= sym_hashes_end =3D sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_Exter= nal_Sym);=0A= if (!elf_bad_symtab (abfd))=0A= sym_hashes_end -=3D symtab_hdr->sh_info;=0A= =20=20=0A= rel_end =3D relocs + sec->reloc_count;=0A= for (rel =3D relocs; rel < rel_end; rel++)=0A= {=0A= struct elf_link_hash_entry *h;=0A= unsigned long r_symndx;=0A= =20=20=0A= r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= if (r_symndx < symtab_hdr->sh_info)=0A= h =3D NULL;=0A= else=0A= h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= =20=20=0A= ! switch (ELF32_R_TYPE (rel->r_info))=0A= {=0A= /* This relocation describes the C++ object vtable hierarchy.=0A= Reconstruct it for later use during GC. */=0A= case R_M32R_GNU_VTINHERIT:=0A= if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offse= t))=0A= return FALSE;=0A= --- 4411,4660 ----=0A= struct elf_link_hash_entry **sym_hashes, **sym_hashes_end;=0A= const Elf_Internal_Rela *rel;=0A= const Elf_Internal_Rela *rel_end;=0A= + struct elf_m32r_link_hash_table *htab;=0A= + bfd *dynobj;=0A= + bfd_vma *local_got_offsets;=0A= + asection *sgot, *srelgot, *sreloc;=0A= =20=20=0A= if (info->relocatable)=0A= return TRUE;=0A= =20=20=0A= + sgot =3D srelgot =3D sreloc =3D NULL;=0A= +=20=0A= symtab_hdr =3D &elf_tdata (abfd)->symtab_hdr;=0A= sym_hashes =3D elf_sym_hashes (abfd);=0A= sym_hashes_end =3D sym_hashes + symtab_hdr->sh_size/sizeof (Elf32_Exter= nal_Sym);=0A= if (!elf_bad_symtab (abfd))=0A= sym_hashes_end -=3D symtab_hdr->sh_info;=0A= =20=20=0A= + htab =3D m32r_elf_hash_table (info);=0A= + dynobj =3D htab->root.dynobj;=0A= + local_got_offsets =3D elf_local_got_offsets (abfd);=0A= +=20=0A= rel_end =3D relocs + sec->reloc_count;=0A= for (rel =3D relocs; rel < rel_end; rel++)=0A= {=0A= + int r_type;=0A= struct elf_link_hash_entry *h;=0A= unsigned long r_symndx;=0A= =20=20=0A= r_symndx =3D ELF32_R_SYM (rel->r_info);=0A= + r_type =3D ELF32_R_TYPE (rel->r_info);=0A= if (r_symndx < symtab_hdr->sh_info)=0A= h =3D NULL;=0A= else=0A= h =3D sym_hashes[r_symndx - symtab_hdr->sh_info];=0A= =20=20=0A= ! /* Some relocs require a global offset table. */=0A= ! if (htab->sgot =3D=3D NULL)=0A= ! {=0A= ! switch (r_type)=0A= ! {=0A= ! case R_M32R_GOT16_HI_ULO:=0A= ! case R_M32R_GOT16_HI_SLO:=0A= ! case R_M32R_GOT16_LO:=0A= ! case R_M32R_GOTPC24:=0A= ! case R_M32R_GOTPC_HI_ULO:=0A= ! case R_M32R_GOTPC_HI_SLO:=0A= ! case R_M32R_GOTPC_LO:=0A= ! case R_M32R_GOT24:=0A= ! if (dynobj =3D=3D NULL)=0A= ! htab->root.dynobj =3D dynobj =3D abfd;=0A= ! if (! create_got_section (dynobj, info))=0A= ! return FALSE;=0A= ! break;=0A= !=20=0A= ! default:=0A= ! break;=0A= ! }=0A= ! }=0A= !=20=0A= ! switch (r_type)=0A= {=0A= + case R_M32R_GOT16_HI_ULO:=0A= + case R_M32R_GOT16_HI_SLO:=0A= + case R_M32R_GOT16_LO:=20=0A= + case R_M32R_GOT24:=0A= +=20=0A= + if (h !=3D NULL)=0A= + h->got.refcount +=3D 1;=0A= + else=0A= + {=0A= + bfd_signed_vma *local_got_refcounts;=0A= +=20=0A= + /* This is a global offset table entry for a local=0A= + symbol. */=0A= + local_got_refcounts =3D elf_local_got_refcounts (abfd);=0A= + if (local_got_refcounts =3D=3D NULL)=0A= + {=0A= + bfd_size_type size;=0A= +=20=0A= + size =3D symtab_hdr->sh_info;=0A= + size *=3D sizeof (bfd_signed_vma);=0A= + local_got_refcounts =3D ((bfd_signed_vma *)=0A= + bfd_zalloc (abfd, size));=0A= + if (local_got_refcounts =3D=3D NULL)=0A= + return FALSE;=0A= + elf_local_got_refcounts (abfd) =3D local_got_refcounts;= =0A= + }=0A= + local_got_refcounts[r_symndx] +=3D 1;=0A= + }=0A= + break;=0A= +=20=0A= + case R_M32R_26_PLTREL:=0A= + /* This symbol requires a procedure linkage table entry. We=0A= + actually build the entry in adjust_dynamic_symbol,=0A= + because this might be a case of linking PIC code without=0A= + linking in any dynamic objects, in which case we don't=0A= + need to generate a procedure linkage table after all. */=0A= +=20=20=0A= + /* If this is a local symbol, we resolve it directly without=0A= + creating a procedure linkage table entry. */=0A= + if (h =3D=3D NULL)=0A= + continue;=0A= +=20=0A= + if (h->elf_link_hash_flags & ELF_LINK_FORCED_LOCAL)=0A= + break;=0A= +=20=0A= + h->elf_link_hash_flags |=3D ELF_LINK_HASH_NEEDS_PLT;=0A= + h->plt.refcount +=3D 1;=0A= + break;=0A= +=20=0A= + case R_M32R_16_RELA:=0A= + case R_M32R_24_RELA:=0A= + case R_M32R_32_RELA:=0A= + case R_M32R_HI16_ULO_RELA:=0A= + case R_M32R_HI16_SLO_RELA:=0A= + case R_M32R_LO16_RELA:=0A= + case R_M32R_SDA16_RELA:=0A= + case R_M32R_18_PCREL_RELA:=0A= + case R_M32R_26_PCREL_RELA:=0A= +=20=0A= + if (h !=3D NULL && !info->shared)=0A= + {=0A= + h->elf_link_hash_flags |=3D ELF_LINK_NON_GOT_REF;=0A= + h->plt.refcount +=3D 1;=0A= + }=0A= +=20=0A= + /* If we are creating a shared library, and this is a reloc=0A= + against a global symbol, or a non PC relative reloc=0A= + against a local symbol, then we need to copy the reloc=0A= + into the shared library. However, if we are linking with=0A= + -Bsymbolic, we do not need to copy a reloc against a=0A= + global symbol which is defined in an object we are=0A= + including in the link (i.e., DEF_REGULAR is set). At=0A= + this point we have not seen all the input files, so it is=0A= + possible that DEF_REGULAR is not set now but will be set=0A= + later (it is never cleared). We account for that=0A= + possibility below by storing information in the=0A= + dyn_relocs field of the hash table entry. A similar=0A= + situation occurs when creating shared libraries and symbol= =0A= + visibility changes render the symbol local.=0A= +=20=0A= + If on the other hand, we are creating an executable, we=0A= + may need to keep relocations for symbols satisfied by a=0A= + dynamic library if we manage to avoid copy relocs for the=0A= + symbol. */=0A= + if ((info->shared=0A= + && (sec->flags & SEC_ALLOC) !=3D 0=0A= + && ((r_type !=3D R_M32R_26_PCREL_RELA=0A= + && r_type !=3D R_M32R_18_PCREL_RELA)=0A= + || (h !=3D NULL=0A= + && (! info->symbolic=0A= + || h->root.type =3D=3D bfd_link_hash_defweak=0A= + || (h->elf_link_hash_flags=0A= + & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0))))=0A= + || (!info->shared=0A= + && (sec->flags & SEC_ALLOC) !=3D 0=0A= + && h !=3D NULL=0A= + && (h->root.type =3D=3D bfd_link_hash_defweak=0A= + || (h->elf_link_hash_flags=0A= + & ELF_LINK_HASH_DEF_REGULAR) =3D=3D 0)))=0A= + {=0A= + struct elf_m32r_dyn_relocs *p;=0A= + struct elf_m32r_dyn_relocs **head;=0A= +=20=0A= + if (dynobj =3D=3D NULL)=0A= + htab->root.dynobj =3D dynobj =3D abfd;=0A= +=20=0A= + /* When creating a shared object, we must copy these=0A= + relocs into the output file. We create a reloc=0A= + section in dynobj and make room for the reloc. */=0A= + if (sreloc =3D=3D NULL)=0A= + {=0A= + const char *name;=0A= +=20=20=0A= + name =3D (bfd_elf_string_from_elf_section=0A= + (abfd,=0A= + elf_elfheader (abfd)->e_shstrndx,=0A= + elf_section_data (sec)->rel_hdr.sh_name));=0A= + if (name =3D=3D NULL)=0A= + return FALSE;=0A= +=20=20=0A= + BFD_ASSERT (strncmp (name, ".rela", 5) =3D=3D 0=0A= + && strcmp (bfd_get_section_name (abfd, sec)= ,=0A= + name + 5) =3D=3D 0);=0A= +=20=20=0A= + sreloc =3D bfd_get_section_by_name (dynobj, name);=0A= + if (sreloc =3D=3D NULL)=0A= + {=0A= + flagword flags;=0A= +=20=20=0A= + sreloc =3D bfd_make_section (dynobj, name);=0A= + flags =3D (SEC_HAS_CONTENTS | SEC_READONLY=0A= + | SEC_IN_MEMORY | SEC_LINKER_CREATED);=0A= + if ((sec->flags & SEC_ALLOC) !=3D 0)=0A= + flags |=3D SEC_ALLOC | SEC_LOAD;=0A= + if (sreloc =3D=3D NULL=0A= + || ! bfd_set_section_flags (dynobj, sreloc, fla= gs)=0A= + || ! bfd_set_section_alignment (dynobj, sreloc,= 2))=0A= + return FALSE;=0A= + }=0A= + elf_section_data (sec)->sreloc =3D sreloc;=0A= + }=0A= +=20=20=0A= + /* If this is a global symbol, we count the number of=0A= + relocations we need for this symbol. */=0A= + if (h !=3D NULL)=0A= + head =3D &((struct elf_m32r_link_hash_entry *) h)->dyn_re= locs;=0A= + else=0A= + {=0A= + asection *s;=0A= +=20=0A= + /* Track dynamic relocs needed for local syms too. */= =0A= + s =3D bfd_section_from_r_symndx (abfd, &htab->sym_sec,= =0A= + sec, r_symndx);=0A= + if (s =3D=3D NULL)=0A= + return FALSE;=0A= +=20=0A= + head =3D ((struct elf_m32r_dyn_relocs **)=0A= + &elf_section_data (s)->local_dynrel);=0A= + }=0A= +=20=0A= + p =3D *head;=0A= + if (p =3D=3D NULL || p->sec !=3D sec)=0A= + {=0A= + bfd_size_type amt =3D sizeof (*p);=0A= + p =3D ((struct elf_m32r_dyn_relocs *) bfd_alloc (dynobj= , amt));=0A= + if (p =3D=3D NULL)=0A= + return FALSE;=0A= + p->next =3D *head;=0A= + *head =3D p;=0A= + p->sec =3D sec;=0A= + p->count =3D 0;=0A= + p->pc_count =3D 0;=0A= + }=0A= +=20=0A= + p->count +=3D 1;=0A= + if (ELF32_R_TYPE (rel->r_info) =3D=3D R_M32R_26_PCREL_RELA= =0A= + || ELF32_R_TYPE (rel->r_info) =3D=3D R_M32R_18_PCREL_RE= LA)=0A= + p->pc_count +=3D 1;=0A= + }=0A= + break;=0A= +=20=0A= /* This relocation describes the C++ object vtable hierarchy.=0A= Reconstruct it for later use during GC. */=0A= + case R_M32R_RELA_GNU_VTINHERIT:=0A= case R_M32R_GNU_VTINHERIT:=0A= if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offse= t))=0A= return FALSE;=0A= ***************=0A= *** 2091,2096 ****=0A= --- 4666,4675 ----=0A= if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_offset)= )=0A= return FALSE;=0A= break;=0A= + case R_M32R_RELA_GNU_VTENTRY:=0A= + if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)= )=0A= + return FALSE;=0A= + break;=0A= }=0A= }=0A= =20=20=0A= ***************=0A= *** 2103,2108 ****=0A= --- 4682,4742 ----=0A= { ".sbss", 5, -2, SHT_NOBITS, SHF_ALLOC + SHF_WRITE },=0A= { NULL, 0, 0, 0, 0 }=0A= };=0A= +=20=0A= + static bfd_boolean=0A= + m32r_elf_fake_sections (abfd, hdr, sec)=0A= + bfd *abfd;=0A= + Elf_Internal_Shdr *hdr ATTRIBUTE_UNUSED;=0A= + asection *sec;=0A= + {=0A= + register const char *name;=0A= +=20=0A= + name =3D bfd_get_section_name (abfd, sec);=0A= +=20=0A= + /* The generic elf_fake_sections will set up REL_HDR using the=0A= + default kind of relocations. But, we may actually need both=0A= + kinds of relocations, so we set up the second header here.=0A= +=20=0A= + This is not necessary for the O32 ABI since that only uses Elf32_Rel= =0A= + relocations (cf. System V ABI, MIPS RISC Processor Supplement,=0A= + 3rd Edition, p. 4-17). It breaks the IRIX 5/6 32-bit ld, since one= =0A= + of the resulting empty .rela.
sections starts with=0A= + sh_offset =3D=3D object size, and ld doesn't allow that. While the = check=0A= + is arguably bogus for empty or SHT_NOBITS sections, it can easily be= =0A= + avoided by not emitting those useless sections in the first place. = */=0A= + if ((sec->flags & SEC_RELOC) !=3D 0)=0A= + {=0A= + struct bfd_elf_section_data *esd;=0A= + bfd_size_type amt =3D sizeof (Elf_Internal_Shdr);=0A= +=20=0A= + esd =3D elf_section_data (sec);=0A= + BFD_ASSERT (esd->rel_hdr2 =3D=3D NULL);=0A= + esd->rel_hdr2 =3D (Elf_Internal_Shdr *) bfd_zalloc (abfd, amt);=0A= + if (!esd->rel_hdr2)=0A= + return FALSE;=0A= + _bfd_elf_init_reloc_shdr (abfd, esd->rel_hdr2, sec,=0A= + !sec->use_rela_p);=0A= + }=0A= +=20=0A= + return TRUE;=0A= + }=0A= +=20=0A= + static enum elf_reloc_type_class=0A= + m32r_elf_reloc_type_class (rela)=0A= + const Elf_Internal_Rela *rela;=0A= + {=0A= + switch ((int) ELF32_R_TYPE (rela->r_info))=0A= + {=0A= + case R_M32R_RELATIVE:=0A= + return reloc_class_relative;=0A= + case R_M32R_JMP_SLOT:=0A= + return reloc_class_plt;=0A= + case R_M32R_COPY:=0A= + return reloc_class_copy;=0A= + default:=0A= + return reloc_class_normal;=0A= + }=0A= + }=0A= =0C=0A= #define ELF_ARCH bfd_arch_m32r=0A= #define ELF_MACHINE_CODE EM_M32R=0A= ***************=0A= *** 2111,2118 ****=0A= =20=20=0A= #define TARGET_BIG_SYM bfd_elf32_m32r_vec=0A= #define TARGET_BIG_NAME "elf32-m32r"=0A= =20=20=0A= ! #define elf_info_to_howto 0=0A= #define elf_info_to_howto_rel m32r_info_to_howto_rel=0A= #define elf_backend_section_from_bfd_section _bfd_m32r_elf_section_from_b= fd_section=0A= #define elf_backend_symbol_processing _bfd_m32r_elf_symbol_processing=0A= --- 4745,4754 ----=0A= =20=20=0A= #define TARGET_BIG_SYM bfd_elf32_m32r_vec=0A= #define TARGET_BIG_NAME "elf32-m32r"=0A= + #define TARGET_LITTLE_SYM bfd_elf32_m32rle_vec=0A= + #define TARGET_LITTLE_NAME "elf32-m32rle"=0A= =20=20=0A= ! #define elf_info_to_howto m32r_info_to_howto=0A= #define elf_info_to_howto_rel m32r_info_to_howto_rel=0A= #define elf_backend_section_from_bfd_section _bfd_m32r_elf_section_from_b= fd_section=0A= #define elf_backend_symbol_processing _bfd_m32r_elf_symbol_processing=0A= ***************=0A= *** 2122,2131 ****=0A= #define elf_backend_gc_sweep_hook m32r_elf_gc_sweep_hook=0A= #define elf_backend_check_relocs m32r_elf_check_relocs=0A= =20=20=0A= #define elf_backend_can_gc_sections 1=0A= ! #if !USE_REL=0A= #define elf_backend_rela_normal 1=0A= #endif=0A= #if 0 /* not yet */=0A= /* relax support */=0A= #define bfd_elf32_bfd_relax_section m32r_elf_relax_section=0A= --- 4758,4792 ----=0A= #define elf_backend_gc_sweep_hook m32r_elf_gc_sweep_hook=0A= #define elf_backend_check_relocs m32r_elf_check_relocs=0A= =20=20=0A= + #define elf_backend_create_dynamic_sections m32r_elf_create_dynamic_s= ections=0A= + #define bfd_elf32_bfd_link_hash_table_create m32r_elf_link_hash_table_= create=0A= + #define elf_backend_size_dynamic_sections m32r_elf_size_dynamic_sec= tions=0A= + #define elf_backend_finish_dynamic_sections m32r_elf_finish_dynamic_s= ections=0A= + #define elf_backend_adjust_dynamic_symbol m32r_elf_adjust_dynamic_s= ymbol=0A= + #define elf_backend_finish_dynamic_symbol m32r_elf_finish_dynamic_s= ymbol=0A= + #define elf_backend_reloc_type_class m32r_elf_reloc_type_class= =0A= + #define elf_backend_copy_indirect_symbol m32r_elf_copy_indirect_sy= mbol=0A= +=20=0A= #define elf_backend_can_gc_sections 1=0A= ! /*#if !USE_REL=0A= #define elf_backend_rela_normal 1=0A= + #endif*/=0A= + #define elf_backend_can_refcount 1=0A= + #define elf_backend_want_got_plt 1=0A= + #define elf_backend_plt_readonly 1=0A= + #define elf_backend_want_plt_sym 0=0A= + #define elf_backend_got_header_size 12=0A= +=20=0A= + #define elf_backend_may_use_rel_p 1=0A= + #ifdef USE_M32R_OLD_RELOC=0A= + #define elf_backend_default_use_rela_p 0=0A= + #define elf_backend_may_use_rela_p 0=0A= + #else=0A= + #define elf_backend_default_use_rela_p 1=0A= + #define elf_backend_may_use_rela_p 1=0A= + #define elf_backend_fake_sections m32r_elf_fake_sections=0A= #endif=0A= +=20=0A= #if 0 /* not yet */=0A= /* relax support */=0A= #define bfd_elf32_bfd_relax_section m32r_elf_relax_section=0A= ***************=0A= *** 2141,2143 ****=0A= --- 4802,4821 ----=0A= #define elf_backend_special_sections m32r_elf_special_sections=0A= =20=20=0A= #include "elf32-target.h"=0A= +=20=0A= + #undef ELF_MAXPAGESIZE=0A= + #define ELF_MAXPAGESIZE 0x1000=0A= +=20=0A= + #undef TARGET_BIG_SYM=0A= + #define TARGET_BIG_SYM bfd_elf32_m32rlin_vec=0A= + #undef TARGET_BIG_NAME=0A= + #define TARGET_BIG_NAME "elf32-m32r-linux"=0A= + #undef TARGET_LITTLE_SYM=0A= + #define TARGET_LITTLE_SYM bfd_elf32_m32rlelin_vec=0A= + #undef TARGET_LITTLE_NAME=0A= + #define TARGET_LITTLE_NAME "elf32-m32rle-linux"=0A= + #undef elf32_bed=0A= + #define elf32_bed elf32_m32r_lin_bed=0A= +=20=0A= + #include "elf32-target.h"=0A= +=20=0A= Index: bfd/reloc.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/bfd/reloc.c,v=0A= retrieving revision 1.96=0A= diff -c -r1.96 reloc.c=0A= *** bfd/reloc.c 30 Nov 2003 18:40:41 -0000 1.96=0A= --- bfd/reloc.c 18 Dec 2003 10:04:33 -0000=0A= ***************=0A= *** 2911,2916 ****=0A= --- 2911,2947 ----=0A= ENUMDOC=0A= This is a 16-bit reloc containing the small data area offset for use in= =0A= add3, load, and store instructions.=0A= + ENUM=0A= + BFD_RELOC_M32R_GOT24=0A= + ENUMX=0A= + BFD_RELOC_M32R_26_PLTREL=0A= + ENUMX=0A= + BFD_RELOC_M32R_COPY=0A= + ENUMX=0A= + BFD_RELOC_M32R_GLOB_DAT=0A= + ENUMX=0A= + BFD_RELOC_M32R_JMP_SLOT=0A= + ENUMX=0A= + BFD_RELOC_M32R_RELATIVE=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOTOFF=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOTPC24=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOT16_HI_ULO=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOT16_HI_SLO=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOT16_LO=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOTPC_HI_ULO=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOTPC_HI_SLO=0A= + ENUMX=0A= + BFD_RELOC_M32R_GOTPC_LO=0A= + ENUMDOC=0A= + For PIC.=0A= +=20=0A= =20=20=0A= ENUM=0A= BFD_RELOC_V850_9_PCREL=0A= Index: bfd/targets.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/bfd/targets.c,v=0A= retrieving revision 1.102=0A= diff -c -r1.102 targets.c=0A= *** bfd/targets.c 30 Nov 2003 18:40:41 -0000 1.102=0A= --- bfd/targets.c 18 Dec 2003 10:04:34 -0000=0A= ***************=0A= *** 542,547 ****=0A= --- 542,550 ----=0A= extern const bfd_target bfd_elf32_littlearm_vec;=0A= extern const bfd_target bfd_elf32_littlemips_vec;=0A= extern const bfd_target bfd_elf32_m32r_vec;=0A= + extern const bfd_target bfd_elf32_m32rle_vec;=0A= + extern const bfd_target bfd_elf32_m32rlin_vec;=0A= + extern const bfd_target bfd_elf32_m32rlelin_vec;=0A= extern const bfd_target bfd_elf32_m68hc11_vec;=0A= extern const bfd_target bfd_elf32_m68hc12_vec;=0A= extern const bfd_target bfd_elf32_m68k_vec;=0A= ***************=0A= *** 831,836 ****=0A= --- 834,842 ----=0A= &bfd_elf32_littlearm_vec,=0A= &bfd_elf32_littlemips_vec,=0A= &bfd_elf32_m32r_vec,=0A= + &bfd_elf32_m32rle_vec,=0A= + &bfd_elf32_m32rlin_vec,=0A= + &bfd_elf32_m32rlelin_vec,=0A= &bfd_elf32_m68hc11_vec,=0A= &bfd_elf32_m68hc12_vec,=0A= &bfd_elf32_m68k_vec,=0A= Index: gas/configure.in=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gas/configure.in,v=0A= retrieving revision 1.145=0A= diff -c -r1.145 configure.in=0A= *** gas/configure.in 3 Dec 2003 15:07:16 -0000 1.145=0A= --- gas/configure.in 18 Dec 2003 10:04:36 -0000=0A= ***************=0A= *** 164,169 ****=0A= --- 164,171 ----=0A= sparc*) cpu_type=3Dsparc arch=3Dsparclite ;; # ??? See tc-sparc.c.= =0A= v850*) cpu_type=3Dv850 ;;=0A= xtensa*) cpu_type=3Dxtensa arch=3Dxtensa ;;=0A= + m32r) cpu_type=3Dm32r target_cpu=3Dm32r endian=3Dbig ;;= =0A= + m32rle) cpu_type=3Dm32r target_cpu=3Dm32r endian=3Dlittle= ;;=0A= *) cpu_type=3D${cpu} ;;=0A= esac=0A= =20=20=0A= ***************=0A= *** 337,343 ****=0A= =20=20=0A= iq2000-*-elf) fmt=3Delf bfd_gas=3Dyes ;;=0A= =20=20=0A= ! m32r-*-*) fmt=3Delf ;;=0A= =20=20=0A= m68hc11-*-* | m6811-*-*) fmt=3Delf ;;=0A= m68hc12-*-* | m6812-*-*) fmt=3Delf ;;=0A= --- 339,346 ----=0A= =20=20=0A= iq2000-*-elf) fmt=3Delf bfd_gas=3Dyes ;;=0A= =20=20=0A= ! m32r-*-elf*) fmt=3Delf ;;=0A= ! m32r-*-linux*) fmt=3Delf em=3Dlinux;;=0A= =20=20=0A= m68hc11-*-* | m6811-*-*) fmt=3Delf ;;=0A= m68hc12-*-* | m6812-*-*) fmt=3Delf ;;=0A= Index: gas/config/tc-m32r.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gas/config/tc-m32r.c,v=0A= retrieving revision 1.33=0A= diff -c -r1.33 tc-m32r.c=0A= *** gas/config/tc-m32r.c 17 Dec 2003 09:41:06 -0000 1.33=0A= --- gas/config/tc-m32r.c 18 Dec 2003 10:04:37 -0000=0A= ***************=0A= *** 70,75 ****=0A= --- 70,78 ----=0A= alignment request. */=0A= static int seen_relaxable_p =3D 0;=0A= =20=20=0A= + /* Non-zero if we are generating PIC code. */=0A= + int pic_code;=0A= +=20=0A= /* Non-zero if -relax specified, in which case sufficient relocs are outp= ut=0A= for the linker to do relaxing.=0A= We do simple forms of relaxing internally, but they are always done.= =0A= ***************=0A= *** 194,200 ****=0A= gas_cgen_cpu_desc->machs =3D mach_table[on].mach_flags;=0A= }=0A= =0C=0A= ! #define M32R_SHORTOPTS "O"=0A= =20=20=0A= const char *md_shortopts =3D M32R_SHORTOPTS;=0A= =20=20=0A= --- 197,203 ----=0A= gas_cgen_cpu_desc->machs =3D mach_table[on].mach_flags;=0A= }=0A= =0C=0A= ! #define M32R_SHORTOPTS "O::K:"=0A= =20=20=0A= const char *md_shortopts =3D M32R_SHORTOPTS;=0A= =20=20=0A= ***************=0A= *** 362,367 ****=0A= --- 365,377 ----=0A= warn_unmatched_high =3D 0;=0A= break;=0A= =20=20=0A= + case 'K':=0A= + if (strcmp (arg, "PIC") !=3D 0)=0A= + as_warn (_("Unrecognized option following -K"));=0A= + else=0A= + pic_code =3D 1;=0A= + break;=0A= +=20=0A= #if 0=0A= /* Not supported yet. */=0A= case OPTION_RELAX:=0A= ***************=0A= *** 436,441 ****=0A= --- 446,454 ----=0A= fprintf (stream, _("\=0A= -Wnuh synonym for -no-warn-unmatched-high\n"));=0A= =20=20=0A= + fprintf (stream, _("\=0A= + -KPIC generate PIC\n"));=0A= +=20=0A= #if 0=0A= fprintf (stream, _("\=0A= -relax create linker relaxable code\n"));=0A= ***************=0A= *** 558,564 ****=0A= }=0A= =20=20=0A= symbol_table_insert (symbolP);=0A= ! if (S_IS_DEFINED (symbolP) && S_GET_SEGMENT (symbolP) !=3D reg_section)= =0A= /* xgettext:c-format */=0A= as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));=0A= =20=20=0A= --- 571,579 ----=0A= }=0A= =20=20=0A= symbol_table_insert (symbolP);=0A= ! if (S_IS_DEFINED (symbolP) && (S_GET_SEGMENT (symbolP) !=3D reg_section= =0A= ! || S_IS_EXTERNAL (symbolP)=0A= ! || S_IS_WEAK (symbolP)))=0A= /* xgettext:c-format */=0A= as_bad (_("symbol `%s' already defined"), S_GET_NAME (symbolP));=0A= =20=20=0A= ***************=0A= *** 1710,1716 ****=0A= However, we can't finish the fragment here and emit the reloc as ins= n=0A= alignment requirements may move the insn about. */=0A= =20=20=0A= ! if (S_GET_SEGMENT (fragP->fr_symbol) !=3D segment)=0A= {=0A= #if 0=0A= int old_fr_fix =3D fragP->fr_fix;=0A= --- 1725,1733 ----=0A= However, we can't finish the fragment here and emit the reloc as ins= n=0A= alignment requirements may move the insn about. */=0A= =20=20=0A= ! if (S_GET_SEGMENT (fragP->fr_symbol) !=3D segment=0A= ! || S_IS_EXTERNAL (fragP->fr_symbol)=0A= ! || S_IS_WEAK (fragP->fr_symbol))=0A= {=0A= #if 0=0A= int old_fr_fix =3D fragP->fr_fix;=0A= ***************=0A= *** 1816,1827 ****=0A= abort ();=0A= }=0A= =20=20=0A= ! if (S_GET_SEGMENT (fragP->fr_symbol) !=3D sec)=0A= {=0A= /* Symbol must be resolved by linker. */=0A= if (fragP->fr_offset & 3)=0A= as_warn (_("Addend to unresolved symbol not on word boundary."));=0A= ! addend =3D fragP->fr_offset >> 2;=0A= }=0A= else=0A= {=0A= --- 1833,1850 ----=0A= abort ();=0A= }=0A= =20=20=0A= ! if (S_GET_SEGMENT (fragP->fr_symbol) !=3D sec=0A= ! || S_IS_EXTERNAL (fragP->fr_symbol)=0A= ! || S_IS_WEAK (fragP->fr_symbol))=0A= {=0A= /* Symbol must be resolved by linker. */=0A= if (fragP->fr_offset & 3)=0A= as_warn (_("Addend to unresolved symbol not on word boundary."));=0A= ! #ifdef USE_M32R_OLD_RELOC=0A= ! addend =3D fragP->fr_offset >> 2; /* Old M32R used USE_REL. */=0A= ! #else=0A= ! addend =3D 0;=0A= ! #endif=0A= }=0A= else=0A= {=0A= ***************=0A= *** 1833,1839 ****=0A= /* Create a relocation for symbols that must be resolved by the linker.= =0A= Otherwise output the completed insn. */=0A= =20=20=0A= ! if (S_GET_SEGMENT (fragP->fr_symbol) !=3D sec)=0A= {=0A= assert (fragP->fr_subtype !=3D 1);=0A= assert (fragP->fr_cgen.insn !=3D 0);=0A= --- 1856,1864 ----=0A= /* Create a relocation for symbols that must be resolved by the linker.= =0A= Otherwise output the completed insn. */=0A= =20=20=0A= ! if (S_GET_SEGMENT (fragP->fr_symbol) !=3D sec=0A= ! || S_IS_EXTERNAL (fragP->fr_symbol)=0A= ! || S_IS_WEAK (fragP->fr_symbol))=0A= {=0A= assert (fragP->fr_subtype !=3D 1);=0A= assert (fragP->fr_cgen.insn !=3D 0);=0A= ***************=0A= *** 1874,1880 ****=0A= {=0A= if (fixP->fx_addsy !=3D (symbolS *) NULL=0A= && (! S_IS_DEFINED (fixP->fx_addsy)=0A= ! || S_GET_SEGMENT (fixP->fx_addsy) !=3D sec))=0A= {=0A= /* The symbol is undefined (or is defined but not in this section).= =0A= Let the linker figure it out. */=0A= --- 1899,1907 ----=0A= {=0A= if (fixP->fx_addsy !=3D (symbolS *) NULL=0A= && (! S_IS_DEFINED (fixP->fx_addsy)=0A= ! || S_GET_SEGMENT (fixP->fx_addsy) !=3D sec=0A= ! || S_IS_EXTERNAL (fixP->fx_addsy)=0A= ! || S_IS_WEAK (fixP->fx_addsy)))=0A= {=0A= /* The symbol is undefined (or is defined but not in this section).= =0A= Let the linker figure it out. */=0A= ***************=0A= *** 2189,2194 ****=0A= --- 2216,2238 ----=0A= else=0A= reloc_type =3D fixP->fx_r_type;=0A= =20=20=0A= + if (fixP->fx_addsy =3D=3D NULL)=0A= + return 1;=0A= +=20=0A= + /* Prevent all adjustments to global symbols. */=0A= + if (S_IS_EXTERN (fixP->fx_addsy))=0A= + return 0;=0A= + if (S_IS_WEAK (fixP->fx_addsy))=0A= + return 0;=0A= +=20=0A= + if (pic_code=0A= + && (reloc_type =3D=3D BFD_RELOC_M32R_24=0A= + || reloc_type =3D=3D BFD_RELOC_M32R_26_PCREL=0A= + || reloc_type =3D=3D BFD_RELOC_M32R_HI16_SLO=0A= + || reloc_type =3D=3D BFD_RELOC_M32R_HI16_ULO=0A= + || reloc_type =3D=3D BFD_RELOC_M32R_LO16))=0A= + return 0;=0A= +=20=0A= /* We need the symbol name for the VTABLE entries. */=0A= if (reloc_type =3D=3D BFD_RELOC_VTABLE_INHERIT=0A= || reloc_type =3D=3D BFD_RELOC_VTABLE_ENTRY)=0A= ***************=0A= *** 2203,2206 ****=0A= --- 2247,2346 ----=0A= if (use_parallel)=0A= m32r_flags |=3D E_M32R_HAS_PARALLEL;=0A= elf_elfheader (stdoutput)->e_flags |=3D m32r_flags;=0A= + }=0A= +=20=0A= + #define GOT_NAME "_GLOBAL_OFFSET_TABLE_"=0A= +=20=20=0A= + /* Translate internal representation of relocation info to BFD target=0A= + format. */=0A= + arelent *=0A= + tc_gen_reloc (section, fixP)=0A= + asection * section;=0A= + fixS * fixP;=0A= + {=0A= + arelent * reloc;=0A= + bfd_reloc_code_real_type code;=0A= +=20=20=0A= + reloc =3D (arelent *) xmalloc (sizeof (arelent));=0A= +=20=20=0A= + reloc->sym_ptr_ptr =3D (asymbol **) xmalloc (sizeof (asymbol *));=0A= + *reloc->sym_ptr_ptr =3D symbol_get_bfdsym (fixP->fx_addsy);=0A= + reloc->address =3D fixP->fx_frag->fr_address + fixP->fx_where;=0A= +=20=20=0A= + code =3D fixP->fx_r_type;=0A= + if (pic_code)=0A= + {=0A= + #ifdef DEBUG_PIC=0A= + printf("%s",bfd_get_reloc_code_name(code));=0A= + #endif=0A= + switch (code)=0A= + {=0A= + case BFD_RELOC_M32R_26_PCREL:=0A= + code =3D BFD_RELOC_M32R_26_PLTREL;=0A= + break;=0A= + case BFD_RELOC_M32R_24:=0A= + if (fixP->fx_addsy !=3D NULL=0A= + && strcmp (S_GET_NAME (fixP->fx_addsy), GOT_NAME) =3D=3D 0)= =0A= + code =3D BFD_RELOC_M32R_GOTPC24;=0A= + else=0A= + code =3D BFD_RELOC_M32R_GOT24;=0A= + break;=0A= + case BFD_RELOC_M32R_HI16_ULO:=0A= + if (fixP->fx_addsy !=3D NULL=0A= + && strcmp (S_GET_NAME (fixP->fx_addsy), GOT_NAME) =3D=3D 0)= =0A= + code =3D BFD_RELOC_M32R_GOTPC_HI_ULO;=0A= + else=0A= + code =3D BFD_RELOC_M32R_GOT16_HI_ULO;=0A= + break;=0A= + case BFD_RELOC_M32R_HI16_SLO:=0A= + if (fixP->fx_addsy !=3D NULL=0A= + && strcmp (S_GET_NAME (fixP->fx_addsy), GOT_NAME) =3D=3D 0)= =0A= + code =3D BFD_RELOC_M32R_GOTPC_HI_SLO;=0A= + else=0A= + code =3D BFD_RELOC_M32R_GOT16_HI_SLO;=0A= + break;=0A= + case BFD_RELOC_M32R_LO16:=0A= + if (fixP->fx_addsy !=3D NULL=0A= + && strcmp (S_GET_NAME (fixP->fx_addsy), GOT_NAME) =3D=3D 0)= =0A= + code =3D BFD_RELOC_M32R_GOTPC_LO;=0A= + else=0A= + code =3D BFD_RELOC_M32R_GOT16_LO;=0A= + break;=0A= + default:=0A= + break;=0A= + }=0A= + #ifdef DEBUG_PIC=0A= + printf(" =3D> %s",bfd_get_reloc_code_name(code));=0A= + #endif=0A= + }=0A= +=20=20=0A= + reloc->howto =3D bfd_reloc_type_lookup (stdoutput, code);=0A= + #ifdef DEBUG_PIC=0A= + printf(" =3D> %s\n",reloc->howto->name);=0A= + #endif=0A= + if (reloc->howto =3D=3D (reloc_howto_type *) NULL)=0A= + {=0A= + as_bad_where (fixP->fx_file, fixP->fx_line,=0A= + _("internal error: can't export reloc type %d (`%s')"),=0A= + fixP->fx_r_type, bfd_get_reloc_code_name (code));=0A= + return NULL;=0A= + }=0A= +=20=20=0A= + /* Use fx_offset for these cases */=0A= + if ( fixP->fx_r_type =3D=3D BFD_RELOC_VTABLE_ENTRY=0A= + || fixP->fx_r_type =3D=3D BFD_RELOC_VTABLE_INHERIT)=0A= + reloc->addend =3D fixP->fx_offset;=0A= + else if (!pic_code=0A= + && fixP->fx_pcrel=0A= + && fixP->fx_addsy !=3D NULL=0A= + && (S_GET_SEGMENT(fixP->fx_addsy) !=3D section)=0A= + && S_IS_DEFINED (fixP->fx_addsy)=0A= + && ! S_IS_EXTERNAL(fixP->fx_addsy)=0A= + && ! S_IS_WEAK(fixP->fx_addsy))=0A= + /* already used fx_offset in the opcode field itseld. */=0A= + reloc->addend =3D 0;=0A= + else=0A= + reloc->addend =3D fixP->fx_addnumber;=0A= +=20=20=0A= + return reloc;=0A= }=0A= Index: gas/config/tc-m32r.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gas/config/tc-m32r.h,v=0A= retrieving revision 1.10=0A= diff -c -r1.10 tc-m32r.h=0A= *** gas/config/tc-m32r.h 3 Dec 2003 17:38:45 -0000 1.10=0A= --- gas/config/tc-m32r.h 18 Dec 2003 10:04:37 -0000=0A= ***************=0A= *** 87,100 ****=0A= HI16 relocs and queue them up for later sorting. */=0A= #define md_cgen_record_fixup_exp m32r_cgen_record_fixup_exp=0A= =20=20=0A= ! #define tc_gen_reloc gas_cgen_tc_gen_reloc=0A= =20=20=0A= #define tc_frob_file_before_fix() m32r_frob_file ()=0A= extern void m32r_frob_file PARAMS ((void));=0A= =20=20=0A= /* No shared lib support, so we don't need to ensure externally=0A= ! visible symbols can be overridden. */=0A= ! #define EXTERN_FORCE_RELOC 0=0A= =20=20=0A= /* When relaxing, we need to emit various relocs we otherwise wouldn't. = */=0A= #define TC_FORCE_RELOCATION(fix) m32r_force_relocation (fix)=0A= --- 87,117 ----=0A= HI16 relocs and queue them up for later sorting. */=0A= #define md_cgen_record_fixup_exp m32r_cgen_record_fixup_exp=0A= =20=20=0A= ! /* #define tc_gen_reloc gas_cgen_tc_gen_reloc */=0A= !=20=0A= ! #define TC_HANDLES_FX_DONE=0A= !=20=0A= ! extern int pic_code;=0A= !=20=0A= ! extern bfd_boolean m32r_fix_adjustable PARAMS ((struct fix *));=0A= !=20=0A= ! /* This arranges for gas/write.c to not apply a relocation if=0A= ! obj_fix_adjustable() says it is not adjustable. */=0A= ! #define TC_FIX_ADJUSTABLE(fixP) obj_fix_adjustable (fixP)=0A= !=20=0A= ! #define TC_RELOC_RTSYM_LOC_FIXUP(FIX) \=0A= ! ((FIX)->fx_addsy =3D=3D NULL \=0A= ! || (! S_IS_EXTERNAL ((FIX)->fx_addsy) \=0A= ! && ! S_IS_WEAK ((FIX)->fx_addsy) \=0A= ! && S_IS_DEFINED ((FIX)->fx_addsy) \=0A= ! && ! S_IS_COMMON ((FIX)->fx_addsy)))=0A= =20=20=0A= #define tc_frob_file_before_fix() m32r_frob_file ()=0A= extern void m32r_frob_file PARAMS ((void));=0A= =20=20=0A= /* No shared lib support, so we don't need to ensure externally=0A= ! visible symbols can be overridden.=0A= ! #define EXTERN_FORCE_RELOC 0 */=0A= =20=20=0A= /* When relaxing, we need to emit various relocs we otherwise wouldn't. = */=0A= #define TC_FORCE_RELOCATION(fix) m32r_force_relocation (fix)=0A= Index: gdb/configure.host=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/configure.host,v=0A= retrieving revision 1.61=0A= diff -c -r1.61 configure.host=0A= *** gdb/configure.host 1 Dec 2003 21:10:46 -0000 1.61=0A= --- gdb/configure.host 18 Dec 2003 10:04:39 -0000=0A= ***************=0A= *** 22,27 ****=0A= --- 22,28 ----=0A= sh*) gdb_host_cpu=3Dsh ;;=0A= x86_64*) gdb_host_cpu=3Di386 ;;=0A= xscale*) gdb_host_cpu=3Darm ;;=0A= + m32r*) gdb_host_cpu=3Dm32r ;;=0A= *) gdb_host_cpu=3D$host_cpu ;;=0A= =20=20=0A= esac=0A= ***************=0A= *** 146,150 ****=0A= --- 147,153 ----=0A= x86_64-*-linux*) gdb_host=3Dx86-64linux ;;=0A= x86_64-*-freebsd*) gdb_host=3Dfbsd64 ;;=0A= x86_64-*-netbsd*) gdb_host=3Dnbsd64 ;;=0A= +=20=0A= + m32r*-*-linux*) gdb_host=3Dlinux ;;=0A= =20=20=0A= esac=0A= Index: include/elf/m32r.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/include/elf/m32r.h,v=0A= retrieving revision 1.6=0A= diff -c -r1.6 m32r.h=0A= *** include/elf/m32r.h 3 Dec 2003 17:38:48 -0000 1.6=0A= --- include/elf/m32r.h 18 Dec 2003 10:04:41 -0000=0A= ***************=0A= *** 25,42 ****=0A= /* Relocations. */=0A= START_RELOC_NUMBERS (elf_m32r_reloc_type)=0A= RELOC_NUMBER (R_M32R_NONE, 0)=0A= ! RELOC_NUMBER (R_M32R_16, 1)=0A= ! RELOC_NUMBER (R_M32R_32, 2)=0A= ! RELOC_NUMBER (R_M32R_24, 3)=0A= ! RELOC_NUMBER (R_M32R_10_PCREL, 4)=0A= ! RELOC_NUMBER (R_M32R_18_PCREL, 5)=0A= ! RELOC_NUMBER (R_M32R_26_PCREL, 6)=0A= ! RELOC_NUMBER (R_M32R_HI16_ULO, 7)=0A= ! RELOC_NUMBER (R_M32R_HI16_SLO, 8)=0A= ! RELOC_NUMBER (R_M32R_LO16, 9)=0A= ! RELOC_NUMBER (R_M32R_SDA16, 10)=0A= ! RELOC_NUMBER (R_M32R_GNU_VTINHERIT, 11)=0A= ! RELOC_NUMBER (R_M32R_GNU_VTENTRY, 12)=0A= END_RELOC_NUMBERS (R_M32R_max)=0A= =20=20=0A= /* Processor specific section indices. These sections do not actually=0A= --- 25,72 ----=0A= /* Relocations. */=0A= START_RELOC_NUMBERS (elf_m32r_reloc_type)=0A= RELOC_NUMBER (R_M32R_NONE, 0)=0A= ! /* REL relocations */=0A= ! RELOC_NUMBER (R_M32R_16, 1) /* For backwards compatibility. */=0A= ! RELOC_NUMBER (R_M32R_32, 2) /* For backwards compatibility. */=0A= ! RELOC_NUMBER (R_M32R_24, 3) /* For backwards compatibility. */=0A= ! RELOC_NUMBER (R_M32R_10_PCREL, 4) /* For backwards compatibility. */= =0A= ! RELOC_NUMBER (R_M32R_18_PCREL, 5) /* For backwards compatibility. */= =0A= ! RELOC_NUMBER (R_M32R_26_PCREL, 6) /* For backwards compatibility. */= =0A= ! RELOC_NUMBER (R_M32R_HI16_ULO, 7) /* For backwards compatibility. */= =0A= ! RELOC_NUMBER (R_M32R_HI16_SLO, 8) /* For backwards compatibility. */= =0A= ! RELOC_NUMBER (R_M32R_LO16, 9) /* For backwards compatibility. */=0A= ! RELOC_NUMBER (R_M32R_SDA16, 10) /* For backwards compatibility. */=0A= ! RELOC_NUMBER (R_M32R_GNU_VTINHERIT, 11)/* For backwards compatibility. = */=0A= ! RELOC_NUMBER (R_M32R_GNU_VTENTRY, 12) /* For backwards compatibility. = */=0A= !=20=0A= ! /* RELA relocations */=0A= ! RELOC_NUMBER (R_M32R_16_RELA, 33)=0A= ! RELOC_NUMBER (R_M32R_32_RELA, 34)=0A= ! RELOC_NUMBER (R_M32R_24_RELA, 35)=0A= ! RELOC_NUMBER (R_M32R_10_PCREL_RELA, 36)=0A= ! RELOC_NUMBER (R_M32R_18_PCREL_RELA, 37)=0A= ! RELOC_NUMBER (R_M32R_26_PCREL_RELA, 38)=0A= ! RELOC_NUMBER (R_M32R_HI16_ULO_RELA, 39)=0A= ! RELOC_NUMBER (R_M32R_HI16_SLO_RELA, 40)=0A= ! RELOC_NUMBER (R_M32R_LO16_RELA, 41)=0A= ! RELOC_NUMBER (R_M32R_SDA16_RELA, 42)=0A= ! RELOC_NUMBER (R_M32R_RELA_GNU_VTINHERIT, 43)=0A= ! RELOC_NUMBER (R_M32R_RELA_GNU_VTENTRY, 44)=0A= !=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=0A= ! RELOC_NUMBER (R_M32R_GOT24, 48)=0A= ! RELOC_NUMBER (R_M32R_26_PLTREL, 49)=0A= ! RELOC_NUMBER (R_M32R_COPY, 50)=0A= ! RELOC_NUMBER (R_M32R_GLOB_DAT, 51)=0A= ! RELOC_NUMBER (R_M32R_JMP_SLOT, 52)=0A= ! RELOC_NUMBER (R_M32R_RELATIVE, 53)=0A= ! RELOC_NUMBER (R_M32R_GOTOFF, 54)=0A= ! RELOC_NUMBER (R_M32R_GOTPC24, 55)=0A= ! RELOC_NUMBER (R_M32R_GOT16_HI_ULO, 56)=0A= ! RELOC_NUMBER (R_M32R_GOT16_HI_SLO, 57)=0A= ! RELOC_NUMBER (R_M32R_GOT16_LO, 58)=0A= ! RELOC_NUMBER (R_M32R_GOTPC_HI_ULO, 59)=0A= ! RELOC_NUMBER (R_M32R_GOTPC_HI_SLO, 60)=0A= ! RELOC_NUMBER (R_M32R_GOTPC_LO, 61)=0A= END_RELOC_NUMBERS (R_M32R_max)=0A= =20=20=0A= /* Processor specific section indices. These sections do not actually=0A= Index: ld/Makefile.am=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/ld/Makefile.am,v=0A= retrieving revision 1.147=0A= diff -c -r1.147 Makefile.am=0A= *** ld/Makefile.am 4 Dec 2003 12:09:25 -0000 1.147=0A= --- ld/Makefile.am 18 Dec 2003 10:04:41 -0000=0A= ***************=0A= *** 230,235 ****=0A= --- 230,238 ----=0A= ei386pe_posix.o \=0A= elnk960.o \=0A= em32relf.o \=0A= + em32rlelf.o \=0A= + em32relf_linux.o \=0A= + em32rlelf_linux.o \=0A= em68hc11elf.o \=0A= em68hc11elfb.o \=0A= em68hc12elf.o \=0A= ***************=0A= *** 603,608 ****=0A= --- 606,620 ----=0A= em32relf.c: $(srcdir)/emulparams/m32relf.sh \=0A= $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS= }=0A= ${GENSCRIPTS} m32relf "$(tdir_m32r)"=0A= + em32rlelf.c: $(srcdir)/emulparams/m32rlelf.sh \=0A= + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS= }=0A= + ${GENSCRIPTS} m32rlelf "$(tdir_m32rlelf)"=0A= + em32relf_linux.c: $(srcdir)/emulparams/m32relf_linux.sh \=0A= + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS= }=0A= + ${GENSCRIPTS} m32relf_linux "$(tdir_m32relf_linux)"=0A= + em32rlelf_linux.c: $(srcdir)/emulparams/m32rlelf_linux.sh \=0A= + $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS= }=0A= + ${GENSCRIPTS} m32rlelf_linux "$(tdir_m32rlelf_linux)"=0A= eelf32_sparc.c: $(srcdir)/emulparams/elf32_sparc.sh \=0A= $(srcdir)/emultempl/elf32.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS= }=0A= ${GENSCRIPTS} elf32_sparc "$(tdir_elf32_sparc)"=0A= Index: ld/configure.tgt=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/ld/configure.tgt,v=0A= retrieving revision 1.141=0A= diff -c -r1.141 configure.tgt=0A= *** ld/configure.tgt 3 Dec 2003 15:07:17 -0000 1.141=0A= --- ld/configure.tgt 18 Dec 2003 10:04:41 -0000=0A= ***************=0A= *** 115,121 ****=0A= ia64-*-netbsd*) targ_emul=3Delf64_ia64 ;;=0A= ia64-*-linux*) targ_emul=3Delf64_ia64 ;;=0A= ia64-*-aix*) targ_emul=3Delf64_aix ;;=0A= ! m32r-*-*) targ_emul=3Dm32relf ;;=0A= m68hc11-*-*|m6811-*-*) targ_emul=3Dm68hc11elf=20=0A= targ_extra_emuls=3D"m68hc11elfb m68hc12elf m68hc12elfb" ;;=0A= m68hc12-*-*|m6812-*-*) targ_emul=3Dm68hc12elf=20=0A= --- 115,124 ----=0A= ia64-*-netbsd*) targ_emul=3Delf64_ia64 ;;=0A= ia64-*-linux*) targ_emul=3Delf64_ia64 ;;=0A= ia64-*-aix*) targ_emul=3Delf64_aix ;;=0A= ! m32r*le-*-elf*) targ_emul=3Dm32rlelf ;;=0A= ! m32r*-*-elf*) targ_emul=3Dm32relf ;;=0A= ! m32r*le-*-linux-gnu*) targ_emul=3Dm32rlelf_linux ;;=0A= ! m32r*-*-linux-gnu*) targ_emul=3Dm32relf_linux ;;=0A= m68hc11-*-*|m6811-*-*) targ_emul=3Dm68hc11elf=20=0A= targ_extra_emuls=3D"m68hc11elfb m68hc12elf m68hc12elfb" ;;=0A= m68hc12-*-*|m6812-*-*) targ_emul=3Dm68hc12elf=20=0A= Index: sim/common/sim-core.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/sim/common/sim-core.c,v=0A= retrieving revision 1.3=0A= diff -c -r1.3 sim-core.c=0A= *** sim/common/sim-core.c 23 Nov 2002 01:12:05 -0000 1.3=0A= --- sim/common/sim-core.c 18 Dec 2003 10:04:47 -0000=0A= ***************=0A= *** 801,806 ****=0A= --- 801,825 ----=0A= }=0A= #endif=0A= =20=20=0A= + #if EXTERN_SIM_CORE_P=0A= + void *=0A= + sim_core_trans_addr (SIM_DESC sd,=0A= + sim_cpu *cpu,=0A= + unsigned map,=0A= + address_word addr)=0A= + {=0A= + sim_core_common *core =3D (cpu =3D=3D NULL ? &STATE_CORE (sd)->common := &CPU_CORE (cpu)->common);=0A= + sim_core_mapping *mapping =3D=0A= + sim_core_find_mapping (core, map,=0A= + addr, /*nr-bytes*/1,=0A= + write_transfer,=0A= + 0 /*dont-abort*/, NULL, NULL_CIA);=0A= + if (mapping =3D=3D NULL)=0A= + return NULL;=0A= + return sim_core_translate(mapping, addr);=0A= + }=0A= + #endif=0A= +=20=0A= =20=20=0A= =20=20=0A= /* define the read/write 1/2/4/8/16/word functions */=0A= Index: sim/m32r/Makefile.in=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/sim/m32r/Makefile.in,v=0A= retrieving revision 1.9=0A= diff -c -r1.9 Makefile.in=0A= *** sim/m32r/Makefile.in 11 Dec 2003 11:33:44 -0000 1.9=0A= --- sim/m32r/Makefile.in 18 Dec 2003 10:04:47 -0000=0A= ***************=0A= *** 23,28 ****=0A= --- 23,29 ----=0A= M32R_OBJS =3D m32r.o cpu.o decode.o sem.o model.o mloop.o=0A= M32RX_OBJS =3D m32rx.o cpux.o decodex.o modelx.o mloopx.o=0A= M32R2_OBJS =3D m32r2.o cpu2.o decode2.o model2.o mloop2.o=0A= + TRAPS_OBJ =3D @traps_obj@=0A= =20=20=0A= CONFIG_DEVICES =3D dv-sockser.o=0A= CONFIG_DEVICES =3D=0A= ***************=0A= *** 40,46 ****=0A= $(M32R_OBJS) \=0A= $(M32RX_OBJS) \=0A= $(M32R2_OBJS) \=0A= ! traps.o devices.o \=0A= $(CONFIG_DEVICES)=0A= =20=20=0A= # Extra headers included by sim-main.h.=0A= --- 41,48 ----=0A= $(M32R_OBJS) \=0A= $(M32RX_OBJS) \=0A= $(M32R2_OBJS) \=0A= ! $(TRAPS_OBJ) \=0A= ! devices.o \=0A= $(CONFIG_DEVICES)=0A= =20=20=0A= # Extra headers included by sim-main.h.=0A= ***************=0A= *** 48,54 ****=0A= $(CGEN_INCLUDE_DEPS) \=0A= arch.h cpuall.h m32r-sim.h $(srcdir)/../../opcodes/m32r-desc.h=0A= =20=20=0A= ! SIM_EXTRA_CFLAGS =3D=0A= =20=20=0A= SIM_RUN_OBJS =3D nrun.o=0A= SIM_EXTRA_CLEAN =3D m32r-clean=0A= --- 50,56 ----=0A= $(CGEN_INCLUDE_DEPS) \=0A= arch.h cpuall.h m32r-sim.h $(srcdir)/../../opcodes/m32r-desc.h=0A= =20=20=0A= ! SIM_EXTRA_CFLAGS =3D @sim_extra_cflags@=0A= =20=20=0A= SIM_RUN_OBJS =3D nrun.o=0A= SIM_EXTRA_CLEAN =3D m32r-clean=0A= ***************=0A= *** 65,70 ****=0A= --- 67,73 ----=0A= arch.o: arch.c $(SIM_MAIN_DEPS)=0A= =20=20=0A= traps.o: traps.c targ-vals.h $(SIM_MAIN_DEPS)=0A= + traps-linux.o: traps.c syscall.h targ-vals.h $(SIM_MAIN_DEPS)=0A= devices.o: devices.c $(SIM_MAIN_DEPS)=0A= =20=20=0A= # M32R objs=0A= Index: sim/m32r/configure.in=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/sim/m32r/configure.in,v=0A= retrieving revision 1.1.1.1=0A= diff -c -r1.1.1.1 configure.in=0A= *** sim/m32r/configure.in 16 Apr 1999 01:35:05 -0000 1.1.1.1=0A= --- sim/m32r/configure.in 18 Dec 2003 10:04:47 -0000=0A= ***************=0A= *** 14,17 ****=0A= --- 14,31 ----=0A= SIM_AC_OPTION_INLINE()=0A= SIM_AC_OPTION_CGEN_MAINT=0A= =20=20=0A= + case "${target_alias}" in=0A= + m32r*-linux*)=0A= + traps_obj=3Dtraps-linux.o=0A= + sim_extra_cflags=3D"-DM32R_LINUX"=0A= + ;;=0A= + *)=0A= + traps_obj=3Dtraps.o=0A= + sim_extra_cflags=3D"-DM32R_ELF"=0A= + ;;=0A= + esac=0A= + AC_SUBST(traps_obj)=0A= + AC_SUBST(sim_extra_cflags)=0A= +=20=0A= +=20=0A= SIM_AC_OUTPUT=0A= Index: sim/m32r/sim-if.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/sim/m32r/sim-if.c,v=0A= retrieving revision 1.6=0A= diff -c -r1.6 sim-if.c=0A= *** sim/m32r/sim-if.c 11 Dec 2003 11:33:44 -0000 1.6=0A= --- sim/m32r/sim-if.c 18 Dec 2003 10:04:47 -0000=0A= ***************=0A= *** 214,219 ****=0A= --- 214,226 ----=0A= addr =3D 0;=0A= sim_pc_set (current_cpu, addr);=0A= =20=20=0A= + #ifdef M32R_LINUX=0A= + m32rbf_h_cr_set (current_cpu,=0A= + m32r_decode_gdb_ctrl_regnum(SPI_REGNUM), 0x1f00000);= =0A= + m32rbf_h_cr_set (current_cpu,=0A= + m32r_decode_gdb_ctrl_regnum(SPU_REGNUM), 0x1f00000);= =0A= + #endif=0A= +=20=0A= #if 0=0A= STATE_ARGV (sd) =3D sim_copy_argv (argv);=0A= STATE_ENVP (sd) =3D sim_copy_argv (envp);=0A= Index: sim/m32r/sim-main.h=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/sim/m32r/sim-main.h,v=0A= retrieving revision 1.5=0A= diff -c -r1.5 sim-main.h=0A= *** sim/m32r/sim-main.h 11 Dec 2003 11:33:44 -0000 1.5=0A= --- sim/m32r/sim-main.h 18 Dec 2003 10:04:47 -0000=0A= ***************=0A= *** 85,90 ****=0A= --- 85,94 ----=0A= (TRANSFER), (ERROR))=0A= =20=20=0A= /* Default memory size. */=0A= + #ifdef M32R_LINUX=0A= + #define M32R_DEFAULT_MEM_SIZE 0x2000000 /* 32M */=0A= + #else=0A= #define M32R_DEFAULT_MEM_SIZE 0x800000 /* 8M */=0A= + #endif=0A= =20=20=0A= #endif /* SIM_MAIN_H */=0A= --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: application/octet-stream; name=m32rlelf.sh Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=m32rlelf.sh Content-length: 72 . ${srcdir}/emulparms/m32relf.sh=0A= OUTPUT_FORMAT=3D"elf32-m32rle"=0A= --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: application/octet-stream; name=m32relf_linux.sh Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=m32relf_linux.sh Content-length: 400 MACHINE=3D=0A= SCRIPT_NAME=3Delf=0A= TEMPLATE_NAME=3Delf32=0A= OUTPUT_FORMAT=3D"elf32-m32r-linux"=0A= TEXT_START_ADDR=3D0x1000=0A= ARCH=3Dm32r=0A= MACHINE=3D=0A= MAXPAGESIZE=3D0x1000=0A= =0A= # Hmmm, there's got to be a better way. This sets the stack to the=0A= # top of simulator memory (32MB).=0A= OTHER_RELOCATING_SECTIONS=3D'PROVIDE (_stack =3D 0x2000000);'=0A= GENERATE_SHLIB_SCRIPT=3Dyes=0A= --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: application/octet-stream; name=m32rlelf_linux.sh Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=m32rlelf_linux.sh Content-length: 85 . ${srcdir}/emulparams/m32relf_linux.sh=0A= OUTPUT_FORMAT=3D"elf32-m32rle-linux"=0A= --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: application/octet-stream; name=traps-linux.c Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=traps-linux.c Content-length: 47144 /* m32r exception, interrupt, and trap (EIT) support=0A= Copyright (C) 1998 Free Software Foundation, Inc.=0A= Contributed by Cygnus Solutions.=0A= =0A= This file is part of GDB, the GNU debugger.=0A= =0A= This program is free software; you can redistribute it and/or modify=0A= it under the terms of the GNU General Public License as published by=0A= the Free Software Foundation; either version 2, or (at your option)=0A= any later version.=0A= =0A= This program is distributed in the hope that it will be useful,=0A= but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= GNU General Public License for more details.=0A= =0A= You should have received a copy of the GNU General Public License along=0A= with this program; if not, write to the Free Software Foundation, Inc.,=0A= 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */=0A= =0A= #include "sim-main.h"=0A= #include "syscall.h"=0A= #include "targ-vals.h"=0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= #include =0A= =0A= #define TRAP_ELF_SYSCALL 0=0A= #define TRAP_LINUX_SYSCALL 2=0A= #define TRAP_FLUSH_CACHE 12=0A= =0A= /* The semantic code invokes this for invalid (unrecognized) instructions. = */=0A= =0A= SEM_PC=0A= sim_engine_invalid_insn (SIM_CPU *current_cpu, IADDR cia, SEM_PC vpc)=0A= {=0A= SIM_DESC sd =3D CPU_STATE (current_cpu);=0A= =0A= #if 0=0A= if (STATE_ENVIRONMENT (sd) =3D=3D OPERATING_ENVIRONMENT)=0A= {=0A= h_bsm_set (current_cpu, h_sm_get (current_cpu));=0A= h_bie_set (current_cpu, h_ie_get (current_cpu));=0A= h_bcond_set (current_cpu, h_cond_get (current_cpu));=0A= /* sm not changed */=0A= h_ie_set (current_cpu, 0);=0A= h_cond_set (current_cpu, 0);=0A= =0A= h_bpc_set (current_cpu, cia);=0A= =0A= sim_engine_restart (CPU_STATE (current_cpu), current_cpu, NULL,=0A= EIT_RSVD_INSN_ADDR);=0A= }=0A= else=0A= #endif=0A= sim_engine_halt (sd, current_cpu, NULL, cia, sim_stopped, SIM_SIGILL);= =0A= return vpc;=0A= }=0A= =0A= /* Process an address exception. */=0A= =0A= void=0A= m32r_core_signal (SIM_DESC sd, SIM_CPU *current_cpu, sim_cia cia,=0A= unsigned int map, int nr_bytes, address_word addr,=0A= transfer_type transfer, sim_core_signals sig)=0A= {=0A= if (STATE_ENVIRONMENT (sd) =3D=3D OPERATING_ENVIRONMENT)=0A= {=0A= m32rbf_h_cr_set (current_cpu, H_CR_BBPC,=0A= m32rbf_h_cr_get (current_cpu, H_CR_BPC));=0A= if (MACH_NUM (CPU_MACH (current_cpu)) =3D=3D MACH_M32R)=0A= {=0A= m32rbf_h_bpsw_set (current_cpu, m32rbf_h_psw_get (current_cpu));= =0A= /* sm not changed */=0A= m32rbf_h_psw_set (current_cpu, m32rbf_h_psw_get (current_cpu) & 0= x80);=0A= }=0A= else if (MACH_NUM (CPU_MACH (current_cpu)) =3D=3D MACH_M32RX)=0A= {=0A= m32rxf_h_bpsw_set (current_cpu, m32rxf_h_psw_get (current_cpu));= =0A= /* sm not changed */=0A= m32rxf_h_psw_set (current_cpu, m32rxf_h_psw_get (current_cpu) & 0= x80);=0A= }=0A= else=0A= {=0A= m32r2f_h_bpsw_set (current_cpu, m32r2f_h_psw_get (current_cpu));= =0A= /* sm not changed */=0A= m32r2f_h_psw_set (current_cpu, m32r2f_h_psw_get (current_cpu) & 0= x80);=0A= }=0A= m32rbf_h_cr_set (current_cpu, H_CR_BPC, cia);=0A= =0A= sim_engine_restart (CPU_STATE (current_cpu), current_cpu, NULL,=0A= EIT_ADDR_EXCP_ADDR);=0A= }=0A= else=0A= sim_core_signal (sd, current_cpu, cia, map, nr_bytes, addr,=0A= transfer, sig);=0A= }=0A= =0C=0A= /* Read/write functions for system call interface. */=0A= =0A= static int=0A= syscall_read_mem (host_callback *cb, struct cb_syscall *sc,=0A= unsigned long taddr, char *buf, int bytes)=0A= {=0A= SIM_DESC sd =3D (SIM_DESC) sc->p1;=0A= SIM_CPU *cpu =3D (SIM_CPU *) sc->p2;=0A= =0A= return sim_core_read_buffer (sd, cpu, read_map, buf, taddr, bytes);=0A= }=0A= =0A= static int=0A= syscall_write_mem (host_callback *cb, struct cb_syscall *sc,=0A= unsigned long taddr, const char *buf, int bytes)=0A= {=0A= SIM_DESC sd =3D (SIM_DESC) sc->p1;=0A= SIM_CPU *cpu =3D (SIM_CPU *) sc->p2;=0A= =0A= return sim_core_write_buffer (sd, cpu, write_map, buf, taddr, bytes);=0A= }=0A= =0A= /* Translate target's address to host's address. */=0A= =0A= static void *=0A= t2h_addr (host_callback *cb, struct cb_syscall *sc,=0A= unsigned long taddr)=0A= {=0A= extern sim_core_trans_addr (SIM_DESC, sim_cpu *, unsigned, address_word);= =0A= void *addr;=0A= SIM_DESC sd =3D (SIM_DESC) sc->p1;=0A= SIM_CPU *cpu =3D (SIM_CPU *) sc->p2;=0A= =0A= if (taddr =3D=3D 0)=0A= return NULL;=0A= =0A= return sim_core_trans_addr (sd, cpu, read_map, taddr);=0A= }=0A= =0A= static unsigned int=0A= conv_endian (unsigned int tvalue)=0A= {=0A= unsigned int hvalue;=0A= unsigned int t1, t2, t3, t4;=0A= =0A= if (CURRENT_HOST_BYTE_ORDER =3D=3D LITTLE_ENDIAN)=0A= {=0A= t1 =3D tvalue & 0xff000000;=0A= t2 =3D tvalue & 0x00ff0000;=0A= t3 =3D tvalue & 0x0000ff00;=0A= t4 =3D tvalue & 0x000000ff;=0A= =0A= hvalue =3D t1 >> 24;=0A= hvalue +=3D t2 >> 8;=0A= hvalue +=3D t3 << 8;=0A= hvalue +=3D t4 << 24;=0A= }=0A= else=0A= hvalue =3D tvalue;=0A= =0A= return hvalue;=0A= }=0A= =0A= static unsigned short=0A= conv_endian16 (unsigned short tvalue)=0A= {=0A= unsigned short hvalue;=0A= unsigned short t1, t2;=0A= =0A= if (CURRENT_HOST_BYTE_ORDER =3D=3D LITTLE_ENDIAN)=0A= {=0A= t1 =3D tvalue & 0xff00;=0A= t2 =3D tvalue & 0x00ff;=0A= =0A= hvalue =3D t1 >> 8;=0A= hvalue +=3D t2 << 8;=0A= }=0A= else=0A= hvalue =3D tvalue;=0A= =0A= return hvalue;=0A= }=0A= =0A= static void=0A= translate_endian(void *addr, size_t size)=0A= {=0A= unsigned int *p =3D (unsigned int *) addr;=0A= int i;=0A= =20=20=0A= for (i =3D 0; i <=3D size - 4; i +=3D 4,p++)=0A= *p =3D conv_endian(*p);=0A= =20=20=0A= if (i <=3D size - 2)=0A= *((unsigned short *) p) =3D conv_endian16(*((unsigned short *) p));=0A= }=0A= =0A= /* Trap support.=0A= The result is the pc address to continue at.=0A= Preprocessing like saving the various registers has already been done. = */=0A= =0A= USI=0A= m32r_trap (SIM_CPU *current_cpu, PCADDR pc, int num)=0A= {=0A= SIM_DESC sd =3D CPU_STATE (current_cpu);=0A= host_callback *cb =3D STATE_CALLBACK (sd);=0A= =0A= #ifdef SIM_HAVE_BREAKPOINTS=0A= /* Check for breakpoints "owned" by the simulator first, regardless=0A= of --environment. */=0A= if (num =3D=3D TRAP_BREAKPOINT)=0A= {=0A= /* First try sim-break.c. If it's a breakpoint the simulator "owns"= =0A= it doesn't return. Otherwise it returns and let's us try. */=0A= sim_handle_breakpoint (sd, current_cpu, pc);=0A= /* Fall through. */=0A= }=0A= #endif=0A= =0A= switch (num)=0A= {=0A= case TRAP_ELF_SYSCALL :=0A= {=0A= CB_SYSCALL s;=0A= =20=0A= CB_SYSCALL_INIT (&s);=0A= s.func =3D m32rbf_h_gr_get (current_cpu, 0);=0A= s.arg1 =3D m32rbf_h_gr_get (current_cpu, 1);=0A= s.arg2 =3D m32rbf_h_gr_get (current_cpu, 2);=0A= s.arg3 =3D m32rbf_h_gr_get (current_cpu, 3);=0A= =20=0A= if (s.func =3D=3D TARGET_SYS_exit)=0A= {=0A= sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, s.arg1)= ;=0A= }=0A= =20=0A= s.p1 =3D (PTR) sd;=0A= s.p2 =3D (PTR) current_cpu;=0A= s.read_mem =3D syscall_read_mem;=0A= s.write_mem =3D syscall_write_mem;=0A= cb_syscall (cb, &s);=0A= m32rbf_h_gr_set (current_cpu, 2, s.errcode);=0A= m32rbf_h_gr_set (current_cpu, 0, s.result);=0A= m32rbf_h_gr_set (current_cpu, 1, s.result2);=0A= break;=0A= }=0A= =0A= case TRAP_LINUX_SYSCALL :=0A= {=0A= CB_SYSCALL s;=0A= unsigned int func, arg1, arg2, arg3, arg4, arg5, arg6, arg7;=0A= int result, result2, errcode;=0A= =0A= if (STATE_ENVIRONMENT (sd) =3D=3D OPERATING_ENVIRONMENT)=0A= {=0A= /* The new pc is the trap vector entry.=0A= We assume there's a branch there to some handler.=0A= Use cr5 as EVB (EIT Vector Base) register. */=0A= USI new_pc =3D m32rbf_h_cr_get (current_cpu, 5) + 0x40 + num * = 4;=0A= return new_pc;=0A= }=0A= =0A= func =3D m32rbf_h_gr_get (current_cpu, 7);=0A= arg1 =3D m32rbf_h_gr_get (current_cpu, 0);=0A= arg2 =3D m32rbf_h_gr_get (current_cpu, 1);=0A= arg3 =3D m32rbf_h_gr_get (current_cpu, 2);=0A= arg4 =3D m32rbf_h_gr_get (current_cpu, 3);=0A= arg5 =3D m32rbf_h_gr_get (current_cpu, 4);=0A= arg6 =3D m32rbf_h_gr_get (current_cpu, 5);=0A= arg7 =3D m32rbf_h_gr_get (current_cpu, 6);=0A= =0A= CB_SYSCALL_INIT (&s);=0A= s.func =3D func;=0A= s.arg1 =3D arg1;=0A= s.arg2 =3D arg2;=0A= s.arg3 =3D arg3;=0A= =0A= s.p1 =3D (PTR) sd;=0A= s.p2 =3D (PTR) current_cpu;=0A= s.read_mem =3D syscall_read_mem;=0A= s.write_mem =3D syscall_write_mem;=0A= =0A= result =3D 0;=0A= result2 =3D 0;=0A= errcode =3D 0;=0A= =0A= switch (func)=0A= {=0A= case __NR_exit:=0A= sim_engine_halt (sd, current_cpu, NULL, pc, sim_exited, arg1);=0A= break;=0A= =0A= case __NR_read:=0A= result =3D read(arg1, t2h_addr(cb, &s, arg2), arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_write:=0A= result =3D write(arg1, t2h_addr(cb, &s, arg2), arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_open:=0A= result =3D open((char *) t2h_addr(cb, &s, arg1), arg2, arg3);= =0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_close:=0A= result =3D close(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_creat:=0A= result =3D creat((char *) t2h_addr(cb, &s, arg1), arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_link:=0A= result =3D link((char *) t2h_addr(cb, &s, arg1),=0A= (char *) t2h_addr(cb, &s, arg2));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_unlink:=0A= result =3D unlink((char *) t2h_addr(cb, &s, arg1));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_chdir:=0A= result =3D chdir((char *) t2h_addr(cb, &s, arg1));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_time:=0A= {=0A= time_t t;=0A= =0A= if (arg1 =3D=3D 0)=0A= {=0A= result =3D (int) time(NULL);=0A= errcode =3D errno;=0A= }=0A= else=0A= {=0A= result =3D (int) time(&t);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &t, sizeof(t));=0A= if ((s.write_mem) (cb, &s, arg1, (char *) &t, sizeof(t)) = !=3D sizeof(t))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= }=0A= break;=0A= =0A= case __NR_mknod:=0A= result =3D mknod((char *) t2h_addr(cb, &s, arg1),=0A= (mode_t) arg2, (dev_t) arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_chmod:=0A= result =3D chmod((char *) t2h_addr(cb, &s, arg1), (mode_t) arg2= );=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_lchown:=0A= result =3D lchown((char *) t2h_addr(cb, &s, arg1),=0A= (uid_t) arg2, (gid_t) arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_lseek:=0A= result =3D (int) lseek(arg1, (off_t) arg2, arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getpid:=0A= result =3D getpid();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getuid:=0A= result =3D getuid();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_utime:=0A= {=0A= struct utimbuf buf;=0A= =0A= if (arg2 =3D=3D 0)=0A= {=0A= result =3D utime((char *) t2h_addr(cb, &s, arg1), NULL);= =0A= errcode =3D errno;=0A= }=0A= else=0A= {=0A= buf =3D *((struct utimbuf *) t2h_addr(cb, &s, arg2));=0A= translate_endian((void *) &buf, sizeof(buf));=0A= result =3D utime((char *) t2h_addr(cb, &s, arg1), &buf);= =0A= errcode =3D errno;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_access:=0A= result =3D access((char *) t2h_addr(cb, &s, arg1), arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_ftime:=0A= {=0A= struct timeb t;=0A= =0A= result =3D ftime(&t);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= t.time =3D conv_endian(t.time);=0A= t.millitm =3D conv_endian16(t.millitm);=0A= t.timezone =3D conv_endian16(t.timezone);=0A= t.dstflag =3D conv_endian16(t.dstflag);=0A= if ((s.write_mem) (cb, &s, arg1, (char *) &t, sizeof(t))=0A= !=3D sizeof(t))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= =0A= case __NR_sync:=0A= sync();=0A= result =3D 0;=0A= break;=0A= =0A= case __NR_rename:=0A= result =3D rename((char *) t2h_addr(cb, &s, arg1),=0A= (char *) t2h_addr(cb, &s, arg2));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_mkdir:=0A= result =3D mkdir((char *) t2h_addr(cb, &s, arg1), arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_rmdir:=0A= result =3D rmdir((char *) t2h_addr(cb, &s, arg1));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_dup:=0A= result =3D dup(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_brk:=0A= result =3D brk((void *) arg1);=0A= errcode =3D errno;=0A= //result =3D arg1;=0A= break;=0A= =0A= case __NR_getgid:=0A= result =3D getgid();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_geteuid:=0A= result =3D geteuid();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getegid:=0A= result =3D getegid();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_ioctl:=0A= result =3D ioctl(arg1, arg2, arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_fcntl:=0A= result =3D fcntl(arg1, arg2, arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_ustat:=0A= {=0A= struct ustat ubuf;=0A= =0A= result =3D ustat(arg1, &ubuf);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= ubuf.f_tfree =3D conv_endian(ubuf.f_tfree);=0A= ubuf.f_tinode =3D conv_endian(ubuf.f_tinode);=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &ubuf, sizeof(ubuf)= )=0A= !=3D sizeof(ubuf))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_dup2:=0A= result =3D dup2(arg1, arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getppid:=0A= result =3D getppid();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getpgrp:=0A= result =3D getpgrp();=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getrlimit:=0A= {=0A= struct rlimit rlim;=0A= =0A= result =3D getrlimit(arg1, &rlim);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &rlim, sizeof(rlim));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &rlim, sizeof(rlim)= )=0A= !=3D sizeof(rlim))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_getrusage:=0A= {=0A= struct rusage usage;=0A= =0A= result =3D getrusage(arg1, &usage);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &usage, sizeof(usage));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &usage, sizeof(usag= e))=0A= !=3D sizeof(usage))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_gettimeofday:=0A= {=0A= struct timeval tv;=0A= struct timezone tz;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= result =3D gettimeofday(&tv, &tz);=0A= errcode =3D errno;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &tv, sizeof(tv));=0A= if ((s.write_mem) (cb, &s, arg1, (char *) &tv, sizeof(tv))=0A= !=3D sizeof(tv))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= =0A= translate_endian((void *) &tz, sizeof(tz));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &tz, sizeof(tz))=0A= !=3D sizeof(tz))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_getgroups:=0A= {=0A= gid_t *list;=0A= =0A= if (arg1 > 0)=0A= list =3D (gid_t *) malloc(arg1 * sizeof(gid_t));=0A= =0A= result =3D getgroups(arg1, list);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) list, arg1 * sizeof(gid_t));=0A= if (arg1 > 0)=0A= if ((s.write_mem) (cb, &s, arg2, (char *) list, arg1 * size= of(gid_t))=0A= !=3D arg1 * sizeof(gid_t))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_select:=0A= {=0A= int n;=0A= fd_set readfds;=0A= fd_set *treadfdsp;=0A= fd_set *hreadfdsp;=0A= fd_set writefds;=0A= fd_set *twritefdsp;=0A= fd_set *hwritefdsp;=0A= fd_set exceptfds;=0A= fd_set *texceptfdsp;=0A= fd_set *hexceptfdsp;=0A= struct timeval *ttimeoutp;=0A= struct timeval timeout;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= n =3D arg1;=0A= =0A= treadfdsp =3D (fd_set *) arg2;=0A= if (treadfdsp !=3D NULL)=0A= {=0A= readfds =3D *((fd_set *) t2h_addr(cb, &s, (unsigned int) = treadfdsp));=0A= translate_endian((void *) &readfds, sizeof(readfds));=0A= hreadfdsp =3D &readfds;=0A= }=0A= else=0A= hreadfdsp =3D NULL;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= twritefdsp =3D (fd_set *) arg3;=0A= if (twritefdsp !=3D NULL)=0A= {=0A= writefds =3D *((fd_set *) t2h_addr(cb, &s, (unsigned int)= twritefdsp));=0A= translate_endian((void *) &writefds, sizeof(writefds));= =0A= hwritefdsp =3D &writefds;=0A= }=0A= else=0A= hwritefdsp =3D NULL;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= texceptfdsp =3D (fd_set *) arg4;=0A= if (texceptfdsp !=3D NULL)=0A= {=0A= exceptfds =3D *((fd_set *) t2h_addr(cb, &s, (unsigned int= ) texceptfdsp));=0A= translate_endian((void *) &exceptfds, sizeof(exceptfds));= =0A= hexceptfdsp =3D &exceptfds;=0A= }=0A= else=0A= hexceptfdsp =3D NULL;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= ttimeoutp =3D (struct timeval *) arg5;=0A= timeout =3D *((struct timeval *) t2h_addr(cb, &s, (unsigned i= nt) ttimeoutp));=0A= translate_endian((void *) &timeout, sizeof(timeout));=0A= =0A= result =3D select(n, hreadfdsp, hwritefdsp, hexceptfdsp, &tim= eout);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= if (treadfdsp !=3D NULL)=0A= {=0A= translate_endian((void *) &readfds, sizeof(readfds));=0A= if ((s.write_mem) (cb, &s, (unsigned long) treadfdsp,=0A= (char *) &readfds, sizeof(readfds)) !=3D sizeof(read= fds))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= =0A= if (twritefdsp !=3D NULL)=0A= {=0A= translate_endian((void *) &writefds, sizeof(writefds));= =0A= if ((s.write_mem) (cb, &s, (unsigned long) twritefdsp,=0A= (char *) &writefds, sizeof(writefds)) !=3D sizeof(wr= itefds))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= =0A= if (texceptfdsp !=3D NULL)=0A= {=0A= translate_endian((void *) &exceptfds, sizeof(exceptfds));= =0A= if ((s.write_mem) (cb, &s, (unsigned long) texceptfdsp,= =0A= (char *) &exceptfds, sizeof(exceptfds)) !=3D sizeof(= exceptfds))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= =0A= translate_endian((void *) &timeout, sizeof(timeout));=0A= if ((s.write_mem) (cb, &s, (unsigned long) ttimeoutp,=0A= (char *) &timeout, sizeof(timeout)) !=3D sizeof(timeout)= )=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_symlink:=0A= result =3D symlink((char *) t2h_addr(cb, &s, arg1),=0A= (char *) t2h_addr(cb, &s, arg2));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_readlink:=0A= result =3D readlink((char *) t2h_addr(cb, &s, arg1),=0A= (char *) t2h_addr(cb, &s, arg2),=0A= arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_readdir:=0A= result =3D (int) readdir((DIR *) t2h_addr(cb, &s, arg1));=0A= errcode =3D errno;=0A= break;=0A= =0A= #if 0=0A= case __NR_mmap:=0A= {=0A= result =3D (int) mmap((void *) t2h_addr(cb, &s, arg1),=0A= arg2, arg3, arg4, arg5, arg6);=0A= errcode =3D errno;=0A= =0A= if (errno =3D=3D 0)=0A= {=0A= sim_core_attach (sd, NULL,=0A= 0, access_read_write_exec, 0,=0A= result, arg2, 0, NULL, NULL);=0A= }=0A= }=0A= break;=0A= #endif=0A= case __NR_mmap:=0A= {=0A= void *addr;=0A= size_t len;=0A= int prot, flags, fildes;=0A= off_t off;=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=0A= addr =3D *((void **) t2h_addr(cb, &s, arg1));=0A= len =3D *((size_t *) t2h_addr(cb, &s, arg1 + 4));=0A= prot =3D *((int *) t2h_addr(cb, &s, arg1 + 8));=0A= flags =3D *((int *) t2h_addr(cb, &s, arg1 + 12));=0A= fildes =3D *((int *) t2h_addr(cb, &s, arg1 + 16));=0A= off =3D *((off_t *) t2h_addr(cb, &s, arg1 + 20));=0A= =0A= addr =3D (void *) conv_endian((unsigned int) addr);=0A= len =3D conv_endian(len);=0A= prot =3D conv_endian(prot);=0A= flags =3D conv_endian(flags);=0A= fildes =3D conv_endian(fildes);=0A= off =3D conv_endian(off);=0A= =0A= //addr =3D (void *) t2h_addr(cb, &s, (unsigned int) addr);= =0A= result =3D (int) mmap(addr, len, prot, flags, fildes, off);= =0A= errcode =3D errno;=0A= =0A= //if (errno =3D=3D 0)=0A= if (result !=3D -1)=0A= {=0A= char c;=0A= if (sim_core_read_buffer (sd, NULL, read_map, &c, result, 1) =3D=3D 0)= =0A= sim_core_attach (sd, NULL,=0A= 0, access_read_write_exec, 0,=0A= result, len, 0, NULL, NULL);=0A= }=0A= }=0A= break;=0A= =0A= case __NR_munmap:=0A= {=0A= result =3D munmap((void *)arg1, arg2);=0A= errcode =3D errno;=0A= if (result !=3D -1)=0A= {=0A= sim_core_detach (sd, NULL, 0, arg2, result);=0A= }=0A= }=0A= break;=0A= =0A= case __NR_truncate:=0A= result =3D truncate((char *) t2h_addr(cb, &s, arg1), arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_ftruncate:=0A= result =3D ftruncate(arg1, arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_fchmod:=0A= result =3D fchmod(arg1, arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_fchown:=0A= result =3D fchown(arg1, arg2, arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_statfs:=0A= {=0A= struct statfs statbuf;=0A= =0A= result =3D statfs((char *) t2h_addr(cb, &s, arg1), &statbuf);= =0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &statbuf, sizeof(statbuf));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &statbuf, sizeof(st= atbuf))=0A= !=3D sizeof(statbuf))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_fstatfs:=0A= {=0A= struct statfs statbuf;=0A= =0A= result =3D fstatfs(arg1, &statbuf);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &statbuf, sizeof(statbuf));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &statbuf, sizeof(st= atbuf))=0A= !=3D sizeof(statbuf))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_syslog:=0A= result =3D syslog(arg1, (char *) t2h_addr(cb, &s, arg2));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_setitimer:=0A= {=0A= struct itimerval value, ovalue;=0A= =0A= value =3D *((struct itimerval *) t2h_addr(cb, &s, arg2));=0A= translate_endian((void *) &value, sizeof(value));=0A= =0A= if (arg2 =3D=3D 0)=0A= {=0A= result =3D setitimer(arg1, &value, NULL);=0A= errcode =3D errno;=0A= }=0A= else=0A= {=0A= result =3D setitimer(arg1, &value, &ovalue);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &ovalue, sizeof(ovalue));=0A= if ((s.write_mem) (cb, &s, arg3, (char *) &ovalue, sizeof= (ovalue))=0A= !=3D sizeof(ovalue))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= }=0A= break;=0A= =0A= case __NR_getitimer:=0A= {=0A= struct itimerval value;=0A= =0A= result =3D getitimer(arg1, &value);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &value, sizeof(value));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &value, sizeof(valu= e))=0A= !=3D sizeof(value))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_stat:=0A= {=0A= char *buf;=0A= int buflen;=0A= struct stat statbuf;=0A= =0A= result =3D stat((char *) t2h_addr(cb, &s, arg1), &statbuf);= =0A= errcode =3D errno;=0A= if (result < 0)=0A= break;=0A= =0A= buflen =3D cb_host_to_target_stat (cb, NULL, NULL);=0A= buf =3D xmalloc (buflen);=0A= if (cb_host_to_target_stat (cb, &statbuf, buf) !=3D buflen)= =0A= {=0A= /* The translation failed. This is due to an internal=0A= host program error, not the target's fault. */=0A= free (buf);=0A= result =3D -1;=0A= errcode =3D ENOSYS;=0A= break;=0A= }=0A= if ((s.write_mem) (cb, &s, arg2, buf, buflen) !=3D buflen)=0A= {=0A= free (buf);=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= break;=0A= }=0A= free (buf);=0A= }=0A= break;=0A= =0A= case __NR_lstat:=0A= {=0A= char *buf;=0A= int buflen;=0A= struct stat statbuf;=0A= =0A= result =3D lstat((char *) t2h_addr(cb, &s, arg1), &statbuf);= =0A= errcode =3D errno;=0A= if (result < 0)=0A= break;=0A= =0A= buflen =3D cb_host_to_target_stat (cb, NULL, NULL);=0A= buf =3D xmalloc (buflen);=0A= if (cb_host_to_target_stat (cb, &statbuf, buf) !=3D buflen)= =0A= {=0A= /* The translation failed. This is due to an internal=0A= host program error, not the target's fault. */=0A= free (buf);=0A= result =3D -1;=0A= errcode =3D ENOSYS;=0A= break;=0A= }=0A= if ((s.write_mem) (cb, &s, arg2, buf, buflen) !=3D buflen)=0A= {=0A= free (buf);=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= break;=0A= }=0A= free (buf);=0A= }=0A= break;=0A= =0A= case __NR_fstat:=0A= {=0A= char *buf;=0A= int buflen;=0A= struct stat statbuf;=0A= =0A= result =3D fstat(arg1, &statbuf);=0A= errcode =3D errno;=0A= if (result < 0)=0A= break;=0A= =0A= buflen =3D cb_host_to_target_stat (cb, NULL, NULL);=0A= buf =3D xmalloc (buflen);=0A= if (cb_host_to_target_stat (cb, &statbuf, buf) !=3D buflen)= =0A= {=0A= /* The translation failed. This is due to an internal=0A= host program error, not the target's fault. */=0A= free (buf);=0A= result =3D -1;=0A= errcode =3D ENOSYS;=0A= break;=0A= }=0A= if ((s.write_mem) (cb, &s, arg2, buf, buflen) !=3D buflen)=0A= {=0A= free (buf);=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= break;=0A= }=0A= free (buf);=0A= }=0A= break;=0A= =0A= case __NR_sysinfo:=0A= {=0A= struct sysinfo info;=0A= =0A= result =3D sysinfo(&info);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= info.uptime =3D conv_endian(info.uptime);=0A= info.loads[0] =3D conv_endian(info.loads[0]);=0A= info.loads[1] =3D conv_endian(info.loads[1]);=0A= info.loads[2] =3D conv_endian(info.loads[2]);=0A= info.totalram =3D conv_endian(info.totalram);=0A= info.freeram =3D conv_endian(info.freeram);=0A= info.sharedram =3D conv_endian(info.sharedram);=0A= info.bufferram =3D conv_endian(info.bufferram);=0A= info.totalswap =3D conv_endian(info.totalswap);=0A= info.freeswap =3D conv_endian(info.freeswap);=0A= info.procs =3D conv_endian16(info.procs);=0A= #if LINUX_VERSION_CODE >=3D 0x20400=0A= info.totalhigh =3D conv_endian(info.totalhigh);=0A= info.freehigh =3D conv_endian(info.freehigh);=0A= info.mem_unit =3D conv_endian(info.mem_unit);=0A= #endif=0A= if ((s.write_mem) (cb, &s, arg1, (char *) &info, sizeof(info)= )=0A= !=3D sizeof(info))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= #if 0=0A= case __NR_ipc:=0A= {=0A= result =3D ipc(arg1, arg2, arg3, arg4,=0A= (void *) t2h_addr(cb, &s, arg5), arg6);=0A= errcode =3D errno;=0A= }=0A= break;=0A= #endif=0A= =0A= case __NR_fsync:=0A= result =3D fsync(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_uname:=0A= /* utsname contains only arrays of char, so it is not necessary= =0A= to translate endian. */=0A= result =3D uname((struct utsname *) t2h_addr(cb, &s, arg1));=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_adjtimex:=0A= {=0A= struct timex buf;=0A= =0A= result =3D adjtimex(&buf);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &buf, sizeof(buf));=0A= if ((s.write_mem) (cb, &s, arg1, (char *) &buf, sizeof(buf))= =0A= !=3D sizeof(buf))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_mprotect:=0A= result =3D mprotect((void *) arg1, arg2, arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_get_kernel_syms:=0A= {=0A= struct kernel_sym table;=0A= =0A= result =3D get_kernel_syms(&table);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= table.value =3D conv_endian(table.value);=0A= if ((s.write_mem) (cb, &s, arg1, (char *) &table, sizeof(tabl= e))=0A= !=3D sizeof(table))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_fchdir:=0A= result =3D fchdir(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_setfsuid:=0A= result =3D setfsuid(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_setfsgid:=0A= result =3D setfsgid(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= #if 0=0A= case __NR__llseek:=0A= {=0A= loff_t buf;=0A= =0A= result =3D _llseek(arg1, arg2, arg3, &buf, arg5);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &buf, sizeof(buf));=0A= if ((s.write_mem) (cb, &s, t2h_addr(cb, &s, arg4),=0A= (char *) &buf, sizeof(buf)) !=3D sizeof(bu= f))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_getdents:=0A= {=0A= struct dirent dir;=0A= =0A= result =3D getdents(arg1, &dir, arg3);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= dir.d_ino =3D conv_endian(dir.d_ino);=0A= dir.d_off =3D conv_endian(dir.d_off);=0A= dir.d_reclen =3D conv_endian16(dir.d_reclen);=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &dir, sizeof(dir))= =0A= !=3D sizeof(dir))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= #endif=0A= =0A= case __NR_flock:=0A= result =3D flock(arg1, arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_msync:=0A= result =3D msync((void *) arg1, arg2, arg3);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_readv:=0A= {=0A= struct iovec vector;=0A= =0A= vector =3D *((struct iovec *) t2h_addr(cb, &s, arg2));=0A= translate_endian((void *) &vector, sizeof(vector));=0A= =0A= result =3D readv(arg1, &vector, arg3);=0A= errcode =3D errno;=0A= }=0A= break;=0A= =0A= case __NR_writev:=0A= {=0A= struct iovec vector;=0A= =0A= vector =3D *((struct iovec *) t2h_addr(cb, &s, arg2));=0A= translate_endian((void *) &vector, sizeof(vector));=0A= =0A= result =3D writev(arg1, &vector, arg3);=0A= errcode =3D errno;=0A= }=0A= break;=0A= =0A= case __NR_fdatasync:=0A= result =3D fdatasync(arg1);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_mlock:=0A= result =3D mlock((void *) t2h_addr(cb, &s, arg1), arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_munlock:=0A= result =3D munlock((void *) t2h_addr(cb, &s, arg1), arg2);=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_nanosleep:=0A= {=0A= struct timespec req, rem;=0A= =0A= req =3D *((struct timespec *) t2h_addr(cb, &s, arg2));=0A= translate_endian((void *) &req, sizeof(req));=0A= =0A= result =3D nanosleep(&req, &rem);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= translate_endian((void *) &rem, sizeof(rem));=0A= if ((s.write_mem) (cb, &s, arg2, (char *) &rem, sizeof(rem))= =0A= !=3D sizeof(rem))=0A= {=0A= result =3D -1;=0A= errcode =3D EINVAL;=0A= }=0A= }=0A= break;=0A= =0A= case __NR_mremap: /* FIXME */=0A= result =3D (int) mremap((void *) t2h_addr(cb, &s, arg1), arg2, = arg3, arg4);=20=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getresuid:=0A= {=0A= uid_t ruid, euid, suid;=0A= =0A= result =3D getresuid(&ruid, &euid, &suid);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= *((uid_t *) t2h_addr(cb, &s, arg1)) =3D conv_endian(ruid);=0A= *((uid_t *) t2h_addr(cb, &s, arg2)) =3D conv_endian(euid);=0A= *((uid_t *) t2h_addr(cb, &s, arg3)) =3D conv_endian(suid);=0A= }=0A= break;=0A= =0A= case __NR_poll:=0A= {=0A= struct pollfd ufds;=0A= =0A= ufds =3D *((struct pollfd *) t2h_addr(cb, &s, arg1));=0A= ufds.fd =3D conv_endian(ufds.fd);=0A= ufds.events =3D conv_endian16(ufds.events);=0A= ufds.revents =3D conv_endian16(ufds.revents);=0A= =0A= result =3D poll(&ufds, arg2, arg3);=0A= errcode =3D errno;=0A= }=0A= break;=0A= =0A= case __NR_getresgid:=0A= {=0A= uid_t rgid, egid, sgid;=0A= =0A= result =3D getresgid(&rgid, &egid, &sgid);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= *((uid_t *) t2h_addr(cb, &s, arg1)) =3D conv_endian(rgid);=0A= *((uid_t *) t2h_addr(cb, &s, arg2)) =3D conv_endian(egid);=0A= *((uid_t *) t2h_addr(cb, &s, arg3)) =3D conv_endian(sgid);=0A= }=0A= break;=0A= =0A= case __NR_pread:=0A= result =3D pread(arg1, (void *) t2h_addr(cb, &s, arg2), arg3, = arg4);=20=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_pwrite:=0A= result =3D pwrite(arg1, (void *) t2h_addr(cb, &s, arg2), arg3,= arg4);=20=0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_chown:=0A= result =3D chown((char *) t2h_addr(cb, &s, arg1), arg2, arg3);= =0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_getcwd:=0A= result =3D (int) getcwd((char *) t2h_addr(cb, &s, arg1), arg2);= =0A= errcode =3D errno;=0A= break;=0A= =0A= case __NR_sendfile:=0A= {=0A= off_t offset;=0A= =0A= offset =3D *((off_t *) t2h_addr(cb, &s, arg3));=0A= offset =3D conv_endian(offset);=0A= =0A= result =3D sendfile(arg1, arg2, &offset, arg3);=0A= errcode =3D errno;=0A= =0A= if (result !=3D 0)=0A= break;=0A= =0A= *((off_t *) t2h_addr(cb, &s, arg3)) =3D conv_endian(offset);= =0A= }=0A= break;=0A= =0A= default:=0A= result =3D -1;=0A= errcode =3D ENOSYS;=0A= break;=0A= }=0A= =20=20=20=20=20=20=20=20=0A= if (result =3D=3D -1)=0A= m32rbf_h_gr_set (current_cpu, 0, -errcode);=0A= else=0A= m32rbf_h_gr_set (current_cpu, 0, result);=0A= break;=0A= }=0A= =0A= case TRAP_BREAKPOINT:=0A= sim_engine_halt (sd, current_cpu, NULL, pc,=0A= sim_stopped, SIM_SIGTRAP);=0A= break;=0A= =0A= case TRAP_FLUSH_CACHE:=0A= /* Do nothing. */=0A= break;=0A= =0A= default :=0A= {=0A= /* Use cr5 as EVB (EIT Vector Base) register. */=0A= USI new_pc =3D m32rbf_h_cr_get (current_cpu, 5) + 0x40 + num * 4;= =0A= return new_pc;=0A= }=0A= }=0A= =0A= /* Fake an "rte" insn. */=0A= /* FIXME: Should duplicate all of rte processing. */=0A= return (pc & -4) + 4;=0A= }=0A= --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw) Content-type: application/octet-stream; name=syscall.h Content-transfer-encoding: quoted-printable Content-disposition: attachment; filename=syscall.h Content-length: 5966 /*=0A= * This file contains the system call numbers.=0A= */=0A= =0A= #define __NR_exit 1=0A= #define __NR_fork 2=0A= #define __NR_read 3=0A= #define __NR_write 4=0A= #define __NR_open 5=0A= #define __NR_close 6=0A= #define __NR_waitpid 7=0A= #define __NR_creat 8=0A= #define __NR_link 9=0A= #define __NR_unlink 10=0A= #define __NR_execve 11=0A= #define __NR_chdir 12=0A= #define __NR_time 13=0A= #define __NR_mknod 14=0A= #define __NR_chmod 15=0A= #define __NR_lchown 16=0A= #define __NR_break 17=0A= #define __NR_oldstat 18=0A= #define __NR_lseek 19=0A= #define __NR_getpid 20=0A= #define __NR_mount 21=0A= #define __NR_umount 22=0A= #define __NR_setuid 23=0A= #define __NR_getuid 24=0A= #define __NR_stime 25=0A= #define __NR_ptrace 26=0A= #define __NR_alarm 27=0A= #define __NR_oldfstat 28=0A= #define __NR_pause 29=0A= #define __NR_utime 30=0A= #define __NR_stty 31=0A= #define __NR_gtty 32=0A= #define __NR_access 33=0A= #define __NR_nice 34=0A= #define __NR_ftime 35=0A= #define __NR_sync 36=0A= #define __NR_kill 37=0A= #define __NR_rename 38=0A= #define __NR_mkdir 39=0A= #define __NR_rmdir 40=0A= #define __NR_dup 41=0A= #define __NR_pipe 42=0A= #define __NR_times 43=0A= #define __NR_prof 44=0A= #define __NR_brk 45=0A= #define __NR_setgid 46=0A= #define __NR_getgid 47=0A= #define __NR_signal 48=0A= #define __NR_geteuid 49=0A= #define __NR_getegid 50=0A= #define __NR_acct 51=0A= #define __NR_umount2 52=0A= #define __NR_lock 53=0A= #define __NR_ioctl 54=0A= #define __NR_fcntl 55=0A= #define __NR_mpx 56=0A= #define __NR_setpgid 57=0A= #define __NR_ulimit 58=0A= #define __NR_oldolduname 59=0A= #define __NR_umask 60=0A= #define __NR_chroot 61=0A= #define __NR_ustat 62=0A= #define __NR_dup2 63=0A= #define __NR_getppid 64=0A= #define __NR_getpgrp 65=0A= #define __NR_setsid 66=0A= #define __NR_sigaction 67=0A= #define __NR_sgetmask 68=0A= #define __NR_ssetmask 69=0A= #define __NR_setreuid 70=0A= #define __NR_setregid 71=0A= #define __NR_sigsuspend 72=0A= #define __NR_sigpending 73=0A= #define __NR_sethostname 74=0A= #define __NR_setrlimit 75=0A= #define __NR_getrlimit 76=0A= #define __NR_getrusage 77=0A= #define __NR_gettimeofday 78=0A= #define __NR_settimeofday 79=0A= #define __NR_getgroups 80=0A= #define __NR_setgroups 81=0A= #define __NR_select 82=0A= #define __NR_symlink 83=0A= #define __NR_oldlstat 84=0A= #define __NR_readlink 85=0A= #define __NR_uselib 86=0A= #define __NR_swapon 87=0A= #define __NR_reboot 88=0A= #define __NR_readdir 89=0A= #define __NR_mmap 90=0A= #define __NR_munmap 91=0A= #define __NR_truncate 92=0A= #define __NR_ftruncate 93=0A= #define __NR_fchmod 94=0A= #define __NR_fchown 95=0A= #define __NR_getpriority 96=0A= #define __NR_setpriority 97=0A= #define __NR_profil 98=0A= #define __NR_statfs 99=0A= #define __NR_fstatfs 100=0A= #define __NR_ioperm 101=0A= #define __NR_socketcall 102=0A= #define __NR_syslog 103=0A= #define __NR_setitimer 104=0A= #define __NR_getitimer 105=0A= #define __NR_stat 106=0A= #define __NR_lstat 107=0A= #define __NR_fstat 108=0A= #define __NR_olduname 109=0A= #define __NR_iopl 110=0A= #define __NR_vhangup 111=0A= #define __NR_idle 112=0A= #define __NR_vm86old 113=0A= #define __NR_wait4 114=0A= #define __NR_swapoff 115=0A= #define __NR_sysinfo 116=0A= #define __NR_ipc 117=0A= #define __NR_fsync 118=0A= #define __NR_sigreturn 119=0A= #define __NR_clone 120=0A= #define __NR_setdomainname 121=0A= #define __NR_uname 122=0A= #define __NR_modify_ldt 123=0A= #define __NR_adjtimex 124=0A= #define __NR_mprotect 125=0A= #define __NR_sigprocmask 126=0A= #define __NR_create_module 127=0A= #define __NR_init_module 128=0A= #define __NR_delete_module 129=0A= #define __NR_get_kernel_syms 130=0A= #define __NR_quotactl 131=0A= #define __NR_getpgid 132=0A= #define __NR_fchdir 133=0A= #define __NR_bdflush 134=0A= #define __NR_sysfs 135=0A= #define __NR_personality 136=0A= #define __NR_afs_syscall 137 /* Syscall for Andrew File System */=0A= #define __NR_setfsuid 138=0A= #define __NR_setfsgid 139=0A= #define __NR__llseek 140=0A= #define __NR_getdents 141=0A= #define __NR__newselect 142=0A= #define __NR_flock 143=0A= #define __NR_msync 144=0A= #define __NR_readv 145=0A= #define __NR_writev 146=0A= #define __NR_getsid 147=0A= #define __NR_fdatasync 148=0A= #define __NR__sysctl 149=0A= #define __NR_mlock 150=0A= #define __NR_munlock 151=0A= #define __NR_mlockall 152=0A= #define __NR_munlockall 153=0A= #define __NR_sched_setparam 154=0A= #define __NR_sched_getparam 155=0A= #define __NR_sched_setscheduler 156=0A= #define __NR_sched_getscheduler 157=0A= #define __NR_sched_yield 158=0A= #define __NR_sched_get_priority_max 159=0A= #define __NR_sched_get_priority_min 160=0A= #define __NR_sched_rr_get_interval 161=0A= #define __NR_nanosleep 162=0A= #define __NR_mremap 163=0A= #define __NR_setresuid 164=0A= #define __NR_getresuid 165=0A= #define __NR_vm86 166=0A= #define __NR_query_module 167=0A= #define __NR_poll 168=0A= #define __NR_nfsservctl 169=0A= #define __NR_setresgid 170=0A= #define __NR_getresgid 171=0A= #define __NR_prctl 172=0A= #define __NR_rt_sigreturn 173=0A= #define __NR_rt_sigaction 174=0A= #define __NR_rt_sigprocmask 175=0A= #define __NR_rt_sigpending 176=0A= #define __NR_rt_sigtimedwait 177=0A= #define __NR_rt_sigqueueinfo 178=0A= #define __NR_rt_sigsuspend 179=0A= #define __NR_pread 180=0A= #define __NR_pwrite 181=0A= #define __NR_chown 182=0A= #define __NR_getcwd 183=0A= #define __NR_capget 184=0A= #define __NR_capset 185=0A= #define __NR_sigaltstack 186=0A= #define __NR_sendfile 187=0A= #define __NR_getpmsg 188 /* some people actually want streams */=0A= #define __NR_putpmsg 189 /* some people actually want streams */=0A= #define __NR_vfork 190=0A= =0A= --Boundary_(ID_sOCBFLknwbyYJqX9GyjGhw)--