Added clang support.
parent
05ab18b44e
commit
eb6f565825
|
@ -12,28 +12,19 @@
|
|||
default: emulate-nohdd
|
||||
|
||||
SHELL:=/bin/bash
|
||||
#ENV:=/usr/xdev/bin
|
||||
TARGET:=x86_64-elf
|
||||
CC:=$(TARGET)-gcc
|
||||
CX:=$(TARGET)-g++
|
||||
CC:=clang
|
||||
CX:=clang++
|
||||
AS:=nasm
|
||||
LD:=$(TARGET)-ld
|
||||
LD:=ld
|
||||
|
||||
# -O2 sets -foptimize-sibling-calls which breaks code...
|
||||
CFLAGS:=-m64 -mcmodel=large -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs -std=c99 -g
|
||||
CFLAGS+=-I ./include -Wno-packed-bitfield-compat -O2 -fno-optimize-sibling-calls -mcmodel=kernel
|
||||
CFLAGS+= -mno-red-zone -ffreestanding -I ./include/Lua -I ./src/Lua
|
||||
CFLAGS:= -mcmodel=large -Wall -Werror -nostdlib -ffreestanding -std=c99 -g
|
||||
CFLAGS+=-I ./include -nostdinc -O2 -fno-optimize-sibling-calls -mcmodel=kernel
|
||||
CFLAGS+= -mno-red-zone -ffreestanding -I ./include/Lua -I ./src/Lua -target x86_64-elf
|
||||
|
||||
#CXFLAGS:= -Wall -Werror -nostdlib -fno-builtin -nostartfiles -I ./include
|
||||
#CXFLAGS+= -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector
|
||||
#CXFLAGS+= -Wno-packed-bitfield-compat -O3 -mcmodel=kernel
|
||||
CXFLAGS:= $(CFLAGS) -fno-rtti -fno-stack-protector -fno-exceptions -std=c++11
|
||||
|
||||
CXFLAGS:=-m64 -mcmodel=large -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs -g
|
||||
CXFLAGS+=-I ./include -Wno-packed-bitfield-compat -O2 -fno-optimize-sibling-calls -mcmodel=kernel
|
||||
CXFLAGS+= -mno-red-zone -ffreestanding -I ./include/Lua -I ./src/Lua -fno-exceptions -fno-rtti
|
||||
CXFLAGS+= -fno-stack-protector -std=c++11
|
||||
|
||||
LFLAGS:=-nostdlib -nostartfiles -nodefaultlibs
|
||||
LFLAGS:=-nostdlib -nostartfiles -nodefaultlibs -m elf_x86_64 -nostdinc -z nodefaultlib -n
|
||||
|
||||
debug: CFLAGS += -DDEBUG -gdwarf-4 -fvar-tracking-assignments -O0
|
||||
debug: CXFLAGS += -DDEBUG -gdwarf-4 -fvar-tracking-assignments -O0
|
||||
|
@ -104,11 +95,11 @@ Lua: $(LUA)
|
|||
|
||||
kernel.bin: version-gen Tier0 Tier1 Lua Alentours
|
||||
@echo "[i] Linking kernel.bin..."
|
||||
@$(LD) -T src/kernel.ld -o kernel.bin $(TIER0) $(TIER1) $(ALENTOURS) -Lsrc/Lua -llua
|
||||
@$(LD) $(LFLAGS) -T src/kernel.ld -o kernel.bin $(TIER0) $(TIER1) $(ALENTOURS) -Lsrc/Lua -llua
|
||||
@echo "[i] Creating debug symbols."
|
||||
@cp kernel.bin ksyms.elf
|
||||
@strip --only-keep-debug ksyms.elf
|
||||
@strip --strip-debug --strip-unneeded kernel.bin
|
||||
#@strip --only-keep-debug ksyms.elf
|
||||
#@strip --strip-debug --strip-unneeded kernel.bin
|
||||
|
||||
hdd.img: kernel.bin
|
||||
@echo "[i] Creating HDD image..."
|
||||
|
@ -124,7 +115,7 @@ hdd.img: kernel.bin
|
|||
emulate-nohdd-debug: debug
|
||||
@echo "[i] Starting GDB..."
|
||||
@echo -e "file kernel.bin\nsymbol-file ksyms.elf\ntarget remote localhost:1234\n" > gdbcommands
|
||||
@terminal -x /bin/bash -c "sleep 1 && gdb -tui -x gdbcommands && rm gdbcommands" &
|
||||
xterm -e /bin/bash -c "sleep 1 && gdb -tui -x gdbcommands && rm gdbcommands" &
|
||||
@echo "[i] Starting QEmu..."
|
||||
@qemu-system-x86_64 --no-kvm -S -gdb tcp::1234 -d int -smp 4 -kernel ../Loader/loader.bin -initrd kernel.bin
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python2
|
||||
import re
|
||||
import string
|
||||
|
||||
f = open("include/Alentours/PCIDB.h", "r")
|
||||
d = f.read()
|
||||
|
@ -13,22 +14,45 @@ in_ventable = False
|
|||
in_devtable = False
|
||||
|
||||
for line in lines:
|
||||
if line.startswith(' { 0x165C, 0x0002'):
|
||||
in_devtable = True
|
||||
if in_devtable and line.startswith("}"):
|
||||
in_devtable = False
|
||||
|
||||
if in_devtable:
|
||||
if not re.match(r' { 0x([a-fA-F0-9]){4}, 0x([a-fA-F0-9]){4}, "[^"\\]*", "[^"\\]*".+', line) or line.find("??") >= 0:
|
||||
print "[i] Removing invalid line %s from PCIDB.h..." % line
|
||||
else:
|
||||
newlines.append(line)
|
||||
else:
|
||||
newlines.append(line)
|
||||
if line.startswith('PCI_DEVTABLE'):
|
||||
in_devtable = True
|
||||
print "[i] In devtable"
|
||||
newlines.append(line)
|
||||
continue
|
||||
if in_devtable and line.startswith("{"):
|
||||
newlines.append(line)
|
||||
continue
|
||||
if in_devtable and line.startswith("}"):
|
||||
newlines.append(line)
|
||||
in_devtable = False
|
||||
continue
|
||||
|
||||
if line.startswith('PCI_VENTABLE'):
|
||||
in_ventable = True
|
||||
print "[i] In ventable"
|
||||
newlines.append(line)
|
||||
continue
|
||||
if in_ventable and line.startswith("{"):
|
||||
newlines.append(line)
|
||||
continue
|
||||
if in_ventable and line.startswith("}"):
|
||||
in_ventable = False
|
||||
newlines.append(line)
|
||||
continue
|
||||
|
||||
if in_devtable:
|
||||
if not re.match('\t' + r'\{ 0x([a-fA-F0-9]){4}, 0x([a-fA-F0-9]){4}, "[^"\\]*", "[^"\\]*".+', line) or line.find("??") >= 0:
|
||||
print "[i] Removing invalid line %s from PCIDB.h..." % line
|
||||
else:
|
||||
newlines.append(filter(lambda x: x in string.printable, line))
|
||||
elif in_ventable:
|
||||
if not re.match('\t' + r'{ 0x([a-fA-F0-9]){4}, "[^"\\]*", "[^"\\]*".+', line):
|
||||
print "[i] Removing invalid line %s from PCIDB.h..." % line
|
||||
else:
|
||||
newlines.append(filter(lambda x: x in string.printable, line))
|
||||
else:
|
||||
newlines.append(filter(lambda x: x in string.printable, line))
|
||||
|
||||
f = open("include/Alentours/PCIDB.h", "w")
|
||||
f.write("\n".join(newlines))
|
||||
f.close()
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ void kmain_newstack(void);
|
|||
// Real kernel entry point, called from loader
|
||||
void kmain(u32 LoadContextAddress)
|
||||
{
|
||||
for(;;){}
|
||||
T_LOAD_CONTEXT *LoadContext = (T_LOAD_CONTEXT*)(u64)LoadContextAddress;
|
||||
kstdio_init();
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "Tier0/kstdio.h"
|
||||
#include "Tier0/kstdlib.h"
|
||||
//#include "Tier0/semaphore.h"
|
||||
#include <stdarg.h>
|
||||
// #include <stdarg.h>
|
||||
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
#define va_arg(v,l) __builtin_va_arg(v,l)
|
||||
|
|
|
@ -9,7 +9,7 @@ SECTIONS
|
|||
|
||||
_start = .;
|
||||
|
||||
.text : AT(ADDR(.text) - KERNEL_VMA)
|
||||
.text :
|
||||
{
|
||||
_code = .;
|
||||
*(.text)
|
||||
|
@ -21,29 +21,32 @@ SECTIONS
|
|||
_start_ctors = .;
|
||||
*(.ctors)
|
||||
_end_ctors = .;
|
||||
|
||||
. = ALIGN(4096);
|
||||
}
|
||||
|
||||
.data : AT(ADDR(.data) - KERNEL_VMA)
|
||||
. = ALIGN(4096);
|
||||
|
||||
.data :
|
||||
{
|
||||
_data = .;
|
||||
*(.data)
|
||||
. = ALIGN(4096);
|
||||
}
|
||||
|
||||
.bss : AT(ADDR(.bss) - KERNEL_VMA)
|
||||
. = ALIGN(4096);
|
||||
|
||||
.bss :
|
||||
{
|
||||
_bss = .;
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
. = ALIGN(4096);
|
||||
*(COMMON)
|
||||
}
|
||||
|
||||
_end = .;
|
||||
|
||||
/DISCARD/ :
|
||||
{
|
||||
*(.eh_frame)
|
||||
*(.eh_frame*)
|
||||
*(.ehframe*)
|
||||
*(.debug*)
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,7 +321,6 @@ u32 create_ia32e_paging(u64 KernelPhysicalStart, u64 KernelVirtualStart, u64 Ker
|
|||
|
||||
Address += 0x1000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue