i386-dis.c: Fix a typo in comments
[deliverable/binutils-gdb.git] / ld / lexsup.c
index 3733a7c8935a6c16286a6ff587978767dab6a4c3..d84b334b346e7d2e49d4482422e1173ecc9ab219 100644 (file)
@@ -185,6 +185,11 @@ static const struct ld_option ld_options[] =
   { {"flto-partition=", required_argument, NULL, OPTION_IGNORE},
     '\0', NULL, N_("Ignored for GCC LTO option compatibility"),
     ONE_DASH },
+#else
+  { {"plugin", required_argument, NULL, OPTION_IGNORE},
+    '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH },
+  { {"plugin-opt", required_argument, NULL, OPTION_IGNORE},
+    '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH },
 #endif /* ENABLE_PLUGINS */
   { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE},
     '\0', NULL, N_("Ignored for GCC linker option compatibility"),
@@ -359,7 +364,7 @@ static const struct ld_option ld_options[] =
   { {"init", required_argument, NULL, OPTION_INIT},
     '\0', N_("SYMBOL"), N_("Call SYMBOL at load-time"), ONE_DASH },
   { {"Map", required_argument, NULL, OPTION_MAP},
-    '\0', N_("FILE"), N_("Write a map file"), ONE_DASH },
+    '\0', N_("FILE/DIR"), N_("Write a linker map to FILE or DIR/<outputname>.map"), ONE_DASH },
   { {"no-define-common", no_argument, NULL, OPTION_NO_DEFINE_COMMON},
     '\0', NULL, N_("Do not define Common storage"), TWO_DASHES },
   { {"no-demangle", no_argument, NULL, OPTION_NO_DEMANGLE },
@@ -504,6 +509,10 @@ static const struct ld_option ld_options[] =
     '\0', NULL, N_("Use C++ typeinfo dynamic list"), TWO_DASHES },
   { {"dynamic-list", required_argument, NULL, OPTION_DYNAMIC_LIST},
     '\0', N_("FILE"), N_("Read dynamic list"), TWO_DASHES },
+  { {"export-dynamic-symbol", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL},
+    '\0', N_("SYMBOL"), N_("Export the specified symbol"), EXACTLY_TWO_DASHES },
+  { {"export-dynamic-symbol-list", required_argument, NULL, OPTION_EXPORT_DYNAMIC_SYMBOL_LIST},
+    '\0', N_("FILE"), N_("Read export dynamic symbol list"), EXACTLY_TWO_DASHES },
   { {"warn-common", no_argument, NULL, OPTION_WARN_COMMON},
     '\0', NULL, N_("Warn about duplicate common symbols"), TWO_DASHES },
   { {"warn-constructors", no_argument, NULL, OPTION_WARN_CONSTRUCTORS},
@@ -517,7 +526,12 @@ static const struct ld_option ld_options[] =
     '\0', NULL, N_("Warn if start of section changes due to alignment"),
     TWO_DASHES },
   { {"warn-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
-    '\0', NULL, N_("Warn if outpout has DT_TEXTREL"),
+    '\0', NULL,
+#if DEFAULT_LD_TEXTREL_CHECK_WARNING
+    N_("Warn if outpout has DT_TEXTREL (default)"),
+#else
+    N_("Warn if outpout has DT_TEXTREL"),
+#endif
     TWO_DASHES },
   { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_TEXTREL},
     '\0', NULL, NULL, NO_HELP },
@@ -583,6 +597,7 @@ parse_args (unsigned argc, char **argv)
     dynamic_list_data,
     dynamic_list
   } opt_dynamic_list = dynamic_list_unset;
+  struct bfd_elf_dynamic_list *export_list = NULL;
 
   shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
   longopts = (struct option *)
@@ -1414,11 +1429,35 @@ parse_args (unsigned argc, char **argv)
            ldfile_open_command_file (optarg);
            saved_script_handle = hold_script_handle;
            parser_input = input_dynamic_list;
