I want to write code in assembly which puts itself in a given ELF. My code looks like:
func_start:
; Getting file descriptor, and additional code here
mov eax, 4; Write Sys_call
mov ebx, [fileDesc]
mov ecx, func_start
mov edx, func_end - func_start
func_end:
But I also want that the file (after the edition) will be able to do the same thing, but for this I have to write my code as position independent. Everything I tried to do in order to get the address of func_start label at runtime failed.
Any ideas?
Edit: What I actually ask is: How can I use my labels in a position-independent way?