* config.bfd (sh-*-linux*): Use bfd_elf*_sh64*lin_vec as sh64
authorAlan Modra <amodra@gmail.com>
Tue, 5 Nov 2002 01:18:56 +0000 (01:18 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 5 Nov 2002 01:18:56 +0000 (01:18 +0000)
vectors in target_selvecs.
(shle-*-netbsdelf*): Use bfd_elf*_sh64*nbsd_vec as sh64 vectors
in target_selvecs.
(sh-*-netbsdelf*): Likewise.
* configure.in (assocvecs): New variable.  Handle assocvecs like
selvecs.
* configure: Regenerate.
* format.c (bfd_check_format_matches): Store bfd_target pointers
in matching_vector instead of target names.  Select first target
from bfd_associated_vector that matches a list of ambiguous targets.
* targets.c (_bfd_associated_vector): New array.
(bfd_associated_vector): New variable.
(_bfd_target_vector): Add bfd_elf*_sh64*lin_vec.
* libbfd-in.h (bfd_associated_vector): Declare.
* libbfd.h: Regenerate.

bfd/ChangeLog
bfd/config.bfd
bfd/configure
bfd/configure.in
bfd/format.c
bfd/libbfd-in.h
bfd/libbfd.h
bfd/targets.c

index c2101974e1375706437a8627158e6a268598c624..4d08a74c5e53b14a5e37cd1b7b0f1b7217c62b55 100644 (file)
@@ -1,3 +1,23 @@
+2002-11-05  Kaz Kojima  <kkojima@rr.iij4u.or.jp>
+           Alan Modra  <amodra@bigpond.net.au>
+
+       * config.bfd (sh-*-linux*): Use bfd_elf*_sh64*lin_vec as sh64
+       vectors in target_selvecs.
+       (shle-*-netbsdelf*): Use bfd_elf*_sh64*nbsd_vec as sh64 vectors
+       in target_selvecs.
+       (sh-*-netbsdelf*): Likewise.
+       * configure.in (assocvecs): New variable.  Handle assocvecs like
+       selvecs.
+       * configure: Regenerate.
+       * format.c (bfd_check_format_matches): Store bfd_target pointers
+       in matching_vector instead of target names.  Select first target
+       from bfd_associated_vector that matches a list of ambiguous targets.
+       * targets.c (_bfd_associated_vector): New array.
+       (bfd_associated_vector): New variable.
+       (_bfd_target_vector): Add bfd_elf*_sh64*lin_vec.
+       * libbfd-in.h (bfd_associated_vector): Declare.
+       * libbfd.h: Regenerate.
+
 2002-11-05  Elias Athanasopoulos  <eathan@otenet.gr>
 
        * vms-gsd.c (_bfd_vms_write_gsd): Check that symbol->udata.p is
index c37dc75854cbf6ad216c55ff84310b41728ba15d..596d6de30b5e7a3a4191b8b70c288596daeb230b 100644 (file)
@@ -949,7 +949,7 @@ case "${targ}" in
     targ_defvec=bfd_elf32_shblin_vec
     targ_selvecs=bfd_elf32_shlin_vec
 #ifdef BFD64
-    targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec"
+    targ_selvecs="${targ_selvecs} bfd_elf32_sh64lin_vec bfd_elf32_sh64blin_vec bfd_elf64_sh64lin_vec bfd_elf64_sh64blin_vec"
 #endif
     ;;
   sh*eb-*-linux*)
@@ -985,7 +985,7 @@ case "${targ}" in
     targ_defvec=bfd_elf32_shlnbsd_vec
     targ_selvecs="bfd_elf32_shnbsd_vec shcoff_vec shlcoff_vec"
 #ifdef BFD64
-    targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec"
+    targ_selvecs="${targ_selvecs} bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec"
 #endif
     ;;
   sh*le-*-netbsdelf*)
@@ -996,7 +996,7 @@ case "${targ}" in
     targ_defvec=bfd_elf32_shnbsd_vec
     targ_selvecs="bfd_elf32_shlnbsd_vec shcoff_vec shlcoff_vec"
 #ifdef BFD64
-    targ_selvecs="${targ_selvecs} bfd_elf32_sh64_vec bfd_elf32_sh64l_vec bfd_elf64_sh64_vec bfd_elf64_sh64l_vec"
+    targ_selvecs="${targ_selvecs} bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec"
 #endif
     ;;
   sh*-*-netbsdelf*)
