commit c7d731b8dd883f1f3ccc84f72f33415b05c3c1c1
parent 32d51f29db633b2948f81517bfbc1932264ee336
Author: mehdi-norouzi <mehdeenoroozi@gmail.com>
Date: Mon, 10 Feb 2025 23:09:35 +0330
fix eh entry and ph file and mem size
Diffstat:
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/elfer/elfer-hello.s b/elfer/elfer-hello.s
@@ -81,7 +81,7 @@ _start:
movl $ev_val_current, (%r9)
lea eh_idx_entry(%r8), %r9
- movq $0x4000B0, (%r9)
+ movq $0x4000C0, (%r9)
lea eh_idx_phoff(%r8), %r9
movq $0x40, (%r9)
@@ -127,13 +127,14 @@ _start:
movq $0x600000, (%r9)
lea ph_idx_filesz(%r8), %r9
- movq $0x1000, (%r9)
+ movq $0x0100, (%r9)
lea ph_idx_memsz(%r8), %r9
- movq $0x1000, (%r9)
+ movq $0x0100, (%r9)
lea ph_idx_align(%r8), %r9
movq $0x1000, (%r9)
+
# write elf_header to the file
mov %rax, %rdi
lea elf_header, %rsi
@@ -153,6 +154,18 @@ _start:
mov $SYSCALL_WRITE, %rax
syscall
+ # write padding
+ lea padding_8b, %rsi
+ mov $8, %rdx
+ mov $SYSCALL_WRITE, %rax
+ syscall
+
+ # write padding
+ lea padding_8b, %rsi
+ mov $8, %rdx
+ mov $SYSCALL_WRITE, %rax
+ syscall
+
# write machine code to the file
lea machine_code, %rsi
mov $machine_code_sz, %rdx