Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] thumb fixes

On Mon, Sep 08, 2008 at 01:36:42PM +0300, Mikko Rapeli wrote:
> NetBSD comes with binutils 2.16.1 and some fixes so switching to
> 2.18.50 solves this thumb issues. The whole tree does not compile with
> ld and others from binutils-2.18.50 but enough to run thumb mode /bin/sh 
> and /bin/cat work with thumb mode /lib/libc.so and others. Though
> /libexec/ld.elf_so still needs to be in ARM mode.

I had forgotten the -mlong-calls workaround on in my build script, but
newer binutils fixes this issues also without it. Here's the latest build 
script for thumb mode userspace:

#!/bin/sh -x

# Used to build NetBSD userspace to thumb

# recuirements:
# netbsd-current source tree
# with binutils 2.18.50 (or with some ARM/thumb fixes)
# and a patch http://mail-index.netbsd.org/port-arm/2008/08/20/msg000342.html

# usage instructions for building a thumb userspace:
# cd netbsd_source_dir
# ./build.sh -U -O obj -j 3 -m evbarm tools && ./thumb.sh 

TOOLDIR=obj/tooldir.$(uname -s)-$(uname -r)-$(uname -i)

./build.sh -j 3 -U -O obj -m evbarm makewrapper || exit -1

echo thumb.sh clean objects

$TOOLDIR/bin/nbmake-evbarm cleandir

echo thumb.sh prepare to build ARM mode libc and linker

CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm obj || exit -1
CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm do-distrib-dirs || exit -1
CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm includes || exit -1
CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm do-lib-csu || exit -1
CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm do-libgcc || exit -1

echo thumb.sh build ARM mode libc for linker

CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm do-lib-libc || exit -1

echo thumb.sh build ARM mode linker linked statically with ARM mode libc, since
echo thumb.sh thumb mode does not work

CPUFLAGS=-mthumb-interwork $TOOLDIR/bin/nbmake-evbarm do-ld.so || exit -1

echo thumb.sh clean destdir and backup ARM mode /libexec/ld.elf_so

rm -rf obj/destdir.evbarm || exit -1
mv obj/libexec obj/libexec-arm || exit -1

echo thumb.sh start sub-shell for thumb compilation


# don't halt on linker warnings (libcrypto's patent warnings)
#export NOGCCERROR=yes

# binutils 2.18.50 brings build issues with GCC, ld, etc
export MKGCCCMDS=no 
export MKGZBOOT=no
export MKBFD=no

export SAFE_CPUFLAGS="-mthumb-interwork"

# contain asm
CSU_FAILING_OBJECTS="crt0 crti crtn gcrt0"

# These cause runtime failures if build in thumb mode
CSU_RUNTIME_FAILING_OBJECTS="crtbegin crtbeginT crtend crtbeginS crtendS"

  eval `echo export CPUFLAGS_$i=\"$SAFE_CPUFLAGS\"`

# gcrt0 target in lib/csu/common_elf has a manual build command and
# an empty .IMPSRC make variable. Working around this by using CPUFLAGS_ 
# variable which defaults safely:

# To get this list: build libc with CPUFLAGS=-mthumb and MAKEFLAGS=-k to 
# gather failing object to log 
# then run:
# grep '^*** Failed tar.*.[so,o] log' | awk -e '{ print $4 }'|  sed -e 
's/\.so//' | sed -e 's/\.o//' | sort | uniq | xargs > thumb_failing_objects.txt 

