mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
56
libc/crt/crt.S
Normal file
56
libc/crt/crt.S
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*-*- mode:asm; 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
|
||||
.yoink __FILE__
|
||||
|
||||
/ 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_xnu:
|
||||
movb $XNU,hostos(%rip)
|
||||
jmp 0f
|
||||
_start: test %rdi,%rdi
|
||||
cmovnz %rdi,%rsp
|
||||
jz 0f
|
||||
movb $FREEBSD,hostos(%rip)
|
||||
0: movslq (%rsp),%r12 # argc
|
||||
lea 8(%rsp),%r13 # argv
|
||||
lea 24(%rsp,%r12,8),%r14 # envp
|
||||
.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 %r14,%rdi
|
||||
repnz scasq
|
||||
mov %rdi,%r15 # auxv
|
||||
jmp __executive
|
||||
.endfn _start,weak,hidden
|
||||
.endfn _start_xnu,weak,hidden
|
30
libc/crt/crt.mk
Normal file
30
libc/crt/crt.mk
Normal file
|
@ -0,0 +1,30 @@
|
|||
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
|
||||
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
|
||||
#
|
||||
# SYNOPSIS
|
||||
#
|
||||
# Cosmopolitan C Runtime.
|
||||
#
|
||||
# OVERVIEW
|
||||
#
|
||||
# This is a special object library defining the Cosmopolitan SysV
|
||||
# userspace runtime entrypoint, i.e. _start(). The $(CRT) argument
|
||||
# should come first in the link order when building ELF binaries;
|
||||
# becauseo it's the lowest level function; it wraps main(); and it
|
||||
# decides which runtime support libraries get schlepped into builds.
|
||||
#
|
||||
# Please note that, when building an αcτµαlly pδrταblε εxεcµταblε,
|
||||
# lower-level entrypoints exist and as such, $(CRT) will generally
|
||||
# come second in link-order after $(APE).
|
||||
|
||||
PKGS += CRT
|
||||
|
||||
CRT_ARTIFACTS += CRT
|
||||
CRT = o/$(MODE)/libc/crt/crt.o
|
||||
CRT_FILES = libc/crt/crt.S
|
||||
CRT_SRCS = libc/crt/crt.S
|
||||
CRT_OBJS = o/$(MODE)/libc/crt/crt.o o/$(MODE)/libc/crt/crt.S.zip.o
|
||||
$(CRT_OBJS): $(BUILD_FILES) libc/crt/crt.mk
|
||||
|
||||
.PHONY: o/$(MODE)/libc/crt
|
||||
o/$(MODE)/libc/crt: $(CRT)
|
Loading…
Add table
Add a link
Reference in a new issue