* Makefile.am (ALL_MACHINES,BFD32_BACKENDS): Add txvu support.
authorDoug Evans <dje@google.com>
Mon, 22 Dec 1997 16:47:21 +0000 (16:47 +0000)
committerDoug Evans <dje@google.com>
Mon, 22 Dec 1997 16:47:21 +0000 (16:47 +0000)
(cpu-txvu.lo,elf32-txvu.lo): Add rules for.
* Makefile.in: Rebuild.
* config.bfd, configure.in: Add txvu support.
* configure: Regenerate.
* archures.c, elf.c, targets.c: Add txvu support.
* bfd-in2.h: Regenerate.
* cpu-txvu.c, elf32-txvu.c: New files.

13 files changed:
bfd/.Sanitize
bfd/ChangeLog
bfd/Makefile.am
bfd/Makefile.in
bfd/archures.c
bfd/bfd-in2.h
bfd/config.bfd
bfd/configure
bfd/configure.in
bfd/cpu-txvu.c [new file with mode: 0644]
bfd/elf.c
bfd/elf32-txvu.c [new file with mode: 0644]
bfd/targets.c

index e713e2a..345328d 100644 (file)
@@ -31,6 +31,14 @@ else
        lose_these_too="${tic80_files} ${lose_these_too}"
 fi
 
+sky_files="cpu-txvu.c elf32-txvu.c"
+
+if ( echo $* | grep keep\-sky > /dev/null ) ; then
+       keep_these_too="${sky_files} ${keep_these_too}"
+else
+       lose_these_too="${sky_files} ${lose_these_too}"
+fi
+
 # All files listed between the "Things-to-keep:" line and the
 # "Files-to-sed:" line will be kept.  All other files will be removed.
 # Directories listed in this section will have their own Sanitize
@@ -514,6 +522,34 @@ else
        done
 fi
 
+sky_files="ChangeLog Makefile.in Makefile.am archures.c elf.c reloc.c targets.c config.bfd configure.in configure bfd-in2.h libbfd.h"
+if ( echo $* | grep keep\-sky > /dev/null ) ; then
+       for i in $sky_files ; do
+               if test ! -d $i && (grep sanitize-sky $i > /dev/null) ; then
+                       if [ -n "${verbose}" ] ; then
+                               echo Keeping sky stuff in $i
+                       fi
+               fi
+       done
+else
+       for i in $sky_files ; do
+               if test ! -d $i && (grep sanitize-sky $i > /dev/null) ; then
+                       if [ -n "${verbose}" ] ; then
+                               echo Removing traces of \"sky\" from $i...
+                       fi
+                       cp $i new
+                       sed '/start\-sanitize\-sky/,/end-\sanitize\-sky/d' < $i > new
+                       if [ -n "${safe}" -a ! -f .Recover/$i ] ; then
+                               if [ -n "${verbose}" ] ; then
+                                       echo Caching $i in .Recover...
+                               fi
+                               mv $i .Recover
+                       fi
+                       mv new $i
+               fi
+       done
+fi
+
 for i in * ; do
        if test ! -d $i && (grep sanitize $i > /dev/null) ; then
                echo '***' Some mentions of Sanitize are still left in $i! 1>&2
index 8fada51..dcd0571 100644 (file)
@@ -1,3 +1,16 @@
+start-sanitize-sky
+Mon Dec 22 15:14:28 1997  Doug Evans  <devans@canuck.cygnus.com>
+
+       * Makefile.am (ALL_MACHINES,BFD32_BACKENDS): Add txvu support.
+       (cpu-txvu.lo,elf32-txvu.lo): Add rules for.
+       * Makefile.in: Rebuild.
+       * config.bfd, configure.in: Add txvu support.
+       * configure: Regenerate.
+       * archures.c, elf.c, targets.c: Add txvu support.
+       * bfd-in2.h: Regenerate.
+       * cpu-txvu.c, elf32-txvu.c: New files.
+
+end-sanitize-sky
 Mon Dec 22 13:20:57 1997  Ian Lance Taylor  <ian@cygnus.com>
 
        * Makefile.am: Rebuild dependencies.
index 3392cf8..980fe0d 100644 (file)
@@ -69,6 +69,9 @@ ALL_MACHINES = \
        $(start-sanitize-tic80) \
        cpu-tic80.lo \
        $(end-sanitize-tic80) \
