set fPIC option for librt
Hello ppl, I am totally new to uClibc. I did search for my problem in the archives but could not really find a solution. My problem: I wrote a simple program : #include time.h #include stdio.h int main() { timer_t tid; if(timer_create(CLOCK_REALTIME, NULL, tid) == 0) printf(timer created\n); else printf(timer create failed\n); timer_delete(tid); return 0; } I cross compiled it with: arm_v6_be_uclibc-gcc timerUse.c -lrt 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?? All help appreciated. cheers - Ben. ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: set fPIC option for librt
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, ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: set fPIC option for librt
Bernhard Reutner-Fischer wrote: 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. Yes, exactly. I do think that there is some bogus asm code that is not PIC, and FORCE_SHAREBLAE_TEXT_SEGMENT is set so linker refuses loading non pic libraries. Carmelo $ 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, ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: set fPIC option for librt
On Thu, Sep 11, 2008 at 02:13:07PM +0200, Carmelo AMOROSO wrote: Bernhard Reutner-Fischer wrote: On Thu, Sep 11, 2008 at 07:32:09PM +0800, JACOB BENJAMIN-VGH684 wrote: 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. Yes, exactly. I do think that there is some bogus asm code that is not PIC, and FORCE_SHAREBLAE_TEXT_SEGMENT is set so linker refuses loading non pic libraries. Perhaps you can pinpoint these spots, Jacob. thanks, ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc
Re: set fPIC option for librt
On (11/09/08 19:32), JACOB BENJAMIN-VGH684 wrote: Hello ppl, I am totally new to uClibc. I did search for my problem in the archives but could not really find a solution. My problem: I wrote a simple program : #include time.h #include stdio.h int main() { timer_t tid; if(timer_create(CLOCK_REALTIME, NULL, tid) == 0) printf(timer created\n); else printf(timer create failed\n); timer_delete(tid); return 0; } I cross compiled it with: arm_v6_be_uclibc-gcc timerUse.c -lrt 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. This means that there are TEXTRELS in the shared libraries, uclibc rejects it by default. If you have FORCE_SHAREABLE_TEXT_SEGMENTS set in your .config then unset it and recompile uclibc and see if it works. -Khem ___ uClibc mailing list uClibc@uclibc.org http://busybox.net/cgi-bin/mailman/listinfo/uclibc