From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21002 invoked by alias); 13 Jan 2012 14:57:13 -0000 Received: (qmail 20991 invoked by uid 22791); 13 Jan 2012 14:57:12 -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 14:56:58 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id DB4C1CB340B; Fri, 13 Jan 2012 15:56:57 +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 nObrwjYfhkZy; Fri, 13 Jan 2012 15:56:57 +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 C77EFCB2966; Fri, 13 Jan 2012 15:56:57 +0100 (CET) Subject: Re: [Patch mach-o/gas] reverse reloc lists Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Tristan Gingold In-Reply-To: <4F2E2258-47B9-4F62-BF65-2D19D7C226A2@sandoe-acoustics.co.uk> Date: Fri, 13 Jan 2012 14:57:00 -0000 Cc: binutils Development Content-Transfer-Encoding: quoted-printable Message-Id: References: <4F2E2258-47B9-4F62-BF65-2D19D7C226A2@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/msg00178.txt.bz2 On Jan 13, 2012, at 3:53 PM, Iain Sandoe wrote: > the mach-o ld wants relocs to be listed in reverse order, and the native = 'as' does this. >=20 > Here is (Tristan's) code to do this. >=20 > To this are added my modifications to the test-suite to deal with tests t= hat are expecting relocs in normal order. >=20 > We skip those tests in the normal places and duplicate reversed versions = in gas/mach-o (which also serve as a good check of the reversal process). = New tests attached, modified ones in-line. >=20 > OK? Yes. Tristan. > Iain >=20 > >=20 > gas: >=20 > * config/obj-macho.c (obj_mach_o_reorder_section_relocs): New. > * config/obj-macho.h (SET_SECTION_RELOCS): Define. > (obj_mach_o_reorder_section_relocs): Declare. >=20 > >=20 > gas/testsuite: >=20 > * gas/all/redef2.d: Skip for Darwin. > * gas/all/redef3.d: Likewise. > * gas/all/weakref1.d: Likewise. > * gas/macros/irp.d: Likewise. > * gas/macros/repeat.d: Likewise. > * gas/macros/rept.d: Likewise. > * gas/macros/test2.d: Likewise. > * gas/macros/vararg.d: Likewise. > * gas/mach-o/macro-irp.d: New. > * gas/mach-o/macro-repeat.d: New. > * gas/mach-o/macro-rept.d: New. > * gas/mach-o/macro-test2.d: New. > * gas/mach-o/macro-vararg.d: New. > * gas/mach-o/redef2.d: New. > * gas/mach-o/redef3.d: New. >=20 > =3D=3D=3D=3D=3D >=20 > gas/config/obj-macho.c | 17 +++++++++++++++++ > gas/config/obj-macho.h | 5 +++++ > 2 files changed, 22 insertions(+), 0 deletions(-) >=20 > diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c > index ddf0988..f0cb43e 100644 > --- a/gas/config/obj-macho.c > +++ b/gas/config/obj-macho.c > @@ -1679,6 +1679,23 @@ obj_mach_o_frob_file_after_relocs (void) > bfd_map_over_sections (stdoutput, obj_mach_o_set_indirect_symbols, (cha= r *) 0); > } >=20 > +/* Reverse relocations order to make ld happy. */ > + > +void > +obj_mach_o_reorder_section_relocs (asection *sec, arelent **rels, unsign= ed int n) > +{ > + unsigned int i; > + unsigned int max =3D n / 2; > + > + for (i =3D 0; i < max; i++) > + { > + arelent *r =3D rels[i]; > + rels[i] =3D rels[n - i - 1]; > + rels[n - i - 1] =3D r; > + } > + bfd_set_reloc (stdoutput, sec, rels, n); > +} > + > /* Support stabs for mach-o. */ >=20 > void > diff --git a/gas/config/obj-macho.h b/gas/config/obj-macho.h > index 2fc5cb6..bb8daf9 100644 > --- a/gas/config/obj-macho.h > +++ b/gas/config/obj-macho.h > @@ -68,6 +68,11 @@ void obj_mach_o_post_relax_hook (void); > #define obj_frob_file_after_relocs obj_mach_o_frob_file_after_relocs > extern void obj_mach_o_frob_file_after_relocs (void); >=20 > +void obj_mach_o_reorder_section_relocs (asection *, arelent **, unsigned= int); > + > +#define SET_SECTION_RELOCS(sec, relocs, n) \ > + obj_mach_o_reorder_section_relocs (sec, relocs, n) > + > #define EMIT_SECTION_SYMBOLS 0 >=20 > #define OBJ_PROCESS_STAB(SEG,W,S,T,O,D) obj_mach_o_process_stab(W,S,T,O,D) >=20 > =3D=3D=3D=3D >=20 > diff --git a/gas/testsuite/gas/all/redef2.d b/gas/testsuite/gas/all/redef= 2.d > index 244d33d..c50cd6c 100644 > --- a/gas/testsuite/gas/all/redef2.d > +++ b/gas/testsuite/gas/all/redef2.d > @@ -1,5 +1,6 @@ > #objdump: -rs -j .data -j "\$DATA\$" > #name: .equ redefinitions (2) > +#not-target: *-*-darwin* >=20 > .*: .* >=20 > diff --git a/gas/testsuite/gas/all/redef3.d b/gas/testsuite/gas/all/redef= 3.d > index 566f9c9..a16fac3 100644 > --- a/gas/testsuite/gas/all/redef3.d > +++ b/gas/testsuite/gas/all/redef3.d > @@ -1,6 +1,6 @@ > #objdump: -rsj .data > #name: .equ redefinitions (3) > -#not-target: arc-*-* > +#not-target: arc-*-* *-*darwin* >=20 > .*: .* >=20 > diff --git a/gas/testsuite/gas/all/weakref1.d b/gas/testsuite/gas/all/wea= kref1.d > index ee37d97..b44d1fc 100644 > --- a/gas/testsuite/gas/all/weakref1.d > +++ b/gas/testsuite/gas/all/weakref1.d > @@ -2,8 +2,9 @@ > #name: weakref tests, relocations > # ecoff (OSF/alpha) lacks .weak support > # pdp11 lacks .long > +# darwin (mach-o) reverses the order of relocs. > # the following must be present in all weakref1*.d > -#not-target: alpha*-*-osf* *-*-ecoff pdp11-*-aout > +#not-target: alpha*-*-osf* *-*-ecoff pdp11-*-aout *-*-darwin* >=20 > #... > RELOCATION RECORDS FOR \[(\.text|\$CODE\$)\]: > diff --git a/gas/testsuite/gas/macros/irp.d b/gas/testsuite/gas/macros/ir= p.d > index e6d7bcf..2c07f8e 100644 > --- a/gas/testsuite/gas/macros/irp.d > +++ b/gas/testsuite/gas/macros/irp.d > @@ -1,5 +1,7 @@ > #objdump: -r > #name: macro irp > +#darwin (mach-o) reverses relocs. > +#not-target: *-*-darwin* >=20 > .*: +file format .* >=20 > diff --git a/gas/testsuite/gas/macros/repeat.d b/gas/testsuite/gas/macros= /repeat.d > index 272e441..1e6e422 100644 > --- a/gas/testsuite/gas/macros/repeat.d > +++ b/gas/testsuite/gas/macros/repeat.d > @@ -1,5 +1,7 @@ > #objdump: -r > #name: nested irp/irpc/rept > +# darwin (mach-o) reverse relocs. > +#not-target: *-*-darwin* >=20 > .*: +file format .* >=20 > diff --git a/gas/testsuite/gas/macros/rept.d b/gas/testsuite/gas/macros/r= ept.d > index 0022d5f..df2ed96 100644 > --- a/gas/testsuite/gas/macros/rept.d > +++ b/gas/testsuite/gas/macros/rept.d > @@ -1,5 +1,7 @@ > #objdump: -r > #name: macro rept > +#darwin (mach-o) reverses relocs. > +#not-target: *-*-darwin* >=20 > .*: +file format .* >=20 > diff --git a/gas/testsuite/gas/macros/test2.d b/gas/testsuite/gas/macros/= test2.d > index 9a7d414..e5041cd 100644 > --- a/gas/testsuite/gas/macros/test2.d > +++ b/gas/testsuite/gas/macros/test2.d > @@ -1,5 +1,7 @@ > #objdump: -r > #name: macro test 2 > +# darwin(mach-o) reverses the order of relocs. > +#not-target: *-*-darwin* >=20 > .*: +file format .* >=20 > diff --git a/gas/testsuite/gas/macros/vararg.d b/gas/testsuite/gas/macros= /vararg.d > index 4b943fd..94c1511 100644 > --- a/gas/testsuite/gas/macros/vararg.d > +++ b/gas/testsuite/gas/macros/vararg.d > @@ -1,5 +1,7 @@ > #objdump: -r > #name: macro vararg > +# darwin (mach-o) reverses relocs. > +#not-target: *-*-darwin* >=20 > .*: +file format .* >=20 > <12011314-rev-relocs-tests.txt> >=20 >=20 >=20