add -fPIC option for shared libbusybox.so

Peter S. Mazinger ps.m at gmx.net
Tue May 2 08:40:21 UTC 2006


On Tue, 2 May 2006, Yasushi SHOJI wrote:

> The current toolchain on x86_64 (amd64) Debian Sid doesn't seems to be
> able to create libbusybox.so if we omit -fPIC when we generate object
> files.
> 
> the linker said:
> 
>     relocation R_X86_64_32 against `a local symbol' can not be used
>     when making a shared object; recompile with -fPIC
> 
> and .config I used (only the build options section)
> 
>     #
>     # Build Options
>     #
>     # CONFIG_STATIC is not set
>     CONFIG_BUILD_LIBBUSYBOX=y
>     # CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
>     CONFIG_FEATURE_SHARED_BUSYBOX=y
>     # CONFIG_LFS is not set
>     # USING_CROSS_COMPILER is not set
>     CROSS_COMPILER_PREFIX=""
>     EXTRA_CFLAGS_OPTIONS=""
>     # CONFIG_BUILD_AT_ONCE is not set
> 
> here is a patch to work around this problem.  the patch assume that
> any other arch is working fine without the flag so the patch adds
> -fPIC iff TARGET_ARCH is x86_64.
> ---
>  Rules.mak |    3 +++
>  1 file changed, 3 insertions(+)
> 
> Index: busybox/Rules.mak
> ===================================================================
> --- busybox.orig/Rules.mak	2006-05-02 13:25:36.000000000 +0900
> +++ busybox/Rules.mak	2006-05-02 13:25:43.000000000 +0900
> @@ -233,6 +233,9 @@ LIB_CFLAGS+=$(CFLAGS_SHARED)
>  ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
>      CFLAGS_PIC:= $(call check_gcc,-fPIC,)
>      LIB_CFLAGS+=$(CFLAGS_PIC)
> +    ifeq ($(strip $(TARGET_ARCH)),x86_64)
> +        CHECKED_CFLAGS+=$(CFLAGS_PIC)
> +    endif
>  endif

this is rather a general issue, I have checked on x86 (bb-1.1.2, changed 
the CONFIG_DISABLE_SHARED, curious name for what it should do) and iirc 
it was also reported for arm on uClibc ml maybe a week ago.
CFLAGS_PIC should be used for all objects going into any shared lib (so 
at least libbb/*), but it is used only at link time (where it is 
superfluos)

Peter

-- 
Peter S. Mazinger <ps dot m at gmx dot net>           ID: 0xA5F059F2
Key fingerprint = 92A4 31E1 56BC 3D5A 2D08  BB6E C389 975E A5F0 59F2




More information about the busybox mailing list