LIBC_FAILING_OBJECTS='accept access acct tmp_adjtime aio_suspend alloca 
atomic_cas_up atomic_init_testset bcopy bind brk byte_swap_2 byte_swap_4 bzero 
cerror chdir chflags chmod chown chroot clk_test_force_onoff clk_test_getstatus 
clock_getres clock_gettime tmp_clock_settime tmp_clone close compat_msgctl 
compat_Ovfork compat___semctl compat_setjmp compat_shmctl compat_sigaction 
compat_sigpending compat_sigprocmask compat_sigreturn compat___sigreturn14 
compat_sigsetjmp compat_sigsuspend compat___sigtramp1 connect divsi3 dup dup2 
exect execve _exit extattrctl extattr_delete_fd extattr_delete_file 
extattr_delete_link extattr_get_fd extattr_get_file extattr_get_link 
extattr_list_fd extattr_list_file extattr_list_link extattr_set_fd 
extattr_set_file extattr_set_link fchdir fchflags fchmod fchown fchroot fcntl 
fdatasync ffs tmp_fhopen40 tmp_fhstat40 tmp_fhstatvfs140 fktrace flock fork 
fpathconf tmp_fstat30 fstatvfs1 fsync fsync_range tmp_ftruncate futimes 
getcontext tmp_getcwd tmp_getdents30 getegid geteuid tmp_getfh30 getgid 
getgroups getitimer tmp_getlogin getpeername getpgid getpgrp getpid getppid 
getpriority getrlimit getrusage getsid getsockname getsockopt gettimeofday 
getuid getvfsstat ioctl issetugid kevent kill kqueue _ksem_close _ksem_destroy 
_ksem_getvalue _ksem_init _ksem_open _ksem_post _ksem_trywait _ksem_unlink 
_ksem_wait ktrace lchflags lchmod lchown lfs_bmapv lfs_markv lfs_segclean 
lfs_segwait link listen tmp_lseek tmp_lstat30 lutimes _lwp_continue _lwp_create 
_lwp_ctl _lwp_detach _lwp_exit _lwp_getname _lwp_getprivate _lwp_kill _lwp_park 
_lwp_self _lwp_setname _lwp_setprivate _lwp_suspend _lwp_unpark _lwp_unpark_all 
_lwp_wait _lwp_wakeup madvise mcount memcmp memcpy memmove memset mincore 
minherit mkdir mkfifo mknod mlock mlockall tmp_mmap modctl tmp_mount50 mprotect 
mq_receive mq_send mq_timedreceive mq_timedsend mremap tmp_msgctl13 msgget 
msgrcv msgsnd tmp_msync13 munlock munlockall munmap nanosleep nfssvc 
tmp_ntp_adjtime tmp_ntp_gettime30 open pathconf pipe pmc_control pmc_get_info 
poll pollts tmp_posix_chown tmp_posix_fadvise50 tmp_posix_fchown 
tmp_posix_lchown tmp_posix_rename tmp_pread tmp_preadv profil pselect ptrace 
tmp_pwrite tmp_pwritev quotactl rasctl read readlink readv reboot recvfrom 
recvmsg rename revoke rmdir sa_enable sa_preempt sa_register sa_setconcurrency 
sa_stacks sa_yield sbrk _sched_getaffinity _sched_getparam _sched_setaffinity 
_sched_setparam sched_yield select semconfig tmp___semctl13 semget semop 
sendmsg sendto setcontext setegid seteuid setgid setgroups setitimer setjmp 
_setjmp tmp_setlogin setpgid setpriority setregid setreuid setrlimit setsid 
setsockopt tmp_settimeofday setuid shmat tmp_shmctl13 shmdt shmget shutdown 
tmp_sigaction_sigtramp tmp_sigaltstack14 tmp_sigpending14 tmp_sigprocmask14 
sigsetjmp tmp_sigsuspend14 tmp_sigtimedwait __sigtramp2 tmp_socket30 socketpair 
tmp_stat30 statvfs1 strcmp strncmp swapcontext swapctl symlink sync sysarch 
syscall __syscall tmp_sysctl timer_create timer_delete timer_getoverrun 
timer_gettime timer_settime tmp_truncate umask undelete unlink unmount utimes 
utrace uuidgen vadvise __vfork14 wait4 write writev'

# functions in these object produce runtime errors in thumb mode:
# initfini calls atomic_init in thumb mode but atomic_init_testset 
# only compiles in ARM mode
RUNTIME_ERRORS='atexit initfini'

# compiler bug with c++ code, note 's/-/_/g':
GCCBUG="application exceptions atffile config formats ui fs tests ext_inst 
fstream_inst fstream_inst ios_inst istream_inst istream locale_inst localename 
ostream_inst sstream_inst string_inst strstream valarray_inst wstring_inst 
wlocale_inst eh_personality vec text" 

# Contains inline ARM asm and do not compile to thumb. Note: there are many
# lock.o's but there is no way to distinguish them with this build hack.
ASM="k_tanf _context_u pthread_lock _pset_bind aio_cancel aio_error aio_fsync 
aio_read aio_return aio_write lio_listio mq_close mq_getattr aio_cancel 
aio_error aio_fsync aio_return aio_write lio_listio mq_close mq_getattr 
mq_notify mq_open mq_setattr mq_unlink pset_assign pset_create pset_destroy 
srtbegin abortfixup stackptr lock "

NEW_ASM='__syscall __clone __clone __fhopen40 __fhstatvfs140 __fhstat40 
__fstat30 __getcwd __getdents30 __getfh30 __getlogin __lstat30 __mount50 
__msgctl13 __ntp_gettime30 __posix_chown __posix_fadvise50 __posix_fchown 
__posix_lchown __posix_rename ____semctl13 __setlogin __shmctl13 
__sigaltstack14 __sigtimedwait __sigpending14 __sigaction_sigtramp __socket30 
__stat30 __sysctl tmp__lwp_getprivate tmp_mremap __msync13 __sigsuspend14 
__sigprocmask14 __clone __fhopen40 __fhstat40 __fhstatvfs140 __fstat30 __getcwd 
__getdents30 __getfh30 __getlogin __lstat30 __mount50 __msgctl13 
__ntp_gettime30 __posix_chown __posix_fadvise50 __posix_fchown __posix_lchown 
__posix_rename ____semctl13 __setlogin __shmctl13 __sigaltstack14 
__sigpending14 __socket30 __sigaction_sigtramp __sigtimedwait __stat30 __sysctl 
tmp__lwp_getprivate tmp_mremap __msync13 __sigsuspend14 __sigprocmask14'

  eval `echo export CPUFLAGS_$i=\"$SAFE_CPUFLAGS\"`


echo thumb.sh Building thumb userspace:

./build.sh -U -O obj -j 3 -m evbarm build || exit -1

echo thumb.sh end thumb compilation sub-shell
) || exit -1

echo "thumb.sh now build stuff (except binutils 2.18.50) that fails to compile 
in thumb mode:"

MKBFD=no CPUFLAGS=-mthumb-interwork ./build.sh -U -u -O obj -j 3 -m evbarm 
build || exit -1

echo thumb.sh install ARM mode /libexec/ld.elf_so from backup
cp -f obj/libexec-arm/ld.elf_so/ld.elf_so obj/destdir.evbarm/libexec/ld.elf_so 
|| exit -1

echo thumb.sh Building distribution

MKBFD=no CPUFLAGS=-mthumb-interwork ./build.sh -U -u -O obj -j 3 -m evbarm 
distribution || exit -1

Home | Main Index | Thread Index | Old Index