From: Richard Sandiford <richard@codesourcery.com>
To: binutils@sourceware.org
Subject: Re: Fix assertion failure on aliases of dynamic weak symbols
Date: Mon, 23 Jul 2007 11:43:00 -0000 [thread overview]
Message-ID: <87ps2j5taz.fsf@firetop.home> (raw)
In-Reply-To: <20070723053533.GA22904@bubble.grove.modra.org> (Alan Modra's message of "Mon\, 23 Jul 2007 15\:05\:33 +0930")
Alan Modra <amodra@bigpond.net.au> writes:
> On Mon, Jul 16, 2007 at 06:10:10PM +0100, Richard Sandiford wrote:
>> bfd/
>> * elflink.c (_bfd_elf_fix_symbol_flags): Only assert the type
>> of weakdef->root.type if weakdef has no regular definition.
>>
>> ld/testsuite/
>> * ld-elf/weak-dyn-1a.s, ld-elf/weak-dyn-1b.s, ld-elf/weak-dyn-1.ld,
>> * ld-elf/weak-dyn-1.rd: New test.
>> * ld-elf/elf.exp: Run it.
>
> This is OK.
Thanks. As HJ asked, I changed the test so that the shared library
uses a normal object definition of the strong symbol. Here's what
I installed, after checking that the new test failed before the
patch and passes after it.
Richard
bfd/
* elflink.c (_bfd_elf_fix_symbol_flags): Only assert the type
of weakdef->root.type if weakdef has no regular definition.
ld/testsuite/
* ld-elf/weak-dyn-1a.s, ld-elf/weak-dyn-1b.s, ld-elf/weak-dyn-1.ld,
* ld-elf/weak-dyn-1.rd: New test.
* ld-elf/elf.exp: Run it.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.269
diff -u -p -r1.269 elflink.c
--- bfd/elflink.c 10 Jul 2007 02:40:31 -0000 1.269
+++ bfd/elflink.c 23 Jul 2007 09:55:13 -0000
@@ -2492,8 +2492,6 @@ _bfd_elf_fix_symbol_flags (struct elf_li
BFD_ASSERT (h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak);
- BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
- || weakdef->root.type == bfd_link_hash_defweak);
BFD_ASSERT (weakdef->def_dynamic);
/* If the real definition is defined by a regular object file,
@@ -2502,8 +2500,11 @@ _bfd_elf_fix_symbol_flags (struct elf_li
if (weakdef->def_regular)
h->u.weakdef = NULL;
else
- (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef,
- h);
+ {
+ BFD_ASSERT (weakdef->root.type == bfd_link_hash_defined
+ || weakdef->root.type == bfd_link_hash_defweak);
+ (*bed->elf_backend_copy_indirect_symbol) (eif->info, weakdef, h);
+ }
}
return TRUE;
Index: ld/testsuite/ld-elf/weak-dyn-1a.s
===================================================================
RCS file: ld/testsuite/ld-elf/weak-dyn-1a.s
diff -N ld/testsuite/ld-elf/weak-dyn-1a.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/weak-dyn-1a.s 23 Jul 2007 09:55:13 -0000
@@ -0,0 +1,13 @@
+ .globl foo
+ .weak foo
+ .type foo,%object
+ .size foo,1
+
+ .globl bar
+ .type bar,%object
+ .size bar,1
+
+ .data
+foo:
+bar:
+ .byte 1
Index: ld/testsuite/ld-elf/weak-dyn-1b.s
===================================================================
RCS file: ld/testsuite/ld-elf/weak-dyn-1b.s
diff -N ld/testsuite/ld-elf/weak-dyn-1b.s
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/weak-dyn-1b.s 23 Jul 2007 09:55:13 -0000
@@ -0,0 +1,2 @@
+ .data
+ .dc.a foo
Index: ld/testsuite/ld-elf/weak-dyn-1.ld
===================================================================
RCS file: ld/testsuite/ld-elf/weak-dyn-1.ld
diff -N ld/testsuite/ld-elf/weak-dyn-1.ld
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/weak-dyn-1.ld 23 Jul 2007 09:55:13 -0000
@@ -0,0 +1,8 @@
+SECTIONS
+{
+ . = 0x800000;
+ PROVIDE (bar = .);
+ .data : {
+ *(.data)
+ }
+}
Index: ld/testsuite/ld-elf/weak-dyn-1.rd
===================================================================
RCS file: ld/testsuite/ld-elf/weak-dyn-1.rd
diff -N ld/testsuite/ld-elf/weak-dyn-1.rd
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ ld/testsuite/ld-elf/weak-dyn-1.rd 23 Jul 2007 09:55:13 -0000
@@ -0,0 +1,3 @@
+#...
+0+800000 .* foo.*
+#pass
Index: ld/testsuite/ld-elf/elf.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-elf/elf.exp,v
retrieving revision 1.10
diff -u -p -r1.10 elf.exp
--- ld/testsuite/ld-elf/elf.exp 6 Jul 2007 14:09:43 -0000 1.10
+++ ld/testsuite/ld-elf/elf.exp 23 Jul 2007 09:55:13 -0000
@@ -36,6 +36,19 @@ foreach t $test_list {
run_dump_test [file rootname $t]
}
+if { [istarget *-*-linux*] } {
+ run_ld_link_tests {
+ {"Weak symbols in dynamic objects 1 (support)"
+ "-shared" "" {weak-dyn-1a.s}
+ {}
+ "libweakdyn1a.so"}
+ {"Weak symbols in dynamic objects 1 (main test)"
+ "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" {weak-dyn-1b.s}
+ {{readelf {--relocs --wide} weak-dyn-1.rd}}
+ "libweakdyn1b.so"}
+ }
+}
+
# The following tests require running the executable generated by ld.
if ![isnative] {
return
prev parent reply other threads:[~2007-07-23 10:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-16 17:13 Richard Sandiford
2007-07-16 21:33 ` H.J. Lu
2007-07-17 1:12 ` PATCH: Remove u.weakdef from elf_link_hash_entry H.J. Lu
2007-07-17 5:39 ` Fix assertion failure on aliases of dynamic weak symbols Ian Lance Taylor
2007-07-17 13:55 ` H.J. Lu
2007-07-17 19:31 ` Ian Lance Taylor
2007-07-18 15:58 ` H.J. Lu
2007-07-18 18:23 ` Richard Sandiford
2007-07-18 21:06 ` H.J. Lu
2007-07-19 19:56 ` PATCH: Check symbol type for symbol alias H.J. Lu
2007-07-20 12:50 ` Richard Sandiford
2007-07-20 13:07 ` H.J. Lu
2007-07-20 15:03 ` Richard Sandiford
2007-07-20 17:05 ` H.J. Lu
2007-07-21 8:55 ` Richard Sandiford
2007-07-23 5:35 ` H.J. Lu
2007-07-23 10:05 ` Fix assertion failure on aliases of dynamic weak symbols Alan Modra
2007-07-23 11:43 ` Richard Sandiford [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ps2j5taz.fsf@firetop.home \
--to=richard@codesourcery.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).