Conversation

Charlotte 🦝 therian

does someone know how to load position independent ELF executables?

specifically i have a file linked to 0x0000_0000_0010_0000 and would like to load it to 0xFFFF_FFFF_0000_0000

what do i need to change. The .got section is obvious, but pointers inside of the data sections still refer to the old location

1
0
1

ok so i think? i need to look at the .dynamic section and perform the relocations outlined there

makes a lot of sense but can i move the sections around with that? doesn’t look that way

2
0
1

@charlotte oh man I really only know how to do this kind of thing with PE not ELF, and even then I've forgotten much of it

0
0
0

ok so in “static-pie” executables (the type i am creating) it relocates against address 0. If you want to relocate it to be at a different location, you need to use the difference between the target address and the original load address as the base address for relocations

0
0
1