ld: Add --undefined-version

Message ID 20221013201332.2747246-1-maskray@google.com
State Repeat Merge
Headers
Series ld: Add --undefined-version |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Fangrui Song Oct. 13, 2022, 8:13 p.m. UTC
  From: Fangrui Song <i@maskray.me>

This cancels a previous --no-undefined-version.
gold has had --undefined-version for a long time.
---
 ld/ldlex.h  | 1 +
 ld/lexsup.c | 5 +++++
 2 files changed, 6 insertions(+)
  

Comments

Alan Modra Oct. 13, 2022, 10:47 p.m. UTC | #1
On Thu, Oct 13, 2022 at 01:13:32PM -0700, Fangrui Song via Binutils wrote:
> From: Fangrui Song <i@maskray.me>
> 
> This cancels a previous --no-undefined-version.
> gold has had --undefined-version for a long time.

OK.
  

Patch

diff --git a/ld/ldlex.h b/ld/ldlex.h
index 57ade1f754b..894582595c1 100644
--- a/ld/ldlex.h
+++ b/ld/ldlex.h
@@ -120,6 +120,7 @@  enum option_values
 #if SUPPORT_ERROR_HANDLING_SCRIPT
   OPTION_ERROR_HANDLING_SCRIPT,
 #endif
+  OPTION_UNDEFINED_VERSION,
   OPTION_NO_UNDEFINED_VERSION,
   OPTION_DEFAULT_SYMVER,
   OPTION_DEFAULT_IMPORTED_SYMVER,
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 299371fb775..5053e784b75 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -396,6 +396,8 @@  static const struct ld_option ld_options[] =
      OPTION_ERROR_HANDLING_SCRIPT},
     '\0', N_("SCRIPT"), N_("Provide a script to help with undefined symbol errors"), TWO_DASHES},
 #endif
+  { {"undefined-version", no_argument, NULL, OPTION_UNDEFINED_VERSION},
+    '\0', NULL, N_("Allow undefined version"), EXACTLY_TWO_DASHES },
   { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION},
     '\0', NULL, N_("Disallow undefined version"), TWO_DASHES },
   { {"default-symver", no_argument, NULL, OPTION_DEFAULT_SYMVER},
@@ -1088,6 +1090,9 @@  parse_args (unsigned argc, char **argv)
 	  break;
 #endif
 
+	case OPTION_UNDEFINED_VERSION:
+	  link_info.allow_undefined_version = true;
+	  break;
 	case OPTION_NO_UNDEFINED_VERSION:
 	  link_info.allow_undefined_version = false;
 	  break;