public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Tristan Gingold <gingold@adacore.com>
To: Iain Sandoe <developer@sandoe-acoustics.co.uk>
Cc: binutils Development <binutils@sourceware.org>
Subject: Re: [Patch mach-o/bfd] Order relocs after the section data.
Date: Fri, 13 Jan 2012 08:18:00 -0000	[thread overview]
Message-ID: <2C1FAEDC-3975-4147-9E10-7D513AB0F590@adacore.com> (raw)
In-Reply-To: <593B950F-2874-450B-94EA-AF8854154BF1@sandoe-acoustics.co.uk>


On Jan 12, 2012, at 10:01 PM, Iain Sandoe wrote:

> this is an almost cosmetic patch that causes us to order relocs after the section data - rather than after the indirect symbols.
> 
> The main purpose is that it makes it easier to compare the output of the native 'as' with GAS.
> 
> I suppose there's a minor 'do what ld expects' content, but one would hope that is largely unimportant...
> 
> OK?

Ok.

Thanks,
Tristan.

> Iain
> 
> bfd:
> 
> 	* mach-o.c (bfd_mach_o_write_relocs): Move the computation of relocs file
> 	position from here ...
> 	(bfd_mach_o_build_seg_command) ... to here.
> 
> 
> bfd/mach-o.c |   27 +++++++++++++++++++--------
> 1 files changed, 19 insertions(+), 8 deletions(-)
> 
> diff --git a/bfd/mach-o.c b/bfd/mach-o.c
> index c519663..2625319 100644
> --- a/bfd/mach-o.c
> +++ b/bfd/mach-o.c
> @@ -1185,7 +1185,6 @@ bfd_mach_o_canonicalize_dynamic_reloc (bfd *abfd, arelent **rels,
> static bfd_boolean
> bfd_mach_o_write_relocs (bfd *abfd, bfd_mach_o_section *section)
> {
> -  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
>   unsigned int i;
>   arelent **entries;
>   asection *sec;
> @@ -1198,13 +1197,6 @@ bfd_mach_o_write_relocs (bfd *abfd, bfd_mach_o_section *section)
>   if (bed->_bfd_mach_o_swap_reloc_out == NULL)
>     return TRUE;
> 
> -  /* Allocate relocation room.  */
> -  mdata->filelen = FILE_ALIGN(mdata->filelen, 2);
> -  section->nreloc = sec->reloc_count;
> -  sec->rel_filepos = mdata->filelen;
> -  section->reloff = sec->rel_filepos;
> -  mdata->filelen += sec->reloc_count * BFD_MACH_O_RELENT_SIZE;
> -
>   if (bfd_seek (abfd, section->reloff, SEEK_SET) != 0)
>     return FALSE;
> 
> @@ -2075,6 +2067,25 @@ bfd_mach_o_build_seg_command (const char *segment,
>     }
> 
>   seg->filesize = mdata->filelen - seg->fileoff;
> +  seg->filesize = FILE_ALIGN(seg->filesize, 2);
> +
> +  /* Allocate relocation room.  */
> +  mdata->filelen = FILE_ALIGN(mdata->filelen, 2);
> +
> +  for (i = 0; i < mdata->nsects; ++i)
> +    {
> +      bfd_mach_o_section *ms = mdata->sections[i];
> +      asection *sec = ms->bfdsection;
> +
> +      if ((ms->nreloc = sec->reloc_count) == 0)
> +        {
> +	  ms->reloff = 0;
> +	  continue;
> +        }
> +      sec->rel_filepos = mdata->filelen;
> +      ms->reloff = sec->rel_filepos;
> +      mdata->filelen += sec->reloc_count * BFD_MACH_O_RELENT_SIZE;
> +    }
> 
>   return TRUE;
> }
> 

  reply	other threads:[~2012-01-13  8:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12 21:01 Iain Sandoe
2012-01-13  8:18 ` Tristan Gingold [this message]
2012-01-13 12:25   ` Iain Sandoe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2C1FAEDC-3975-4147-9E10-7D513AB0F590@adacore.com \
    --to=gingold@adacore.com \
    --cc=binutils@sourceware.org \
    --cc=developer@sandoe-acoustics.co.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).