+       $(start-sanitize-sky) \
+       cpu-txvu.lo \
+       $(end-sanitize-sky) \
        cpu-v850.lo \
        cpu-vax.lo \
        cpu-we32k.lo \
@@ -164,6 +167,9 @@ BFD32_BACKENDS = \
        elf32-ppc.lo \
        elf32-sh.lo \
        elf32-sparc.lo \
+       $(start-sanitize-sky) \
+       elf32-txvu.lo \
+       $(end-sanitize-sky) \
        elf32-v850.lo \
        elf32.lo \
        elflink.lo \
@@ -589,6 +595,13 @@ coff-tic80.lo: coff-tic80.c $(INCDIR)/bfdlink.h elf-bfd.h \
   $(INCDIR)/coff/tic80.h $(INCDIR)/coff/internal.h coffcode.h
 end-sanitize-tic80:
 
+start-sanitize-sky:
+cpu-txvu.lo: cpu-txvu.c
+elf32-txvu.lo: elf32-txvu.c elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+  $(INCDIR)/elf/txvu.h elf32-target.h
+end-sanitize-sky:
+
 # What appears below is generated by a hacked mkdep using gcc -MM.
 
 # DO NOT DELETE THIS LINE -- mkdep uses it.
index 9a831bd..63664d2 100644 (file)
@@ -151,6 +151,9 @@ ALL_MACHINES = \
        $(start-sanitize-tic80) \
        cpu-tic80.lo \
        $(end-sanitize-tic80) \
+       $(start-sanitize-sky) \
+       cpu-txvu.lo \
+       $(end-sanitize-sky) \
        cpu-v850.lo \
        cpu-vax.lo \
        cpu-we32k.lo \
@@ -246,6 +249,9 @@ BFD32_BACKENDS = \
        elf32-ppc.lo \
        elf32-sh.lo \
        elf32-sparc.lo \
+       $(start-sanitize-sky) \
+       elf32-txvu.lo \
+       $(end-sanitize-sky) \
        elf32-v850.lo \
        elf32.lo \
        elflink.lo \
@@ -1035,6 +1041,13 @@ coff-tic80.lo: coff-tic80.c $(INCDIR)/bfdlink.h elf-bfd.h \
   $(INCDIR)/coff/tic80.h $(INCDIR)/coff/internal.h coffcode.h
 end-sanitize-tic80:
 
+start-sanitize-sky:
+cpu-txvu.lo: cpu-txvu.c
+elf32-txvu.lo: elf32-txvu.c elf-bfd.h $(INCDIR)/elf/common.h \
+  $(INCDIR)/elf/internal.h $(INCDIR)/elf/external.h $(INCDIR)/bfdlink.h \
+  $(INCDIR)/elf/txvu.h elf32-target.h
+end-sanitize-sky:
+
 # What appears below is generated by a hacked mkdep using gcc -MM.
 
 # DO NOT DELETE THIS LINE -- mkdep uses it.
index 92f30a5..59e1961 100644 (file)
@@ -158,6 +158,10 @@ DESCRIPTION
 . {* start-sanitize-tic80 *}
 .  bfd_arch_tic80,     {* TI TMS320c80 (MVP) *}
 . {* end-sanitize-tic80 *}
+. {* start-sanitize-sky *}
+.  bfd_arch_txvu,     {* TX VU *}
+.#define bfd_mach_txvu 0
+. {* end-sanitize-sky *}
 .  bfd_arch_v850,      {* NEC V850 *}
 .#define bfd_mach_v850          0
 . {* start-sanitize-v850e *}
@@ -168,7 +172,9 @@ DESCRIPTION
 .#define bfd_mach_arc_base 0
 .  bfd_arch_m32r,      {* Mitsubishi M32R/D *}
 .#define bfd_mach_m32r         0 {* backwards compatibility *}
+. {* start-sanitize-m32rx *}
 .#define bfd_mach_m32rx                'x'
+. {* end-sanitize-m32rx *}
 .  bfd_arch_mn10200,   {* Matsushita MN10200 *}
 .  bfd_arch_mn10300,   {* Matsushita MN10300 *}
 .  bfd_arch_last
@@ -236,6 +242,9 @@ extern const bfd_arch_info_type bfd_sparc_arch;
 /* start-sanitize-tic80 */
 extern const bfd_arch_info_type bfd_tic80_arch;
 /* end-sanitize-tic80 */
