Remove link_info.pic
authorAlan Modra <amodra@gmail.com>
Wed, 19 Aug 2015 03:02:54 +0000 (12:32 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 19 Aug 2015 03:23:54 +0000 (12:53 +0930)
Adding type_pie to output_type allows us to remove link_info.pic and
with some reordering of the enum, produces better code.

include/
* bfdlink.h (enum output_type): Delete type_executable, add type_pde
and type_pie.  Reorder.
(struct bfd_link_info): Delete pic field.
(bfd_link_executable, bfd_link_pde, bfd_link_pie, bfd_link_pic): Adjust.
ld/
* emultempl/aix.em: Don't set link_info.pic.
* emultempl/pe.em: Likewise.
* emultempl/pep.em: Likewise.
* emultempl/sunos.em: Likewise.
* lexsup.c (parse_args): Likewise.  Set type_pie for -pie.
* plugin.c (set_tv_header <LDPT_LINKER_OUTPUT>): Simplify.

include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/emultempl/aix.em
ld/emultempl/pe.em
ld/emultempl/pep.em
ld/emultempl/sunos.em
ld/lexsup.c
ld/plugin.c

index 5197abfffd0263eb03988a68e6c905c0f4606234..e4dad82d52c575528657b4390d1e9e4a37b84547 100644 (file)
@@ -1,3 +1,10 @@
+2015-08-19  Alan Modra  <amodra@gmail.com>
+
+       * bfdlink.h (enum output_type): Delete type_executable, add type_pde
+       and type_pie.  Reorder.
+       (struct bfd_link_info): Delete pic field.
+       (bfd_link_executable, bfd_link_pde, bfd_link_pie, bfd_link_pic): Adjust.
+
 2015-08-19  Alan Modra  <amodra@gmail.com>
 
        * bfdlink.h (bfd_link_pde): Define.
index 62309a5c6827e2798dec3b9ce91e758691baaabe..458a768b2139a91284cab42ecb4c0aca06d4e5de 100644 (file)
@@ -263,19 +263,18 @@ struct bfd_elf_version_tree;
 
 enum output_type
 {
-  type_executable = 0,
+  type_pde,
+  type_relocatable,
+  type_pie,
   type_dll,
-  type_relocatable
 };
 
-#define bfd_link_executable(info)  ((info)->type == type_executable)
+#define bfd_link_pde(info)        ((info)->type == type_pde)
 #define bfd_link_dll(info)        ((info)->type == type_dll)
 #define bfd_link_relocatable(info) ((info)->type == type_relocatable)
-#define bfd_link_pic(info)        (info)->pic
-#define bfd_link_pie(info)        (bfd_link_executable (info) \
-                                   && bfd_link_pic (info))
-#define bfd_link_pde(info)        (bfd_link_executable (info) \
-                                   && !bfd_link_pic (info))
+#define bfd_link_pie(info)        ((info)->type == type_pie)
+#define bfd_link_executable(info)  (bfd_link_pde (info) || bfd_link_pie (info))
+#define bfd_link_pic(info)        (bfd_link_dll (info) || bfd_link_pie (info))
 
 /* This structure holds all the information needed to communicate
    between BFD and the linker when doing a link.  */
@@ -285,9 +284,6 @@ struct bfd_link_info
   /* Output type.  */
   ENUM_BITFIELD (output_type) type : 2;
 
-  /* TRUE if BFD should generate a position independent object.  */
-  unsigned int pic : 1;
-
   /* TRUE if BFD should pre-bind symbols in a shared object.  */
   unsigned int symbolic: 1;
 
index 67821df6fd7a9224c036ac9264dd32d7f800af8c..222ef3d160a75272bef3e5c6e9565c363f79f724 100644 (file)
@@ -1,3 +1,12 @@
+2015-08-19  Alan Modra  <amodra@gmail.com>
+
+       * emultempl/aix.em: Don't set link_info.pic.
+       * emultempl/pe.em: Likewise.
+       * emultempl/pep.em: Likewise.
+       * emultempl/sunos.em: Likewise.
+       * lexsup.c (parse_args): Likewise.  Set type_pie for -pie.
+       * plugin.c (set_tv_header <LDPT_LINKER_OUTPUT>): Simplify.
+
 2015-08-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld/ldctor.c: Replace shared, executable, relocatable and pie
