fixed linker and syscall

git-svn-id: svn://kolibrios.org@9053 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
pavelyakov 2021-07-12 12:28:41 +00:00
parent 716db38e51
commit 1979e6ff29
5 changed files with 99 additions and 174 deletions

View File

@ -1,18 +1,19 @@
PROGRAM=example
SOURCES=syscalls.o colors.go.o colors.gox os.go.o os.gox $(PROGRAM).go.o
LIBOBJ=os.go.o syscalls.o colors.go.o
GOFLAGS= -nostdlib -nostdinc -fno-stack-protector -fno-split-stack -static -m32 -g -I.
GO=gccgo
ASFLAGS= -felf
GOFLAGS = -m32 -c -nostdlib -nostdinc -fno-stack-protector -fno-split-stack -static -fno-leading-underscore -fno-common -fno-pie -g -I.
GO = gccgo
GCC = gcc
ASFLAGS= -g -f elf32 -F dwarf
NASM= nasm $(ASFLAGS)
OBJCOPY=objcopy
LDFLAGS=-T static.lds -n -m elf_i386
LDFLAGS=-n -T static.lds -m elf_i386 --no-ld-generated-unwind-info
all: $(SOURCES) link
clean:
rm *.o *.gox $(PROGRAM).kex
rm -f *.o *.gox $(PROGRAM).kex
link:
ld $(LDFLAGS) -o $(PROGRAM).kex $(SOURCES)
$(OBJCOPY) $(PROGRAM).kex -O binary

View File

@ -10,25 +10,20 @@ const (
)
func RedrawAll(bar_pos int){
btn_txt1:=" <- "
btn_txt2:=" -> "
str:="I love KolibriOS"
title:="Test Golang"
os.Redraw(1)
os.Window(500,250,420,200, title)
os.WriteText(32,32, 0x11000000 | colors.Green,str, 10)
os.Redraw(1)
os.Window(500,250,420,200, "Test Golang")
os.DrawLine(32, 80, 150, 80, colors.Green)
os.CreateButton(32, 128, 80, 30, Btn1, colors.Blue);
os.CreateButton(300, 128, 80, 30, Btn2, colors.Blue);
os.WriteText(32,128, 0x11000000 | colors.White,btn_txt1, 10)
os.WriteText(320,128, 0x11000000 | colors.White,btn_txt2, 10)
os.DrawBar(uint32(bar_pos), 90, 100, 30, colors.Red);
os.WriteText(32,128, 0x11000000 | colors.White," <- ")
os.WriteText(320,128, 0x11000000 | colors.White," -> ")
os.DrawBar(bar_pos, 90, 100, 30, colors.Red);
}
func Load() {
time := os.GetTime()
os.DebugOutStr("Time: ")
os.DebugOutHex(time)
//time := os.GetTime()
//os.DebugOutStr("Time: ")
//os.DebugOutHex(time)
var pos=32;
for true {
switch os.Event() {

View File

@ -20,9 +20,10 @@ func CreateButton(x uint32, y uint32, xsize uint32, ysize uint32, id uint32, col
func Exit()
func Redraw(uint32)
func Window(y uint32, x uint32, w uint32,h uint32, title string)
func WriteText(x uint32 ,y uint32 , color uint32, text string, len uint32)
func WriteText(x uint32 ,y uint32 , color uint32, text string)
func WriteText2(uint32 ,string ,uint32, uint32,uint32)
func DrawLine(x1 uint32, y1 uint32, x2 uint32, y2 uint32, color uint32)(uint32)
func DrawBar(x uint32, y uint32, xsize uint32, ysize uint32, color uint32)
func DrawBar(x int, y int, xsize int, ysize int, color uint32)
func DebugOutHex(uint32)
func DebugOutChar(byte)
func DebugOutStr(string)

View File

@ -1,113 +1,31 @@
/*OUTPUT_FORMAT("binary")*/
ENTRY(__start)
SECTIONS
{
.text 0x000000:
. = 0x00000;
.text :
{
LONG(0x554e454D);
LONG(0x32305445);
LONG(0x31305445);
LONG(1);
LONG(__start);
LONG(___iend);
LONG(___memsize);
LONG(___stacktop);
LONG(go.kernel.Load);
LONG(__end);
LONG(0x10000);
LONG(0x10000);
LONG(0);
LONG(0);
LONG(0); /* full path */
LONG(0); /*FIXME tls data */
*(.init)
*(.text)
*(SORT(.text$*))
*(.text.*)
*(.glue_7t)
*(.glue_7)
___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*)); LONG (0);
___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*)); LONG (0);
*(.fini)
/* ??? Why is .gcc_exc here? */
*(.gcc_exc)
PROVIDE (etext = .);
*(.gcc_except_table)
}
.rdata ALIGN(16) :
{
*(.rdata)
*(SORT(.rdata$*))
___RUNTIME_PSEUDO_RELOC_LIST__ = .;
__RUNTIME_PSEUDO_RELOC_LIST__ = .;
*(.rdata_runtime_pseudo_reloc)
___RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
__RUNTIME_PSEUDO_RELOC_LIST_END__ = .;
}
.CRT ALIGN(16) :
{
___crt_xc_start__ = . ;
*(SORT(.CRT$XC*)) /* C initialization */
___crt_xc_end__ = . ;
___crt_xi_start__ = . ;
*(SORT(.CRT$XI*)) /* C++ initialization */
___crt_xi_end__ = . ;
___crt_xl_start__ = . ;
*(SORT(.CRT$XL*)) /* TLS callbacks */
/* ___crt_xl_end__ is defined in the TLS Directory support code */
___crt_xp_start__ = . ;
*(SORT(.CRT$XP*)) /* Pre-termination */
___crt_xp_end__ = . ;
___crt_xt_start__ = . ;
*(SORT(.CRT$XT*)) /* Termination */
___crt_xt_end__ = . ;
}
.data ALIGN(16) :
{
__data_start__ = . ;
*(.data)
*(.data2)
*(SORT(.data$*))
*(.jcr)
__CRT_MT = .;
LONG(0);
__data_end__ = . ;
*(.data_cygwin_nocopy)
}
.eh_frame ALIGN(16) :
{
.eh_frame : {
*(.eh_frame)
___iend = . ;
}
bss ALIGN(16):
{
*(.bss)
*(COMMON)
. = ALIGN(16);
___menuet__app_path_area = .;
. = . + 1024 + 16;
___stacktop = .;
___memsize = . ;
.group : {
*(.group)
}
/DISCARD/ :
{
*(.debug$S)
*(.debug$T)
*(.debug$F)
*(.drectve)
*(.note.GNU-stack)
*(.comment)
*(.debug_abbrev)
*(.debug_info)
*(.debug_line)
*(.debug_frame)
*(.debug_loc)
*(.debug_pubnames)
*(.debug_aranges)
*(.debug_ranges)
}
.data : {
*(.data)
}
.rodata : {
*(.rodata)
*(.rodata.*)
}
__end = .;
}

View File

@ -1,9 +1,6 @@
SECTION .text
[GLOBAL __start]
extern go.kernel.Load
global go.os.Sleep
global go.os.Event
global go.os.GetButtonID
@ -18,10 +15,7 @@ global go.os.DrawBar
global go.os.DebugOutHex
global go.os.DebugOutChar
global go.os.DebugOutStr
__start:
call go.kernel.Load
ret
global go.os.WriteText2
go.os.Sleep:
push ebp
@ -35,12 +29,8 @@ go.os.Sleep:
go.os.Event:
push ebp
mov ebp,esp
mov eax, 10
int 0x40
mov esp,ebp
pop ebp
ret
go.os.GetButtonID:
@ -56,12 +46,8 @@ go.os.GetButtonID:
ret
go.os.Exit:
push ebp
mov ebp,esp
mov eax, -1
int 0x40
mov esp,ebp
pop ebp
ret
go.os.Redraw:
@ -95,42 +81,66 @@ go.os.Window:
ret
go.os.WriteText:
push ebp
mov ebp,esp
mov eax,4
mov ebx,[esp+4]
mov ebx,[ebp+8]
shl ebx,16
mov bx,[esp+8]
mov ecx,[esp+12]
mov edx,[esp+16]
mov esi,[esp+20]
mov bx,[ebp+12]
mov ecx,[ebp+16]
mov edx,[ebp+20]
mov esi,[ebp+24]
int 0x40
mov esp,ebp
pop ebp
ret
go.os.DrawLine:
push ebx
mov ebx,[esp+8]
go.os.WriteText2:
push ebp
mov ebp,esp
mov eax,47
mov ebx,[ebp+8]
shl ebx,16
mov bx,[esp+16]
mov ecx,[esp+12]
mov ecx,[ebp+12]
mov edx,[ebp+20]
shl edx,16
add edx, [ebp+24]
mov esi,[ebp+28]
int 0x40
mov esp,ebp
pop ebp
ret
go.os.DrawLine:
push ebp
mov ebp,esp
mov ebx,[ebp+8]
shl ebx,16
mov bx,[ebp+16]
mov ecx,[ebp+12]
shl ecx,16
mov cx,[esp+20]
mov edx,[esp+24]
mov cx,[ebp+20]
mov edx,[ebp+24]
mov eax,38
int 0x40
pop ebx
mov esp,ebp
pop ebp
ret
go.os.DrawBar:
push ebx
push ebp
mov ebp,esp
mov eax,13
mov ebx,[esp+8]
mov ebx,[ebp+8]
shl ebx,16
mov bx,[esp+16]
mov ecx,[esp+12]
mov bx,[ebp+16]
mov ecx,[ebp+12]
shl ecx,16
mov cx,[esp+20]
mov edx,[esp+24]
mov cx,[ebp+20]
mov edx,[ebp+24]
int 0x40
pop ebx
mov esp,ebp
pop ebp
ret
go.os.GetTime:
@ -138,7 +148,7 @@ go.os.GetTime:
int 0x40
ret
go.os.DebugOutHex:
go.os.DebugOutHex:
mov eax, [esp+4]
mov edx, 8
.new_char:
@ -155,7 +165,7 @@ go.os.DebugOutHex:
jnz .new_char
ret
go.os.DebugOutChar:
go.os.DebugOutChar:
mov al, [esp+4]
pushf
pushad
@ -182,20 +192,20 @@ go.os.DebugOutStr:
ret
go.os.CreateButton:
push ebx
push esi
mov ebx,[esp+12]
shl ebx,16
mov bx,[esp+20]
mov ecx,[esp+16]
shl ecx,16
mov cx,[esp+24]
mov edx,[esp+28]
mov esi,[esp+32]
mov eax,8
push ebp
mov ebp,esp
mov eax, 8
mov ebx, [ebp+8]
shl ebx, 16
mov bx, [ebp+16]
mov ecx, [ebp+12]
shl ecx, 16
mov cx, [ebp+20]
mov edx, [ebp+24]
mov esi, [ebp+28]
int 0x40
pop esi
pop ebx
mov esp,ebp
pop ebp
ret
SECTION .data