gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > Does using the linkscripts keep any relocation information?

#143860 - Dwedit - Fri Oct 26, 2007 9:30 pm

In devkitARM, after the .o files are run through the linker (using one of the GBA or NDS linkscripts) to produce an .elf file, does this elf file contain any relocation information?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#143876 - kusma - Sat Oct 27, 2007 12:46 am

only if you supply the -fPIC option (or was it -mPIC?) during compilation

edit: stupid me, not reading the post fully before posting. i'm dead tired from delayed flights, sorry.

#143880 - gmiller - Sat Oct 27, 2007 12:54 am

The ELF specification does include stuff about reloation but it might not be enough. See:

http://www.skyfree.org/linux/references/ELF_Format.pdf

#143883 - tepples - Sat Oct 27, 2007 2:10 am

What do you need relocatable code for? The most easily relocatable code is position-independent code (PIC), which DLDI uses.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#143895 - chishm - Sat Oct 27, 2007 4:29 am

tepples wrote:
What do you need relocatable code for? The most easily relocatable code is position-independent code (PIC), which DLDI uses.

Compiling as PIC code isn't enough. For example, the glue between ARM and THUMB code, which is added by the linker, is not automatically made position independent. Libraries may also need to be recompiled as PIC. DLDI gets around this by searching for addresses within all parts of the binary.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com