]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* ldlang.h (struct lang_input_statement_flags): Add pushed
authorUlrich Drepper <drepper@gmail.com>
Sat, 9 Aug 2014 00:26:41 +0000 (20:26 -0400)
committerUlrich Drepper <drepper@gmail.com>
Sat, 9 Aug 2014 00:26:41 +0000 (20:26 -0400)
        member.
        * ldlex.h (enum option_values): Add OPTION_PUSH_STATE and
        OPTION_POP_STATE.
        * lexsup.c (ld_options): Add entries for --push-state and
        --pop-state.
        (parse_args): Handle OPTION_PUSH_STATE and OPTION_POP_STATE.
        * ld.texinfo: Document --push-state and --pop-state.

ld/ChangeLog
ld/ld.texinfo
ld/ldlang.h
ld/ldlex.h
ld/lexsup.c

index b34d360e0e8191a5dc5f38cfb6a7b08d3e351603..b80e69f1ed593f86d8411687c4f56b326956949c 100644 (file)
@@ -1,3 +1,14 @@
+2014-08-08  Ulrich Drepper  <drepper@gmail.com>
+
+       * ldlang.h (struct lang_input_statement_flags): Add pushed
+       member.
+       * ldlex.h (enum option_values): Add OPTION_PUSH_STATE and
+       OPTION_POP_STATE.
+       * lexsup.c (ld_options): Add entries for --push-state and
+       --pop-state.
+       (parse_args): Handle OPTION_PUSH_STATE and OPTION_POP_STATE.
+       * ld.texinfo: Document --push-state and --pop-state.
+
 2014-08-06  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR14918
index 5762dc6e3602eaae4036042da278c5608de18ee5..b559b4f5ed0cb0a2fca9724ddbcd7e43c9515a06 100644 (file)
@@ -827,6 +827,34 @@ the linker may make more use of this option.  Also currently there is
 no difference in the linker's behaviour for different non-zero values
 of this option.  Again this may change with future releases.
 
+@kindex --push-state
+@cindex push state governing input file handling
+@item --push-state
+The @option{--push-state} allows to preserve the current state of the
+flags which govern the input file handling so that they can all be
+restored with one corresponding @option{--pop-state} option.
+
+The option which are covered are: @option{-Bdynamic}, @option{-Bstatic},
+@option{-dn}, @option{-dy}, @option{-call_shared}, @option{-non_shared},
+@option{-static}, @option{-N}, @option{-n}, @option{--whole-archive},
+@option{--no-whole-archive}, @option{-r}, @option{-Ur},
+@option{--copy-dt-needed-entries}, @option{--no-copy-dt-needed-entries},
+@option{--as-needed}, @option{--no-as-needed}, and @option{-a}.
+
+One target for this option are specifications for @file{pkg-config}.  When
+used with the @option{--libs} option all possibly needed libraries are
+listed and then possibly linked with all the time.  It is better to return
+something as follows:
+
+@smallexample
+-Wl,--push-state,--as-needed -libone -libtwo -Wl,--pop-state
+@end smallexample
+
+@kindex --pop-state
+@cindex pop state governing input file handling
+Undoes the effect of --push-state, restores the previous values of the
+flags governing input file handling.
+
 @kindex -q
 @kindex --emit-relocs
 @cindex retain relocations in final executable
index 0f7fdd4325b36c238ad8795ba3c82fba146d9923..45420cd1e07e98af01eaf14e6734e0c7687d067e 100644 (file)
@@ -282,6 +282,9 @@ struct lang_input_statement_flags
   /* Set if reloading an archive or --as-needed lib.  */
   unsigned int reload : 1;
 #endif /* ENABLE_PLUGINS */
+
+  /* Head of list of pushed flags.  */
+  struct lang_input_statement_flags *pushed;
 };
 
 typedef struct lang_input_statement_struct
index b2753c38c12123259083dc1fa48dc33a3565b150..63f4c8160230dec32ebd1b0773786d173b30fda9 100644 (file)
@@ -137,6 +137,8 @@ enum option_values
   OPTION_DEFAULT_SCRIPT,
   OPTION_PRINT_OUTPUT_FORMAT,
   OPTION_IGNORE_UNRESOLVED_SYMBOL,
+  OPTION_PUSH_STATE,
+  OPTION_POP_STATE,
 };
 
 /* The initial parser states.  */
index 52b4fdb565c2e5818e1cefe7940db97906f9a9a8..3a1ea9e37308578d621a56058d406a8c858537f6 100644 (file)
@@ -505,6 +505,12 @@ static const struct ld_option ld_options[] =
     OPTION_IGNORE_UNRESOLVED_SYMBOL},
     '\0', N_("SYMBOL"),
     N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES },
+  { {"push-state", no_argument, NULL, OPTION_PUSH_STATE},
+    '\0', NULL, N_("Push state of flags governing input file handling"),
+    TWO_DASHES },
+  { {"pop-state", no_argument, NULL, OPTION_POP_STATE},
+    '\0', NULL, N_("Pop state of flags governing input file handling"),
+    TWO_DASHES },
 };
 
 #define OPTION_COUNT ARRAY_SIZE (ld_options)
@@ -1444,6 +1450,23 @@ parse_args (unsigned argc, char **argv)
               einfo (_("%P%X: --hash-size needs a numeric argument\n"));
           }
           break;
+
+       case OPTION_PUSH_STATE:
+         input_flags.pushed = xmemdup (&input_flags,
+                                       sizeof (input_flags),
+                                       sizeof (input_flags));
+         break;
+
+       case OPTION_POP_STATE:
+         if (input_flags.pushed == NULL)
+           einfo (_("%P%F: no state pushed before popping\n"));
+         else
+           {
+             struct lang_input_statement_flags *oldp = input_flags.pushed;
+             memcpy (&input_flags, oldp, sizeof (input_flags));
+             free (oldp);
+           }
+         break;
        }
     }