+/* start-sanitize-sky */
+extern const bfd_arch_info_type bfd_txvu_arch;
+/* end-sanitize-sky */
 extern const bfd_arch_info_type bfd_vax_arch;
 extern const bfd_arch_info_type bfd_we32k_arch;
 extern const bfd_arch_info_type bfd_z8k_arch;
@@ -275,6 +284,9 @@ static const bfd_arch_info_type * const bfd_archures_list[] =
 /* start-sanitize-tic80 */
   &bfd_tic80_arch,
 /* end-sanitize-tic80 */
+/* start-sanitize-sky */
+  &bfd_txvu_arch,
+/* end-sanitize-sky */
   &bfd_vax_arch,
   &bfd_we32k_arch,
   &bfd_z8k_arch,
index fc2651f..1a16e89 100644 (file)
@@ -1250,6 +1250,10 @@ enum bfd_architecture
   /* start-sanitize-tic80 */
   bfd_arch_tic80,      /* TI TMS320c80 (MVP) */
   /* end-sanitize-tic80 */
+  /* start-sanitize-sky */
+  bfd_arch_txvu,      /* TX VU */
+#define bfd_mach_txvu 0
+  /* end-sanitize-sky */
   bfd_arch_v850,       /* NEC V850 */
 #define bfd_mach_v850          0
   /* start-sanitize-v850e */
index facfcb3..d10a174 100755 (executable)
@@ -550,6 +550,14 @@ case "${targ}" in
     ;;
 
 # end-sanitize-tic80
+
+# start-sanitize-sky
+  txvu-*-*)
+    targ_defvec=bfd_elf32_txvu_vec
+    ;;
+
+# end-sanitize-tic80
+
   v850-*-*)
     targ_defvec=bfd_elf32_v850_vec
     ;;
index 87c2e3b..34203e4 100755 (executable)
@@ -2653,6 +2653,9 @@ do
     bfd_elf32_sh_vec)          tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_shl_vec)         tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_sparc_vec)       tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
+# start-sanitize-sky
+    bfd_elf32_txvu_vec)                tb="$tb elf32-txvu.lo elf32.lo $elf" ;;
+# end-sanitize-sky
     bfd_elf32_v850_vec)                tb="$tb elf32-v850.lo elf32.lo $elf" ;;
     bfd_elf64_big_generic_vec)         tb="$tb elf64-gen.lo elf64.lo $elf"
                                target64=true ;;
@@ -2824,17 +2827,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:2828: checking for $ac_hdr" >&5
+echo "configure:2831: 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
-#line 2833 "configure"
+#line 2836 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2838: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2841: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2863,12 +2866,12 @@ done
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:2867: checking for $ac_func" >&5
+echo "configure:2870: 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 <<EOF
-#line 2872 "configure"
+#line 2875 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -2891,7 +2894,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:2895: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:2898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
@@ -2916,7 +2919,7 @@ fi
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:2920: checking for working mmap" >&5
+echo "configure:2923: 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
@@ -2924,7 +2927,7 @@ else
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 2928 "configure"
+#line 2931 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -3064,7 +3067,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:3068: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:3071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
 then
   ac_cv_func_mmap_fixed_mapped=yes
 else
@@ -3089,12 +3092,12 @@ fi
 for ac_func in madvise mprotect
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:3093: checking for $ac_func" >&5
+echo "configure:3096: 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 <<EOF
-#line 3098 "configure"
+#line 3101 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -3117,7 +3120,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:3121: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:3124: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
   rm -rf conftest*
   eval "ac_cv_func_$ac_func=yes"
 else
index c07be1e..cff2661 100644 (file)
@@ -261,6 +261,10 @@ changequote([,])dnl
   sparc-*-netbsd* | sparc-*-openbsd*)
        COREFILE=netbsd-core.lo
        ;;
+  sparc*-*-linux*)
+       COREFILE=trad-core.lo
+       AC_DEFINE(TRAD_HEADER,"hosts/sparclinux.h")
+       ;;
   tahoe-*-*)
        COREFILE=trad-core.lo
        AC_DEFINE(TRAD_HEADER,"hosts/tahoe.h")
@@ -375,7 +379,7 @@ selarchs="$f"
 # Target backend .o files.
 tb=
 
