This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Fwd: [PATCH] Add ld.gold option "--dynamic-list-only"
- From: Cary Coutant <ccoutant at google dot com>
- To: Vyacheslav Ostapenko <ostap73 at gmail dot com>, Binutils <binutils at sourceware dot org>
- Date: Tue, 11 Mar 2014 13:26:50 -0700
- Subject: Fwd: [PATCH] Add ld.gold option "--dynamic-list-only"
- Authentication-results: sourceware.org; auth=none
- References: <CAJgOwdkGnSh3ywit_NEQdW3NxVf_q=rTqFa0gUbeMFz6ZXvQiA at mail dot gmail dot com> <CAHACq4pwdv2AxX6B4XuGLku_xOjiKzxUC6Z5mLcdZ0kfSVHfkw at mail dot gmail dot com> <CAJgOwd=0nhubZxvV9bUKdxGsuSeoK3wsZ8n51w18zBYMHeA+AA at mail dot gmail dot com> <CAHACq4ogn0_DbVxr50T-ZezQLWH8JXEfZfhK=QckNOBVB+WFyQ at mail dot gmail dot com> <CAJgOwdmp5aq6hYm-Fyt2CKxSu=zoFMXXxLv+HoLfOosTxpiSEQ at mail dot gmail dot com> <CAHACq4r6GRhGGKW=L1t2hBT8-anQVwNQjWYqD0JYhGd0T0GYOQ at mail dot gmail dot com> <CAJgOwdm+wVy_TEDx5raCg7zF2Lw8029CyU7MjY4K4POJhC0cQQ at mail dot gmail dot com> <CAHACq4r-BgO6NyQ_7r87DZwrRrthO50yZpG_fsSstLEGMk4JUg at mail dot gmail dot com> <CAJgOwd=w+bFL+g3QBv_Aw27ALywyF2j4Zy5ps5g2SQ76EJh=ow at mail dot gmail dot com> <CAHACq4osiF5v5G2O1MRBug2q8Rxh_M6+J1ejTj6iR-CQ=NACmg at mail dot gmail dot com> <CAJgOwdkVg1mqhFN53OKR8EgD1kRf9fFbzwQ2NKUKFwLE6FgjBQ at mail dot gmail dot com>
The binutils list got dropped accidentally from our conversation.
Here's the missing part of the conversation...
Does anyone have any comment on whether a symbol that is both in
--dynamic-list script and in an --exclude-libs library should be
exported? I think it's a bug that --exclude-libs overrides
--dynamic-list -- the other way around is the only way that makes
sense to me.
-cary
----------
From: Vyacheslav Ostapenko <ostap73@gmail.com>
Date: Tue, Mar 11, 2014 at 10:52 AM
To: Cary Coutant <ccoutant@google.com>
> You can say --exclude-libs=ALL.
The project itself is divided into static libraries which should have exports.
> Yes, that's what I meant. I included "default" in the list simply
> because that (unfortunately) is the name of the visibility, and the
> option should allow you to specify all four values
> (--default-visibility=default would be the default, and would be a way
> to cancel/override an earlier use of the option).
Ok
That's doable.
Thanks for suggestion,
Slava
----------
From: Cary Coutant <ccoutant@google.com>
Date: Tue, Mar 11, 2014 at 11:04 AM
To: Vyacheslav Ostapenko <ostap73@gmail.com>
>> You can say --exclude-libs=ALL.
>
> The project itself is divided into static libraries which should have exports.
But your --dynamic-list-only option would still apply to *all*
libraries (and all .o files as well). How would that work if
--exclude-libs=ALL doesn't?
-cary
----------
From: Vyacheslav Ostapenko <ostap73@gmail.com>
Date: Tue, Mar 11, 2014 at 11:45 AM
To: Cary Coutant <ccoutant@google.com>
--dynamic-list-only excludes everything that is not in dynamic list.
--exclude-libs=ALL excludes everything from static libs even if those
symbols are in dynamic list.
I 1st thought that this is a bug, but from description it is not clear
is it correct behavior or not. In any case, changing it now would
break things for people who already use this and expect this behavior,
so I don't think it's an option.
----------
From: Cary Coutant <ccoutant@google.com>
Date: Tue, Mar 11, 2014 at 12:25 PM
To: Vyacheslav Ostapenko <ostap73@gmail.com>
> --exclude-libs=ALL excludes everything from static libs even if those
> symbols are in dynamic list.
> I 1st thought that this is a bug, but from description it is not clear
> is it correct behavior or not. In any case, changing it now would
> break things for people who already use this and expect this behavior,
> so I don't think it's an option.
I think it's a bug. The ld manual says: "Specifies a list of archive
libraries from which symbols should not be automatically exported."
The keyword here is "automatically". If you put a symbol in
--dynamic-list, it should be exported regardless of that. The patch
below should fix that.
-cary
diff --git a/gold/symtab.cc b/gold/symtab.cc
index 1a69f5b..d77747e 100644
--- a/gold/symtab.cc
+++ b/gold/symtab.cc
@@ -1219,8 +1219,10 @@ Symbol_table::add_from_relobj(
// Fix up visibility if object has no-export set.
if (relobj->no_export()
- && (orig_st_shndx != elfcpp::SHN_UNDEF || !is_ordinary))
- {
+ && (orig_st_shndx != elfcpp::SHN_UNDEF || !is_ordinary)
+ && !(parameters->options().in_dynamic_list(name)
+ || parameters->options().is_export_dynamic_symbol(name)))
+ {
// We may have copied symbol already above.
if (psym != &sym2)
{
----------
From: Vyacheslav Ostapenko <ostap73@gmail.com>
Date: Tue, Mar 11, 2014 at 12:30 PM
To: Cary Coutant <ccoutant@google.com>
Yes, this should fix it.
In this case should I work on the default_visibility option? I think
it still might be usable.
Thanks,
Slava