diff options
Diffstat (limited to 'doc/HOWTO_bbox_with_uclibc.txt')
-rw-r--r-- | doc/HOWTO_bbox_with_uclibc.txt | 302 |
1 files changed, 302 insertions, 0 deletions
diff --git a/doc/HOWTO_bbox_with_uclibc.txt b/doc/HOWTO_bbox_with_uclibc.txt new file mode 100644 index 0000000..bcbbbb6 --- /dev/null +++ b/doc/HOWTO_bbox_with_uclibc.txt @@ -0,0 +1,302 @@ +How to build busybox statically against uclibc, minimizing its size. + +Very sketchy at the moment. Send questions to vda.linux@googlemail.com. + +First, build and install cross-compiling toolchain. Start with binutils. +When binutils are built and installed, you should have these files: + +$ ls -l /usr/bin/i486-linux-uclibc-* | grep binutils +lrwxrwxrwx 1 root root 72 Jul 21 18:17 /usr/bin/i486-linux-uclibc-addr2line -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-addr2line +lrwxrwxrwx 1 root root 65 Jul 21 18:17 /usr/bin/i486-linux-uclibc-ar -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-ar +lrwxrwxrwx 1 root root 65 Jul 21 18:17 /usr/bin/i486-linux-uclibc-as -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-as +lrwxrwxrwx 1 root root 70 Jul 21 18:17 /usr/bin/i486-linux-uclibc-c++filt -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-c++filt +lrwxrwxrwx 1 root root 65 Jul 21 18:17 /usr/bin/i486-linux-uclibc-ld -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-ld +lrwxrwxrwx 1 root root 65 Jul 21 18:17 /usr/bin/i486-linux-uclibc-nm -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-nm +lrwxrwxrwx 1 root root 70 Jul 21 18:17 /usr/bin/i486-linux-uclibc-objcopy -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-objcopy +lrwxrwxrwx 1 root root 70 Jul 21 18:17 /usr/bin/i486-linux-uclibc-objdump -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-objdump +lrwxrwxrwx 1 root root 69 Jul 21 18:17 /usr/bin/i486-linux-uclibc-ranlib -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-ranlib +lrwxrwxrwx 1 root root 70 Jul 21 18:17 /usr/bin/i486-linux-uclibc-readelf -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-readelf +lrwxrwxrwx 1 root root 67 Jul 21 18:17 /usr/bin/i486-linux-uclibc-size -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-size +lrwxrwxrwx 1 root root 70 Jul 21 18:17 /usr/bin/i486-linux-uclibc-strings -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-strings +lrwxrwxrwx 1 root root 68 Jul 21 18:17 /usr/bin/i486-linux-uclibc-strip -> /usr/app/binutils-2.17-i486-linux-uclibc/bin/i486-linux-uclibc-strip + +After that, build cross-gcc. You should now have this: + +$ ls -l /usr/bin/i486-linux-uclibc-* | grep -v binutils +lrwxrwxrwx 1 root root 62 Aug 21 13:38 /usr/bin/i486-linux-uclibc-c++ -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-c++ +lrwxrwxrwx 1 root root 62 Aug 21 13:38 /usr/bin/i486-linux-uclibc-cpp -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-cpp +lrwxrwxrwx 1 root root 62 Aug 21 13:38 /usr/bin/i486-linux-uclibc-g++ -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-g++ +lrwxrwxrwx 1 root root 62 Aug 21 13:38 /usr/bin/i486-linux-uclibc-gcc -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-gcc +lrwxrwxrwx 1 root root 68 Aug 21 12:43 /usr/bin/i486-linux-uclibc-gcc-4.1.1 -> /usr/app/gcc-4.1.1-i486-linux-uclibc/bin/i486-linux-uclibc-gcc-4.1.1 +lrwxrwxrwx 1 root root 68 Aug 21 13:38 /usr/bin/i486-linux-uclibc-gcc-4.2.1 -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-gcc-4.2.1 +lrwxrwxrwx 1 root root 65 Aug 21 13:38 /usr/bin/i486-linux-uclibc-gccbug -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-gccbug +lrwxrwxrwx 1 root root 63 Aug 21 13:38 /usr/bin/i486-linux-uclibc-gcov -> /usr/app/gcc-4.2.1-i486-linux-uclibc/bin/i486-linux-uclibc-gcov + +Depending on your packaging choice, you may end up with actual files in /usr/bin, +not symlinks. In fact, having symlinks is not typical, but I find it much +more convenient. + +Now you need to build uclibc. +Full uclibc .config can be found at the end of this file. +Key points: + +Uncheck shared library support: +[ ] Generate only Position Independent Code (PIC) +[ ] Enable support for shared libraries + +Since busybox uses --gc-sections, it's advantageous to pass +"-ffunction-sections -fdata-sections" options to gcc. This will make +your busybox binary ~6k smaller. I set the following option +in .config for that: + +UCLIBC_EXTRA_CFLAGS="-ffunction-sections -fdata-sections -falign-functions=1 -falign-labels=1 -falign-loops=1 -falign-jumps=1 -fomit-frame-pointer" + +Build and install you uclibc. + +Now you can build busybox against it by using + +export ARCH=i386 +make CROSS_COMPILE=i486-linux-uclibc- ... + +After you built it, find busybox_ld.out file in the top build directory, +rename it to busybox_ldscript, remove everything except linker script, +and edit it as follows: + +--- busybox_ld.out 2007-09-16 20:19:51.000000000 +0100 ++++ busybox_ldscript 2007-08-25 18:10:15.000000000 +0100 +@@ -65,7 +65,7 @@ + PROVIDE (__etext = .); + PROVIDE (_etext = .); + PROVIDE (etext = .); +- .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } ++ .rodata : { *(.rodata SORT_BY_ALIGNMENT(.rodata.*) .gnu.linkonce.r.*) } + .rodata1 : { *(.rodata1) } + .eh_frame_hdr : { *(.eh_frame_hdr) } + .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) } +@@ -134,7 +134,7 @@ + .got.plt : { *(.got.plt) } + .data : + { +- *(.data .data.* .gnu.linkonce.d.*) ++ *(.data SORT_BY_ALIGNMENT(.data.*) .gnu.linkonce.d.*) + KEEP (*(.gnu.linkonce.d.*personality*)) + SORT(CONSTRUCTORS) + } +@@ -144,7 +144,7 @@ + .bss : + { + *(.dynbss) +- *(.bss .bss.* .gnu.linkonce.b.*) ++ *(.bss SORT_BY_ALIGNMENT(.bss.*) .gnu.linkonce.b.*) + *(COMMON) + /* Align here to ensure that the .bss section occupies space up to + _end. Align after .bss to ensure correct alignment even if the + +Now delete busybox and busybox_unstripped binaries, and rerun make. +It will do final link again, with smaller result. Example: + +$ size busybox busybox.optimized + text data bss dec hex filename + 772898 1084 10844 784826 bf9ba busybox + 772680 1051 10724 784455 bf847 busybox.optimized + +Nearly 400 bytes saved on padding. + +Sample uclibc .config follows +============================= +# +# Automatically generated make config: don't edit +# Fri Aug 3 12:16:10 2007 +# +# TARGET_alpha is not set +# TARGET_arm is not set +# TARGET_bfin is not set +# TARGET_cris is not set +# TARGET_e1 is not set +# TARGET_frv is not set +# TARGET_h8300 is not set +# TARGET_hppa is not set +TARGET_i386=y +# TARGET_i960 is not set +# TARGET_ia64 is not set +# TARGET_m68k is not set +# TARGET_microblaze is not set +# TARGET_mips is not set +# TARGET_nios is not set +# TARGET_nios2 is not set +# TARGET_powerpc is not set +# TARGET_sh is not set +# TARGET_sh64 is not set +# TARGET_sparc is not set +# TARGET_v850 is not set +# TARGET_vax is not set +# TARGET_x86_64 is not set + +# +# Target Architecture Features and Options +# +TARGET_ARCH="i386" +FORCE_OPTIONS_FOR_ARCH=y +# CONFIG_GENERIC_386 is not set +# CONFIG_386 is not set +CONFIG_486=y +# CONFIG_586 is not set +# CONFIG_586MMX is not set +# CONFIG_686 is not set +# CONFIG_PENTIUMII is not set +# CONFIG_PENTIUMIII is not set +# CONFIG_PENTIUM4 is not set +# CONFIG_K6 is not set +# CONFIG_K7 is not set +# CONFIG_ELAN is not set +# CONFIG_CRUSOE is not set +# CONFIG_WINCHIPC6 is not set +# CONFIG_WINCHIP2 is not set +# CONFIG_CYRIXIII is not set +# CONFIG_NEHEMIAH is not set +TARGET_SUBARCH="" + +# +# Using ELF file format +# +ARCH_LITTLE_ENDIAN=y + +# +# Using Little Endian +# +ARCH_HAS_MMU=y +ARCH_USE_MMU=y +UCLIBC_HAS_FLOATS=y +UCLIBC_HAS_FPU=y +DO_C99_MATH=y +KERNEL_HEADERS="../linux-2.6.18.1/include" +HAVE_DOT_CONFIG=y + +# +# General Library Settings +# +# HAVE_NO_PIC is not set +# DOPIC is not set +# HAVE_NO_SHARED is not set +# ARCH_HAS_NO_LDSO is not set +# HAVE_SHARED is not set +UCLIBC_CTOR_DTOR=y +# HAS_NO_THREADS is not set +# UCLIBC_HAS_THREADS is not set +UCLIBC_HAS_LFS=y +# MALLOC is not set +# MALLOC_SIMPLE is not set +MALLOC_STANDARD=y +# MALLOC_GLIBC_COMPAT is not set +UCLIBC_DYNAMIC_ATEXIT=y +# COMPAT_ATEXIT is not set +# UCLIBC_SUSV3_LEGACY is not set +# UCLIBC_SUSV3_LEGACY_MACROS is not set +UCLIBC_HAS_SHADOW=y +# UCLIBC_HAS_PROGRAM_INVOCATION_NAME is not set +UCLIBC_HAS___PROGNAME=y +UNIX98PTY_ONLY=y +ASSUME_DEVPTS=y +UCLIBC_HAS_TM_EXTENSIONS=y +UCLIBC_HAS_TZ_CACHING=y +UCLIBC_HAS_TZ_FILE=y +UCLIBC_HAS_TZ_FILE_READ_MANY=y +UCLIBC_TZ_FILE_PATH="/etc/TZ" + +# +# Advanced Library Settings +# +UCLIBC_PWD_BUFFER_SIZE=256 +UCLIBC_GRP_BUFFER_SIZE=256 + +# +# Networking Support +# +UCLIBC_HAS_IPV6=y +UCLIBC_HAS_RPC=y +UCLIBC_HAS_FULL_RPC=y +UCLIBC_HAS_REENTRANT_RPC=y +# UCLIBC_USE_NETLINK is not set +# UCLIBC_HAS_BSD_RES_CLOSE is not set + +# +# String and Stdio Support +# +UCLIBC_HAS_STRING_GENERIC_OPT=y +UCLIBC_HAS_STRING_ARCH_OPT=y +UCLIBC_HAS_CTYPE_TABLES=y +UCLIBC_HAS_CTYPE_SIGNED=y +UCLIBC_HAS_CTYPE_UNSAFE=y +# UCLIBC_HAS_CTYPE_CHECKED is not set +# UCLIBC_HAS_CTYPE_ENFORCED is not set +# UCLIBC_HAS_WCHAR is not set +# UCLIBC_HAS_LOCALE is not set +# UCLIBC_HAS_HEXADECIMAL_FLOATS is not set +# UCLIBC_HAS_GLIBC_CUSTOM_PRINTF is not set +# USE_OLD_VFPRINTF is not set +UCLIBC_PRINTF_SCANF_POSITIONAL_ARGS=9 +# UCLIBC_HAS_SCANF_GLIBC_A_FLAG is not set +# UCLIBC_HAS_STDIO_BUFSIZ_NONE is not set +# UCLIBC_HAS_STDIO_BUFSIZ_256 is not set +# UCLIBC_HAS_STDIO_BUFSIZ_512 is not set +UCLIBC_HAS_STDIO_BUFSIZ_1024=y +# UCLIBC_HAS_STDIO_BUFSIZ_2048 is not set +# UCLIBC_HAS_STDIO_BUFSIZ_4096 is not set +# UCLIBC_HAS_STDIO_BUFSIZ_8192 is not set +UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE=y +# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4 is not set +# UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8 is not set +# UCLIBC_HAS_STDIO_SHUTDOWN_ON_ABORT is not set +UCLIBC_HAS_STDIO_GETC_MACRO=y +UCLIBC_HAS_STDIO_PUTC_MACRO=y +UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION=y +# UCLIBC_HAS_FOPEN_LARGEFILE_MODE is not set +# UCLIBC_HAS_FOPEN_EXCLUSIVE_MODE is not set +# UCLIBC_HAS_GLIBC_CUSTOM_STREAMS is not set +UCLIBC_HAS_PRINTF_M_SPEC=y +UCLIBC_HAS_ERRNO_MESSAGES=y +# UCLIBC_HAS_SYS_ERRLIST is not set +UCLIBC_HAS_SIGNUM_MESSAGES=y +# UCLIBC_HAS_SYS_SIGLIST is not set +UCLIBC_HAS_GNU_GETOPT=y +UCLIBC_HAS_GNU_GETSUBOPT=y + +# +# Big and Tall +# +UCLIBC_HAS_REGEX=y +UCLIBC_HAS_REGEX_OLD=y +UCLIBC_HAS_FNMATCH=y +UCLIBC_HAS_FNMATCH_OLD=y +UCLIBC_HAS_WORDEXP=y +UCLIBC_HAS_FTW=y +UCLIBC_HAS_GLOB=y +# UCLIBC_HAS_GNU_GLOB is not set + +# +# Library Installation Options +# +RUNTIME_PREFIX="/usr/app/uclibc-NEW/$(TARGET_ARCH)/" +DEVEL_PREFIX="/usr/app/uclibc-NEW/$(TARGET_ARCH)/usr/" + +# +# Security options +# +# UCLIBC_HAS_ARC4RANDOM is not set +# HAVE_NO_SSP is not set +# UCLIBC_HAS_SSP is not set +UCLIBC_BUILD_NOEXECSTACK=y + +# +# uClibc development/debugging options +# +CROSS_COMPILER_PREFIX="" +UCLIBC_EXTRA_CFLAGS="-ffunction-sections -fdata-sections -falign-functions=1 -falign-labels=1 -falign-loops=1 -falign-jumps=1 -fomit-frame-pointer" +# DODEBUG is not set +DOSTRIP=y +# DOASSERTS is not set +# UCLIBC_MALLOC_DEBUGGING is not set +WARNINGS="-Wall" +# EXTRA_WARNINGS is not set +# DOMULTI is not set +# UCLIBC_MJN3_ONLY is not set |