-elf="elflink.lo"
+elf="elflink.lo dwarf2.lo"
 
 for vec in $selvecs
 do
@@ -427,6 +431,9 @@ do
     bfd_elf32_sh_vec)          tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_shl_vec)         tb="$tb elf32-sh.lo elf32.lo $elf coff-sh.lo" ;;
     bfd_elf32_sparc_vec)       tb="$tb elf32-sparc.lo elf32.lo $elf" ;;
+# start-sanitize-sky
+    bfd_elf32_txvu_vec)                tb="$tb elf32-txvu.lo elf32.lo $elf" ;;
+# end-sanitize-sky
     bfd_elf32_v850_vec)                tb="$tb elf32-v850.lo elf32.lo $elf" ;;
     bfd_elf64_big_generic_vec)         tb="$tb elf64-gen.lo elf64.lo $elf"
                                target64=true ;;
diff --git a/bfd/cpu-txvu.c b/bfd/cpu-txvu.c
new file mode 100644 (file)
index 0000000..77520ee
--- /dev/null
@@ -0,0 +1,35 @@
+/* BFD support for the TXVU processor.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+
+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"
+
+#define N(number, print, default, next)  \
+{  32, 32, 8, bfd_arch_txvu, number, "txvu", print, 4, \
+   default, bfd_default_compatible, bfd_default_scan, next }
+
+#if 0 /* Additional variants go here.  */
+static const bfd_arch_info_type arch_info_struct[] = 
+{
+};
+#endif
+
+const bfd_arch_info_type bfd_txvu_arch =
+  N( bfd_mach_txvu, "txvu", true, NULL );
index 1a5cf5d..ab9d757 100644 (file)
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2431,6 +2431,15 @@ assign_file_positions_for_segments (abfd)
          if (m->count > 0)
            {
              BFD_ASSERT (p->p_type == PT_LOAD);
+
+             if (p->p_vaddr < off)
+               {
+                 _bfd_error_handler ("%s: Not enough room for program headers, try linking with -N",
+                                     bfd_get_filename (abfd));
+                 bfd_set_error (bfd_error_bad_value);
+                 return false;
+               }
+             
              p->p_vaddr -= off;
              if (! m->p_paddr_valid)
                p->p_paddr -= off;
@@ -2900,6 +2909,11 @@ prep_headers (abfd)
     case bfd_arch_mn10300:
       i_ehdrp->e_machine = EM_CYGNUS_MN10300;
       break;
+/* start-sanitize-sky */
+    case bfd_arch_txvu:
+      i_ehdrp->e_machine = EM_CYGNUS_TXVU;
+      break;
+/* end-sanitize-sky */
       /* also note that EM_M32, AT&T WE32100 is unknown to bfd */
     default:
       i_ehdrp->e_machine = EM_NONE;
diff --git a/bfd/elf32-txvu.c b/bfd/elf32-txvu.c
new file mode 100644 (file)
index 0000000..96a067c
--- /dev/null
@@ -0,0 +1,362 @@
+/* TXVU-specific support for 32-bit ELF.
+   Copyright (C) 1997 Free Software Foundation, Inc.
+
+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"
+#include "elf-bfd.h"
+#include "elf/txvu.h"
+
+static reloc_howto_type *bfd_elf32_bfd_reloc_type_lookup
+  PARAMS ((bfd *abfd, bfd_reloc_code_real_type code));
+static void txvu_info_to_howto_rel
+  PARAMS ((bfd *, arelent *, Elf32_Internal_Rela *));
+static boolean txvu_elf_relocate_section
+  PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *,
+          Elf_Internal_Rela *, Elf_Internal_Sym *, asection **));
+
+/* Use RELA, not REL.  REL incurs complications one would rather not
+   deal with.  */
+/*#define USE_REL*/
+
+static reloc_howto_type txvu_elf_howto_table[] =
+{
+  /* This reloc does nothing.  */
+  HOWTO (R_TXVU_NONE,          /* type */
+        0,                     /* rightshift */
+        2,                     /* size (0 = byte, 1 = short, 2 = long) */
+        32,                    /* bitsize */
+        false,                 /* pc_relative */
+        0,                     /* bitpos */
+        complain_overflow_bitfield, /* complain_on_overflow */
+        bfd_elf_generic_reloc, /* special_function */
+        "R_TXVU_NONE",         /* name */
+        false,                 /* partial_inplace */
+        0,                     /* src_mask */
+        0,                     /* dst_mask */
+        false),                /* pcrel_offset */
+
+  /* insert reloc entries here */
+};
+\f
+/* Map BFD reloc types to TXVU ELF reloc types.  */
+
+struct txvu_reloc_map
+{
+  unsigned char bfd_reloc_val;
+  unsigned char elf_reloc_val;
+};
+
+static const struct txvu_reloc_map txvu_reloc_map[] =
+{
+  { BFD_RELOC_NONE, R_TXVU_NONE },
+  /* insert reloc entries here */
+};
+
+static reloc_howto_type *
+bfd_elf32_bfd_reloc_type_lookup (abfd, code)
+     bfd *abfd;
+     bfd_reloc_code_real_type code;
+{
+  unsigned int i;
+
+  for (i = 0;
+       i < sizeof (txvu_reloc_map) / sizeof (struct txvu_reloc_map);
+       i++)
+    {
+      if (txvu_reloc_map[i].bfd_reloc_val == code)
+       return &txvu_elf_howto_table[txvu_reloc_map[i].elf_reloc_val];
+    }
+
+  return NULL;
+}
+
+/* Set the howto pointer for an TXVU ELF reloc.  */
+
+static void
+txvu_info_to_howto_rel (abfd, cache_ptr, dst)
+     bfd *abfd;
+     arelent *cache_ptr;
+     Elf32_Internal_Rela *dst;
+{
+  unsigned int r_type = ELF32_R_TYPE (dst->r_info);
+  BFD_ASSERT (r_type < (unsigned int) R_TXVU_max);
+  cache_ptr->howto = &txvu_elf_howto_table[r_type];
+}
+\f
+/* Relocate a TXVU ELF section.
+
+   The RELOCATE_SECTION function is called by the new ELF backend linker
+   to handle the relocations for a section.
+
+   The relocs are always passed as Rela structures; if the section
+   actually uses Rel structures, the r_addend field will always be
+   zero.
+
+   This function is responsible for adjust the section contents as
+   necessary, and (if using Rela relocs and generating a
+   relocateable output file) adjusting the reloc addend as
+   necessary.
+
+   This function does not have to worry about setting the reloc
+   address or the reloc symbol index.
+
+   LOCAL_SYMS is a pointer to the swapped in local symbols.
+
+   LOCAL_SECTIONS is an array giving the section in the input file
+   corresponding to the st_shndx field of each local symbol.
+
+   The global hash table entry for the global symbols can be found
+   via elf_sym_hashes (input_bfd).
+
+   When generating relocateable output, this function must handle
+   STB_LOCAL/STT_SECTION symbols specially.  The output symbol is
+   going to be the section symbol corresponding to the output
+   section, which means that the addend must be adjusted
+   accordingly.  */
+
+static boolean
+txvu_elf_relocate_section (output_bfd, info, input_bfd, input_section,
+                          contents, relocs, local_syms, local_sections)
+     bfd *output_bfd;
+     struct bfd_link_info *info;
+     bfd *input_bfd;
+     asection *input_section;
+     bfd_byte *contents;
+     Elf_Internal_Rela *relocs;
+     Elf_Internal_Sym *local_syms;
+     asection **local_sections;
+{
+  Elf_Internal_Shdr *symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd);
+  Elf_Internal_Rela *rel, *relend;
+  bfd *dynobj = elf_hash_table (info)->dynobj;
+  /* Assume success.  */
+  boolean ret = true;
+
+  rel = relocs;
+  relend = relocs + input_section->reloc_count;
+  for (; rel < relend; rel++)
+    {
+      int r_type;
+      reloc_howto_type *howto;
+      unsigned long r_symndx;
+      /* We can't modify r_addend here as elf_link_input_bfd has an assert to
+        ensure it's zero (we use REL relocs, not RELA).  Therefore this
+        should be assigning zero to `addend', but for clarity we use
+        `r_addend'.  */
+      /* ??? The previous comment is old, revisit and delete.  */
+      bfd_vma addend = rel->r_addend;
+      bfd_vma offset = rel->r_offset;
+      struct elf_link_hash_entry *h;
+      Elf_Internal_Sym *sym;
+      asection *sec;
+      const char *sym_name;
+      bfd_reloc_status_type r;
+      const char *errmsg = NULL;
+
+      r_type = ELF32_R_TYPE (rel->r_info);
+      if (r_type < 0 || r_type >= (int) R_TXVU_max)
+       {
+         (*_bfd_error_handler) ("%s: unknown relocation type %d",
+                                bfd_get_filename (input_bfd),
+                                (int) r_type);
+         bfd_set_error (bfd_error_bad_value);
+         ret = false;
+         continue;
+       }
+
+      howto = txvu_elf_howto_table + r_type;
+      r_symndx = ELF32_R_SYM (rel->r_info);
+
+      if (info->relocateable)
+       {
+         /* This is a relocateable link.  We don't have to change
+            anything, unless the reloc is against a section symbol,
+            in which case we have to adjust according to where the
+            section symbol winds up in the output section.  */
+         sec = NULL;
+         if (r_symndx >= symtab_hdr->sh_info)
+           {
+             /* External symbol.  */
+             continue;
+           }
+
+         /* Local symbol.  */
+         sym = local_syms + r_symndx;
+         sym_name = "<local symbol>";
+         /* STT_SECTION: symbol is associated with a section.  */
+         if (ELF_ST_TYPE (sym->st_info) != STT_SECTION)
+           {
+             /* Symbol isn't associated with a section.  Nothing to do.  */
+             continue;
+           }
+
+         sec = local_sections[r_symndx];
+         addend += sec->output_offset + sym->st_value;
+         rel->r_addend = addend;
+
+         /* Addends are stored with relocs.  We're done.  */
+         continue;
+       }
+      else
+       {
+         bfd_vma relocation;
+
+         /* This is a final link.  */
+         h = NULL;
+         sym = NULL;
+         sec = NULL;
+
+         if (r_symndx < symtab_hdr->sh_info)
+           {
+             /* Local symbol.  */
+             sym = local_syms + r_symndx;
+             sec = local_sections[r_symndx];
+             sym_name = "<local symbol>";
+             relocation = (sec->output_section->vma
+                           + sec->output_offset
+                           + sym->st_value);
+           }
+         else
+           {
+             /* External symbol.  */
+             h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+             while (h->root.type == bfd_link_hash_indirect
+                    || h->root.type == bfd_link_hash_warning)
+               h = (struct elf_link_hash_entry *) h->root.u.i.link;
+             sym_name = h->root.root.string;
+
+             if (h->root.type == bfd_link_hash_defined
+                 || h->root.type == bfd_link_hash_defweak)
+               {
+                 sec = h->root.u.def.section;
+                 if (sec->output_section == NULL)
+                   relocation = 0;
+                 else
+                   relocation = (h->root.u.def.value
+                                 + sec->output_section->vma
+                                 + sec->output_offset);
+               }
+             else if (h->root.type == bfd_link_hash_undefweak)
+               relocation = 0;
+             else
+               {
+                 if (! ((*info->callbacks->undefined_symbol)
+                        (info, h->root.root.string, input_bfd,
+                         input_section, offset)))
+                   return false;
+                 relocation = 0;
+               }
+           }
+
+         /* Sanity check the address.  */
+         if (offset > input_section->_raw_size)
+           {
+             r = bfd_reloc_outofrange;
+             goto check_reloc;
+           }
+
+         switch ((int) r_type)
+           {
+             /* insert reloc handling code here */
+           default :
+             r = _bfd_final_link_relocate (howto, input_bfd, input_section,
+                                           contents, offset,
+                                           relocation, addend);
+             break;
+           }
+       }
+
+    check_reloc:
+
+      if (r != bfd_reloc_ok)
+       {
+         /* FIXME: This should be generic enough to go in a utility.  */
+         const char *name;
+
+         if (h != NULL)
+           name = h->root.root.string;
+         else
+           {
+             name = (bfd_elf_string_from_elf_section
+                     (input_bfd, symtab_hdr->sh_link, sym->st_name));
+             if (name == NULL || *name == '\0')
+               name = bfd_section_name (input_bfd, sec);
+           }
+
+         if (errmsg != NULL)
+           goto common_error;
+
+         switch (r)
+           {
+           case bfd_reloc_overflow:
+             if (! ((*info->callbacks->reloc_overflow)
+                    (info, name, howto->name, (bfd_vma) 0,
+                     input_bfd, input_section, offset)))
+               return false;
+             break;
+
+           case bfd_reloc_undefined:
+             if (! ((*info->callbacks->undefined_symbol)
+                    (info, name, input_bfd, input_section,
+                     offset)))
+               return false;
+             break;
+
+           case bfd_reloc_outofrange:
+             errmsg = "internal error: out of range error";
+             goto common_error;
+
+           case bfd_reloc_notsupported:
+             errmsg = "internal error: unsupported relocation error";
+             goto common_error;
+
+           case bfd_reloc_dangerous:
+             errmsg = "internal error: dangerous error";
+             goto common_error;
+
+           default:
+             errmsg = "internal error: unknown error";
+             /* fall through */
+
+           common_error:
+             if (!((*info->callbacks->warning)
+                   (info, errmsg, name, input_bfd, input_section,
+                    offset)))
+               return false;
+             break;
+           }
+       }
+    }
+
+  return ret;
+}
+\f
+#define ELF_ARCH               bfd_arch_txvu
+#define ELF_MACHINE_CODE       EM_CYGNUS_TXVU
+#define ELF_MAXPAGESIZE                0x1000
+
+#define TARGET_BIG_SYM          bfd_elf32_txvu_vec
+#define TARGET_BIG_NAME                "elf32-txvu"
+
+#define elf_info_to_howto                      txvu_info_to_howto_rel
+#define elf_backend_relocate_section           txvu_elf_relocate_section
+                                       
+#include "elf32-target.h"
index b8d4dd2..687ff9a 100644 (file)
@@ -483,10 +483,8 @@ extern const bfd_target armpei_big_vec;
 extern const bfd_target b_out_vec_big_host;
 extern const bfd_target b_out_vec_little_host;
 extern const bfd_target bfd_elf64_alpha_vec;
