OSDN Git Service

Change linker's default behaviour - it will now reject binary files whoes
authorNick Clifton <nickc@redhat.com>
Mon, 23 Dec 2002 10:45:02 +0000 (10:45 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 23 Dec 2002 10:45:02 +0000 (10:45 +0000)
architecture it does not recognise, unless it has explicitly told to accept
them.

bfd/ChangeLog
bfd/archures.c
bfd/bfd-in2.h
bfd/targets.c

index 2e02617..106eb2c 100644 (file)
@@ -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
index d969a9b..b73766f 100644 (file)
@@ -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);
index d010632..362cc8f 100644 (file)
@@ -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));
index 604368c..998327d 100644 (file)
@@ -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;