FreeBSD CSU fixes

* Assembler blocks in non-pure assembler functions must always declare all
changed registers
* argc is read as *(long*) in C -> changed plongint to pptrint
* fixed ident section
This commit is contained in:
Jonas Maebe 2021-11-27 12:01:47 +01:00
parent 9314bbbf08
commit e1a739d15d
2 changed files with 10 additions and 9 deletions

View File

@ -41,12 +41,12 @@ const R_X86_64_IRELATIVE = 37;
procedure freebsdIdentTag;nostackframe;assembler; procedure freebsdIdentTag;nostackframe;assembler;
asm asm
.section ".note.openbsd.ident", "a" .section ".note.tag", "a"
.p2align 2 .p2align 2
.long 8 .long 8
.long 4 .long 4
.long 1 .long 1
.asciz "OpenBSD" .asciz "FreeBSD"
.long 0 .long 0
.text .text
@ -61,27 +61,28 @@ end;
procedure do_cpuid(funcnr : integer; var p); procedure do_cpuid(funcnr : integer; var p);
begin begin
asm asm
mov rax,rdi mov rax,funcnr
cpuid cpuid
mov rsi,@p
mov [rsi],eax mov [rsi],eax
mov [rsi+4],ebx mov [rsi+4],ebx
mov [rsi+8],ecx mov [rsi+8],ecx
mov [rsi+12],edx mov [rsi+12],edx
end['rbx']; // rbx is callee saved in sysv end['rax','rbx','rcx','rdx','rsi'];
end; end;
procedure cpuid_count(funcnr : integer;count:integer;var p); procedure cpuid_count(funcnr : integer;count:integer;var p);
begin begin
asm asm
mov rax,rdi // funcnr mov rax,funcnr
mov rcx,rsi // count mov rcx,count
mov rsi,rdx // save pointer since cpuid destroys edx mov rsi,@p
cpuid cpuid
mov [rsi],eax mov [rsi],eax
mov [rsi+4],ebx mov [rsi+4],ebx
mov [rsi+8],ecx mov [rsi+8],ecx
mov [rsi+12],edx mov [rsi+12],edx
end['rbx']; end['rax','rbx','rcx','rdx','rsi'];
end; end;
procedure crt1_handle_rela(r : pelf_rela); procedure crt1_handle_rela(r : pelf_rela);

View File

@ -21,7 +21,7 @@ var argc: longint;
env : ppchar; env : ppchar;
s : pchar; s : pchar;
begin begin
argc:=plongint(ap)^; argc:=pptrint(ap)^;
argv:=ppchar(ap[1]); argv:=ppchar(ap[1]);
env:= ppchar(ap[2+argc]); env:= ppchar(ap[2+argc]);
environ:=env; environ:=env;