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
fdb'object.o',0;the object file to be loaded
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
addrax,64;skip the header
And here's the object file I'm loading
;compile to create object.o
movrdx,29 learsi,[x] ;address
;mov rsi,x ;this won't work. Why?
movedi,1 moveax,1 syscall;print the string
xdb'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).
John, it doesn't work on my machine. Maybe you missed the fact that it is a loaded object, and not a linked / executable file. Of course both work if it was in an executable / linked object. That means I can't properly execute a string code which is addressed using MOV, this way?
Joined: 16 Jun 2003
Location: Kraków, Poland
LEA in this case uses RIP-relative addressing and therefore does not need relocation (unless it refers to an address in some other section), while the opcode of MOV contains an absolute address that has to be relocated. So the fact that LEA works in your case but MOV doesn't, means that your loader has not applied the relocations correctly.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum