This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: PR ld/14862: Assertion fault in binutils-2.23.51.0.5/bfd/elf-strtab.c:247
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Tue, 20 Nov 2012 14:21:57 -0800
- Subject: PATCH: PR ld/14862: Assertion fault in binutils-2.23.51.0.5/bfd/elf-strtab.c:247
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
I checked in this patch to remove ref_dynamic_nonweak added by accident:
http://sourceware.org/ml/binutils-cvs/2012-10/msg00164.html
which contains:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&r1=1.348&r2=1.349
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.455&r2=1.456
without ChangeLog entries.
H.J.
---
bfd/
2012-11-20 H.J. Lu <hongjiu.lu@intel.com>
PR ld/14862
* elf-bfd.h (elf_link_hash_entry): Remove ref_dynamic_nonweak
added by accident.
(elf_link_add_object_symbols): Don't set nor check
ref_dynamic_nonweak.
ld/testsuite/
2012-11-20 H.J. Lu <hongjiu.lu@intel.com>
PR ld/14862
* ld-elf/shared.exp (build_tests): Build libpr14862-1.o and
libpr14862.so.
(run_tests): Test pr14862.
* ld-elf/pr14862-1.c: New file.
* ld-elf/pr14862-2.c: Likewise.
* ld-elf/pr14862.map: Likewise.
* ld-elf/pr14862.out: Likewise.
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index aa78ecd..b8d82b1 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -168,8 +168,6 @@ struct elf_link_hash_entry
/* Symbol has a non-weak reference from a non-shared object (other than
the object in which it is defined). */
unsigned int ref_regular_nonweak : 1;
- /* Symbol has a non-weak reference from a shared object. */
- unsigned int ref_dynamic_nonweak : 1;
/* Dynamic symbol has been adjustd. */
unsigned int dynamic_adjusted : 1;
/* Symbol needs a copy reloc. */
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 2fcbac3..f22e023 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4394,8 +4394,6 @@ error_free_dyn:
{
h->def_dynamic = 0;
h->ref_dynamic = 1;
- /* PR 12549: Note if the dynamic reference is weak. */
- h->ref_dynamic_nonweak = (bind != STB_WEAK);
}
}
@@ -4413,9 +4411,6 @@ error_free_dyn:
{
h->ref_dynamic = 1;
hi->ref_dynamic = 1;
- /* PR 12549: Note if the dynamic reference is weak. */
- hi->ref_dynamic_nonweak =
- h->ref_dynamic_nonweak = (bind != STB_WEAK);
}
else
{
@@ -4503,8 +4498,8 @@ error_free_dyn:
if (!add_needed
&& definition
&& ((dynsym
- && h->ref_regular_nonweak)
- || (h->ref_dynamic_nonweak
+ && h->ref_regular)
+ || (h->ref_dynamic
&& (elf_dyn_lib_class (abfd) & DYN_AS_NEEDED) != 0
&& !on_needed_list (elf_dt_name (abfd), htab->needed))))
{
diff --git a/ld/testsuite/ld-elf/pr14862-1.c b/ld/testsuite/ld-elf/pr14862-1.c
new file mode 100644
index 0000000..258a834
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr14862-1.c
@@ -0,0 +1,9 @@
+extern void bar () __attribute__((weak));
+
+int
+main (void)
+{
+ if (bar)
+ bar ();
+ return 0;
+}
diff --git a/ld/testsuite/ld-elf/pr14862-2.c b/ld/testsuite/ld-elf/pr14862-2.c
new file mode 100644
index 0000000..1b9b393
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr14862-2.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void
+bar (void)
+{
+ printf ("OK\n");
+}
diff --git a/ld/testsuite/ld-elf/pr14862.map b/ld/testsuite/ld-elf/pr14862.map
new file mode 100644
index 0000000..2947640
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr14862.map
@@ -0,0 +1,4 @@
+VERS_1 {
+ global: bar;
+ local: *;
+};
diff --git a/ld/testsuite/ld-elf/pr14862.out b/ld/testsuite/ld-elf/pr14862.out
new file mode 100644
index 0000000..d86bac9
--- /dev/null
+++ b/ld/testsuite/ld-elf/pr14862.out
@@ -0,0 +1 @@
+OK
diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp
index c9f2056..9b35d53 100644
--- a/ld/testsuite/ld-elf/shared.exp
+++ b/ld/testsuite/ld-elf/shared.exp
@@ -173,6 +173,12 @@ set build_tests {
{"Build libpr14323-2.so"
"-shared" "-fPIC"
{pr14323-2.c} {} "libpr14323-2.so"}
+ {"Build pr14862-1.o"
+ "-r -nostdlib" ""
+ {pr14862-1.c} {} "libpr14862-1.o"}
+ {"Build libpr14862.so"
+ "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
+ {pr14862-2.c} {} "libpr14862.so"}
}
run_cc_link_tests $build_tests
@@ -308,6 +314,9 @@ set run_tests {
{"Run with pr14323-1.c pr14323-2.so"
"tmpdir/libpr14323-2.so" ""
{pr14323-1.c} "pr14323" "pass.out"}
+ {"Run with pr14862-1.c libpr14862.so"
+ "--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" ""
+ {dummy.c} "pr14862" "pr14862.out"}
}
# NetBSD ELF systems do not currently support the .*_array sections.