Jun Sun wrote:
> On Thu, Nov 27, 2008 at 02:24:48AM +0800, Lin KJ wrote:
> > In the ARM uClinux world, it seems that the user land XIP code should be 
> > compiled with the "-fpic" and "-msingle-pic-base" flags.
> > Why not just "-fpic" flag?
> > Is it concern with the elf2flt tool?
> 
> I think it has more to do the loading FLAT executables. FLAT
> does not need run-time loader. As a result, relocatable symboles
> are only fixed up once by kernel.  Single pic base would be much
> eaiser to do for this case.

That's not the reason.

When using XIP, FLAT executable code is never relocated by the kernel,
while the writable data segment is relocated every time you start the
executable.

(Non-XIP excutables relocate both the code and data at every time.)

The reason you need -msingle-pic-base is because the data segment is
at a separate, independent location from the code segment.

With traditional PIC, the data segment is always PC-relative a fixed
offset from the code segment, and PC-relative instructions are used to
access data from the code.

This is not true for XIP, hence the extra option so the data segment
address is passed in a dedicated CPU register.

> > I can have the applications and uClibc to be compiled with
> > "-msingle-pic-base", but how about the libgcc.a?  Does the
> > libgcc.a have to be produced with the "-msingle-pic-base" too?

Some parts of libgcc.a will work without -msingle-pic-base, but some
parts may need it.  Many programs don't use all of libgcc.a.

I see in the ARM uClinux toolchains I'm using that there are multiple
versions of libgcc.a, and if -msingle-pic-base is used to link a
program, then it selects the version of libgcc.a which was compiled
with that option.

-- Jamie
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev

Reply via email to