COFF - relocation entries

COFF - relocation entries

Post by Alexei A. Frounz » Sun, 28 Nov 1999 04:00:00



Hi people!

I'm writing a loader for COFF ".o" object files. I've read info about COFF file
format at the www.delorie.com, but it's still not clear how to handle the
relocation entries.

Could you explain me that? Maybe some kind of examle would be good for that?

Thanks in advance.
Alexei A. Frounze

 
 
 

COFF - relocation entries

Post by Mark & Candice Whit » Mon, 29 Nov 1999 04:00:00


I read your discussion thread of "JLOC and COFF" with John Fine.
So I'm sure your talking about nonlinked COFF, but just in case
I will say it seems trivial to write a loader for linked COFF.

If your working on a way to use COFF as a dll type format for your
hobby OS, please make it easy and available for others to add to their
projects.

Just out of curiosity why are you using COFF not ELF?
ELF has object, and linked forms like COFF, but also a
dynamically linkable form too. According to Dark Fiber:
http://www.mega-tokyo.com/os/os-faq.html
recompiling the dos bintools to work with ELF is not to hard.
(I have not done this and still use COFF, so I'll be quiet now.)


> Hi people!

> I'm writing a loader for COFF ".o" object files. I've read info about COFF file
> format at the www.delorie.com, but it's still not clear how to handle the
> relocation entries.

> Could you explain me that? Maybe some kind of examle would be good for that?

> Thanks in advance.
> Alexei A. Frounze

--
Mark & Candice White
System programming hobbyists.
http://members.home.net/mhewii/welcome.htm

_________________New Years Cheer__________
To the nerds, geeks and computer techs
there's no need to frown
you'll be getting over-time
when the bug brings the system down.

 
 
 

COFF - relocation entries

Post by Alexei A. Frounz » Mon, 29 Nov 1999 04:00:00



Quote:> I read your discussion thread of "JLOC and COFF" with John Fine.
> So I'm sure your talking about nonlinked COFF, but just in case
> I will say it seems trivial to write a loader for linked COFF.

Nonlinked means a COFF file w/o optinoal (a.out) header? Linked with such header,
right?

Quote:> If your working on a way to use COFF as a dll type format for your
> hobby OS, please make it easy and available for others to add to their
> projects.

Not dlls (although why not?), but executables. I've chosen COFF because DJGPP is a
free compiler that generates such files. I want to make development easy for anyone.

Quote:> Just out of curiosity why are you using COFF not ELF?

Don't know. ELF is not bad... But DJGPP for DOS doesn't generate ELFs, although for
Linux ELF is a normal thing (I use DOS/Win).

Bye.
Alexei A. Frounze
------------------------------------
If you wanna stay a coder,
You must keep your minds in order.
;-))

 
 
 

COFF - relocation entries

Post by Gautier de Montmolli » Tue, 30 Nov 1999 04:00:00


Interesting... If it could allow making a smart linker
that can use the rich modularity information of GNAT to trim
unused code & data (in a Turbo / Borland Pascal way) it could be
very interesting!

--
Gautier

_____\\________________\_______\_________
http://members.xoom.com/gdemont/gsoft.htm

 
 
 

COFF - relocation entries

Post by Mark & Candice Whit » Tue, 30 Nov 1999 04:00:00




> > I read your discussion thread of "JLOC and COFF" with John Fine.
> > So I'm sure your talking about nonlinked COFF, but just in case
> > I will say it seems trivial to write a loader for linked COFF.

> Nonlinked means a COFF file w/o optinoal (a.out) header? Linked with such header,
> right?

djgpp and nasm make coff files made to be linked, djgpp can be setup to do
the linking to.
I use a modified linker script to make linked coff with out the go32(dos) stuff.
I take this file load it in mem at 0x1000 and look the dword at 0x1024 for the
start of the code, and jump there. (with pmode all set up)
I have yet to have a problem with offsets or such because ld already linked it to be
a flat file.

Quote:

> > If your working on a way to use COFF as a dll type format for your
> > hobby OS, please make it easy and available for others to add to their
> > projects.

