aboutsummaryrefslogtreecommitdiff
path: root/bfd
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
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')
-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 2e02617..106eb2c 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 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);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index d010632..362cc8f 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 604368c..998327d 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;