mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-08-07 02:10:27 +00:00
Update OpenExecutable logic to properly check BSD/Linux error conditions
This commit is contained in:
parent
13ff8745c9
commit
efa12a67f9
1 changed files with 13 additions and 12 deletions
|
@ -121,19 +121,20 @@ OpenExecutable:
|
|||
mov -0x08(%rbp),%eax # __NR_open
|
||||
mov %r14,%rdi
|
||||
mov -0x20(%rbp),%esi # O_RDWR
|
||||
syscall
|
||||
mov %eax,%r15d
|
||||
mov $-1,%eax # check if successful
|
||||
cmp %eax,%r15d
|
||||
jne 0f
|
||||
clc # clear carry flag
|
||||
syscall
|
||||
jc .Lohno # bsd error
|
||||
cmp $-4095,%eax
|
||||
jae .Lohno # linux error
|
||||
jmp .Lok
|
||||
|
||||
// Open executable in read-only mode.
|
||||
mov -0x08(%rbp),%eax # __NR_open
|
||||
mov %r14,%rdi
|
||||
mov -0x48(%rbp),%esi # O_RDONLY
|
||||
syscall
|
||||
mov %eax,%r15d
|
||||
0:
|
||||
// Open executable in read-only mode.
|
||||
.Lohno: mov -0x08(%rbp),%eax # __NR_open
|
||||
mov %r14,%rdi
|
||||
mov -0x48(%rbp),%esi # O_RDONLY
|
||||
syscall
|
||||
|
||||
.Lok: mov %eax,%r15d
|
||||
|
||||
// Map code segment.
|
||||
mov -0x10(%rbp),%eax # __NR_mmap
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue