OSDN Git Service

* bfd.c (bfd_alt_mach_code): New function.
authoraoliva <aoliva>
Fri, 24 Aug 2001 13:55:54 +0000 (13:55 +0000)
committeraoliva <aoliva>
Fri, 24 Aug 2001 13:55:54 +0000 (13:55 +0000)
* bfd-in2.h: Rebuilt.

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

index 5160843..7e92107 100644 (file)
@@ -1,5 +1,10 @@
 2001-08-24  Alexandre Oliva  <aoliva@redhat.com>
 
+       * bfd.c (bfd_alt_mach_code): New function.
+       * bfd-in2.h: Rebuilt.
+
+2001-08-24  Alexandre Oliva  <aoliva@redhat.com>
+
        * elf-m10300.c (mn10300_elf_relocate_section): Test the right
        `type' field in the hash entry when deciding whether to follow a
        link.
index 4b6f44e..64c995c 100644 (file)
@@ -3296,6 +3296,9 @@ extern bfd_byte *bfd_get_relocated_section_contents
                  struct bfd_link_order *, bfd_byte *,
                  boolean, asymbol **));
 
+boolean
+bfd_alt_mach_code PARAMS ((bfd *abfd, int index));
+
 symindex
 bfd_get_next_mapent PARAMS ((bfd *abfd, symindex previous, carsym **sym));
 
index 2f5e260..aa3dd2a 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1288,3 +1288,58 @@ bfd_fprintf_vma (abfd, stream, value)
   else
     fprintf_vma ((FILE *) stream, value);
 }
+
+/*
+FUNCTION
+       bfd_alt_mach_code
+
+SYNOPSIS
+       boolean bfd_alt_mach_code(bfd *abfd, int index);
+
+DESCRIPTION
+
+       When more than one machine code number is available for the
+       same machine type, this function can be used to switch between
+       the preferred one (index == 0) and any others.  Currently,
+       only ELF supports this feature, with up to two alternate
+       machine codes.
+*/
+
+boolean
+bfd_alt_mach_code (abfd, index)
+     bfd *abfd;
+     int index;
+{
+  if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
+    {
+      int code;
+
+      switch (index)
+       {
+       case 0:
+         code = get_elf_backend_data (abfd)->elf_machine_code;
+         break;
+
+       case 1:
+         code = get_elf_backend_data (abfd)->elf_machine_alt1;
+         if (code == 0)
+           return false;
+         break;
+
+       case 2:
+         code = get_elf_backend_data (abfd)->elf_machine_alt2;
+         if (code == 0)
+           return false;
+         break;
+
+       default:
+         return false;
+       }
+
+      elf_elfheader (abfd)->e_machine = code;
+
+      return true;
+    }
+
+  return false;
+}