> Not dlls (although why not?), but executables. I've chosen COFF because DJGPP is a
> free compiler that generates such files. I want to make development easy for anyone.

ELF is made to be dynamically linked.

Quote:

> > Just out of curiosity why are you using COFF not ELF?

> Don't know. ELF is not bad... But DJGPP for DOS doesn't generate ELFs, although for
> Linux ELF is a normal thing (I use DOS/Win).

I use djgpp also and use coff because I was already booting with it before I found
out that I could just rebuild as,ld,ar... to make elf in DOS.
If ease is what your after you could rebuild these and post them for others.

Quote:

> Bye.
> Alexei A. Frounze
> ------------------------------------
> If you wanna stay a coder,
> You must keep your minds in order.
> ;-))

--
Mark & Candice White
System programming hobbyists.
http://members.home.net/mhewii/welcome.htm

_________________New Years Cheer__________
To the nerds, geeks and computer techs
there's no need to frown
you'll be getting over-time
when the bug brings the system down.

 
 
 

COFF - relocation entries

Post by Gautier de Montmolli » Tue, 30 Nov 1999 04:00:00


Interesting... If it could allow making a smart linker
that can use the rich modularity information of GNAT to trim
unused code & data (in a Turbo / Borland Pascal way) it could be
very interesting!

--
Gautier

_____\\________________\_______\_________
http://members.xoom.com/gdemont/gsoft.htm

 
 
 

COFF - relocation entries

Post by Eli Zaretski » Tue, 30 Nov 1999 04:00:00



Quote:> Just out of curiosity why are you using COFF not ELF?
> ELF has object, and linked forms like COFF, but also a
> dynamically linkable form too. According to Dark Fiber:
> http://www.mega-tokyo.com/os/os-faq.html
> recompiling the dos bintools to work with ELF is not to hard.

Moving DJGPP to ELF involves much more than reconfiguring Binutils.
The stub loader needs to be rewritten, the entire debug support
library needs to be enhanced to know about ELF debug info, several
core development tools need major revisions, and all the toolkit
libraries that use assembly need to be revised.  For such a formidable
task, there's currently not enough motivation.

More details about this can be found in section 22.21 of the DJGPP FAQ
list.

 
 
 

COFF - relocation entries

Post by Dark Fibe » Tue, 30 Nov 1999 04:00:00




Quote:> Moving DJGPP to ELF involves much more than reconfiguring Binutils.
> The stub loader needs to be rewritten, the entire debug support
> library needs to be enhanced to know about ELF debug info, several
> core development tools need major revisions, and all the toolkit
> libraries that use assembly need to be revised.  For such a formidable
> task, there's currently not enough motivation.

if you read my os faq you'd see its not about moving the entire DJGPP
platform to elf, its about compiling ELF support into the base utils so
objcopy, nm, objdump, ld etc support handling of ELF files. by default
its all still coff so poses no problems to djgpp since coff is its
default, it just has elf support so you can ld --target=i386-elf32 etc.

--

Write Your Own Operating System [FAQ]
    http://www.mega-tokyo.com/os

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. COFF relocation tables

Hi!

 Can anyone help with COFF relocation tables ?
 I mean the following information WANTED :
 1. What information is stored in the place of relocation
    in the .o files (for ADDR32 and REL32 types)
    As I guess, for ADDR32 the offset from r_symndx symbol
    is stored. Am I right ?
    What is that number for REL32 ?
 2. What is standard way to resolve relocations ?
    I need a sample algorithm WITH COMMENTS ! ;-)
    I have a few peaces of code, but they are poor commented
    at that very place.
 3. What is those ".lib" standard section ? I've never saw one in
    my object files.

        Thanx for any help!
--
                                                        Sincerely yours,
Ilya

http://spy.isp.nsc.ru

2. Sun Product Line

3. Relocation.

4. CURSOS DE DISE?O E INTERIORISMO

5. Relocation and linking

6. Need grep that displays context (ie lines surrounding string)

7. Relocation and linking (fwd)

8. DAT file access

9. Relocations for PE exeutables

10. The .EXE programs's relocation-header

11. dos .exe relocation

12. MZ EXE Relocation...

13. .EXE Relocation information