+           current_dynamic_list_p = &link_info.dynamic_list;
            yyparse ();
          }
          if (opt_dynamic_list != dynamic_list_data)
            opt_dynamic_list = dynamic_list;
          break;
+       case OPTION_EXPORT_DYNAMIC_SYMBOL:
+         {
+           struct bfd_elf_version_expr *expr
+             = lang_new_vers_pattern (NULL, xstrdup (optarg), NULL,
+                                      FALSE);
+           lang_append_dynamic_list (&export_list, expr);
+          }
+         break;
+       case OPTION_EXPORT_DYNAMIC_SYMBOL_LIST:
+         /* This option indicates a small script that only specifies
+            an export list.  Read it, but don't assume that we've
+            seen a linker script.  */
+         {
+           FILE *hold_script_handle;
+
+           hold_script_handle = saved_script_handle;
+           ldfile_open_command_file (optarg);
+           saved_script_handle = hold_script_handle;
+           parser_input = input_dynamic_list;
+           current_dynamic_list_p = &export_list;
+           yyparse ();
+         }
+         break;
        case OPTION_WARN_COMMON:
          config.warn_common = TRUE;
          break;
@@ -1595,6 +1634,41 @@ parse_args (unsigned argc, char **argv)
        }
     }
 
+  /* Run a couple of checks on the map filename.  */
+  if (config.map_filename)
+    {
+      if (config.map_filename[0] == 0)
+       {
+         einfo (_("%P: no file/directory name provided for map output; ignored\n"));
+         config.map_filename = NULL;
+       }
+      else
+       {
+         struct stat s;
+
+         /* If the map filename is actually a directory then create
+            a file inside it, based upon the output filename.  */
+         if (stat (config.map_filename, &s) >= 0
+             && S_ISDIR (s.st_mode))
+           {
+             char * new_name;
+
+             /* FIXME: This is a (trivial) memory leak.  */
+             if (asprintf (&new_name, "%s/%s.map",
+                           config.map_filename, output_filename) < 0)
+               {
+                 /* If this alloc fails then something is probably very
+                    wrong.  Better to halt now rather than continue on
+                    into more problems.  */
+                 einfo (_("%P%F: cannot create name for linker map file: %E\n"));
+                 new_name = NULL;
+               }
+
+             config.map_filename = new_name;
+           }
+       }
+    }
+
   if (command_line.soname && command_line.soname[0] == '\0')
     {
       einfo (_("%P: SONAME must not be empty string; ignored\n"));
@@ -1626,6 +1700,49 @@ parse_args (unsigned argc, char **argv)
       && command_line.check_section_addresses < 0)
     command_line.check_section_addresses = 0;
 
+  if (export_list)
+    {
+      struct bfd_elf_version_expr *head = export_list->head.list;
+      struct bfd_elf_version_expr *next;
+
+      /* For --export-dynamic-symbol[-list]:
+        1. When building executable, treat like --dynamic-list.
+        2. When building shared object:
+           a. If -Bsymbolic or --dynamic-list are used, treat like
+              --dynamic-list.
+           b. Otherwise, ignored.
+       */
+      if (!bfd_link_relocatable (&link_info)
+         && (bfd_link_executable (&link_info)
+             || opt_symbolic != symbolic_unset
+             || opt_dynamic_list != dynamic_list_unset))
+       {
+         /* Append the export list to link_info.dynamic_list.  */
+         if (link_info.dynamic_list)
+           {
+             for (next = head; next->next != NULL; next = next->next)
+               ;
+             next->next = link_info.dynamic_list->head.list;
+             link_info.dynamic_list->head.list = head;
+           }
+         else
+           link_info.dynamic_list = export_list;
+
+         if (opt_dynamic_list != dynamic_list_data)
+           opt_dynamic_list = dynamic_list;
+       }
+      else
+       {
+         /* Free the export list.  */
+         for (; head->next != NULL; head = next)
+           {
+             next = head->next;
+             free (head);
+           }
+         free (export_list);
+       }
+    }
+
   switch (opt_dynamic_list)
     {
     case dynamic_list_unset:
This page took 0.024698 seconds and 4 git commands to generate.