Re: Decreasing size of final executable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2023-06-30 at 08:28 +0200, Jędrzej Dudkiewicz via Gcc-help wrote:
> This is basically the same as
> https://stackoverflow.com/questions/76580329/hide-symbols-from-executable
> I pasted it below in its entirety.
> 
> If this is primarily a binutils question I will paste it there, but I
> *think* it is mostly a gcc related question.
> 
> ------8< ------8< ------8< ------8< ------8< ------8< ------8< ------
> <https://stackoverflow.com/posts/76580329/timeline>
> 
> I use gcc 9.2.0 to compile c++ program for arm. I use boost 1.71.0 (mainly
> asio). My final executable works fine, but even after stripping readelf -W
> prog --dyn-syms shows e.g. these entries:
> 
>    904: 000dc518     1 OBJECT  UNIQUE DEFAULT   25
> _ZN5boost4asio6detail30execution_context_service_baseINS1_16resolver_serviceINS0_2ip3tcpEEEE2idE
>    912: 000dc498     1 OBJECT  UNIQUE DEFAULT   25
> _ZN5boost4asio6detail30execution_context_service_baseINS1_18signal_set_serviceEE2idE
>    943: 000dc46c     4 OBJECT  UNIQUE DEFAULT   25
> _ZN5boost4asio6detail17posix_global_implINS0_14system_contextEE11static_ptr_E
>    951: 000dc4b0     1 OBJECT  UNIQUE DEFAULT   25
> _ZN5boost4asio6detail12service_baseINS1_14strand_serviceEE2idE
>    990: 000dc48c     4 OBJECT  UNIQUE DEFAULT   25
> _ZGVN5boost4asio6detail10call_stackINS1_14strand_service11strand_implEhE4top_E
>   1005: 0009a484    38 OBJECT  WEAK   DEFAULT   15
> _ZTSN5boost4asio22service_already_existsE
>   1006: 000a3808    87 OBJECT  WEAK   DEFAULT   15
> _ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_any_castEEEEE
>   1024: 0009ad9c    65 OBJECT  WEAK   DEFAULT   15
> _ZTSN5boost16exception_detail19error_info_injectorISt11logic_errorEE
>   1038: 0009ee34   128 OBJECT  WEAK   DEFAULT   15
> _ZTSN5boost4asio6detail30execution_context_service_baseINS1_22deadline_timer_serviceINS0_11time_traitsINS_10posix_time5ptimeEEEEEEE
>   1045: 0009ade0    84 OBJECT  WEAK   DEFAULT   15
> _ZTSN5boost16exception_detail10clone_implINS0_19error_info_injectorISt11logic_errorEEEE
> 
> As far as I can tell, these symbols are known to the compiler/linker, as
> their Ndx is not UND (so undefined), which means their presence in the
> symbol table is not necessary. Since the whole program has 690kB and as
> strings shows these entries in the symbol table take more or less 140kB,
> I'd like to remove them.
> 
> Currently I am compiling using the following compiler/linker options:
> -fvisibility=hidden -fvisibility-inlines-hidden -flto -Wl,--exclude-libs,ALL
> -Wl,-r,--discard-all -Wl,-flto

Hmm, isn't "-r" for partial linking?  How can you use it to link an
executable?

-- 
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux