* Assembler part of libc now also exports "name@params_size" for every system function

because of stdcall convention. 
* Some fixes in calculating relocations procedure.

git-svn-id: svn://kolibrios.org@159 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Andrey Halyavin (halyavin) 2006-09-23 14:00:36 +00:00
parent 6127c7381d
commit 4d719e6bc5
28 changed files with 92 additions and 127 deletions

View File

@ -82,7 +82,7 @@ extern void stdcall _msys_sound_speaker_play(void* data);
extern void stdcall _msys_write_text(int x,int y,int color,char* text,int len); extern void stdcall _msys_write_text(int x,int y,int color,char* text,int len);
extern void* stdcall _msys_start_thread(void (* func_ptr)(void),int stack_size,int* pid); extern void* stdcall _msys_start_thread(void (* func_ptr)(void),int stack_size,int* pid);
extern void stdcall _msys_window_redraw(int status); extern void stdcall _msys_window_redraw(int status);
extern void* stdcall malloc(int); extern void* malloc(int);
extern void stdcall free(void*); extern void free(void*);
extern void* stdcall realloc(void*,int); extern void* realloc(void*,int);
#endif #endif

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_set_background_size public_stdcall _msys_set_background_size,8
_msys_set_background_size:
;arg1 - xsize ;arg1 - xsize
;arg2 - ysize ;arg2 - ysize
push ebx push ebx
@ -12,8 +12,7 @@ _msys_set_background_size:
int 0x40 int 0x40
pop ebx pop ebx
ret 8 ret 8
public _msys_write_background_mem public_stdcall _msys_write_background_mem,8
_msys_write_background_mem:
;arg1 - pos ;arg1 - pos
;arg2 - color ;arg2 - color
push ebx push ebx
@ -24,16 +23,14 @@ _msys_write_background_mem:
int 0x40 int 0x40
pop ebx pop ebx
ret 8 ret 8
public _msys_draw_background public_stdcall _msys_draw_background,0
_msys_draw_background:
mov edx,ebx mov edx,ebx
mov eax,15 mov eax,15
mov ebx,3 mov ebx,3
int 0x40 int 0x40
mov ebx,edx mov ebx,edx
ret ret
public _msys_set_background_draw_type public_stdcall _msys_set_background_draw_type,4
_msys_set_background_draw_type:
;arg1 - type ;arg1 - type
mov edx,ebx mov edx,ebx
mov eax,15 mov eax,15
@ -42,8 +39,7 @@ _msys_set_background_draw_type:
int 0x40 int 0x40
mov ebx,edx mov ebx,edx
ret 4 ret 4
public _msys_background_blockmove public_stdcall _msys_background_blockmove,12
_msys_background_blockmove:
;arg1 - source ;arg1 - source
;arg2 - position in dest ;arg2 - position in dest
;arg3 - size ;arg3 - size

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_make_button public_stdcall _msys_make_button,24
_msys_make_button:
;arg1 - x ;arg1 - x
;arg2 - y ;arg2 - y
;arg3 - xsize ;arg3 - xsize
@ -22,8 +22,7 @@ _msys_make_button:
pop esi ebx pop esi ebx
ret 24 ret 24
public _msys_get_button_id public_stdcall _msys_get_button_id,0
_msys_get_button_id:
mov eax,17 mov eax,17
int 0x40 int 0x40
test al,al test al,al

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_system_clock public_stdcall _msys_get_system_clock,0
_msys_get_system_clock:
mov eax,3 mov eax,3
int 0x40 int 0x40
ret ret

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_date public_stdcall _msys_get_date,0
_msys_get_date:
mov eax,29 mov eax,29
int 0x40 int 0x40
ret ret

View File

@ -1,8 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public_stdcall _msys_debug_out,4
public _msys_debug_out
_msys_debug_out:
;arg1 - char to out ;arg1 - char to out
push ebx push ebx
mov ecx,[esp+8] mov ecx,[esp+8]

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_delay public_stdcall _msys_delay,4
_msys_delay:
;arg1 - time ;arg1 - time
mov edx,ebx mov edx,ebx
mov eax,5 mov eax,5

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_dga_get_resolution public_stdcall _msys_dga_get_resolution,16
_msys_dga_get_resolution:
;arg1 - *xres ;arg1 - *xres
;arg2 - *yres ;arg2 - *yres
;arg3 - *bpp ;arg3 - *bpp

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_draw_bar public_stdcall _msys_draw_bar,20
_msys_draw_bar:
;arg1 - x ;arg1 - x
;arg2 - y ;arg2 - y
;arg3 - xsize ;arg3 - xsize

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_putimage public_stdcall _msys_putimage,20
_msys_putimage:
;arg1 - x ;arg1 - x
;arg2 - y ;arg2 - y
;arg3 - xsize ;arg3 - xsize

View File

@ -1,8 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public_stdcall _msys_draw_window,36
public _msys_draw_window
_msys_draw_window:
;arg1 - xcoord ;arg1 - xcoord
;arg2 - ycoord ;arg2 - ycoord
;arg3 - xsize ;arg3 - xsize

View File

@ -1,19 +1,17 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_wait_for_event_infinite public_stdcall _msys_wait_for_event_infinite,0
_msys_wait_for_event_infinite:
mov eax,10 mov eax,10
int 0x40 int 0x40
ret ret
public _msys_check_for_event public_stdcall _msys_check_for_event,0
_msys_check_for_event:
mov eax,11 mov eax,11
int 0x40 int 0x40
ret ret
public _msys_wait_for_event public_stdcall _msys_wait_for_event,4
_msys_wait_for_event:
;arg1 - time ;arg1 - time
mov edx,ebx mov edx,ebx
mov eax,23 mov eax,23
@ -22,8 +20,7 @@ _msys_wait_for_event:
mov ebx,edx mov ebx,edx
ret 4 ret 4
public _msys_set_wanted_events public_stdcall _msys_set_wanted_events,4
_msys_set_wanted_events:
;arg1 - flags ;arg1 - flags
mov edx,ebx mov edx,ebx
mov eax,40 mov eax,40

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_exit public_stdcall _msys_exit,0
_msys_exit:
xor eax,eax xor eax,eax
dec eax dec eax
int 0x40 int 0x40

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_read_file public_stdcall _msys_read_file,20
_msys_read_file:
;arg1 - file name ;arg1 - file name
;arg2 - file offset ;arg2 - file offset
;arg3 - size to read ;arg3 - size to read
@ -48,8 +48,7 @@ copy_file_name:
pop edi esi pop edi esi
ret ret
public _msys_write_file public_stdcall _msys_write_file,12
_msys_write_file:
;arg1 - file name ;arg1 - file name
;arg2 - size ;arg2 - size
;arg3 - data ;arg3 - data
@ -74,8 +73,7 @@ _msys_write_file:
pop ebp pop ebp
ret 12 ret 12
public _msys_run_program public_stdcall _msys_run_program,8
_msys_run_program:
;arg1 - program name ;arg1 - program name
;arg2 - parameters ;arg2 - parameters
push ebp push ebp

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_send_message public_stdcall _msys_send_message,12
_msys_send_message:
;arg1 - pid ;arg1 - pid
;arg2 - msg ;arg2 - msg
;arg3 - size ;arg3 - size
@ -15,8 +15,7 @@ _msys_send_message:
pop esi ebx pop esi ebx
ret 12 ret 12
public _msys_define_receive_area public_stdcall _msys_define_receive_area,8
_msys_define_receive_area:
;arg1 - area ;arg1 - area
;arg2 - size ;arg2 - size
push ebx push ebx

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_irq_owner public_stdcall _msys_get_irq_owner,4
_msys_get_irq_owner:
;arg1 - irq ;arg1 - irq
mov edx,ebx mov edx,ebx
mov eax,41 mov eax,41
@ -10,8 +10,7 @@ _msys_get_irq_owner:
mov ebx,edx mov ebx,edx
ret 4 ret 4
public _msys_get_data_read_by_irq public_stdcall _msys_get_data_read_by_irq,12
_msys_get_data_read_by_irq:
;arg1 - irq ;arg1 - irq
;arg2 - *size ;arg2 - *size
;arg3 - data ;arg3 - data
@ -37,8 +36,7 @@ _msys_get_data_read_by_irq:
mov ebx,edx mov ebx,edx
ret ret
public _msys_send_data_to_device public_stdcall _msys_send_data_to_device,8
_msys_send_data_to_device:
;arg1 - port ;arg1 - port
;arg2 - data ;arg2 - data
mov edx,ebx mov edx,ebx
@ -49,8 +47,7 @@ _msys_send_data_to_device:
mov ebx,edx mov ebx,edx
ret 8 ret 8
public _msys_receive_data_from_device public_stdcall _msys_receive_data_from_device,8
_msys_receive_data_from_device:
;arg1 - port ;arg1 - port
;arg2 - data ;arg2 - data
mov edx,ebx mov edx,ebx
@ -63,8 +60,7 @@ _msys_receive_data_from_device:
mov ebx,edx mov ebx,edx
ret 8 ret 8
public _msys_program_irq public_stdcall _msys_program_irq,8
_msys_program_irq:
;arg1 - intrtable ;arg1 - intrtable
;arg2 - irq ;arg2 - irq
mov edx,ebx mov edx,ebx
@ -75,8 +71,7 @@ _msys_program_irq:
mov ebx,edx mov ebx,edx
ret 8 ret 8
public _msys_reserve_irq public_stdcall _msys_reserve_irq,4
_msys_reserve_irq:
;arg1 - irq ;arg1 - irq
mov edx,ebx mov edx,ebx
mov eax,45 mov eax,45
@ -86,8 +81,7 @@ _msys_reserve_irq:
mov ebx,edx mov ebx,edx
ret 4 ret 4
public _msys_free_irq public_stdcall _msys_free_irq,4
_msys_free_irq:
;arg1 - irq ;arg1 - irq
mov edx,ebx mov edx,ebx
mov eax,45 mov eax,45
@ -98,8 +92,7 @@ _msys_free_irq:
mov ebx,edx mov ebx,edx
ret 4 ret 4
public _msys_reserve_port_area public_stdcall _msys_reserve_port_area,8
_msys_reserve_port_area:
;arg1 - start ;arg1 - start
;arg2 - end ;arg2 - end
push ebx push ebx
@ -111,8 +104,7 @@ _msys_reserve_port_area:
pop ebx pop ebx
ret 8 ret 8
public _msys_free_port_area public_stdcall _msys_free_port_area,8
_msys_free_port_area:
;arg1 - start ;arg1 - start
;arg2 - end ;arg2 - end
push ebx push ebx

View File

@ -1,13 +1,12 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_key public_stdcall _msys_get_key,0
_msys_get_key:
mov eax,2 mov eax,2
int 0x40 int 0x40
ret ret
public _msys_set_keyboard_mode public_stdcall _msys_set_keyboard_mode,4
_msys_set_keyboard_mode:
;arg1 - mode ;arg1 - mode
mov edx,ebx mov edx,ebx
mov eax,66 mov eax,66

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_line public_stdcall _msys_line,20
_msys_line:
;arg1 - x1 ;arg1 - x1
;arg2 - y1 ;arg2 - y1
;arg3 - x2 ;arg3 - x2

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_midi_reset public_stdcall _msys_midi_reset,0
_msys_midi_reset:
mov edx,ebx mov edx,ebx
mov eax,20 mov eax,20
xor ebx,ebx xor ebx,ebx
@ -10,8 +10,7 @@ _msys_midi_reset:
mov ebx,edx mov ebx,edx
ret ret
public _msys_midi_send public_stdcall _msys_midi_send,4
_msys_midi_send:
;arg1 - data ;arg1 - data
mov edx,ebx mov edx,ebx
mov eax,20 mov eax,20

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_pci_version public_stdcall _msys_get_pci_version,0
_msys_get_pci_version:
mov edx,ebx mov edx,ebx
mov eax,62 mov eax,62
xor ebx,ebx xor ebx,ebx
@ -10,8 +10,7 @@ _msys_get_pci_version:
mov ebx,edx mov ebx,edx
ret ret
public _msys_get_last_pci_bus public_stdcall _msys_get_last_pci_bus,0
_msys_get_last_pci_bus:
mov edx,ebx mov edx,ebx
mov eax,62 mov eax,62
xor ebx,ebx xor ebx,ebx
@ -21,8 +20,7 @@ _msys_get_last_pci_bus:
mov ebx,edx mov ebx,edx
ret ret
public _msys_get_pci_access_mechanism public_stdcall _msys_get_pci_access_mechanism,0
_msys_get_pci_access_mechanism:
mov edx,ebx mov edx,ebx
mov eax,62 mov eax,62
mov ebx,2 mov ebx,2
@ -31,8 +29,7 @@ _msys_get_pci_access_mechanism:
mov ebx,edx mov ebx,edx
ret ret
public _msys_pci_read_config_byte public_stdcall _msys_pci_read_config_byte,16
_msys_pci_read_config_byte:
;arg1 - bus ;arg1 - bus
;arg2 - dev ;arg2 - dev
;arg3 - fn ;arg3 - fn
@ -49,8 +46,7 @@ _msys_pci_read_config_byte:
mov ebx,edx mov ebx,edx
ret 16 ret 16
public _msys_pci_read_config_word public_stdcall _msys_pci_read_config_word,16
_msys_pci_read_config_word:
;arg1 - bus ;arg1 - bus
;arg2 - dev ;arg2 - dev
;arg3 - fn ;arg3 - fn
@ -67,8 +63,7 @@ _msys_pci_read_config_word:
mov ebx,edx mov ebx,edx
ret 16 ret 16
public _msys_pci_read_config_dword public_stdcall _msys_pci_read_config_dword,16
_msys_pci_read_config_dword:
;arg1 - bus ;arg1 - bus
;arg2 - dev ;arg2 - dev
;arg3 - fn ;arg3 - fn
@ -85,8 +80,7 @@ _msys_pci_read_config_dword:
mov ebx,edx mov ebx,edx
ret 16 ret 16
public _msys_pci_write_config_byte public_stdcall _msys_pci_write_config_byte,20
_msys_pci_write_config_byte:
;arg1 - bus ;arg1 - bus
;arg2 - dev ;arg2 - dev
;arg3 - fn ;arg3 - fn
@ -105,8 +99,7 @@ _msys_pci_write_config_byte:
pop ebx pop ebx
ret 20 ret 20
public _msys_pci_write_config_word public_stdcall _msys_pci_write_config_word,20
_msys_pci_write_config_word:
;arg1 - bus ;arg1 - bus
;arg2 - dev ;arg2 - dev
;arg3 - fn ;arg3 - fn
@ -125,8 +118,7 @@ _msys_pci_write_config_word:
pop ebx pop ebx
ret 20 ret 20
public _msys_pci_write_config_dword public_stdcall _msys_pci_write_config_dword,20
_msys_pci_write_config_dword:
;arg1 - bus ;arg1 - bus
;arg2 - dev ;arg2 - dev
;arg3 - fn ;arg3 - fn

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_putpixel public_stdcall _msys_putpixel,12
_msys_putpixel:
;arg1 - x ;arg1 - x
;arg2 - y ;arg2 - y
;arg3 - color ;arg3 - color

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_process_table public_stdcall _msys_get_process_table,8
_msys_get_process_table:
;arg1 - pointer to information ;arg1 - pointer to information
;arg2 - pid ;arg2 - pid
mov edx,ebx mov edx,ebx

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_get_screen_size public_stdcall _msys_get_screen_size,8
_msys_get_screen_size:
;arg1 - x ;arg1 - x
;arg2 - y ;arg2 - y
mov eax,14 mov eax,14

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_sound_load_block public_stdcall _msys_sound_load_block,4
_msys_sound_load_block:
;arg1 - blockptr ;arg1 - blockptr
mov edx,ebx mov edx,ebx
mov eax,55 mov eax,55
@ -11,8 +11,7 @@ _msys_sound_load_block:
mov ebx,edx mov ebx,edx
ret 4 ret 4
public _msys_sound_play_block public_stdcall _msys_sound_play_block,0
_msys_sound_play_block:
mov edx,ebx mov edx,ebx
mov eax,55 mov eax,55
xor ebx,ebx xor ebx,ebx
@ -21,8 +20,7 @@ _msys_sound_play_block:
mov ebx,edx mov ebx,edx
ret ret
public _msys_sound_set_channels public_stdcall _msys_sound_set_channels,4
_msys_sound_set_channels:
;arg1 - channels ;arg1 - channels
push ebx push ebx
mov eax,55 mov eax,55
@ -33,8 +31,7 @@ _msys_sound_set_channels:
pop ebx pop ebx
ret 4 ret 4
public _msys_sound_set_data_size public_stdcall _msys_sound_set_data_size,4
_msys_sound_set_data_size:
;arg1 - data size ;arg1 - data size
push ebx push ebx
mov eax,55 mov eax,55
@ -46,8 +43,7 @@ _msys_sound_set_data_size:
pop ebx pop ebx
ret 4 ret 4
public _msys_sound_set_frequency public_stdcall _msys_sound_set_frequency,4
_msys_sound_set_frequency:
;arg1 - frequency ;arg1 - frequency
push ebx push ebx
mov eax,55 mov eax,55
@ -58,8 +54,7 @@ _msys_sound_set_frequency:
pop ebx pop ebx
ret 4 ret 4
public _msys_sound_speaker_play public_stdcall _msys_sound_speaker_play,4
_msys_sound_speaker_play:
;arg1 - data ;arg1 - data
mov edx,ebx mov edx,ebx
mov eax,55 mov eax,55

View File

@ -1,8 +1,8 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
extrn malloc extrn malloc
public _msys_start_thread public_stdcall _msys_start_thread,12
_msys_start_thread:
;arg1 - proc ;arg1 - proc
;arg2 - stacksize ;arg2 - stacksize
;arg3 - pid ;arg3 - pid

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_window_redraw public_stdcall _msys_window_redraw,4
_msys_window_redraw:
;arg1 - status ;arg1 - status
mov edx,ebx mov edx,ebx
mov eax,12 mov eax,12

View File

@ -1,7 +1,7 @@
format ELF format ELF
include "public_stdcall.inc"
section '.text' executable section '.text' executable
public _msys_write_text public_stdcall _msys_write_text,20
_msys_write_text:
;arg1 - x ;arg1 - x
;arg2 - y ;arg2 - y
;arg3 - color ;arg3 - color

View File

@ -96,11 +96,12 @@ void build_reloc(me_info* me)
Elf32_Sym* esym = ((Elf32_Sym *)symtab_section->data)+sym; Elf32_Sym* esym = ((Elf32_Sym *)symtab_section->data)+sym;
int sect=esym->st_shndx; int sect=esym->st_shndx;
ss=findsection(me,sect); ss=findsection(me,sect);
if (ss==0) continue; if (ss==0)
ss=me->bss_sections;
if (rel->r_offset>s->data_size) if (rel->r_offset>s->data_size)
continue; continue;
if (type==R_386_PC32) if (type==R_386_PC32)
*(int*)(rel->r_offset+s->data)+=ss->sh_addr+esym->st_value-rel->r_offset-s->sh_addr; *(int*)(rel->r_offset+s->data)=ss->sh_addr+esym->st_value-rel->r_offset-s->sh_addr-4;
else if (type==R_386_32) else if (type==R_386_32)
*(int*)(rel->r_offset+s->data)+=ss->sh_addr+esym->st_value; *(int*)(rel->r_offset+s->data)+=ss->sh_addr+esym->st_value;
} }