[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [microblaze-uclinux] XIP / PIC
Hi Vincent,
The MicroBlaze compiler and linker tools support a very rudimentary form
of PIC (-fpic switch). Basically, register r20 is reserved as a kind of
"base address"/GOT register. Subsequently, every data access is offset
from the value of this register. Branches and jumps are not a problem as
long as text is continuous. Jump tables also use register r20, to make
them immune to relocation.
However, the compiler does not mark data as offset from a GOT section
and subsequently the linker never generates linkage using a GOT section.
(Using a GOT section is the typical convention for PIC code in other
architectures). Yet, by compiling your code starting for an address map
starting at 0x0, using a linker script that places all the sections
continuously in memory - you could technically load the ELF to a memory
location of your choice, fixup register r20 to contain the value of the
memory base location and things might work.
However note,
1. PIC support has not been formally verified so far with our testing.
2. PIC is not fully supported by the default EDK CRT files, libraries,
download/debug tools etc. To be able to run uClinux applications in PIC
mode, you would possibly need to tweak the uClinux equivalents of the
above items.
3. The model assumed above is quite simplistic. Other scenarios might
break. For e.g, shared libraries that by definition require separate
(from text) non-contiguous data sections will not work.
4. I am not 100% sure how easy it is to change the uClinux loader and
whether elf2flt will be compatible with these changes.
hth,
Vasanth
> -----Original Message-----
> From: owner-microblaze-uclinux@itee.uq.edu.au
[mailto:owner-microblaze-
> uclinux@itee.uq.edu.au] On Behalf Of Carr, Vincent
> Sent: Thursday, July 21, 2005 9:49 AM
> To: microblaze-uclinux@itee.uq.edu.au
> Subject: RE: [microblaze-uclinux] XIP / PIC
>
> Hi all,
>
> I've asked the below question as part of a longer email a few weeks
> back. Can anyone answer it this time round?
>
> > For applications to run directly from flash (XIP) the compiler must
> > be capable of generating Position Independent Code(PIC) and capable
of
>
> > generating the PIC form of flat executable.
> >
> > Does the current version of mb-gcc support PIC?
>
> Going twice..
>
> Vincent
>
>
> ___________________________
> microblaze-uclinux mailing list
> microblaze-uclinux@itee.uq.edu.au
> Project Home Page :
http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
> Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-
> uclinux/
>
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@itee.uq.edu.au
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/