Page 1 of 1

COFF relocation... how to?

Posted: Wed Jan 02, 2008 6:37 pm
by lukem95
i managed to get ELF reloc working very easily (ok.. i mean executable, boring elf's here) but im finding the COFF spec (not that its really a spec, the delorie.com explanation) rather more confusing.

so far i know that i need to read the file header and optional header, this tells me the entry point to call, as well as some other stuff im not sure how to use yet.

could somebody clarify what i need to relocate in order to get this working? somebody that has already done it, could you please give me a short list of how it works?

thankyou, lukem95

Posted: Thu Jan 03, 2008 6:25 am
by digo_rp
man could you help me ? I´m trying to load and execute .elf files. but I can´t understand...

How do you execute that elf file ? could you show me some source ?

please....

Posted: Thu Jan 03, 2008 2:12 pm
by lukem95
yeah, download elf.h, its very easy to find and write a function to iterate through all the fields to determine its for the right architecture and everything.

You then need to relocate the executable (PT_LOAD) sections.

Code: Select all

for(i = 0; i < header->phnum; i++)
    {
          /* Check if its loadable */
          if( pHeader[i].type == 1 ) /* PT_LOAD == 1 */
          {
              if(!kmalloc(pHeader[i].memSize))
                   return -1;
              
          }
    }