This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH/RFA] Ambiguity problem of REL objects on ELF sh*-*-*


Alan Modra <amodra@bigpond.net.au> wrote:
>   Thanks for looking at this problem.  I'd like to see a solution
> that is a little more maintainable though.  I suggest putting
> the associated targets into config.bfd and modifying the existing
> mechanism for extracting DEFAULT_VECTOR to also define
> ASSOCIATED_VECS, which will then be stored in a static var
> declared in target.c.  That way we keep target selection in one
> place.  Hmm, perhaps you could even use targ_selvecs, choosing
> the first of targ_selvecs that matches any of the set of
> ambiguous vectors.

Cool! Here is a revised patch according to your suggestion. I've
just tested it for
  sh-unknown-elf, sh-unknown-linux-gnu, sh64-unknown-linux-gnu,
  sh-unknown-netbsdelf and i686-pc-linux-gnu
with/without --enable-targets=all and found no new regressions.
Thanks a lot.

Regards,
	kaz

--
2002-11-01  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

[bfd]
	* 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.
	* format.c (bfd_check_format_matches): Permit a target if it
	is an associated target.
	* 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.

[opcodes]
	* sh-dis.c (INCLUDE_SHMEDIA): Define if ARCH_all was defined.

diff -u3prN ORIG/src/bfd/config.bfd LOCAL/src/bfd/config.bfd
--- ORIG/src/bfd/config.bfd	Sat Oct 26 11:59:55 2002
+++ LOCAL/src/bfd/config.bfd	Fri Nov  1 22:26:48 2002
@@ -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*)
diff -u3prN ORIG/src/bfd/configure.in LOCAL/src/bfd/configure.in
--- ORIG/src/bfd/configure.in	Wed Oct 23 21:05:15 2002
+++ LOCAL/src/bfd/configure.in	Fri Nov  1 22:26:48 2002
@@ -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)
diff -u3prN ORIG/src/bfd/format.c LOCAL/src/bfd/format.c
--- ORIG/src/bfd/format.c	Sat Oct 26 11:59:56 2002
+++ LOCAL/src/bfd/format.c	Fri Nov  1 22:33:37 2002
@@ -235,6 +235,25 @@ bfd_check_format_matches (abfd, format, 
 	      break;
 	    }
 
+	  /* Permit also if it is an associated target.  */
+	  if (bfd_associated_vector)
+	    {
+	      const bfd_target **assoc = bfd_associated_vector;
+
+	      while (*assoc)
+		{
+		  if (temp == *assoc)
+		    break;
+		  ++assoc;
+		}
+
+	      if (*assoc)
+		{
+		  match_count = 1;
+		  break;
+		}
+	    }
+
 	  if (matching)
 	    matching_vector[match_count] = temp->name;
 
diff -u3prN ORIG/src/bfd/targets.c LOCAL/src/bfd/targets.c
--- ORIG/src/bfd/targets.c	Wed Oct 23 21:05:20 2002
+++ LOCAL/src/bfd/targets.c	Fri Nov  1 22:32:42 2002
@@ -859,6 +859,8 @@ static const bfd_target * const _bfd_tar
 	&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_tar
 	&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
@@ -1105,6 +1109,17 @@ const bfd_target *bfd_default_vector[] =
 #endif
 	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
diff -u3prN ORIG/src/bfd/libbfd-in.h LOCAL/src/bfd/libbfd-in.h
--- ORIG/src/bfd/libbfd-in.h	Wed Jun  5 12:43:10 2002
+++ LOCAL/src/bfd/libbfd-in.h	Fri Nov  1 22:26:48 2002
@@ -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.  */
 
diff -u3prN ORIG/src/opcodes/sh-dis.c LOCAL/src/opcodes/sh-dis.c
--- ORIG/src/opcodes/sh-dis.c	Thu May 23 03:16:45 2002
+++ LOCAL/src/opcodes/sh-dis.c	Fri Nov  1 22:26:48 2002
@@ -24,6 +24,10 @@ Foundation, Inc., 59 Temple Place - Suit
 #include "sh-opc.h"
 #include "dis-asm.h"
 
+#ifdef ARCH_all
+#define INCLUDE_SHMEDIA
+#endif
+
 static void print_movxy
   PARAMS ((sh_opcode_info *, int, int, fprintf_ftype, void *));
 static void print_insn_ddt PARAMS ((int, struct disassemble_info *));


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]