cosmopolitan/libc/crt/crt.S
Justine Tunney 416fd86676 Make improvements
- Emulator can now test the αcτµαlly pδrταblε εxεcµταblε bootloader

- Whipped up a webserver named redbean. It services 150k requests per
  second on a single core. Bundling assets inside zip enables extremely
  fast serving for two reasons. The first is that zip central directory
  lookups go faster than stat() system calls. The second is that both
  zip and gzip content-encoding use DEFLATE, therefore, compressed
  responses can be served via the sendfile() system call which does an
  in-kernel copy directly from the zip executable structure. Also note
  that red bean zip executables can be deployed easily to all platforms,
  since these native executables work on Linux, Mac, BSD, and Windows.

- Address sanitizer now works very well
2020-09-14 00:02:34 -07:00

69 lines
3 KiB
ArmAsm

/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/dce.h"
#include "libc/macros.h"
#include "libc/notice.inc"
#include "libc/runtime/internal.h"
.section .start,"ax",@progbits
.source __FILE__
nop
/ System Five userspace program entrypoint.
/
/ @param rsp is [n,argv₀..argvₙ₋₁,0,envp₀..,0,auxv₀..,0,..]
/ @note FreeBSD is special (see freebsd/lib/csu/amd64/...)
/ @noreturn
_start: test %rdi,%rdi
cmovnz %rdi,%rsp
jz 0f
movb $FREEBSD,hostos(%rip)
0: mov (%rsp),%ebx # argc
lea 8(%rsp),%rsi # argv
lea 24(%rsp,%rbx,8),%rdx # envp
.frame0
/ bofram 9f
.weak idata.iat,idata.iatend
ezlea missingno,ax # make win32 imps noop
ezlea idata.iat,di
ezlea idata.iatend,cx
sub %rdi,%rcx
shr $3,%ecx
rep stosq
xor %eax,%eax # find end of environ
or $-1,%ecx
mov %rdx,%rdi
repnz scasq
mov %rdi,%rcx # auxv
mov %ebx,%edi
call _executive
9: .endfn _start,weak,hidden
ud2
/ Macintosh userspace program entrypoint.
/
/ @param rsp is [n,argv₀..argvₙ₋₁,0,envp₀..,0,auxv₀..,0,..]
/ @note FreeBSD is special (see freebsd/lib/csu/amd64/...)
/ @noreturn
_start_xnu:
movb $XNU,hostos(%rip)
jmp 0b
.endfn _start_xnu,weak,hidden