BusyboxとuClibcでちょっと遊んでみようかと思いいじってみたが……な結果になってしまった。
ターゲットはPowerPCとして、クロスコンパイラはDebianのものを使用する。
まずは、uClibc-0.9.29をコンパイルする。
# make defconfig
# make
省略
#uclibc
CC libc/sysdeps/linux/common/sbrk.os
CC libc/sysdeps/linux/common/sched_get_priority_max.os
CC libc/sysdeps/linux/common/sched_get_priority_min.os
CC libc/sysdeps/linux/common/sched_getaffinity.os
libc/sysdeps/linux/common/sched_getaffinity.c: In function `__syscall_sched_getaffinity':
libc/sysdeps/linux/common/sched_getaffinity.c:35: error: `' undeclared (first use in this function)
libc/sysdeps/linux/common/sched_getaffinity.c:35: error: (Each undeclared identifier is reported only once
libc/sysdeps/linux/common/sched_getaffinity.c:35: error: for each function it appears in.)
make[1]: *** [libc/sysdeps/linux/common/sched_getaffinity.os] Error 1
make: *** [lib/libc.so.0] Error 2
まぁ、すんなりいくとは思っていないのでググって見る。
パッチを発見した!
ここからuClibc-0.9.29-conditional-sched_affinity.patchをダウンロードしてパッチを当てる。
それ!!
AS lib/crti.o
AS lib/crtn.o
STRIP -x -R .note -R .comment lib/libc.a
AR cr lib/libc.a
STRIP -x -R .note -R .comment lib/uclibc_nonshared.a
AR cr lib/uclibc_nonshared.a
AR cr libc/libc_so.a
LD libuClibc-0.9.29.so
libc/libc_so.a(pread_write.os): In function `pwrite64':
pread_write.c:(.text+0x58): undefined reference to `__illegally_sized_syscall_arg4'
make[1]: *** [lib/libc.so] Error 1
make: *** [lib/libc.so.0] Error 2
ふ~ん……
色々調べたら、下記をDisableにすればよさそう!
General Library Settings ---> Large File Support
えいや!!
\(^o^)/ コンパイルが通ったぞ!!
次にbusybox-1.7.0をダウンロードしてコンパイル。
# export CFLAGS='-I /usr/powerpc-linux-uclibc/usr/include -nostdlib -L /usr/powerpc-linux-uclibc/lib -L /usr/powerpc-linux-uclibc/usr/lib'
# make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu- menuconfig
# make ARCH=powerpc CROSS_COMPILE=powerpc-linux-gnu-
省略
from runit/runsv.c:32:
runit/runsv.c: In function `gettimeofday_ns':
runit/runsv.c:134: error: `__NR_clock_gettime' undeclared (first use in this function)
runit/runsv.c:134: error: (Each undeclared identifier is reported only once
runit/runsv.c:134: error: for each function it appears in.)
make[1]: *** [runit/runsv.o] Error 1
make: *** [runit] Error 2
runsvか~
使いそうに無いからBusyboxの下記項目をDisableにしたれ!!
Runit Utilities ---> runsv
再度コンパイル
Trying libraries: crypt m
Failed: powerpc-linux-gnu-gcc -o busybox_unstripped -Wl,-Map -Wl,busybox_unstripped.map -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libunarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a ipsvd/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a archival/built-in.o archival/libunarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o ipsvd/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -Wl,--end-group
archival/lib.a(tar.o): In function `writeTarFile':
tar.c:(.text.writeTarFile+0x11c): undefined reference to `fcntl64'
coreutils/lib.a(cal.o): In function `cal_main':
cal.c:(.text.cal_main+0x33a): undefined reference to `__stdout'
cal.c:(.text.cal_main+0x33e): undefined reference to `__stdout'
cal.c:(.text.cal_main+0x374): undefined reference to `__fputc_unlocked'
coreutils/lib.a(catv.o): In function `catv_main':
省略
libbb/lib.a(login.o): In function `print_login_issue':
login.c:(.text.print_login_issue+0xcc): undefined reference to `__fgetc_unlocked'
login.c:(.text.print_login_issue+0x1f4): undefined reference to `__fgetc_unlocked'
libbb/lib.a(str_tolower.o): In function `str_tolower':
str_tolower.c:(.text.str_tolower+0x16): undefined reference to `__ctype_tolower'
str_tolower.c:(.text.str_tolower+0x1a): undefined reference to `__ctype_tolower'
libbb/lib.a(update_passwd.o): In function `update_passwd':
update_passwd.c:(.text.update_passwd+0x1cc): undefined reference to `fcntl64'
update_passwd.c:(.text.update_passwd+0x270): undefined reference to `fcntl64'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
uClibcの下記項目をDisableにすると解決!
(これでいいのか?)
String and Stdio Support ---> Provide a macro version of getc()
String and Stdio Support ---> Provide a macro version of putc()
LINK busybox_unstripped
Trying libraries: crypt m
Failed: powerpc-linux-gnu-gcc -o busybox_unstripped -Wl,-Map -Wl,busybox_unstripped.map -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libunarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a ipsvd/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a archival/built-in.o archival/libunarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o ipsvd/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -Wl,--end-group
coreutils/lib.a(sort.o): In function `get_key':
sort.c:(.text.get_key+0x2be): undefined reference to `__ctype_toupper'
sort.c:(.text.get_key+0x2c2): undefined reference to `__ctype_toupper'
editors/lib.a(awk.o): In function `awk_split':
awk.c:(.text.awk_split+0x1ca): undefined reference to `__ctype_toupper'
awk.c:(.text.awk_split+0x1ce): undefined reference to `__ctype_toupper'
awk.c:(.text.awk_split+0x1de): undefined reference to `__ctype_tolower'
awk.c:(.text.awk_split+0x1e2): undefined reference to `__ctype_tolower'
editors/lib.a(vi.o): In function `get_one_address':
vi.c:(.text.get_one_address+0x4e): undefined reference to `__ctype_tolower'
vi.c:(.text.get_one_address+0x52): undefined reference to `__ctype_tolower'
editors/lib.a(vi.o): In function `do_cmd':
vi.c:(.text.do_cmd+0x31a): undefined reference to `__ctype_tolower'
editors/lib.a(vi.o):vi.c:(.text.do_cmd+0x31e): more undefined references to `__ctype_tolower' follow
editors/lib.a(vi.o): In function `do_cmd':
vi.c:(.text.do_cmd+0x150a): undefined reference to `__ctype_toupper'
vi.c:(.text.do_cmd+0x1512): undefined reference to `__ctype_toupper'
vi.c:(.text.do_cmd+0x152e): undefined reference to `__ctype_tolower'
vi.c:(.text.do_cmd+0x1536): undefined reference to `__ctype_tolower'
modutils/lib.a(insmod.o): In function `print_load_map':
insmod.c:(.text.print_load_map+0x296): undefined reference to `__ctype_tolower'
insmod.c:(.text.print_load_map+0x29a): undefined reference to `__ctype_tolower'
networking/lib.a(dnsd.o): In function `convname':
dnsd.c:(.text.convname+0x22): undefined reference to `__ctype_tolower'
networking/lib.a(dnsd.o):dnsd.c:(.text.convname+0x26): more undefined references to `__ctype_tolower' follow
networking/lib.a(ifupdown.o): In function `setlocalenv':
ifupdown.c:(.text.setlocalenv+0x62): undefined reference to `__ctype_toupper'
ifupdown.c:(.text.setlocalenv+0x66): undefined reference to `__ctype_toupper'
networking/lib.a(ipcalc.o): In function `ipcalc_main':
ipcalc.c:(.text.ipcalc_main+0x276): undefined reference to `__ctype_tolower'
ipcalc.c:(.text.ipcalc_main+0x27a): undefined reference to `__ctype_tolower'
networking/lib.a(nslookup.o): In function `server_print':
nslookup.c:(.text.server_print+0x2): undefined reference to `_res'
nslookup.c:(.text.server_print+0xe): undefined reference to `_res'
networking/lib.a(nslookup.o): In function `set_default_dns':
nslookup.c:(.text.set_default_dns+0x22): undefined reference to `_res'
nslookup.c:(.text.set_default_dns+0x26): undefined reference to `_res'
networking/lib.a(wget.o): In function `gethdr':
wget.c:(.text.gethdr+0x6e): undefined reference to `__ctype_tolower'
wget.c:(.text.gethdr+0x72): undefined reference to `__ctype_tolower'
libbb/lib.a(str_tolower.o): In function `str_tolower':
str_tolower.c:(.text.str_tolower+0x16): undefined reference to `__ctype_tolower'
str_tolower.c:(.text.str_tolower+0x1a): undefined reference to `__ctype_tolower'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
も~
面倒くさいな~(-_-;)
uClibcの下記項目をDisable!
String and Stdio Support ---> Use Table Versions Of 'ctype.h' Functions.
再度、uClibcをコンパイル・インストール!
Busyboxをコンパイルすると
Trying libraries: crypt m
Failed: powerpc-linux-gnu-gcc -o busybox_unstripped -Wl,-Map -Wl,busybox_unstripped.map -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libunarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a ipsvd/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a archival/built-in.o archival/libunarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o ipsvd/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -Wl,--end-group
networking/lib.a(nslookup.o): In function `server_print':
nslookup.c:(.text.server_print+0x2): undefined reference to `_res'
nslookup.c:(.text.server_print+0xe): undefined reference to `_res'
networking/lib.a(nslookup.o): In function `set_default_dns':
nslookup.c:(.text.set_default_dns+0x22): undefined reference to `_res'
nslookup.c:(.text.set_default_dns+0x26): undefined reference to `_res'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
nslookupか……
とりあえずBusyboxの下記項目をDisable
Networking Utilities ---> nslookup をdisable
やった~!
コンパイルが通った!
あれ(?_?)
リンクライブラリがglibcだぞ!
# export LDFLAGS='-nostdlib -L /usr/powerpc-linux-uclibc/lib'
どれどれ、どうですか?
attempt to open /usr/powerpc-linux-uclibc/lib/libm.so failed
attempt to open /usr/powerpc-linux-uclibc/lib/libm.a failed
attempt to open /usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/libm.so failed
attempt to open /usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/libm.a failed
attempt to open /usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/../../../../powerpc-linux-gnu/lib/libm.so succeeded
-lm (/usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/../../../../powerpc-linux-gnu/lib/libm.so)
ld.so.1 needed by /usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/../../../../powerpc-linux-gnu/lib/libm.so
found ld.so.1 at /usr/powerpc-linux-gnu/lib/ld.so.1
libc.so.6 needed by /usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/../../../../powerpc-linux-gnu/lib/libm.so
found libc.so.6 at /usr/powerpc-linux-gnu/lib/libc.so.6
failedですか……
ln -s libcrypt-0.9.29.so /usr/powerpc-linux-uclibc/lib/libcrypt.so
ln -s libm-0.9.29.so /usr/powerpc-linux-uclibc/lib/libm.so
ln -s libuClibc-0.9.29.so /usr/powerpc-linux-uclibc/lib/libc.so
とりあえずリンクを追加して、実行!
Trying libraries: crypt m
Failed: powerpc-linux-gnu-gcc -nostdlib -L/usr/powerpc-linux-uclibc/lib -o busybox_unstripped -Wl,-Map -Wl,busybox_unstripped.map -Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections -Wl,--start-group applets/built-in.o archival/lib.a archival/libunarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a ipsvd/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a archival/built-in.o archival/libunarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o ipsvd/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o -Wl,--end-group -Wl,--start-group -lcrypt -lm -Wl,--end-group
/usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/../../../../powerpc-linux-gnu/bin/ld: warning: libc.so.0, needed by /usr/powerpc-linux-uclibc/lib/libcrypt.so, not found (try using -rpath or -rpath-link)
/usr/lib/gcc-lib/powerpc-linux-gnu/3.3.6/../../../../powerpc-linux-gnu/bin/ld: warning: cannot find entry symbol _start; defaulting to 00000000100003b1
/usr/powerpc-linux-uclibc/lib/libm.so: undefined reference to `strtof'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1
う~……(?_?)
# powerpc-linux-gnu-readelf -a /usr/powerpc-linux-uclibc/lib/libm-0.9.29.so | grep strtof
00023140 00006415 R_PPC_JMP_SLOT 00000000 strtof + 0
100: 00000000 80 FUNC GLOBAL DEFAULT UND strtof
何で、ライブラリがUNDなのでしょうか?
残念ながら、上記の問題は解決できませんでした……
誰か、教えてプリーズ!!