mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[libc] Pull crt0 out into its own module
Sorta. crt0 is a separate module as far as bonnibel is concerned, but it's still part of the libc module file.
This commit is contained in:
@@ -12,6 +12,8 @@ ccflags: [
|
||||
"-U__linux",
|
||||
"-U__linux__",
|
||||
|
||||
"-DMSPACES",
|
||||
|
||||
"--sysroot='${source_root}/sysroot'"
|
||||
]
|
||||
|
||||
@@ -32,3 +34,6 @@ ldflags: [
|
||||
"--no-dependent-libraries",
|
||||
]
|
||||
|
||||
libs: [
|
||||
"${target_dir}/crt0.o",
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
---
|
||||
|
||||
ccflags: [
|
||||
"-fpie"
|
||||
]
|
||||
@@ -8,3 +9,7 @@ ldflags: [
|
||||
"--dynamic-linker", "/jsix/lib/ld.so",
|
||||
"--push-state", "--as-needed", "-Bstatic", "-lc++", "-lc++abi", "-lunwind", "--pop-state",
|
||||
]
|
||||
|
||||
libs: [
|
||||
"${target_dir}/crt0.o",
|
||||
]
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
asflags: [ "-I${source_root}/src/kernel/" ]
|
||||
asflags: []
|
||||
|
||||
ccflags: [
|
||||
"--target=x86_64-jsix-elf",
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
%include "util/got.inc"
|
||||
extern _GLOBAL_OFFSET_TABLE_
|
||||
|
||||
extern main
|
||||
extern exit
|
||||
extern __init_libj6
|
||||
extern __init_libc
|
||||
|
||||
; Put the address of the given symbol in rax
|
||||
; This macro is the same as in util/got.inc,
|
||||
; but crt0 can't have a dep on libutil
|
||||
%macro lookup_GOT 1
|
||||
lea rax, [rel _GLOBAL_OFFSET_TABLE_]
|
||||
mov rax, [rax + %1 wrt ..got]
|
||||
%endmacro
|
||||
|
||||
global _start:function weak (_libc_crt0_start.end - _libc_crt0_start)
|
||||
global _libc_crt0_start:function (_libc_crt0_start.end - _libc_crt0_start)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ def glob(ext, root=''):
|
||||
|
||||
sources = []
|
||||
for ext in ("c", "cpp", "s", "inc"):
|
||||
sources += glob(ext) + glob(ext + ".cog")
|
||||
sources += [f for f in glob(ext) + glob(ext + ".cog") if not "crt" in f]
|
||||
|
||||
headers = []
|
||||
for ext in ("h",):
|
||||
@@ -26,7 +26,7 @@ for ext in ("h",):
|
||||
|
||||
libc = module("libc",
|
||||
kind = "lib",
|
||||
deps = [ "j6" ],
|
||||
deps = [ "j6", "crt0.o" ],
|
||||
basename = "libc",
|
||||
include_phase = "late",
|
||||
sources = sources,
|
||||
@@ -39,3 +39,9 @@ libc.variables["ccflags"] = [
|
||||
"-DPRINTF_SUPPORT_DECIMAL_SPECIFIERS=0",
|
||||
"-DPRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS=0",
|
||||
]
|
||||
|
||||
crt = module("crt0.o",
|
||||
kind = "cp",
|
||||
sources = [
|
||||
"arch/amd64/crt/crt0.s",
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user