index 794cb62055141f0f23429515f9484e35fa7d1f8d..294554eb04d636068e8fc7fe11b3b42dfeb31746 100755 (executable)
@@ -5975,12 +5975,14 @@ fi
 all_targets=false
 defvec=
 selvecs=
+assocvecs=
 selarchs=
 TDEFINES=
 for targ in $target $canon_targets
 do
     if test "x$targ" = "xall"; then
         all_targets=true
+       assocvecs="$assocvecs $targ_defvec $targ_selvecs"
     else
        . $srcdir/config.bfd
        if test "x$targ" = "x$target"; then
@@ -6011,6 +6013,17 @@ done
 selvecs="$f"
 
 
+# uniq the associated vectors in all the configured targets.
+f=""
+for i in $assocvecs ; do
+    case " $f " in
+    *" $i "*) ;;
+    *) f="$f $i" ;;
+    esac
+done
+assocvecs="$f"
+
+
 # uniq the architectures in all the configured targets.
 f=""
 for i in $selarchs ; do
@@ -6320,9 +6333,12 @@ if test x${all_targets} = xtrue ; then
   selvecs=
   havevecs=
   selarchs=
+  test -n "$assocvecs" &&
+    assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
 else   # all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
+  assocvecs=
   test -n "$selvecs" &&
     havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
   test -n "$selvecs" &&
@@ -6343,10 +6359,10 @@ case ${host64}-${target64}-${want64} in
     if test -n "$GCC" ; then
        bad_64bit_gcc=no;
        echo $ac_n "checking for gcc version with buggy 64-bit support""... $ac_c" 1>&6
-echo "configure:6347: checking for gcc version with buggy 64-bit support" >&5
+echo "configure:6363: checking for gcc version with buggy 64-bit support" >&5
        # Add more tests for gcc versions with non-working 64-bit support here.
        cat > conftest.$ac_ext <<EOF
-#line 6350 "configure"
+#line 6366 "configure"
 #include "confdefs.h"
 :__GNUC__:__GNUC_MINOR__:__i386__:
 EOF
@@ -6383,6 +6399,7 @@ esac
 tdefaults=""
 test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
 test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
+test -n "${assocvecs}" && tdefaults="${tdefaults} -DASSOCIATED_VECS='${assocvecs}'"
 test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
 test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
 
@@ -6391,17 +6408,17 @@ for ac_hdr in stdlib.h unistd.h sys/stat.h sys/types.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6395: checking for $ac_hdr" >&5
+echo "configure:6412: 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 6400 "configure"
+#line 6417 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6405: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6422: \"$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*
@@ -6430,12 +6447,12 @@ done
 for ac_func in getpagesize
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6434: checking for $ac_func" >&5
+echo "configure:6451: 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 6439 "configure"
+#line 6456 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6458,7 +6475,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6479: \"$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
@@ -6483,7 +6500,7 @@ fi
 done
 
 echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6487: checking for working mmap" >&5
+echo "configure:6504: 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
@@ -6491,7 +6508,7 @@ else
   ac_cv_func_mmap_fixed_mapped=no
 else
   cat > conftest.$ac_ext <<EOF
-#line 6495 "configure"
+#line 6512 "configure"
 #include "confdefs.h"
 
 /* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6644,7 +6661,7 @@ main()
 }
 
 EOF
-if { (eval echo configure:6648: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6665: \"$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
@@ -6669,12 +6686,12 @@ fi
 for ac_func in madvise mprotect
 do
 echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6673: checking for $ac_func" >&5
+echo "configure:6690: 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 6678 "configure"
+#line 6695 "configure"
 #include "confdefs.h"
 /* System header to define __stub macros and hopefully few prototypes,
     which can conflict with char $ac_func(); below.  */
@@ -6697,7 +6714,7 @@ $ac_func();
 
 ; return 0; }
 EOF
-if { (eval echo configure:6701: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6718: \"$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
index b59089d5e8f86c01755169ff90d6ac7db5420ad2..7b41ad23eb191ef51e74d162d9fa76b657d8371d 100644 (file)
@@ -471,12 +471,14 @@ fi
 all_targets=false
 defvec=
 selvecs=
+assocvecs=
 selarchs=
 TDEFINES=
 for targ in $target $canon_targets
 do
     if test "x$targ" = "xall"; then
         all_targets=true
+       assocvecs="$assocvecs $targ_defvec $targ_selvecs"
     else
        . $srcdir/config.bfd
        if test "x$targ" = "x$target"; then
@@ -507,6 +509,17 @@ done
 selvecs="$f"
 
 
+# uniq the associated vectors in all the configured targets.
+f=""
+for i in $assocvecs ; do
+    case " $f " in
+    *" $i "*) ;;
+    *) f="$f $i" ;;
+    esac
+done
+assocvecs="$f"
+
+
 # uniq the architectures in all the configured targets.
 f=""
 for i in $selarchs ; do
