This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Not linking 32-bit and 64-bit objects
I think we may as well make bfd_default_compatible test for matching
word size. This change will affect hppa, powerpc, mips, s390 and sh.
sparc, and x86 (as of a few hours ago) already checked for matching
word size.
cpu-i370.c:i370_compatible behaved more or less the same as
bfd_default_compatible, so I zapped it. cpu-h8300.c:compatible
needed to check the arch to be safe.
bfd/ChangeLog
* archures.c (bfd_default_compatible): Test bits_per_word.
* cpu-i386.c (i386_compatible): Remove. Replace occurrences with
bfd_default_compatible.
* cpu-i370.c (i370_compatible): Likewise.
* cpu-sparc.c (sparc_compatible): Likewise.
* cpu-h8300.c (compatible): Test in->arch == out->arch.
Index: bfd/archures.c
===================================================================
RCS file: /cvs/src/src/bfd/archures.c,v
retrieving revision 1.46
diff -u -p -r1.46 archures.c
--- archures.c 2002/02/19 18:22:16 1.46
+++ archures.c 2002/03/13 06:45:55
@@ -722,6 +722,9 @@ bfd_default_compatible (a, b)
if (a->arch != b->arch)
return NULL;
+ if (a->bits_per_word != b->bits_per_word)
+ return NULL;
+
if (a->mach > b->mach)
return a;
Index: bfd/cpu-h8300.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-h8300.c,v
retrieving revision 1.6
diff -u -p -r1.6 cpu-h8300.c
--- cpu-h8300.c 2001/09/18 09:57:22 1.6
+++ cpu-h8300.c 2002/03/13 06:45:55
@@ -91,7 +91,7 @@ compatible (in, out)
const bfd_arch_info_type *out;
{
/* It's really not a good idea to mix and match modes. */
- if (in->mach != out->mach)
+ if (in->arch != out->arch || in->mach != out->mach)
return 0;
else
return in;
Index: bfd/cpu-i370.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-i370.c,v
retrieving revision 1.3
diff -u -p -r1.3 cpu-i370.c
--- cpu-i370.c 2001/03/08 21:03:58 1.3
+++ cpu-i370.c 2002/03/13 06:45:55
@@ -24,27 +24,6 @@ Foundation, Inc., 59 Temple Place - Suit
#include "sysdep.h"
#include "libbfd.h"
-/* The common i360/370 architecture comes in many forms */
-
-static const bfd_arch_info_type *i370_compatible
- PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
-static const bfd_arch_info_type *
-i370_compatible (a, b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- BFD_ASSERT (a->arch == bfd_arch_i370);
- switch (b->arch)
- {
- default:
- return NULL;
- case bfd_arch_i370:
- return bfd_default_compatible (a, b);
- }
- /*NOTREACHED*/
-}
-
static const bfd_arch_info_type arch_info_struct[] =
{
/* hack alert: old old machines are really 16 and 24 bit arch ... */
@@ -58,7 +37,7 @@ static const bfd_arch_info_type arch_inf
"i370:360",
3,
false, /* not the default */
- i370_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[1]
},
@@ -72,7 +51,7 @@ static const bfd_arch_info_type arch_inf
"i370:370",
3,
false, /* not the default */
- i370_compatible,
+ bfd_default_compatible,
bfd_default_scan,
0
},
@@ -89,7 +68,7 @@ const bfd_arch_info_type bfd_i370_arch =
"i370:common",
3,
true, /* the default */
- i370_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[0]
};
Index: bfd/cpu-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-i386.c,v
retrieving revision 1.7
diff -u -p -r1.7 cpu-i386.c
--- cpu-i386.c 2002/03/12 13:16:05 1.7
+++ cpu-i386.c 2002/03/13 06:45:55
@@ -22,22 +22,6 @@ Foundation, Inc., 59 Temple Place - Suit
#include "sysdep.h"
#include "libbfd.h"
-/* Don't mix 32 bit and 64 bit files. */
-
-static const bfd_arch_info_type *i386_compatible
- PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
-static const bfd_arch_info_type *
-i386_compatible (a, b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->bits_per_word != b->bits_per_word)
- return NULL;
-
- return bfd_default_compatible (a, b);
-}
-
const bfd_arch_info_type bfd_i386_arch_intel_syntax =
{
32, /* 32 bits in a word */
@@ -49,7 +33,7 @@ const bfd_arch_info_type bfd_i386_arch_i
"i386:intel",
3,
true,
- i386_compatible,
+ bfd_default_compatible,
bfd_default_scan ,
0,
};
@@ -64,7 +48,7 @@ const bfd_arch_info_type bfd_x86_64_arch
"x86-64:intel",
3,
true,
- i386_compatible,
+ bfd_default_compatible,
bfd_default_scan ,
&bfd_i386_arch_intel_syntax,
};
@@ -79,7 +63,7 @@ static const bfd_arch_info_type i8086_ar
"i8086",
3,
false,
- i386_compatible,
+ bfd_default_compatible,
bfd_default_scan ,
&bfd_x86_64_arch_intel_syntax,
};
@@ -95,7 +79,7 @@ const bfd_arch_info_type bfd_x86_64_arch
"x86-64",
3,
true,
- i386_compatible,
+ bfd_default_compatible,
bfd_default_scan ,
&i8086_arch,
};
@@ -111,7 +95,7 @@ const bfd_arch_info_type bfd_i386_arch =
"i386",
3,
true,
- i386_compatible,
+ bfd_default_compatible,
bfd_default_scan ,
&bfd_x86_64_arch
};
Index: bfd/cpu-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/cpu-sparc.c,v
retrieving revision 1.4
diff -u -p -r1.4 cpu-sparc.c
--- cpu-sparc.c 2001/03/08 21:03:58 1.4
+++ cpu-sparc.c 2002/03/13 06:45:55
@@ -1,5 +1,6 @@
/* BFD support for the SPARC architecture.
- Copyright 1992, 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
+ Copyright 1992, 1995, 1996, 1998, 2000, 2002
+ Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -21,22 +22,6 @@ Foundation, Inc., 59 Temple Place - Suit
#include "sysdep.h"
#include "libbfd.h"
-/* Don't mix 32 bit and 64 bit files. */
-
-static const bfd_arch_info_type *sparc_compatible
- PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
-
-static const bfd_arch_info_type *
-sparc_compatible (a, b)
- const bfd_arch_info_type *a;
- const bfd_arch_info_type *b;
-{
- if (a->bits_per_word != b->bits_per_word)
- return NULL;
-
- return bfd_default_compatible (a, b);
-}
-
static const bfd_arch_info_type arch_info_struct[] =
{
{
@@ -49,7 +34,7 @@ static const bfd_arch_info_type arch_inf
"sparc:sparclet",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[1],
},
@@ -63,7 +48,7 @@ static const bfd_arch_info_type arch_inf
"sparc:sparclite",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[2],
},
@@ -77,7 +62,7 @@ static const bfd_arch_info_type arch_inf
"sparc:v8plus",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[3],
},
@@ -91,7 +76,7 @@ static const bfd_arch_info_type arch_inf
"sparc:v8plusa",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[4],
},
@@ -105,7 +90,7 @@ static const bfd_arch_info_type arch_inf
"sparc:sparclite_le",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[5],
},
@@ -119,7 +104,7 @@ static const bfd_arch_info_type arch_inf
"sparc:v9",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[6],
},
@@ -133,7 +118,7 @@ static const bfd_arch_info_type arch_inf
"sparc:v9a",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[7],
},
@@ -147,7 +132,7 @@ static const bfd_arch_info_type arch_inf
"sparc:v8plusb",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[8],
},
@@ -161,7 +146,7 @@ static const bfd_arch_info_type arch_inf
"sparc:v9b",
3,
false,
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
0,
}
@@ -178,7 +163,7 @@ const bfd_arch_info_type bfd_sparc_arch
"sparc",
3,
true, /* the default */
- sparc_compatible,
+ bfd_default_compatible,
bfd_default_scan,
&arch_info_struct[0],
};
--
Alan Modra
IBM OzLabs - Linux Technology Centre