ldasm.S revision 1.2
1/* $OpenBSD: ldasm.S,v 1.2 2004/02/09 16:47:19 drahn Exp $ */ 2 3/* 4 * Copyright (c) 2004 Dale Rahn 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 16 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 */ 28 29#define DL_DATA_SIZE (16 * 4) /* XXX */ 30#include <machine/asm.h> 31#include <sys/syscall.h> 32#include <arm/swi.h> 33 34ENTRY(_dl_start) 35 mov fp, sp 36 mov r5, sp 37 mov lr, r6 @ save lr 38 sub sp, sp, #4+4+DL_DATA_SIZE 39 add r7, sp, #4 @ dl_data 40 41 mov r0, fp @ original stack 42 mov r1, r7 @ dl_data 43 44 bl _dl_boot_bind 45 46 add r0, r5, #4 @ argv 47 ldr r1, [r5, #0x0] @ envp 48 add r1, r1, #2 49 add r1, fp, r1, lsl #2 50 ldr r2, [r7, #7*4] @ loff from dl_data 51 mov r3, r7 @ dl_data 52 bl _dl_boot 53 54 mov sp, fp 55 mov fp, #0 56 mov lr, r6 57 58 mov pc, r0 59 60 61ENTRY(_dl_bind_start) 62 63 /* STUB */ 64 65 66/* ld.so SYSCALLS */ 67 68#define DL_SYSCALL(n) DL_SYSCALL2(n,n) 69#define DL_SYSCALL2(n,c) \ 70 .global __CONCAT(_dl_,n) ;\ 71 .type __CONCAT(_dl_,n)%function ;\ 72__CONCAT(_dl_,n): ;\ 73 swi SWI_OS_NETBSD|__CONCAT(SYS_,c) ;\ 74 bcs .L_cerr ;\ 75 mov pc, lr 76 77 .section ".text" 78 .align 4 79DL_SYSCALL(close) 80 81 82 .global _dl_exit 83 .type _dl_exit%function 84_dl_exit: 85 swi SWI_OS_NETBSD|SYS_exit 86 1: 87 b 1b 88 89DL_SYSCALL(issetugid) 90DL_SYSCALL2(_syscall,__syscall) 91DL_SYSCALL(munmap) 92DL_SYSCALL(mprotect) 93DL_SYSCALL(open) 94DL_SYSCALL(read) 95DL_SYSCALL(write) 96DL_SYSCALL(stat) 97DL_SYSCALL(fstat) 98DL_SYSCALL(fcntl) 99DL_SYSCALL2(sysctl,__sysctl) 100 101DL_SYSCALL(getdirentries) 102 103 .global _dl_sigprocmask 104 .type _dl_sigprocmask%function 105_dl_sigprocmask: 106 teq r1, #0 107 moveq r0, #1 108 moveq r1, #0 109 ldrne r1, [r1] 110 swi SWI_OS_NETBSD|SYS_sigprocmask 111 bcs .L_cerr 112 teq r2, #0 113 strne r0, [r2] 114 mov r0, #0 115 mov pc, lr 116 117.L_cerr: 118 mov r0, #0 119 sub r0, r0, #1 120 mov pc, lr 121