@@ -816,9 +829,12 @@ if test x${all_targets} = xtrue ; then
   selvecs=
   havevecs=
   selarchs=
+  test -n "$assocvecs" &&
+    assocvecs=`echo $assocvecs | sed -e 's/^/\&/' -e 's/ \(.\)/,\&\1/g'`
 else   # all_targets is true
   # Only set these if they will be nonempty, for the clever echo.
   havevecs=
+  assocvecs=
   test -n "$selvecs" &&
     havevecs=`echo $selvecs | sed -e 's/^/-DHAVE_/' -e 's/ \(.\)/ -DHAVE_\1/g'`
   test -n "$selvecs" &&
@@ -866,6 +882,7 @@ AC_SUBST(bfd_default_target_size)
 tdefaults=""
 test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
 test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
+test -n "${assocvecs}" && tdefaults="${tdefaults} -DASSOCIATED_VECS='${assocvecs}'"
 test -n "${selarchs}" && tdefaults="${tdefaults} -DSELECT_ARCHITECTURES='${selarchs}'"
 test -n "${havevecs}" && tdefaults="${tdefaults} ${havevecs}"
 AC_SUBST(tdefaults)
index ef6b46edfb81639321544fe7180eee3c9b8f17f8..33291d0f94437c47513b6fc493fc44845137f293 100644 (file)
@@ -119,8 +119,9 @@ bfd_check_format_matches (abfd, format, matching)
      char ***matching;
 {
   extern const bfd_target binary_vec;
-  const bfd_target * const *target, *save_targ, *right_targ, *ar_right_targ;
-  char **matching_vector = NULL;
+  const bfd_target * const *target;
+  const bfd_target **matching_vector = NULL;
+  const bfd_target *save_targ, *right_targ, *ar_right_targ;
   int match_count;
   int ar_match_index;
 
@@ -145,8 +146,8 @@ bfd_check_format_matches (abfd, format, matching)
       bfd_size_type amt;
 
       *matching = NULL;
-      amt = sizeof (char *) * 2 * _bfd_target_vector_entries;
-      matching_vector = (char **) bfd_malloc (amt);
+      amt = sizeof (*matching_vector) * 2 * _bfd_target_vector_entries;
+      matching_vector = (const bfd_target **) bfd_malloc (amt);
       if (!matching_vector)
        return false;
     }
@@ -170,7 +171,7 @@ bfd_check_format_matches (abfd, format, matching)
          abfd->xvec = right_targ;      /* Set the target as returned.  */
 
          if (matching)
-           free (matching_vector);
+           free ((PTR) matching_vector);
 
          return true;                  /* File position has moved, BTW.  */
        }
@@ -193,7 +194,7 @@ bfd_check_format_matches (abfd, format, matching)
          abfd->format = bfd_unknown;
 
          if (matching)
-           free (matching_vector);
+           free ((PTR) matching_vector);
 
          bfd_set_error (bfd_error_file_not_recognized);
 
@@ -236,7 +237,7 @@ bfd_check_format_matches (abfd, format, matching)
            }
 
          if (matching)
-           matching_vector[match_count] = temp->name;
+           matching_vector[match_count] = temp;
 
          match_count++;
 
@@ -259,7 +260,7 @@ bfd_check_format_matches (abfd, format, matching)
          if (ar_right_targ != bfd_default_vector[0])
            ar_right_targ = *target;
          if (matching)
-           matching_vector[ar_match_index] = (*target)->name;
+           matching_vector[ar_match_index] = *target;
          ar_match_index++;
        }
       else if (err != bfd_error_wrong_format)
@@ -268,7 +269,7 @@ bfd_check_format_matches (abfd, format, matching)
          abfd->format = bfd_unknown;
 
          if (matching)
-           free (matching_vector);
+           free ((PTR) matching_vector);
 
          return false;
        }
