aboutsummaryrefslogtreecommitdiff
path: root/bfd/archures.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2002-12-23 10:45:03 +0000
committerNick Clifton <nickc@redhat.com>2002-12-23 10:45:03 +0000
commit312b768e2f1579346e7ffe978202fda06cb37224 (patch)
tree3322c12eef2b97a147b0754f4d65aba2483f77a9 /bfd/archures.c
parent8745eafadc9d43dbd9f9a0d2cc33e12f11ca1cd6 (diff)
downloadgdb-312b768e2f1579346e7ffe978202fda06cb37224.zip
gdb-312b768e2f1579346e7ffe978202fda06cb37224.tar.gz
gdb-312b768e2f1579346e7ffe978202fda06cb37224.tar.bz2
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/archures.c')
-rw-r--r--bfd/archures.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/bfd/archures.c b/bfd/archures.c
index d969a9b..b73766f 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);