This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: HELP! How to add secrel psuedo op for pe-i386?


Thank you VERY much for the reply.  See below for comments please.

On 17 Jan 2003, Nick Clifton wrote:

> > I think the "correct" way to handle this is to implement the secrel psuedo
> > op like IA64 does.  I only have a very vauge idea what this means.
> >
> > Can a binutils guru enlighten me on what's involved here?  Thanks.
>
> I'll try.  Basically you change gcc so that instead of generating:
>
>         .word <value>
>
> it generates something like this:
>
>         .word <value> @secrel (<label>)
>
> for a DWARF2 section-relative relocation.
Done and easy.

> The exact syntax you choose is up to you, and presumably you would
> choose something that fits in with current x86 assembler syntax.
>
I am searching the net trying to figure that out.  I am not very
experienced in x86 or Windows, so if anyone knows, please speak up.

> Then you extend the x86 backend in GAS (file: gas/config/tc-i386.c) so
> that it can parse the new syntax and generate a relocation for the
> value.  In fact you will probably need a set of relocations to handle
> different sized values (ie 8-bit, 16-bit, 32-bit and 64-bit).
>
This is where it starts getting really messy, for me at least.

No.  I only need 32-bit, as that is all the i386 PE format specifies,
and it is all dwarf2 needs.

> GAS actually creates relocations by a two stage process.  First it
> creates a 'fixup' which is a structure describing an area of the
> to-be-output binary that will need extra processing once it has
> finished its pass of the input source file(s).  Then it processes
> these fixups, creating relocations if necessary.
>
> To add new x86 relocation numbers you will need to modify
> include/elf/i386.h and bfd/reloc.c.  (After which you will need to run
> "make headers" in the bfd build directory to recreate the other header
> files).  You will then need to extend the bfd/elf32-i386.c source file
> to handle your new relocations.
>
Just to clarify, this PE/coff, not elf.  So, include/coff/internal.h and
bfd/coff-i386.c are the relevant files.

Is BFD_RELOC_32_BASEREL appropriate here?  If so, I do not need to modify
bfd/reloc.c.

> Of course there is no real documentation on how to do any of this, so
> the source code is still the best guide.  As you have found the IA64
> port has done this already, so you can use that as your guide.
>
Since they did it for elf, not coff, it seems to be a very loose guide.
Also, it seams every port has their own way of doing things.  There is a
lot of port specific code that looks like it should have been shared.

Just more confusion for me :).

> Finally you should create an assembler test case to make sure that the
> assembler and disassembler can handle these new pseudo ops and
> relocations.
>
I look into that.  Thanks.

-- 
Brian Ford
Senior Realtime Software Engineer
VITAL - Visual Simulation Systems
FlightSafety International
Phone: 314-551-8460
Fax:   314-551-8444




--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]