This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: ld script fails to hide symbols
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Ronghua Zhang <ronghuazhang at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Fri, 15 Feb 2019 14:01:50 -0800
- Subject: Re: ld script fails to hide symbols
- References: <CAGEcEtKYTDi2wkFm0pKHRUsV4c7y45TRKWqrvVjOMMWMNs8ecQ@mail.gmail.com> <CAMe9rOpC8-3JLNccE5QAxAYPN=Vuy8TqyF82EdTre78ccCtOdQ@mail.gmail.com> <CAGEcEtKeg4aMy=vcbxQQra0pvSv7=gHVvbNxg9aKr=oPZi9vtA@mail.gmail.com>
On Fri, Feb 15, 2019 at 1:59 PM Ronghua Zhang <ronghuazhang@gmail.com> wrote:
>
> Thanks. readily -sW gives the same result.
>
> This is the exposed boost symbol
>
> 946: 0000000000000108 8 TLS LOCAL DEFAULT 19 _ZN5boost4asio6detail15keyword_tss_ptrINS1_10call_stackINS1_15task_io_serviceENS1_27task_io_service_thread_infoEE7contextEE6value_E
Local symbol isn't exported.
> This is the weak symbol
>
> 116549: 00000000002ab480 9 FUNC WEAK DEFAULT 12 _ZNK3api7Service13GetCachedSizeEv
For your case, WEAK == GLOBAL.
H.J.
> On Fri, Feb 15, 2019 at 12:17 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>> On Fri, Feb 15, 2019 at 11:33 AM Ronghua Zhang <ronghuazhang@gmail.com> wrote:
>> >
>> > I have a .so library that uses boost and google protobuf. I don't want
>> > symbols from boost and goole protobuf library to be exposed, so I used the
>> > following ldscript:
>> >
>> > {
>> > global:
>> > extern "C++" {
>> > mynamespace::*;
>> > };
>> > local: *;
>> > };
>> >
>> > From the output of nm, almost all symbols from boost and google protobuf
>> > disappeared, but a few symbols are left:
>> >
>> > nm -D -C <mylib.so>
>>
>> Don't use nm for these kinds of things. Please use "readelf -sW" instead.
>>
>> > 0000000000000108 b
>> > boost::asio::detail::keyword_tss_ptr<boost::asio::detail::call_stack<boost::asio::detail::task_io_service,
>> > boost::asio::detail::task_io_service_thread_info>::context>::value_
>> > 0000000000000000 d google::protobuf::internal::ArenaImpl::thread_cache_
>> > 00000000000000d8 b grpc_core::ExecCtx::exec_ctx_
>> >
>> > I also noticed that although most are marked T as expected, a few
>> > functions in the library as marked weak symbols (W). Why is that?
>> >
>> > 00000000002b5ae0 W mynamespace::ServiceImpl::data_collection() const
>> >
>> > The function is impleme
>>
>>
>>
>> --
>> H.J.
--
H.J.