From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/1261 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: porting checklist Date: Sat, 7 Jul 2012 20:13:44 -0400 Message-ID: <20120708001344.GU544@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0" X-Trace: dough.gmane.org 1341706511 1801 80.91.229.3 (8 Jul 2012 00:15:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Jul 2012 00:15:11 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-1262-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jul 08 02:15:10 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Snf9Z-0000tK-JS for gllmg-musl@plane.gmane.org; Sun, 08 Jul 2012 02:15:09 +0200 Original-Received: (qmail 22114 invoked by uid 550); 8 Jul 2012 00:15:08 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 22086 invoked from network); 8 Jul 2012 00:15:07 -0000 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:1261 Archived-At: --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, At Rob Landley's suggestion, here's a quick checklist of the essentials for porting musl to a new arch. There's some duplication with njk's porting guide, but I wrote this one just now off the top of my head to be up-to-date. I'm hoping this will help speed up work developing and integrating rdp's ports and any further new ports. Rich --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="arch.txt" The following is a porting checklist for musl. It lists all essential header and asm file locations that need to be ported to get a new arch working on musl. It's grouped/ordered so that you can focus first on getting a basic test program to run, then add features from there. ======================================================================== Requirements to be able to run anything at all: crt: must provide entry point code to call __libc_start_main, and _init/_fini function prologue/epilogue for the linker to paste together with the calls provided by the compiler's crt functions. arch/*/bits: headers for the arch's user and kernel abi. types which are used in multiple headers are defined in alltypes.h.sh which is a shell script that, when run, generates an alltypes.h full of the necessary #ifdef directives to control which types are made visible. generally, macro and struct definitions that do not seem to vary between archs have been put directly in the main headers rather than arch-specific bits headers, so if additional variations are found in new archs, it may be necessary to reorganize some definitions into the bits headers for both existing archs and the new arch. arch/*/atomic.h: must provide certain atomic/asm ops. 32-bit and pointer-size atomic cas are essential; everything else can be implemented in terms of cas if no better implementation is possible. the and/or ops do not need to be atomic on the whole object; really they should be considered atomic set-bit/clear-bit functions. src/internal: generic syscall code ======================================================================== Requirements for most single-threaded, static-linked programs to work: src/setjmp: needs arch-specific setjmp/longjmp code. no signal mask save/restore or unwinding is wanted or allowed. src/signal: sa_restorer code for signal handler return must match what gdb expects for the arch, and sigsetjmp must call sigprocmask and then tail-call to setjmp. ======================================================================== Requirements for dynamic linking: arch/*/reloc.h: this file is just a code fragment containing the arch-specific parts of the dynamic linker. generally the types of relocations that must be performed in do_single_reloc are the same for most archs, but their names are arch-specific. src/ldso: dlsym asm must pass the return address as the third argument to __dlsym. _start is the dynamic linker entry point. ======================================================================== Requirements for threads: src/thread: __unmapself must make an munmap syscall without touching the stack then make the exit syscall. __set_thread_area must provide a unified interface (same on all archs) for setting the thread pointer register. syscall_cp must check cancellation flag and make a syscall, and provide the proper labels so that the cancellation handler code can determine if it was invoked at a cancellation point. clone function always takes the desired thread pointer value as one of its arguments (not a user_desc pointer on x86, etc.). arch/*/pthread_arch.h: the __pthread_self function must return the thread pointer (pthread_t) for the current thread. it may assume it has already been initialized. the CANCEL_REG_IP is the word offset in the arch's ucontext_t object of the saved instruction pointer, needed for cancellation handling purposes. --k+w/mQv8wyuph6w0--