From 0bcb993b9f9ddf2dce0a3e137d42c027ac1edf70 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Sat, 4 Sep 1999 17:07:46 +0000 Subject: [PATCH] 1999-09-04 Steve Chamberlain * cpu-pj.c: New file. * elf32-pj.c: New file. * config.bfd (pj*): New cpu. (pj-*-*, pjl-*-*): New targets. * configure.in (bfd_elf32_pj_vec): New target vector. (bfd_elf32_pjl_vec): New target vector. * archures.c (bfd_arch_pj): Define. * elf.c (prep_headers): Handle bfd_arch_pj. * reloc.c: Define BFD_RELOC_PJ_* relocations. * targets.c (bfd_elf32_pj_vec, bfd_elf32_pjl_vec): Declare and add to target vector list. * Makefile.am: Rebuild dependencies. (ALL_MACHINES): Add cpu-pj.lo. (ALL_MACHINES_CFILES): Add cpu-pj.c. (BFD32_BACKENDS): Add elf32-pj.lo. (BFD32_BACKENDS_CFILES): Add elf32-pj.c. * configure, Makefile.in, bfd-in2.h, libbfd.h: Rebuild. --- bfd/ChangeLog | 20 +++ bfd/Makefile.am | 8 ++ bfd/Makefile.in | 8 ++ bfd/archures.c | 2 + bfd/bfd-in2.h | 9 ++ bfd/config.bfd | 11 ++ bfd/configure | 26 ++-- bfd/configure.in | 2 + bfd/cpu-pj.c | 85 ++++++++++++ bfd/elf.c | 3 + bfd/elf32-pj.c | 349 +++++++++++++++++++++++++++++++++++++++++++++++ bfd/libbfd.h | 6 + bfd/reloc.c | 15 ++ bfd/targets.c | 4 + 14 files changed, 536 insertions(+), 12 deletions(-) create mode 100644 bfd/cpu-pj.c create mode 100644 bfd/elf32-pj.c diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 0e3c2ca8ec..44733602a8 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,23 @@ +1999-09-04 Steve Chamberlain + + * cpu-pj.c: New file. + * elf32-pj.c: New file. + * config.bfd (pj*): New cpu. + (pj-*-*, pjl-*-*): New targets. + * configure.in (bfd_elf32_pj_vec): New target vector. + (bfd_elf32_pjl_vec): New target vector. + * archures.c (bfd_arch_pj): Define. + * elf.c (prep_headers): Handle bfd_arch_pj. + * reloc.c: Define BFD_RELOC_PJ_* relocations. + * targets.c (bfd_elf32_pj_vec, bfd_elf32_pjl_vec): Declare and add + to target vector list. + * Makefile.am: Rebuild dependencies. + (ALL_MACHINES): Add cpu-pj.lo. + (ALL_MACHINES_CFILES): Add cpu-pj.c. + (BFD32_BACKENDS): Add elf32-pj.lo. + (BFD32_BACKENDS_CFILES): Add elf32-pj.c. + * configure, Makefile.in, bfd-in2.h, libbfd.h: Rebuild. + 1999-09-04 Ian Lance Taylor * elf-bfd.h (ELF_LINK_NON_GOT_REF): Define. diff --git a/bfd/Makefile.am b/bfd/Makefile.am index c74be341de..0c5e12db4a 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -58,6 +58,7 @@ ALL_MACHINES = \ cpu-mcore.lo \ cpu-mips.lo \ cpu-ns32k.lo \ + cpu-pj.lo \ cpu-powerpc.lo \ cpu-rs6000.lo \ cpu-sh.lo \ @@ -92,6 +93,7 @@ ALL_MACHINES_CFILES = \ cpu-mcore.c \ cpu-mips.c \ cpu-ns32k.c \ + cpu-pj.c \ cpu-powerpc.c \ cpu-rs6000.c \ cpu-sh.c \ @@ -168,6 +170,7 @@ BFD32_BACKENDS = \ elf-m10300.lo \ elf32-mcore.lo \ elf32-mips.lo \ + elf32-pj.lo \ elf32-ppc.lo \ elf32-sh.lo \ elf32-sparc.lo \ @@ -291,6 +294,7 @@ BFD32_BACKENDS_CFILES = \ elf-m10300.c \ elf32-mcore.c \ elf32-mips.c \ + elf32-pj.c \ elf32-ppc.c \ elf32-sh.c \ elf32-sparc.c \ @@ -693,6 +697,7 @@ cpu-m10300.lo: cpu-m10300.c cpu-mcore.lo: cpu-mcore.c cpu-mips.lo: cpu-mips.c cpu-ns32k.lo: cpu-ns32k.c ns32k.h +cpu-pj.lo: cpu-pj.c cpu-powerpc.lo: cpu-powerpc.c cpu-rs6000.lo: cpu-rs6000.c cpu-sh.lo: cpu-sh.c @@ -884,6 +889,9 @@ elf32-mips.lo: elf32-mips.c $(INCDIR)/bfdlink.h genlink.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \ elf32-target.h +elf32-pj.lo: elf32-pj.c $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/elf/pj.h $(INCDIR)/elf/reloc-macros.h elf32-target.h elf32-ppc.lo: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h elf32-target.h diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 52f9c4d6f0..b2ea4ed142 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -175,6 +175,7 @@ ALL_MACHINES = \ cpu-mcore.lo \ cpu-mips.lo \ cpu-ns32k.lo \ + cpu-pj.lo \ cpu-powerpc.lo \ cpu-rs6000.lo \ cpu-sh.lo \ @@ -210,6 +211,7 @@ ALL_MACHINES_CFILES = \ cpu-mcore.c \ cpu-mips.c \ cpu-ns32k.c \ + cpu-pj.c \ cpu-powerpc.c \ cpu-rs6000.c \ cpu-sh.c \ @@ -287,6 +289,7 @@ BFD32_BACKENDS = \ elf-m10300.lo \ elf32-mcore.lo \ elf32-mips.lo \ + elf32-pj.lo \ elf32-ppc.lo \ elf32-sh.lo \ elf32-sparc.lo \ @@ -411,6 +414,7 @@ BFD32_BACKENDS_CFILES = \ elf-m10300.c \ elf32-mcore.c \ elf32-mips.c \ + elf32-pj.c \ elf32-ppc.c \ elf32-sh.c \ elf32-sparc.c \ @@ -1223,6 +1227,7 @@ cpu-m10300.lo: cpu-m10300.c cpu-mcore.lo: cpu-mcore.c cpu-mips.lo: cpu-mips.c cpu-ns32k.lo: cpu-ns32k.c ns32k.h +cpu-pj.lo: cpu-pj.c cpu-powerpc.lo: cpu-powerpc.c cpu-rs6000.lo: cpu-rs6000.c cpu-sh.lo: cpu-sh.c @@ -1414,6 +1419,9 @@ elf32-mips.lo: elf32-mips.c $(INCDIR)/bfdlink.h genlink.h \ $(INCDIR)/coff/sym.h $(INCDIR)/coff/symconst.h $(INCDIR)/coff/internal.h \ $(INCDIR)/coff/ecoff.h $(INCDIR)/coff/mips.h ecoffswap.h \ elf32-target.h +elf32-pj.lo: elf32-pj.c $(INCDIR)/bfdlink.h elf-bfd.h \ + $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ + $(INCDIR)/elf/pj.h $(INCDIR)/elf/reloc-macros.h elf32-target.h elf32-ppc.lo: elf32-ppc.c $(INCDIR)/bfdlink.h elf-bfd.h \ $(INCDIR)/elf/common.h $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h \ $(INCDIR)/elf/ppc.h $(INCDIR)/elf/reloc-macros.h elf32-target.h diff --git a/bfd/archures.c b/bfd/archures.c index 7f2c5f7236..dbd75077ad 100644 --- a/bfd/archures.c +++ b/bfd/archures.c @@ -187,6 +187,7 @@ DESCRIPTION . bfd_arch_fr30, .#define bfd_mach_fr30 0x46523330 . bfd_arch_mcore, +. bfd_arch_pj, . bfd_arch_last . }; @@ -245,6 +246,7 @@ extern const bfd_arch_info_type bfd_mn10200_arch; extern const bfd_arch_info_type bfd_mn10300_arch; extern const bfd_arch_info_type bfd_powerpc_arch; extern const bfd_arch_info_type bfd_rs6000_arch; +extern const bfd_arch_info_type bfd_pj_arch; extern const bfd_arch_info_type bfd_sh_arch; extern const bfd_arch_info_type bfd_sparc_arch; extern const bfd_arch_info_type bfd_tic30_arch; diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 2e47b538f1..f79438e89d 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -1350,6 +1350,7 @@ enum bfd_architecture bfd_arch_fr30, #define bfd_mach_fr30 0x46523330 bfd_arch_mcore, + bfd_arch_pj, bfd_arch_last }; @@ -1885,6 +1886,14 @@ to compensate for the borrow when the low bits are added. */ BFD_RELOC_NS32K_DISP_16_PCREL, BFD_RELOC_NS32K_DISP_32_PCREL, +/* Picojava relocs. Not all of these appear in object files. */ + BFD_RELOC_PJ_CODE_HI16, + BFD_RELOC_PJ_CODE_LO16, + BFD_RELOC_PJ_CODE_DIR16, + BFD_RELOC_PJ_CODE_DIR32, + BFD_RELOC_PJ_CODE_REL16, + BFD_RELOC_PJ_CODE_REL32, + /* Power(rs6000) and PowerPC relocations. */ BFD_RELOC_PPC_B26, BFD_RELOC_PPC_BA26, diff --git a/bfd/config.bfd b/bfd/config.bfd index 1f948aa8ec..afa5de7652 100644 --- a/bfd/config.bfd +++ b/bfd/config.bfd @@ -38,6 +38,7 @@ i[3456]86) targ_archs=bfd_i386_arch ;; m68*) targ_archs=bfd_m68k_arch ;; m88*) targ_archs=bfd_m88k_arch ;; mips*) targ_archs=bfd_mips_arch ;; +pj*) targ_archs="bfd_pj_arch bfd_i386_arch";; powerpc*) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;; rs6000) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;; sparc*) targ_archs=bfd_sparc_arch ;; @@ -562,6 +563,16 @@ case "${targ}" in targ_underscore=yes ;; + pj-*-*) + targ_defvec=bfd_elf32_pj_vec + targ_selvecs="bfd_elf32_pj_vec bfd_elf32_pjl_vec" + ;; + + pjl-*-*) + targ_defvec=bfd_elf32_pjl_vec + targ_selvecs="bfd_elf32_pjl_vec bfd_elf32_pj_vec bfd_elf32_i386_vec" + ;; + powerpc-*-aix* | powerpc-*-beos*) targ_defvec=rs6000coff_vec ;; diff --git a/bfd/configure b/bfd/configure index 725f83c7ce..6acf252752 100755 --- a/bfd/configure +++ b/bfd/configure @@ -5413,6 +5413,8 @@ do bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;; bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;; bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;; + bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; + bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;; @@ -5594,17 +5596,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:5598: checking for $ac_hdr" >&5 +echo "configure:5600: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:5608: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:5610: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -5633,12 +5635,12 @@ done for ac_func in getpagesize do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5637: checking for $ac_func" >&5 +echo "configure:5639: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5667: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -5686,7 +5688,7 @@ fi done echo $ac_n "checking for working mmap""... $ac_c" 1>&6 -echo "configure:5690: checking for working mmap" >&5 +echo "configure:5692: checking for working mmap" >&5 if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -5694,7 +5696,7 @@ else ac_cv_func_mmap_fixed_mapped=no else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:5840: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_func_mmap_fixed_mapped=yes else @@ -5859,12 +5861,12 @@ fi for ac_func in madvise mprotect do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:5863: checking for $ac_func" >&5 +echo "configure:5865: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:5893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else diff --git a/bfd/configure.in b/bfd/configure.in index c56747345d..6981bc2615 100644 --- a/bfd/configure.in +++ b/bfd/configure.in @@ -461,6 +461,8 @@ do bfd_elf32_mcore_little_vec) tb="$tb elf32-mcore.lo elf32.lo $elf" ;; bfd_elf32_mn10200_vec) tb="$tb elf-m10200.lo elf32.lo $elf" ;; bfd_elf32_mn10300_vec) tb="$tb elf-m10300.lo elf32.lo $elf" ;; + bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; + bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf32.lo $elf" ;; bfd_elf32_sh_vec) tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;; diff --git a/bfd/cpu-pj.c b/bfd/cpu-pj.c new file mode 100644 index 0000000000..44ddd33260 --- /dev/null +++ b/bfd/cpu-pj.c @@ -0,0 +1,85 @@ +/* BFD library support routines for the Pico Java architecture. + Copyright (C) 1999 Free Software Foundation, Inc. + Hacked by Steve Chamberlain of Transmeta. sac@pobox.com + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "libbfd.h" + + +static boolean +scan_mach (info, string) + const struct bfd_arch_info *info; + const char *string; +{ + if (strcasecmp (info->printable_name, string) == 0) + return true; + return false; +} + + +#if 0 +/* This routine is provided two arch_infos and returns whether + they'd be compatible */ + +static const bfd_arch_info_type * +compatible (a,b) + const bfd_arch_info_type *a; + const bfd_arch_info_type *b; +{ + if (a->arch != b->arch || a->mach != b->mach) + return NULL; + return a; +} +#endif + + +static const bfd_arch_info_type arch_info_struct[] = +{ + { + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_pj, + 0, + "pj", /* arch_name */ + "pj", /* printable name */ + 1, + false, /* not the default */ + bfd_default_compatible, + scan_mach, + 0, + }, +}; + +const bfd_arch_info_type bfd_pj_arch = +{ + 32, /* 32 bits in a word */ + 32, /* 32 bits in an address */ + 8, /* 8 bits in a byte */ + bfd_arch_pj, + 0, + "pj", /* arch_name */ + "pj", /* printable name */ + 1, + true, /* the default machine */ + bfd_default_compatible, + scan_mach, + &arch_info_struct [0] +}; diff --git a/bfd/elf.c b/bfd/elf.c index 997408ce16..5bfde4e484 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -3185,6 +3185,9 @@ prep_headers (abfd) case bfd_arch_mn10300: i_ehdrp->e_machine = EM_CYGNUS_MN10300; break; + case bfd_arch_pj: + i_ehdrp->e_machine = EM_PJ; + break; /* also note that EM_M32, AT&T WE32100 is unknown to bfd */ default: i_ehdrp->e_machine = EM_NONE; diff --git a/bfd/elf32-pj.c b/bfd/elf32-pj.c new file mode 100644 index 0000000000..3b96949f47 --- /dev/null +++ b/bfd/elf32-pj.c @@ -0,0 +1,349 @@ +/* picoJava specific support for 32-bit ELF + Copyright 1999 Free Software Foundation, Inc. + Contributed by Steve Chamberlan of Transmeta (sac@pobox.com). + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#include "bfd.h" +#include "sysdep.h" +#include "bfdlink.h" +#include "libbfd.h" +#include "elf-bfd.h" +#include "elf/pj.h" + +static bfd_reloc_status_type pj_elf_reloc + PARAMS ((bfd *, arelent *, asymbol *, PTR, asection *, bfd *, char **)); +static reloc_howto_type *pj_elf_reloc_type_lookup + PARAMS ((bfd *, bfd_reloc_code_real_type)); +static void pj_elf_info_to_howto + PARAMS ((bfd *, arelent *, Elf_Internal_Rela *)); + +static reloc_howto_type pj_elf_howto_table[] = +{ + /* No relocation. */ + HOWTO (R_PJ_NONE, /* type */ + 0, /* rightshift */ + 0, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_NONE", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + /* 32 bit absolute relocation. Setting partial_inplace to true and + src_mask to a non-zero value is similar to the COFF toolchain. */ + HOWTO (R_PJ_DATA_DIR32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_DIR32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + /* 32 bit PC relative relocation. */ + HOWTO (R_PJ_CODE_REL32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_REL32", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0xffffffff, /* dst_mask */ + true), /* pcrel_offset */ + +/* 16 bit PC relative relocation. */ + HOWTO (R_PJ_CODE_REL16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + true, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_signed, /* complain_on_overf6w */ + pj_elf_reloc, /* special_function */ + "R_PJ_REL16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + EMPTY_HOWTO (4), + EMPTY_HOWTO (5), + HOWTO (R_PJ_CODE_DIR32, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 32, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_bitfield, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_CODE_DIR32", /* name */ + true, /* partial_inplace */ + 0xffffffff, /* src_mask */ + 0xffffffff, /* dst_mask */ + false), /* pcrel_offset */ + + EMPTY_HOWTO (7), + EMPTY_HOWTO (8), + EMPTY_HOWTO (9), + EMPTY_HOWTO (10), + EMPTY_HOWTO (11), + EMPTY_HOWTO (12), + + HOWTO (R_PJ_CODE_LO16, /* type */ + 0, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_LO16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + + HOWTO (R_PJ_CODE_HI16, /* type */ + 16, /* rightshift */ + 1, /* size (0 = byte, 1 = short, 2 = long) */ + 16, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_unsigned, /* complain_on_overflow */ + pj_elf_reloc, /* special_function */ + "R_PJ_HI16", /* name */ + false, /* partial_inplace */ + 0xffff, /* src_mask */ + 0xffff, /* dst_mask */ + true), /* pcrel_offset */ + + /* GNU extension to record C++ vtable hierarchy */ + HOWTO (R_PJ_GNU_VTINHERIT, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + NULL, /* special_function */ + "R_PJ_GNU_VTINHERIT", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + /* GNU extension to record C++ vtable member usage */ + HOWTO (R_PJ_GNU_VTENTRY, /* type */ + 0, /* rightshift */ + 2, /* size (0 = byte, 1 = short, 2 = long) */ + 0, /* bitsize */ + false, /* pc_relative */ + 0, /* bitpos */ + complain_overflow_dont, /* complain_on_overflow */ + _bfd_elf_rel_vtable_reloc_fn, /* special_function */ + "R_PJ_GNU_VTENTRY", /* name */ + false, /* partial_inplace */ + 0, /* src_mask */ + 0, /* dst_mask */ + false), /* pcrel_offset */ + + +}; + +/* This function is used for normal relocs. This is like the COFF + function, and is almost certainly incorrect for other ELF targets. */ + +static bfd_reloc_status_type +pj_elf_reloc (abfd, reloc_entry, symbol_in, data, input_section, output_bfd, + error_message) + bfd *abfd; + arelent *reloc_entry; + asymbol *symbol_in; + PTR data; + asection *input_section; + bfd *output_bfd; + char **error_message ATTRIBUTE_UNUSED; +{ + unsigned long insn; + bfd_vma sym_value; + enum elf_pj_reloc_type r_type; + bfd_vma addr = reloc_entry->address; + bfd_byte *hit_data = addr + (bfd_byte *) data; + + r_type = (enum elf_pj_reloc_type) reloc_entry->howto->type; + + if (output_bfd != NULL) + { + /* Partial linking--do nothing. */ + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + if (symbol_in != NULL + && bfd_is_und_section (symbol_in->section)) + return bfd_reloc_undefined; + + if (bfd_is_com_section (symbol_in->section)) + sym_value = 0; + else + sym_value = (symbol_in->value + + symbol_in->section->output_section->vma + + symbol_in->section->output_offset); + + switch (r_type) + { + case R_PJ_DATA_DIR32: + insn = bfd_get_32 (abfd, hit_data); + insn += sym_value + reloc_entry->addend; + bfd_put_32 (abfd, insn, hit_data); + break; + + /* Relocations in code are always bigendian, no matter what the + data endianness is. */ + + case R_PJ_CODE_DIR32: + insn = bfd_getb32 (hit_data); + insn += sym_value + reloc_entry->addend; + bfd_putb32 (insn, hit_data); + break; + + case R_PJ_CODE_REL16: + insn = bfd_getb16 (hit_data); + insn += sym_value + reloc_entry->addend + - (input_section->output_section->vma + + input_section->output_offset); + bfd_putb16 (insn, hit_data); + break; + case R_PJ_CODE_LO16: + insn = bfd_getb16 (hit_data); + insn += sym_value + reloc_entry->addend; + bfd_putb16 (insn, hit_data); + break; + + case R_PJ_CODE_HI16: + insn = bfd_getb16 (hit_data); + insn += (sym_value + reloc_entry->addend) >> 16; + bfd_putb16 (insn, hit_data); + break; + + default: + abort (); + break; + } + + return bfd_reloc_ok; +} + +/* This structure is used to map BFD reloc codes to PJ ELF relocs. */ + +struct elf_reloc_map +{ + bfd_reloc_code_real_type bfd_reloc_val; + unsigned char elf_reloc_val; +}; + +/* An array mapping BFD reloc codes to PJ ELF relocs. */ + +static const struct elf_reloc_map pj_reloc_map[] = +{ + { BFD_RELOC_NONE, R_PJ_NONE }, + { BFD_RELOC_32, R_PJ_DATA_DIR32 }, + { BFD_RELOC_PJ_CODE_DIR16, R_PJ_CODE_DIR16 }, + { BFD_RELOC_PJ_CODE_DIR32, R_PJ_CODE_DIR32 }, + { BFD_RELOC_PJ_CODE_LO16, R_PJ_CODE_LO16 }, + { BFD_RELOC_PJ_CODE_HI16, R_PJ_CODE_HI16 }, + { BFD_RELOC_PJ_CODE_REL32, R_PJ_CODE_REL32 }, + { BFD_RELOC_PJ_CODE_REL16, R_PJ_CODE_REL16 }, + { BFD_RELOC_VTABLE_INHERIT, R_PJ_GNU_VTINHERIT }, + { BFD_RELOC_VTABLE_ENTRY, R_PJ_GNU_VTENTRY }, +}; + +/* Given a BFD reloc code, return the howto structure for the + corresponding PJ ELf reloc. */ + +static reloc_howto_type * +pj_elf_reloc_type_lookup (abfd, code) + bfd *abfd ATTRIBUTE_UNUSED; + bfd_reloc_code_real_type code; +{ + unsigned int i; + + for (i = 0; i < sizeof (pj_reloc_map) / sizeof (struct elf_reloc_map); i++) + { + if (pj_reloc_map[i].bfd_reloc_val == code) + return &pj_elf_howto_table[(int) pj_reloc_map[i].elf_reloc_val]; + } + + return NULL; +} + +/* Given an ELF reloc, fill in the howto field of a relent. */ + +static void +pj_elf_info_to_howto (abfd, cache_ptr, dst) + bfd *abfd ATTRIBUTE_UNUSED; + arelent *cache_ptr; + Elf_Internal_Rela *dst; +{ + unsigned int r; + + r = ELF32_R_TYPE (dst->r_info); + + BFD_ASSERT (r < (unsigned int) R_PJ_max); + + cache_ptr->howto = &pj_elf_howto_table[r]; +} + +/* Take this moment to fill in the special picoJava bits in the + e_flags field. */ + +static void +pj_elf_final_write_processing (abfd, linker) + bfd *abfd; + boolean linker ATTRIBUTE_UNUSED; +{ + elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_ARCH; + elf_elfheader (abfd)->e_flags |= EF_PICOJAVA_GNUCALLS; +} + +#define TARGET_BIG_SYM bfd_elf32_pj_vec +#define TARGET_BIG_NAME "elf32-pj" +#define TARGET_LITTLE_SYM bfd_elf32_pjl_vec +#define TARGET_LITTLE_NAME "elf32-pjl" +#define ELF_ARCH bfd_arch_pj +#define ELF_MACHINE_CODE EM_PJ +#define ELF_MAXPAGESIZE 0x1000 +#define bfd_elf32_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents +#define bfd_elf32_bfd_reloc_type_lookup pj_elf_reloc_type_lookup +#define elf_backend_final_write_processing pj_elf_final_write_processing +#define elf_info_to_howto pj_elf_info_to_howto +#include "elf32-target.h" diff --git a/bfd/libbfd.h b/bfd/libbfd.h index 5fc3f38605..9a252ee7ef 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -708,6 +708,12 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@", "BFD_RELOC_NS32K_DISP_8_PCREL", "BFD_RELOC_NS32K_DISP_16_PCREL", "BFD_RELOC_NS32K_DISP_32_PCREL", + "BFD_RELOC_PJ_CODE_HI16", + "BFD_RELOC_PJ_CODE_LO16", + "BFD_RELOC_PJ_CODE_DIR16", + "BFD_RELOC_PJ_CODE_DIR32", + "BFD_RELOC_PJ_CODE_REL16", + "BFD_RELOC_PJ_CODE_REL32", "BFD_RELOC_PPC_B26", "BFD_RELOC_PPC_BA26", "BFD_RELOC_PPC_TOC16", diff --git a/bfd/reloc.c b/bfd/reloc.c index a1713b20c0..e749b606d3 100644 --- a/bfd/reloc.c +++ b/bfd/reloc.c @@ -2105,6 +2105,21 @@ ENUMX ENUMDOC ns32k relocations +ENUM + BFD_RELOC_PJ_CODE_HI16 +ENUMX + BFD_RELOC_PJ_CODE_LO16 +ENUMX + BFD_RELOC_PJ_CODE_DIR16 +ENUMX + BFD_RELOC_PJ_CODE_DIR32 +ENUMX + BFD_RELOC_PJ_CODE_REL16 +ENUMX + BFD_RELOC_PJ_CODE_REL32 +ENUMDOC + Picojava relocs. Not all of these appear in object files. + ENUM BFD_RELOC_PPC_B26 ENUMX diff --git a/bfd/targets.c b/bfd/targets.c index 724137059f..df80ec6e72 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -529,6 +529,8 @@ extern const bfd_target bfd_elf32_m68k_vec; extern const bfd_target bfd_elf32_m88k_vec; extern const bfd_target bfd_elf32_mn10200_vec; extern const bfd_target bfd_elf32_mn10300_vec; +extern const bfd_target bfd_elf32_pj_vec; +extern const bfd_target bfd_elf32_pjl_vec; extern const bfd_target bfd_elf32_powerpc_vec; extern const bfd_target bfd_elf32_powerpcle_vec; extern const bfd_target bfd_elf32_sh_vec; @@ -709,6 +711,8 @@ const bfd_target * const bfd_target_vector[] = { &bfd_elf32_m68k_vec, &bfd_elf32_m88k_vec, &bfd_elf32_sparc_vec, + &bfd_elf32_pj_vec, + &bfd_elf32_pjl_vec, &bfd_elf32_powerpc_vec, &bfd_elf32_powerpcle_vec, &bfd_elf32_v850_vec, -- 2.34.1