Skip to content

Commit

Permalink
fix: make crt-stack position-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
gemesa committed Dec 20, 2024
1 parent 0f444a8 commit 8676348
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ $(BUILDDIR)/linux/x64/crt-hello: lab/linux/asm-hive/x64/crt-hello.s
gcc $< -fPIE -pie -g -o $@

$(BUILDDIR)/linux/x64/crt-stack: lab/linux/asm-hive/x64/crt-stack.s
gcc $< -g -o $@
gcc $< -fPIE -pie -g -o $@

$(BUILDDIR)/linux/x64/nocrt-hello: lab/linux/asm-hive/x64/nocrt-hello.s
as $< -g -o $(BUILDDIR)/linux/x64/nocrt-hello.o
Expand Down
12 changes: 6 additions & 6 deletions lab/linux/asm-hive/x64/crt-stack.s
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ main_:
mov $10, %edi
mov $11, %esi
call sum
mov $format_string, %edi
lea format_string(%rip), %rdi
mov %eax, %esi
call printf
mov $10, %edi
mov $11, %esi
call mul
mov $format_string, %edi
lea format_string(%rip), %rdi
mov %eax, %esi
call printf
xor %eax, %eax
mov $10, %edi
mov $11, %esi
call calc
mov $format_string, %edi
lea format_string(%rip), %rdi
mov %eax, %esi
call printf
pop %rbp
Expand Down Expand Up @@ -132,20 +132,20 @@ main:
mov edi, 10
mov esi, 11
call sum
mov edi, offset format_string
lea rdi, [rip + format_string]
mov esi, eax
call printf
mov edi, 10
mov esi, 11
call mul
mov edi, offset format_string
lea rdi, [rip + format_string]
mov esi, eax
call printf
xor eax, eax
mov edi, 10
mov esi, 11
call calc
mov edi, offset format_string
lea rdi, [rip + format_string]
mov esi, eax
call printf
pop rbp
Expand Down

0 comments on commit 8676348

Please sign in to comment.