aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/plugin.c14
-rw-r--r--ld/testsuite/ld-plugin/lto.exp16
-rw-r--r--ld/testsuite/ld-plugin/pr31956c.c19
-rw-r--r--ld/testsuite/ld-plugin/pr31956d.c7
-rw-r--r--ld/testsuite/ld-plugin/pr31956d.d4
5 files changed, 58 insertions, 2 deletions
diff --git a/ld/plugin.c b/ld/plugin.c
index 03ee988..51c4765 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -778,8 +778,18 @@ get_symbols (const void *handle, int nsyms, struct ld_plugin_symbol *syms,
{
blhe = h;
/* Check if a symbol is a wrapper symbol. */
- if (blhe && blhe->wrapper_symbol)
- wrap_status = wrapper;
+ if (blhe)
+ {
+ if (blhe->wrapper_symbol)
+ wrap_status = wrapper;
+ else if (link_info.wrap_hash != NULL)
+ {
+ struct bfd_link_hash_entry *unwrap
+ = unwrap_hash_lookup (&link_info, (bfd *) abfd, blhe);
+ if (unwrap != NULL && unwrap != h)
+ wrap_status = wrapper;
+ }
+ }
}
else
{
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 9476caf..604dc8c 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -547,6 +547,22 @@ set lto_link_elf_tests [list \
"pr31956b" \
] \
[list \
+ "PR ld/31956 (malloc)" \
+ "-Wl,--wrap=malloc" \
+ "-O2 -flto" \
+ {pr31956c.c} \
+ {} \
+ "pr31956c" \
+ ] \
+ [list \
+ "PR ld/31956 (unused)" \
+ "-Wl,--wrap=parse_line" \
+ "-O2 -flto" \
+ {pr31956d.c} \
+ {{"nm" {} "pr31956d.d"}} \
+ "pr31956d" \
+ ] \
+ [list \
"Build pr30281.so" \
"-shared -Wl,--version-script,pr30281.t \
-O2 -fPIC -flto-partition=max -flto=2" \
diff --git a/ld/testsuite/ld-plugin/pr31956c.c b/ld/testsuite/ld-plugin/pr31956c.c
new file mode 100644
index 0000000..4a46b2b
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr31956c.c
@@ -0,0 +1,19 @@
+#include <stdlib.h>
+
+extern void *__real_malloc (size_t);
+
+void *
+__wrap_malloc (size_t n)
+{
+ if (n == 0)
+ return NULL;
+ else
+ return __real_malloc (n);
+};
+
+int
+main (void)
+{
+ void *ptr = malloc (30);
+ return ptr == NULL ? 1 : 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr31956d.c b/ld/testsuite/ld-plugin/pr31956d.c
new file mode 100644
index 0000000..cb7f2d5
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr31956d.c
@@ -0,0 +1,7 @@
+void __wrap_parse_line(void) {};
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/ld/testsuite/ld-plugin/pr31956d.d b/ld/testsuite/ld-plugin/pr31956d.d
new file mode 100644
index 0000000..b579cdc
--- /dev/null
+++ b/ld/testsuite/ld-plugin/pr31956d.d
@@ -0,0 +1,4 @@
+#failif
+#...
+[0-9a-f]+ T .*parse_line
+#...