This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [Android] The reason why -Bsymbolic is turned on by default
- From: Andrew Haley <aph at redhat dot com>
- To: Alexander Ivchenko <aivchenk at gmail dot com>
- Cc: Maxim Kuvyrkov <maxim dot kuvyrkov at gmail dot com>, ard dot biesheuvel at gmail dot com, gcc <gcc at gcc dot gnu dot org>
- Date: Wed, 03 Apr 2013 11:26:24 +0100
- Subject: Re: [Android] The reason why -Bsymbolic is turned on by default
- References: <CACysShhf84eXKOVLrnB_GxGvPzLwWsGFgR4k4SrYz+UThuqATQ at mail dot gmail dot com> <515BF5A7 dot 9070808 at redhat dot com> <CACysShhr2aRRU4a2NgiEDtqv=9eViOd=0PrZQLJiSCc40Kpx2A at mail dot gmail dot com>
On 04/03/2013 11:02 AM, Alexander Ivchenko wrote:
> Thank you for your answers, seems that the question about the reason
> with default -Bsymbolic is still open.. we are not clairvoyant, but it
> is implemented in GCC so we should understand the reason :)
I suppose so, but we always follow the platform ABI, whatever it is.
Doug Kwan was the original author.
> Having that in mind, we have:
> 1) All shared libraries for Android are built with -Bsymbolic
> 2) Dynamic loader throws an error if we are doing COPY relocation
> against DT_SYMBOLIC libs.
>
> So any COPY relocation is doomed to failure.. Ard, what was the reason
> for introducing the support of this type of relocations in dynamic
> loader in the first place?
Well, I could opine that the true breakage is copy relocs, not -Bsymbolic.
Copy relocs are an ingenious solution to a problem, but they're a kludge.
-Bsymbolic allows you to do something that's not strictly compatible with
Standard C/C++, and it's somewhat risky. However, it's not really a
terrible idea for shared libraries directly to reference their own data,
and for executables to reference the data in the shared library. The
linker doesn't only link C programs, and not all languages have the one
definition rule.
One could also argue that -Bsymbolic and PIC can be safer, because it
doesn't bind the size of a data symbol at compile time.
Andrew.