set fPIC option for librt

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Thu Sep 11 11:57:22 UTC 2008


On Thu, Sep 11, 2008 at 07:32:09PM +0800, JACOB BENJAMIN-VGH684 wrote:
>Hello ppl,

>and ran the resultant a.out on a monta vista box
>I got an error saying something to the effect of "Can't modify text
>section. Use GCC option -fPIC for shared objects, please".
> 
>I looked into the config files and echo-ed out stuff in the makefiles
>(esp Makefile.in in uClibc/librt) only to find out the CC variable is
>set to arm_v6_be_uclibc-gcc only. Using this compile the os files are
>created.
>I hardcoded "CC:= arm_v6_be_uclibc-gcc -fPIC"
>and then re-compiled uClibc and the program as well and it ran perfectly
>well.
> 
>Now how and where do i make the config files to have fPIC set for the
>cross compiler??


I was under the impression that we already use pic for the shared
objects, but ok.

$ grep FLAGS .config
UCLIBC_EXTRA_CFLAGS=""

i.e. run 'make menuconfig'
go to the "uClibc development/debugging options" menu and set the
"Enter any extra CFLAGS to use to build uClibc" according to your needs.

Of course you can pass UCLIBC_EXTRA_{C,LD}FLAGS down via make if you do
not want or need to keep them in your .config.

Just as a sidenote, you should not hardcode anything in any makefile,
that's what .config is for, or a wrapper-script that passes down the
desired flags, if you really need (you shouldn't).

> 
>All help appreciated.

HTH,



More information about the uClibc mailing list