ld: Handle --dynamic-list* before -Bsymbolic -Bsymbolic-functions
authorFangrui Song <maskray@google.com>
Thu, 21 May 2020 01:31:39 +0000 (18:31 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Sun, 24 May 2020 11:47:46 +0000 (04:47 -0700)
--dynamic-list* should work both before and after -Bsymbolic and
-Bsymbolic-functions.

PR ld/26018
* lexsup.c (parse_args): Simplify.
* testsuite/ld-elf/dl4e.out: New.
* testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.

ld/ChangeLog
ld/lexsup.c
ld/testsuite/ld-elf/dl4e.out [new file with mode: 0644]
ld/testsuite/ld-elf/shared.exp

index 0a2efa13053e63fb010597c8818ef03bc6bb86af..533685b363d7b05b55b8019fb09dca1bd9ec4b02 100644 (file)
@@ -1,3 +1,10 @@
+2020-05-24  Fangrui Song <maskray@google.com>
+
+       PR ld/26018
+       * lexsup.c (parse_args): Simplify.
+       * testsuite/ld-elf/dl4e.out: New.
+       * testsuite/ld-elf/shared.exp: Updated for PR ld/26018 tests.
+
 2020-05-23  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/26018
index fe9526b527197e6d2adbb3026367e5ed0d3f634f..04db2f129f872891b5d97ccb223e023a6cf21140 100644 (file)
@@ -1390,22 +1390,16 @@ parse_args (unsigned argc, char **argv)
          break;
        case OPTION_DYNAMIC_LIST_DATA:
          opt_dynamic_list = dynamic_list_data;
-         if (opt_symbolic == symbolic)
-           opt_symbolic = symbolic_unset;
          break;
        case OPTION_DYNAMIC_LIST_CPP_TYPEINFO:
          lang_append_dynamic_list_cpp_typeinfo ();
          if (opt_dynamic_list != dynamic_list_data)
            opt_dynamic_list = dynamic_list;
-         if (opt_symbolic == symbolic)
-           opt_symbolic = symbolic_unset;
          break;
        case OPTION_DYNAMIC_LIST_CPP_NEW:
          lang_append_dynamic_list_cpp_new ();
          if (opt_dynamic_list != dynamic_list_data)
            opt_dynamic_list = dynamic_list;
-         if (opt_symbolic == symbolic)
-           opt_symbolic = symbolic_unset;
          break;
        case OPTION_DYNAMIC_LIST:
          /* This option indicates a small script that only specifies
@@ -1422,8 +1416,6 @@ parse_args (unsigned argc, char **argv)
          }
          if (opt_dynamic_list != dynamic_list_data)
            opt_dynamic_list = dynamic_list;
-         if (opt_symbolic == symbolic)
-           opt_symbolic = symbolic_unset;
          break;
        case OPTION_WARN_COMMON:
          config.warn_common = TRUE;
@@ -1632,6 +1624,19 @@ parse_args (unsigned argc, char **argv)
       && command_line.check_section_addresses < 0)
     command_line.check_section_addresses = 0;
 
+  switch (opt_dynamic_list)
+    {
+    case dynamic_list_unset:
+      break;
+    case dynamic_list_data:
+      link_info.dynamic_data = TRUE;
+      /* Fall through.  */
+    case dynamic_list:
+      link_info.dynamic = TRUE;
+      opt_symbolic = symbolic_unset;
+      break;
+    }
+
   /* -Bsymbolic and -Bsymbols-functions are for shared library output.  */
   if (bfd_link_dll (&link_info))
     switch (opt_symbolic)
@@ -1651,25 +1656,13 @@ parse_args (unsigned argc, char **argv)
            free (link_info.dynamic_list);
            link_info.dynamic_list = NULL;
          }
-       opt_dynamic_list = dynamic_list_unset;
        break;
       case symbolic_functions:
-       opt_dynamic_list = dynamic_list_data;
+       link_info.dynamic = TRUE;
+       link_info.dynamic_data = TRUE;
        break;
       }
 
-  switch (opt_dynamic_list)
-    {
-    case dynamic_list_unset:
-      break;
-    case dynamic_list_data:
-      link_info.dynamic_data = TRUE;
-      /* Fall through.  */
-    case dynamic_list:
-      link_info.dynamic = TRUE;
-      break;
-    }
-
   if (!bfd_link_dll (&link_info))
     {
       if (command_line.filter_shlib)
diff --git a/ld/testsuite/ld-elf/dl4e.out b/ld/testsuite/ld-elf/dl4e.out
new file mode 100644 (file)
index 0000000..e5da6e2
--- /dev/null
@@ -0,0 +1,6 @@
+bar OK2
+bar OK4
+DSO1
+DSO2
+OK2
+OK4
index 33664305150fdd2dc2f11b794fa88ed75335ad41..7d35f3f3795436d6df112bc1681697d8cbf1abac 100644 (file)
@@ -598,6 +598,9 @@ set build_tests {
   {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
    "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
    {dl2.c dl2xxx.c} {} "libdl2c.so"}
+  {"Build libdl2d.so with --dynamic-list-data -Bsymbolic"
+   "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
+   {dl2.c dl2xxx.c} {} "libdl2d.so"}
   {"Build libdl4a.so with --dynamic-list=dl4.list"
    "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
    {dl4.c dl4xxx.c} {} "libdl4a.so"}
@@ -874,6 +877,9 @@ set run_tests [list \
     [list "Run with libdl2c.so" \
      "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
      {dl2main.c} "dl2c" "dl2b.out" ] \
+    [list "Run with libdl2d.so" \
+     "-Wl,--no-as-needed tmpdir/libdl2d.so" "" \
+     {dl2main.c} "dl2d" "dl2a.out" ] \
     [list "Run with libdl4a.so" \
      "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
      {dl4main.c} "dl4a" "dl4a.out" ] \
@@ -888,10 +894,10 @@ set run_tests [list \
      {dl4main.c} "dl4d" "dl4b.out" ] \
     [list "Run with libdl4e.so" \
      "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
-     {dl4main.c} "dl4e" "dl4a.out" ] \
+     {dl4main.c} "dl4e" "dl4e.out" ] \
     [list "Run with libdl4f.so" \
      "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
-     {dl4main.c} "dl4f" "dl4a.out" ] \
+     {dl4main.c} "dl4f" "dl4e.out" ] \
     [list "Run with libdata1.so" \
      "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
      {dynbss1.c} "dynbss1" "pass.out" ] \
@@ -988,7 +994,7 @@ set dlopen_run_tests [list \
      {dl6cmain.c} "dl6c1" "dl6b.out" ] \
     [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
      "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
-     {dl6dmain.c} "dl6d1" "dl6b.out" ] \
+     {dl6dmain.c} "dl6d1" "dl6a.out" ] \
     [list "Run pr21964-2" \
      "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \
      {pr21964-2c.c} "pr21964-2" "pass.out" ] \