From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21395 invoked by alias); 13 Jan 2012 08:18:24 -0000 Received: (qmail 21383 invoked by uid 22791); 13 Jan 2012 08:18:22 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 13 Jan 2012 08:18:09 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 43B69CB2D1F; Fri, 13 Jan 2012 09:18:09 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U74sC2woKf5h; Fri, 13 Jan 2012 09:18:09 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 30C7FCB2D1B; Fri, 13 Jan 2012 09:18:09 +0100 (CET) Subject: Re: [Patch mach-o/bfd] Order relocs after the section data. Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Tristan Gingold In-Reply-To: <593B950F-2874-450B-94EA-AF8854154BF1@sandoe-acoustics.co.uk> Date: Fri, 13 Jan 2012 08:18:00 -0000 Cc: binutils Development Content-Transfer-Encoding: quoted-printable Message-Id: <2C1FAEDC-3975-4147-9E10-7D513AB0F590@adacore.com> References: <593B950F-2874-450B-94EA-AF8854154BF1@sandoe-acoustics.co.uk> To: Iain Sandoe X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2012-01/txt/msg00172.txt.bz2 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. >=20 > The main purpose is that it makes it easier to compare the output of the = native 'as' with GAS. >=20 > I suppose there's a minor 'do what ld expects' content, but one would hop= e that is largely unimportant... >=20 > OK? Ok. Thanks, Tristan. > Iain >=20 > bfd: >=20 > * 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. >=20 >=20 > bfd/mach-o.c | 27 +++++++++++++++++++-------- > 1 files changed, 19 insertions(+), 8 deletions(-) >=20 > 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, a= relent **rels, > static bfd_boolean > bfd_mach_o_write_relocs (bfd *abfd, bfd_mach_o_section *section) > { > - bfd_mach_o_data_struct *mdata =3D 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_sec= tion *section) > if (bed->_bfd_mach_o_swap_reloc_out =3D=3D NULL) > return TRUE; >=20 > - /* Allocate relocation room. */ > - mdata->filelen =3D FILE_ALIGN(mdata->filelen, 2); > - section->nreloc =3D sec->reloc_count; > - sec->rel_filepos =3D mdata->filelen; > - section->reloff =3D sec->rel_filepos; > - mdata->filelen +=3D sec->reloc_count * BFD_MACH_O_RELENT_SIZE; > - > if (bfd_seek (abfd, section->reloff, SEEK_SET) !=3D 0) > return FALSE; >=20 > @@ -2075,6 +2067,25 @@ bfd_mach_o_build_seg_command (const char *segment, > } >=20 > seg->filesize =3D mdata->filelen - seg->fileoff; > + seg->filesize =3D FILE_ALIGN(seg->filesize, 2); > + > + /* Allocate relocation room. */ > + mdata->filelen =3D FILE_ALIGN(mdata->filelen, 2); > + > + for (i =3D 0; i < mdata->nsects; ++i) > + { > + bfd_mach_o_section *ms =3D mdata->sections[i]; > + asection *sec =3D ms->bfdsection; > + > + if ((ms->nreloc =3D sec->reloc_count) =3D=3D 0) > + { > + ms->reloff =3D 0; > + continue; > + } > + sec->rel_filepos =3D mdata->filelen; > + ms->reloff =3D sec->rel_filepos; > + mdata->filelen +=3D sec->reloc_count * BFD_MACH_O_RELENT_SIZE; > + } >=20 > return TRUE; > } >=20