-/* start-sanitize-arc */
 extern const bfd_target bfd_elf32_bigarc_vec;
 extern const bfd_target bfd_elf32_littlearc_vec;
-/* end-sanitize-arc */
 extern const bfd_target bfd_elf32_big_generic_vec;
 extern const bfd_target bfd_elf32_bigmips_vec;
 extern const bfd_target bfd_elf64_bigmips_vec;
@@ -510,9 +508,10 @@ extern const bfd_target bfd_elf32_powerpcle_vec;
 extern const bfd_target bfd_elf32_sh_vec;
 extern const bfd_target bfd_elf32_shl_vec;
 extern const bfd_target bfd_elf32_sparc_vec;
-/* start-sanitize-v850 */
+/* start-sanitize-sky */
+extern const bfd_target bfd_elf32_txvu_vec;
+/* end-sanitize-sky */
 extern const bfd_target bfd_elf32_v850_vec;
-/* end-sanitize-v850 */
 extern const bfd_target bfd_elf64_big_generic_vec;
 extern const bfd_target bfd_elf64_little_generic_vec;
 extern const bfd_target bfd_elf64_sparc_vec;
@@ -541,6 +540,7 @@ extern const bfd_target bfd_powerpcle_pei_vec;
 extern const bfd_target i386pe_vec;
 extern const bfd_target i386pei_vec;
 extern const bfd_target go32coff_vec;
