Xref: news2.mv.net comp.os.msdos.djgpp:5838 From: malcolm AT manawatu DOT gen DOT nz (Malcolm Taylor) Newsgroups: comp.os.msdos.djgpp Subject: Re: Relocation and linking Date: Wed, 10 Jul 1996 22:59:56 GMT Organization: Grafik Software Lines: 35 Message-ID: <4s1gjv$as4@news.manawatu.gen.nz> References: <4rqh6b$70b AT leporello DOT cs DOT unibo DOT it> Reply-To: malcolm AT manawatu DOT gen DOT nz NNTP-Posting-Host: malcolm.manawatu.gen.nz Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp gaggi AT cs DOT unibo DOT it (Nicola Gaggi) wrote: >Hello folks, >I need information on how relocation and linking is done under DJGPP for >a project I am working on. >I have used the utility 'objdump' and I have read the include file 'coff.h' to >understand the format of the COFF file and I find that in the relocation part >of these files there are only entries for external symbols and data, how can >static and local declared symbols be relocated? May I have to scan all the >code to find where jump istructions (function calls and unconditional jumps) >are and modify the target address of the istructions? I dont think this is the >best way to do relocation (even DOS use a better approach :) )! Firstly if you are wanting DLLs then there is already a simple package available, and a few people working on a more complete version. This might be easier than reinventing the wheel. Even if you don't want this the code for the DLLs will give you a large amount of info on the COFF format if you don't mind studying it :) The COFF format stores no information about local symbols. Relocation in the COFF format is handled with the relocation entries, which can be referenced relative to another symbol. Most COFF format files have bss, .data and .text which are all symbols that point to the beginning of each section. These are used by one relocation type which will specify an offset from these. Any other symbol can be used in the same manner, but these are normally easiest. If I remember right there are only two different relocation types used by DJGPP. I don't remember this clearly, but I think the difference is in the way that they calculate the final address from the one already there. Hope this helps, Malcolm