index d4147f3befe3f8e5a2546ec1c266d766fca1a95d..3975e2f097c51ef072163e53bd136e8684e28c00 100644 (file)
@@ -533,7 +533,6 @@ gld${EMULATION_NAME}_handle_option (int optc)
       if (*optarg == 'S')
        {
          link_info.type = type_dll;
-         link_info.pic = TRUE;
          ++optarg;
        }
       if (*optarg == '\0' || optarg[1] == '\0')
index e817b4707a4ef95d4018b6755015952ebf8ea292..72e2f114064fd475d7ee9c612c7ae747912363b4 100644 (file)
@@ -1956,10 +1956,7 @@ gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIB
 
          /* def_file_print (stdout, pe_def_file); */
          if (pe_def_file->is_dll == 1)
-           {
-             link_info.type = type_dll;
-             link_info.pic = 1;
-           }
+           link_info.type = type_dll;
 
          if (pe_def_file->base_address != (bfd_vma)(-1))
            {
index 8b30b1cf5d6e33d116e83e88261132a4193ba1c9..c82e496d425309f60968c32614b6bfcfe342fc10 100644 (file)
@@ -1789,10 +1789,7 @@ gld_${EMULATION_NAME}_unrecognized_file (lang_input_statement_type *entry ATTRIB
 
          /* def_file_print (stdout, pep_def_file); */
          if (pep_def_file->is_dll == 1)
-           {
-             link_info.type = type_dll;
-             link_info.pic = 1;
-           }
+           link_info.type = type_dll;
 
          if (pep_def_file->base_address != (bfd_vma)(-1))
            {
index c026e35a5e5db2178ef04ae5a66fb0e13a7b8494..4422f19d0d260c6327f4b6b460a9614789a91421 100644 (file)
@@ -689,7 +689,6 @@ gld${EMULATION_NAME}_before_allocation (void)
              if (! found_assign)
                {
                  link_info.type = type_dll;
-                 link_info.pic = TRUE;
                  break;
                }
            }
index 777d6e241a578c3f26cf4c0be3d05c4bd44089f3..ace180335685a06ab13c0e3c6ea613c224eeeb6d 100644 (file)
@@ -1121,7 +1121,6 @@ parse_args (unsigned argc, char **argv)
                einfo (_("%P%F: -r and -shared may not be used together\n"));
 
              link_info.type = type_dll;
-             link_info.pic = TRUE;
              /* When creating a shared library, the default
                 behaviour is to ignore any unresolved references.  */
              if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
@@ -1138,8 +1137,7 @@ parse_args (unsigned argc, char **argv)
              if (bfd_link_relocatable (&link_info))
                einfo (_("%P%F: -r and -pie may not be used together\n"));
 
-             link_info.type = type_executable;
-             link_info.pic = TRUE;
+             link_info.type = type_pie;
            }
          else
            einfo (_("%P%F: -pie not supported\n"));
index 5f7bbd895031f736b2d3aeab71dafd1157b9f558..8e53255ecd485dc59e4be392deecc54bb85e7bfc 100644 (file)
@@ -872,11 +872,10 @@ set_tv_header (struct ld_plugin_tv *tv)
          TVU(val) = major * 100 + minor;
          break;
        case LDPT_LINKER_OUTPUT:
-         TVU(val) = (bfd_link_relocatable (&link_info)
-                     ? LDPO_REL
-                     : (bfd_link_executable (&link_info)
-                        ? (bfd_link_pic (&link_info) ? LDPO_PIE : LDPO_EXEC)
-                        : LDPO_DYN));
+         TVU(val) = (bfd_link_relocatable (&link_info) ? LDPO_REL
+                     : bfd_link_pde (&link_info) ? LDPO_EXEC
+                     : bfd_link_pie (&link_info) ? LDPO_PIE
+                     : LDPO_DYN);
          break;
        case LDPT_OUTPUT_NAME:
          TVU(string) = output_filename;