COFF relocation... how to?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

COFF relocation... how to?

Post 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
~ Lukem95 [ Cake ]
Release: 0.08b
Image
digo_rp
Member
Member
Posts: 233
Joined: Sun Jun 05, 2005 11:00 pm

Post 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....
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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;
              
          }
    }
~ Lukem95 [ Cake ]
Release: 0.08b
Image
Post Reply