Fwd: [PATCH] Add ld.gold option "--dynamic-list-only"

Cary Coutant ccoutant@google.com
Tue Mar 11 20:26:00 GMT 2014


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



More information about the Binutils mailing list