I am trying to write a custom object loader for ELF64 and should be able to execute the loaded object from memory they were loaded. It's working just fine until I ran into the old MOV vs LEA problem again;
Here's my pseudo program
format ELF64 executable 3
entry start
segment readable writeable
f db 'object.o',0 ;the object file to be loaded
segment readable executable
start:
;open the file
;get the object size
;create dynamic memory based on the size
;save/load the object to that memory. Pointer in RAX
add rax,64 ;skip the header
jmp rax
And here's the object file I'm loading
;compile to create object.o
format elf64
mov rdx,29
lea rsi,[x] ;address
;mov rsi,x ;this won't work. Why?
mov edi,1
mov eax,1
syscall ;print the string
xor edi,edi
mov rax,60
syscall ;exit code
x db 'Hi, I am from the loaded file.'
See the commented line. That's the problem. I can't address the string by using MOV but it is working perfectly using LEA (the message got printed from the loaded object).
What's wrong here?