From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28106 invoked by alias); 12 Jan 2012 21:01:41 -0000 Received: (qmail 28093 invoked by uid 22791); 12 Jan 2012 21:01:39 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from c2bthomr10.btconnect.com (HELO mail.btconnect.com) (213.123.20.128) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 12 Jan 2012 21:01:25 +0000 Received: from host81-138-1-83.in-addr.btopenworld.com (EHLO thor.office) ([81.138.1.83]) by c2bthomr10.btconnect.com with ESMTP id FWU40464; Thu, 12 Jan 2012 21:01:23 +0000 (GMT) Message-Id: <593B950F-2874-450B-94EA-AF8854154BF1@sandoe-acoustics.co.uk> From: Iain Sandoe To: binutils Development Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: [Patch mach-o/bfd] Order relocs after the section data. Date: Thu, 12 Jan 2012 21:01:00 -0000 Cc: Tristan Gingold X-Mirapoint-IP-Reputation: reputation=Fair-1, source=Queried, refid=tid=0001.0A0B0303.4F0F4A22.0083, actions=tag X-Junkmail-Premium-Raw: score=7/50, refid=2.7.2:2012.1.11.215414:17:7.586, ip=81.138.1.83, rules=__HAS_MSGID, __SANE_MSGID, __MSGID_APPLEMAIL, __TO_MALFORMED_2, __CT, __CT_TEXT_PLAIN, __CTE, __MIME_VERSION, __MIME_VERSION_APPLEMAIL, __HAS_X_MAILER, __X_MAILER_APPLEMAIL, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, __USER_AGENT_APPLEMAIL, RDNS_SUSP, BODY_SIZE_7000_LESS, NO_URI_FOUND X-Junkmail-Signature-Raw: score=unknown, refid=str=0001.0A0B0208.4F0F4A23.00B2,ss=1,re=0.000,fgs=0, ip=0.0.0.0, so=2011-07-25 19:15:43, dmn=2011-05-27 18:58:46, mode=multiengine 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/msg00170.txt.bz2 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? 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; }