+extern const bfd_target go32stubbedcoff_vec;
 extern const bfd_target i386linux_vec;
 extern const bfd_target i386lynx_aout_vec;
 extern const bfd_target i386lynx_coff_vec;
@@ -576,7 +576,10 @@ extern const bfd_target pmac_xcoff_vec;
 extern const bfd_target rs6000coff_vec;
 extern const bfd_target shcoff_vec;
 extern const bfd_target shlcoff_vec;
+extern const bfd_target shcoff_small_vec;
+extern const bfd_target shlcoff_small_vec;
 extern const bfd_target sparcle_aout_vec;
+extern const bfd_target sparclinux_vec;
 extern const bfd_target sparclynx_aout_vec;
 extern const bfd_target sparclynx_coff_vec;
 extern const bfd_target sparcnetbsd_vec;
@@ -607,6 +610,7 @@ extern const bfd_target cisco_core_vec;
 extern const bfd_target hpux_core_vec;
 extern const bfd_target hppabsd_core_vec;
 extern const bfd_target irix_core_vec;
+extern const bfd_target netbsd_core_vec;
 extern const bfd_target osf_core_vec;
 extern const bfd_target sco_core_vec;
 extern const bfd_target trad_core_vec;
@@ -646,9 +650,7 @@ const bfd_target * const bfd_target_vector[] = {
 #ifdef BFD64
        &bfd_elf64_alpha_vec,
 #endif
-/* start-sanitize-arc */
        &bfd_elf32_bigarc_vec,
-/* end-sanitize-arc */
        &bfd_elf32_bigmips_vec,
 #ifdef BFD64
        &bfd_elf64_bigmips_vec,
@@ -661,9 +663,7 @@ const bfd_target * const bfd_target_vector[] = {
        &bfd_elf32_i386_vec,
        &bfd_elf32_i860_vec,
        &bfd_elf32_little_generic_vec,
-/* start-sanitize-arc */
        &bfd_elf32_littlearc_vec,
-/* end-sanitize-arc */
        &bfd_elf32_littlemips_vec,
 #ifdef BFD64
        &bfd_elf64_littlemips_vec,
@@ -675,9 +675,10 @@ const bfd_target * const bfd_target_vector[] = {
        &bfd_elf32_m88k_vec,
        &bfd_elf32_sparc_vec,
        &bfd_elf32_powerpc_vec,
-/* start-sanitize-v850 */
+/* start-sanitize-sky */
+       &bfd_elf32_txvu_vec,
+/* end-sanitize-sky */
        &bfd_elf32_v850_vec,
-/* end-sanitize-v850 */
 #ifdef BFD64                   /* No one seems to use this.  */
        &bfd_elf64_big_generic_vec,
        &bfd_elf64_little_generic_vec,
@@ -722,6 +723,7 @@ const bfd_target * const bfd_target_vector[] = {
        &bfd_powerpc_pei_vec,
        &bfd_powerpcle_pei_vec,
        &go32coff_vec,
+       &go32stubbedcoff_vec,
 #if 0
        /* Since a.out files lack decent magic numbers, no way to recognize
           which kind of a.out file it is.  */
@@ -790,7 +792,10 @@ const bfd_target * const bfd_target_vector[] = {
        &ppcboot_vec,
        &shcoff_vec,
        &shlcoff_vec,
+       &shcoff_small_vec,
+       &shlcoff_small_vec,
        &sparcle_aout_vec,
+       &sparclinux_vec,
        &sparclynx_aout_vec,
        &sparclynx_coff_vec,
        &sparcnetbsd_vec,
@@ -867,13 +872,10 @@ struct targmatch
   const char *triplet;
   /* The BFD vector.  If this is NULL, then the vector is found by
      searching forward for the next structure with a non NULL vector
-     field.  If this is UNSUPPORTED_TARGET, then the target is not
-     supported.  */
+     field.  */
   const bfd_target *vector;
 };
 
-#define UNSUPPORTED_TARGET ((const bfd_target *) 1)
-
 /* targmatch.h is built by Makefile out of config.bfd.  */
 static const struct targmatch bfd_target_match[] = {
 #include "targmatch.h"
@@ -904,8 +906,7 @@ find_target (name)
        {
          while (match->vector == NULL)
            ++match;
-         if (match->vector != UNSUPPORTED_TARGET)
-           return match->vector;
+         return match->vector;
          break;
        }
     }
@@ -931,41 +932,11 @@ boolean
 bfd_set_default_target (name)
      const char *name;
 {
-  const bfd_target *old_default;
   const bfd_target *target;
 
-  old_default = bfd_default_vector[0];
-  if (old_default != NULL)
-    {
-      register const struct targmatch *match;
-
-      /* Try to save some strcmp and fnmatch calls by seeing if we
-         already have the default.  */
-
-      if (strcmp (name, old_default->name) == 0)
-       return true;
-
-      for (match = &bfd_target_match[0]; match->triplet != NULL; match++)
-       {
-         if (match->vector == old_default)
-           {
-             const struct targmatch *back;
-
-             back = match;
-             do
-               {
-                 if (fnmatch (back->triplet, name, 0) == 0)
-                   return true;
-
-                 if (back == &bfd_target_match[0])
-                   break;
-
-                 --back;
-               }
-             while (back->vector == NULL);
-           }
-       }
-    }
+  if (bfd_default_vector[0] != NULL
+      && strcmp (name, bfd_default_vector[0]->name) == 0)
+    return true;
 
   target = find_target (name);
   if (target == NULL)