* NEWS: Mention --vfp11-denorm-fix option.
[binutils-gdb.git] / ld / emultempl / armelf.em
index d52d387f9d16bde7fb1b32c5024c77635e123233..4522a8bf0c68b92b229dcfabe01cd35bd1680f2e 100644 (file)
@@ -35,6 +35,7 @@ static int target1_is_rel = 0${TARGET1_IS_REL};
 static char *target2_type = "${TARGET2_TYPE}";
 static int fix_v4bx = 0;
 static int use_blx = 0;
+static bfd_arm_vfp11_fix vfp11_denorm_fix = BFD_ARM_VFP11_FIX_DEFAULT;
 
 static void
 gld${EMULATION_NAME}_before_parse (void)
@@ -124,6 +125,10 @@ arm_elf_before_allocation (void)
 
   bfd_elf32_arm_set_byteswap_code (&link_info, byteswap_code);
 
+  /* Choose type of VFP11 erratum fix, or warn if specified fix is unnecessary
+     due to architecture version.  */
+  bfd_elf32_arm_set_vfp11_fix (output_bfd, &link_info);
+
   /* We should be able to set the size of the interworking stub section.  We
      can't do it until later if we have dynamic sections, though.  */
   if (! elf_hash_table (&link_info)->dynamic_sections_created)
@@ -131,8 +136,12 @@ arm_elf_before_allocation (void)
       /* Here we rummage through the found bfds to collect glue information.  */
       LANG_FOR_EACH_INPUT_STATEMENT (is)
        {
+          /* Initialise mapping tables for code/data.  */
+          bfd_elf32_arm_init_maps (is->the_bfd);
+
          if (!bfd_elf32_arm_process_before_allocation (is->the_bfd,
-                                                       &link_info))
+                                                       &link_info)
+             || !bfd_elf32_arm_vfp11_erratum_scan (is->the_bfd, &link_info))
            /* xgettext:c-format */
            einfo (_("Errors encountered processing file %s"), is->filename);
        }
@@ -145,6 +154,22 @@ arm_elf_before_allocation (void)
   bfd_elf32_arm_allocate_interworking_sections (& link_info);
 }
 
+static void
+arm_elf_after_allocation (void)
+{
+  /* Call the standard elf routine.  */
+  after_allocation_default ();
+
+  {
+    LANG_FOR_EACH_INPUT_STATEMENT (is)
+      {
+        /* Figure out where VFP11 erratum veneers (and the labels returning
+           from same) have been placed.  */
+        bfd_elf32_arm_vfp11_fix_veneer_locations (is->the_bfd, &link_info);
+      }
+  }
+}
+
 static void
 arm_elf_finish (void)
 {
@@ -214,7 +239,7 @@ static void
 arm_elf_create_output_section_statements (void)
 {
   bfd_elf32_arm_set_target_relocs (&link_info, target1_is_rel, target2_type,
-                                   fix_v4bx, use_blx);
+                                   fix_v4bx, use_blx, vfp11_denorm_fix);
 }
 
 EOF
@@ -230,6 +255,7 @@ PARSE_AND_LIST_PROLOGUE='
 #define OPTION_TARGET2                 305
 #define OPTION_FIX_V4BX                        306
 #define OPTION_USE_BLX                 307
+#define OPTION_VFP11_DENORM_FIX                308
 '
 
 PARSE_AND_LIST_SHORTOPTS=p
@@ -243,6 +269,7 @@ PARSE_AND_LIST_LONGOPTS='
   { "target2", required_argument, NULL, OPTION_TARGET2},
   { "fix-v4bx", no_argument, NULL, OPTION_FIX_V4BX},
   { "use-blx", no_argument, NULL, OPTION_USE_BLX},
+  { "vfp11-denorm-fix", required_argument, NULL, OPTION_VFP11_DENORM_FIX},
 '
 
 PARSE_AND_LIST_OPTIONS='
@@ -253,6 +280,7 @@ PARSE_AND_LIST_OPTIONS='
   fprintf (file, _("     --target2=<type>         Specify definition of R_ARM_TARGET2\n"));
   fprintf (file, _("     --fix-v4bx               Rewrite BX rn as MOV pc, rn for ARMv4\n"));
   fprintf (file, _("     --use-blx                Enable use of BLX instructions\n"));
+  fprintf (file, _("     --vfp11-denorm-fix       Specify how to fix VFP11 denorm erratum\n"));
 '
 
 PARSE_AND_LIST_ARGS_CASES='
@@ -287,12 +315,24 @@ PARSE_AND_LIST_ARGS_CASES='
     case OPTION_USE_BLX:
       use_blx = 1;
       break;
+    
+    case OPTION_VFP11_DENORM_FIX:
+      if (strcmp (optarg, "none") == 0)
+        vfp11_denorm_fix = BFD_ARM_VFP11_FIX_NONE;
+      else if (strcmp (optarg, "scalar") == 0)
+        vfp11_denorm_fix = BFD_ARM_VFP11_FIX_SCALAR;
+      else if (strcmp (optarg, "vector") == 0)
+        vfp11_denorm_fix = BFD_ARM_VFP11_FIX_VECTOR;
+      else
+        einfo (_("Unrecognized VFP11 fix type '\''%s'\''.\n"), optarg);
+      break;
 '
 
 # We have our own after_open and before_allocation functions, but they call
 # the standard routines, so give them a different name.
 LDEMUL_AFTER_OPEN=arm_elf_after_open
 LDEMUL_BEFORE_ALLOCATION=arm_elf_before_allocation
+LDEMUL_AFTER_ALLOCATION=arm_elf_after_allocation
 LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=arm_elf_create_output_section_statements
 
 # Replace the elf before_parse function with our own.