Building an XIP application on arm-elf
Jeff Johnston
jjohnstn@redhat.com
Thu Feb 23 23:50:00 GMT 2006
Shaun Jackman wrote:
> Hello,
>
> I'd like to try my hand at building an XIP application with newlib for
> an arm-elf target. The application will be statically linked, so I'm
> not worried about shared libraries yet. To build the XIP application
> though, all the code has to be compiled as PIC. This includes libc, of
> course. Well, now I say of course. That fine point slipped my mind
> this morning.
>
> Can newlib be coerced to build both a PIC and non-PIC libc.a in the
> same build tree? I suspect the answer is no. In which case I'll build
> the PIC libc.a in a separate build tree. I see newlib/configure has a
> --with-pic option. Should I use this? Or should I simply pass -fPIC on
> to the target's CFLAGS somehow?
>
Newlib can only be coerced to build two or more versions of libc.a in
the same build tree through a multilib option. A multilib solution also
automatically takes care of libgcc.a and any other target libraries for you.
The --with-pic option is for libtool's usage. Using libtool requires
you build on a native platform because it performs execution tests which
won't run if you are doing a cross-build. You have to specify libtool
usage in the newlib configure.host file. By default, libtool usage in
newlib builds a shared library unless overridden by --disable-shared on
the configure. I am assuming you are building cross-platform in this case.
You can pass -fPIC on a newlib build by specifying TARGET_CFLAGS=-fPIC
on the make call.
> Off-topic, will I likely have to do the same thing for libgcc.a?
>
Yes, the arm-linux configuration knows to add -fPIC, but not arm-elf, if
I read the gcc/config/arm files correctly. I'm not sure how you
override the target flags in this case.
-- Jeff J.
More information about the Newlib
mailing list