[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup e
From: |
ccoutant at google dot com |
Subject: |
[Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error |
Date: |
Mon, 20 May 2013 17:41:58 +0000 |
http://sourceware.org/bugzilla/show_bug.cgi?id=15478
--- Comment #10 from Cary Coutant <ccoutant at google dot com> 2013-05-20
17:41:58 UTC ---
> That is rather explicit, isn't it? For gold to match this behavior, I
> think all we need to do is remove the test for sym->in_reg() in the
> following code in Symbol_table::set_dynsym_indexes:
>
> // If the symbol is defined in a dynamic object and is
> // referenced strongly in a regular object, then mark the
> // dynamic object as needed. This is used to implement
> // --as-needed.
> if (sym->is_from_dynobj()
> && sym->in_reg()
> && !sym->is_undef_binding_weak())
> sym->object()->set_is_needed();
Close, but not quite. If the symbol isn't referenced from the main
program, we won't be adding a dynsym entry for it, so the test for
as-needed needs to be copied to the if clause just above:
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 2e17529..595df56 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -2381,7 +2381,17 @@ Symbol_table::set_dynsym_indexes(unsigned int index,
// and without a version.
if (!sym->should_add_dynsym_entry(this))
- sym->set_dynsym_index(-1U);
+ {
+ sym->set_dynsym_index(-1U);
+ // If the symbol is defined in a dynamic object and is
+ // referenced strongly in a dynamic object, then mark the
+ // dynamic object as needed. This is used to implement
+ // --as-needed. This is for compatibility with the GNU
+ // linker.
+ if (sym->is_from_dynobj()
+ && !sym->is_undef_binding_weak())
+ sym->object()->set_is_needed();
+ }
else if (!sym->has_dynsym_index())
{
sym->set_dynsym_index(index);
I've added a test case for this, too. Ian, if you think this is
reasonable, I'll go ahead and commit it.
-cary
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
- [Bug gold/15478] New: -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/16
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ccoutant at google dot com, 2013/05/16
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/16
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ccoutant at google dot com, 2013/05/17
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/17
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ccoutant at google dot com, 2013/05/17
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/17
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ian at airs dot com, 2013/05/18
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/19
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ccoutant at google dot com, 2013/05/20
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error,
ccoutant at google dot com <=
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ccoutant at google dot com, 2013/05/20
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/20
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, ian at airs dot com, 2013/05/21
- [Bug gold/15478] -no-as-needed required to avoid runtime symbol lookup error, sparkprime at gmail dot com, 2013/05/21