@@ -289,7 +290,27 @@ bfd_check_format_matches (abfd, format, matching)
            {
              memcpy (matching_vector,
                      matching_vector + _bfd_target_vector_entries,
-                     sizeof (char *) * match_count);
+                     sizeof (*matching_vector) * match_count);
+           }
+       }
+    }
+
+  if (match_count > 1 && bfd_associated_vector != NULL)
+    {
+      const bfd_target * const *assoc = bfd_associated_vector;
+
+      while ((right_targ = *assoc++) != NULL)
+       {
+         int i = match_count;
+
+         while (--i >= 0)
+           if (matching_vector[i] == right_targ)
+             break;
+
+         if (i >= 0)
+           {
+             match_count = 1;
+             break;
            }
        }
     }
@@ -299,7 +320,7 @@ bfd_check_format_matches (abfd, format, matching)
       abfd->xvec = right_targ;         /* Change BFD's target permanently.  */
 
       if (matching)
-       free (matching_vector);
+       free ((PTR) matching_vector);
 
       return true;                     /* File position has moved, BTW.  */
     }
@@ -312,7 +333,7 @@ bfd_check_format_matches (abfd, format, matching)
       bfd_set_error (bfd_error_file_not_recognized);
 
       if (matching)
-       free (matching_vector);
+       free ((PTR) matching_vector);
     }
   else
     {
@@ -320,8 +341,15 @@ bfd_check_format_matches (abfd, format, matching)
 
       if (matching)
        {
-         *matching = matching_vector;
+         *matching = (char **) matching_vector;
          matching_vector[match_count] = NULL;
+         /* Return target names.  This is a little nasty.  Maybe we
+            should do another bfd_malloc?  */
+         while (--match_count >= 0)
+           {
+             const char *name = matching_vector[match_count]->name;
+             *(const char **) &matching_vector[match_count] = name;
+           }
        }
     }
 
index 776dcd62f910ce620da3e11c5504c001a1178446..00d5bd3a6b97955b1e3dff34a500d9e3365db5d3 100644 (file)
@@ -567,6 +567,9 @@ extern bfd *bfd_last_cache;
 extern const bfd_target * const *bfd_target_vector;
 extern const bfd_target *bfd_default_vector[];
 
+/* List of associated target vectors.  */
+extern const bfd_target * const *bfd_associated_vector;
+
 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
    other common header files.  */
 
index ef001f335308b302e3e743334aa84a8b3156d45a..6d40e91cbaf17f31ab9c0dd51c699d2e768017f9 100644 (file)
@@ -572,6 +572,9 @@ extern bfd *bfd_last_cache;
 extern const bfd_target * const *bfd_target_vector;
 extern const bfd_target *bfd_default_vector[];
 
+/* List of associated target vectors.  */
+extern const bfd_target * const *bfd_associated_vector;
+
 /* Functions shared by the ECOFF and MIPS ELF backends, which have no
    other common header files.  */
 
index e665898bc63780e0b71a7fb114dae8fc416a783c..a6a0d17e826cf2c017c00a11ae04b2afebbdd69e 100644 (file)
@@ -859,6 +859,8 @@ static const bfd_target * const _bfd_target_vector[] = {
        &bfd_elf32_sh64l_vec,
        &bfd_elf32_sh64lnbsd_vec,
        &bfd_elf32_sh64nbsd_vec,
+       &bfd_elf32_sh64lin_vec,
+       &bfd_elf32_sh64blin_vec,
 #endif
        &bfd_elf32_sparc_vec,
        &bfd_elf32_tradbigmips_vec,
@@ -889,6 +891,8 @@ static const bfd_target * const _bfd_target_vector[] = {
        &bfd_elf64_sh64l_vec,
        &bfd_elf64_sh64lnbsd_vec,
        &bfd_elf64_sh64nbsd_vec,
+       &bfd_elf64_sh64lin_vec,
+       &bfd_elf64_sh64blin_vec,
 #if 0
        &bfd_elf64_sparc_vec,
 #endif
@@ -1106,6 +1110,17 @@ const bfd_target *bfd_default_vector[] = {
        NULL
 };
 
+/* bfd_associated_vector[] contains the associated target vectors used
+   to reduce the ambiguity in bfd_check_format_matches.  */
+
+static const bfd_target *_bfd_associated_vector[] = {
+#ifdef ASSOCIATED_VECS
+       ASSOCIATED_VECS,
+#endif
+       NULL
+};
+const bfd_target * const *bfd_associated_vector = _bfd_associated_vector;
+
 /* When there is an ambiguous match, bfd_check_format_matches puts the
    names of the matching targets in an array.  This variable is the maximum
    number of entries that the array could possibly need.  */
This page took 0.039967 seconds and 4 git commands to generate.