Automatic date update in version.in
[binutils-gdb.git] / ld / plugin.c
index bb369f46955eb641ff9bfcc19b57e83f9e216e5e..fe2031046775d40dbff25c6870348216c414e44f 100644 (file)
@@ -1,5 +1,5 @@
 /* Plugin control for the GNU linker.
-   Copyright (C) 2010-2021 Free Software Foundation, Inc.
+   Copyright (C) 2010-2022 Free Software Foundation, Inc.
 
    This file is part of the GNU Binutils.
 
@@ -102,7 +102,9 @@ typedef struct view_buffer
    pointer.  */
 typedef struct plugin_input_file
 {
+  /* The dummy BFD.  */
   bfd *abfd;
+  /* The original input BFD.  Non-NULL if it is an archive member.  */
   bfd *ibfd;
   view_buffer_t view_buffer;
   char *name;
@@ -861,8 +863,11 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
          /* We need to know if the sym is referenced from non-IR files.  Or
             even potentially-referenced, perhaps in a future final link if
             this is a partial one, perhaps dynamically at load-time if the
-            symbol is externally visible.  Also check for wrapper symbol.  */
-         if (blhe->non_ir_ref_regular || wrap_status == wrapper)
+            symbol is externally visible.  Also check for __real_SYM
+            reference and wrapper symbol.  */
+         if (blhe->non_ir_ref_regular
+             || blhe->ref_real
+             || wrap_status == wrapper)
            res = LDPR_PREVAILING_DEF;
          else if (wrap_status == wrapped)
            res = LDPR_RESOLVED_IR;
@@ -1220,7 +1225,7 @@ plugin_object_p (bfd *ibfd)
 
   file.handle = input;
   input->abfd = abfd;
-  input->ibfd = ibfd;
+  input->ibfd = ibfd->my_archive != NULL ? ibfd : NULL;
   input->view_buffer.addr = NULL;
   input->view_buffer.filesize = 0;
   input->view_buffer.offset = 0;