On 30/03/2013, at 7:55 AM, Alexander Ivchenko wrote:

> Hi,
> 
> When compiling a shared library with "-mandroid -shared" the option
> -Bsymbolic for linker is turned on by default. What was the reason
> behind that default?  Isn't using of -Bsymbolic somehow dangerous and
> should be avoided..? (as e.g. is explained in the mail from Richard
> Henderson http://gcc.gnu.org/ml/gcc/2001-05/msg01551.html).
> 
> Since there is no (AFAIK) option like -Bno-symbolic we cannot use
> -fno-pic binary with COPY relocations in it (android dynamic loader
> will throw an error when there is COPY relocation against DT_SYMBOLIC
> library..)

I don't know the exact reason behind -Bsymbolic (it came as a requirement from 
Google's Android team), but I believe it produces slightly faster code (and 
fancy symbol preemption is not required on phones and TVs).  Also, it might be 
that kernel can share more memory pages of libraries compiled with -Bsymbolic, 
but I'm not sure.

Now, it appears the problem is that an application cannot use COPY relocation 
to fetch a symbol out of shared -Bsymbolic library.  I don't quite understand 
why this is forbidden by Bionic's linker.  I understand why COPY relocations 
shouldn't be applied to the inside of DT_SYMBOLIC library.  However, I don't 
immediately see the problem of applying COPY relocation against symbol from 
DT_SYMBOLIC library to the inside of an executable.

Ard, you committed 5ae44f302b7d1d19f25c4c6f125e32dc369961d9 to Bionic that adds 
handling of ARM COPY relocations.  Can you comment on why COPY relocations from 
executables to DT_SYMBOLIC libraries are forbidden?

Thank you,

--
Maxim Kuvyrkov
KugelWorks

Reply via email to