delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/01/17/13:44:18

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
To: ford AT vss DOT fsi DOT com
Cc: cygwin AT cygwin DOT com, binutils AT sources DOT redhat DOT com, dave AT beermex DOT com
Subject: Re: HELP! How to add secrel psuedo op for pe-i386?
References: <Pine DOT GSO DOT 4 DOT 44 DOT 0301161204580 DOT 12926-100000 AT eos>
From: Nick Clifton <nickc AT redhat DOT com>
Date: 17 Jan 2003 18:43:40 +0000
In-Reply-To: <Pine.GSO.4.44.0301161204580.12926-100000@eos>
Message-ID: <m3iswnmxb7.fsf@north-pole.nickc.cambridge.redhat.com>
Lines: 53
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1
MIME-Version: 1.0

Hi Brian,

> > So, all I need to do is define ASM_OUTPUT_DWARF_OFFSET correctly in
> > gcc/config/i386/cygwin.h.
> >
> > Does anyone have a good way to define a section relative offset in
> > assembly for Cygwin, or do I need to define labels for the sections in the
> > link script and use them?  That seems messy.
> >
> 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.  The exact syntax you choose
is up to you, and presumably you would choose something that fits in
with current x86 assembler syntax.

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).

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.

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.

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

Cheers
        Nick


--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019