summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-12-23 10:45:02 +0000
committerNick Clifton <nickc@redhat.com>2002-12-23 10:45:02 +0000
commitf7b105487bd2cd1ba86079003bf6d66f1772401f (patch)
treeccb2e89f8f194b4198b5aa2663043f48de92d677 /bfd
parent5124c6969f1ccf1d5053f828cc1cdb2a4a9d64dc (diff)
downloadgdb-f7b105487bd2cd1ba86079003bf6d66f1772401f.tar.gz
Change linker's default behaviour - it will now reject binary files whoes
architecture it does not recognise, unless it has explicitly told to accept them.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog7
-rw-r--r--bfd/archures.c38
-rw-r--r--bfd/bfd-in2.h3
-rw-r--r--bfd/targets.c2
4 files changed, 35 insertions, 15 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2e02617c13c..106eb2cd9a3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2002-12-23 Nick Clifton <nickc@redhat.com>
+
+ * archures.c (bfd_arch_get_compatible): Add third parameter
+ 'accept_unknowns'. Only accept unknown format BFDs if
+ accept_unknowns is true, or if the format is "binary".
+ * bfd-in2.h: Regenerate.
+
2002-12-21 Nick Clifton <nickc@redhat.com>
* coff-arm.c (coff_arm_relocate_section): Disable WINCE workaround
diff --git a/bfd/archures.c b/bfd/archures.c
index d969a9b82b8..b73766f775f 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -547,27 +547,39 @@ FUNCTION
SYNOPSIS
const bfd_arch_info_type *bfd_arch_get_compatible(
const bfd *abfd,
- const bfd *bbfd);
+ const bfd *bbfd,
+ bfd_boolean accept_unknowns);
DESCRIPTION
- Determine whether two BFDs'
- architectures and machine types are compatible. Calculates
- the lowest common denominator between the two architectures
- and machine types implied by the BFDs and returns a pointer to
- an <<arch_info>> structure describing the compatible machine.
+ Determine whether two BFDs' architectures and machine types
+ are compatible. Calculates the lowest common denominator
+ between the two architectures and machine types implied by
+ the BFDs and returns a pointer to an <<arch_info>> structure
+ describing the compatible machine.
*/
const bfd_arch_info_type *
-bfd_arch_get_compatible (abfd, bbfd)
+bfd_arch_get_compatible (abfd, bbfd, accept_unknowns)
const bfd *abfd;
const bfd *bbfd;
+ bfd_boolean accept_unknowns;
{
- /* If either architecture is unknown, then all we can do is assume
- the user knows what he's doing. */
- if (abfd->arch_info->arch == bfd_arch_unknown)
- return bbfd->arch_info;
- if (bbfd->arch_info->arch == bfd_arch_unknown)
- return abfd->arch_info;
+ const bfd * ubfd = NULL;
+
+ /* Look for an unknown architecture. */
+ if (((ubfd = abfd) && ubfd->arch_info->arch == bfd_arch_unknown)
+ || ((ubfd = bbfd) && ubfd->arch_info->arch == bfd_arch_unknown))
+ {
+ /* We can allow an unknown architecture if accept_unknowns
+ is true, or if the target is the "binary" format, which
+ has an unknown architecture. Since the binary format can
+ only be set by explicit request from the user, it is safe
+ to assume that they know what they are doing. */
+ if (accept_unknowns
+ || strcmp (bfd_get_target (ubfd), "binary") == 0)
+ return ubfd->arch_info;
+ return NULL;
+ }
/* Otherwise architecture-specific code has to decide. */
return abfd->arch_info->compatible (abfd->arch_info, bbfd->arch_info);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index d0106326508..362cc8f04f4 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1752,7 +1752,8 @@ bfd_arch_list PARAMS ((void));
const bfd_arch_info_type *
bfd_arch_get_compatible PARAMS ((
const bfd *abfd,
- const bfd *bbfd));
+ const bfd *bbfd,
+ bfd_boolean accept_unknowns));
void
bfd_set_arch_info PARAMS ((bfd *abfd, const bfd_arch_info_type *arg));
diff --git a/bfd/targets.c b/bfd/targets.c
index 604368c2014..998327de1d0 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -1244,7 +1244,7 @@ bfd_find_target (target_name, abfd)
else
targname = getenv ("GNUTARGET");
- /* This is safe; the vector cannot be null */
+ /* This is safe; the vector cannot be null. */
if (targname == NULL || strcmp (targname, "default") == 0)
{
abfd->target_defaulted = TRUE;