use: wrt ..plt instead no-pie
This commit is contained in:
parent
174a587414
commit
8ae1a6e876
2
Makefile
2
Makefile
@ -6,7 +6,7 @@ SRC := $(wildcard $(SRCDIR)/*.asm)
|
||||
OBJ := $(patsubst $(SRCDIR)/%.asm,$(OBJDIR)/%.o,$(SRC))
|
||||
|
||||
CC = gcc
|
||||
CFLAGS = -g -no-pie
|
||||
CFLAGS = -g
|
||||
|
||||
AS = nasm
|
||||
ASFLAGS = -f elf64 -g
|
||||
|
@ -10,8 +10,8 @@ section .text
|
||||
mov rbx, rdi
|
||||
mov rdi, rax
|
||||
|
||||
call malloc
|
||||
|
||||
call malloc wrt ..plt
|
||||
|
||||
cmp rax, 0
|
||||
je error
|
||||
|
||||
|
@ -1,6 +1,23 @@
|
||||
extern __errno_location
|
||||
|
||||
section .text
|
||||
global ft_write
|
||||
ft_write:
|
||||
mov rax, 1
|
||||
|
||||
syscall
|
||||
|
||||
cmp rax, 0
|
||||
jne syscall_failed
|
||||
|
||||
ret
|
||||
|
||||
syscall_failed:
|
||||
|
||||
neg rax
|
||||
mov rbx, rax
|
||||
|
||||
call __errno_location wrt ..plt
|
||||
mov [rax], rbx
|
||||
mov rax, -1
|
||||
ret
|
@ -78,4 +78,5 @@ int main()
|
||||
printf("\n");
|
||||
|
||||
ft_write(1, "bozo\n", 5);
|
||||
printf("%s\n", ft_strdup("sdsfsd"));
|
||||
}
|
Loading…
Reference in New Issue
Block a user