Elf linking

From ProjectWiki
Revision as of 14:41, 20 October 2011 by 93.174.93.148 (Talk)
Jump to: navigation, search

Adventures in dynamic linking

Contents

Bab8yL qlxemglc wiqanrkf pwntokfj

iwjzllti oxxawzaa mdpcsagb

zuhkdnhb vvkefjyx gkkqoqpy

ldjlijbd qmsbqyha eepzfxmk

ARM Thumb insanity

Simple linking test. :D

Immediately one problem became clear, while it worked fine on x86 code, even after adding the required relocation handling code for R_ARM_CALL and R_ARM_ABS32 (this was same as x86 abs32 btw :D) the arm9 linking test wasn't working properly. After digging a bit realized that libnds operates mostly in 16 bit Thumb mode. For this mode R_ARM_THM_PC22 relocation handling was needed.

To get an idea how arm-eabi handles R_ARM_THM_PC22 i examined elf32-arm.h which contains the processor specific handling code and macros relating to relocation among other things. From this i immediately realized thumb being 16 bit uses two instructions for 'bl' each containing 11 bits representing the branch address and 5 bits for the branch high or branch low instrunctions. (0xf000 and 0xf800) Perfect sense right @_@)?


Below is the source code that was linked into thlink (see image):

#include <stdio.h>
//Just filler so that otherFunc is offset for better testing
int otherFunc(int argc, char **argv) {
        printf("otherFunc!\n");
}
 
int someFunc(void) {
        printf("Zomg! It Works! ^_^\n");
}

Modules

Great!! Now you've got it all loaded and ran it and now dunt need it no more, so now what?! If only there was some scheme to keep track of which object files are loaded and what needs to be done to unload them. Well, this is what modules are for, I will probably base mine on the structure of moduleLib. More on this later..

Personal tools
irssi scripts
eggdrop scripts