* [Patch mach-o/gas] reverse reloc lists
@ 2012-01-13 14:53 Iain Sandoe
2012-01-13 14:57 ` Tristan Gingold
0 siblings, 1 reply; 2+ messages in thread
From: Iain Sandoe @ 2012-01-13 14:53 UTC (permalink / raw)
To: binutils Development; +Cc: Tristan Gingold
[-- Attachment #1: Type: text/plain, Size: 5536 bytes --]
the mach-o ld wants relocs to be listed in reverse order, and the
native 'as' does this.
Here is (Tristan's) code to do this.
To this are added my modifications to the test-suite to deal with
tests that are expecting relocs in normal order.
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.
OK?
Iain
<Tristan>
gas:
* 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.
<Iain>
gas/testsuite:
* 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.
=====
gas/config/obj-macho.c | 17 +++++++++++++++++
gas/config/obj-macho.h | 5 +++++
2 files changed, 22 insertions(+), 0 deletions(-)
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,
(char *) 0);
}
+/* Reverse relocations order to make ld happy. */
+
+void
+obj_mach_o_reorder_section_relocs (asection *sec, arelent **rels,
unsigned int n)
+{
+ unsigned int i;
+ unsigned int max = n / 2;
+
+ for (i = 0; i < max; i++)
+ {
+ arelent *r = rels[i];
+ rels[i] = rels[n - i - 1];
+ rels[n - i - 1] = r;
+ }
+ bfd_set_reloc (stdoutput, sec, rels, n);
+}
+
/* Support stabs for mach-o. */
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);
+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
#define OBJ_PROCESS_STAB(SEG,W,S,T,O,D)
obj_mach_o_process_stab(W,S,T,O,D)
====
diff --git a/gas/testsuite/gas/all/redef2.d b/gas/testsuite/gas/all/
redef2.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*
.*: .*
diff --git a/gas/testsuite/gas/all/redef3.d b/gas/testsuite/gas/all/
redef3.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*
.*: .*
diff --git a/gas/testsuite/gas/all/weakref1.d b/gas/testsuite/gas/all/
weakref1.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*
#...
RELOCATION RECORDS FOR \[(\.text|\$CODE\$)\]:
diff --git a/gas/testsuite/gas/macros/irp.d b/gas/testsuite/gas/macros/
irp.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*
.*: +file format .*
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*
.*: +file format .*
diff --git a/gas/testsuite/gas/macros/rept.d b/gas/testsuite/gas/
macros/rept.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*
.*: +file format .*
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*
.*: +file format .*
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*
.*: +file format .*
[-- Attachment #2: 12011314-rev-relocs-tests.txt --]
[-- Type: text/plain, Size: 8712 bytes --]
gas/testsuite/gas/all/redef2.d | 1 +
gas/testsuite/gas/all/redef3.d | 2 +-
gas/testsuite/gas/all/weakref1.d | 3 +-
gas/testsuite/gas/mach-o/macro-irp.d | 14 ++++++++++
gas/testsuite/gas/mach-o/macro-repeat.d | 44 +++++++++++++++++++++++++++++++
gas/testsuite/gas/mach-o/macro-rept.d | 11 +++++++
gas/testsuite/gas/mach-o/macro-test2.d | 11 +++++++
gas/testsuite/gas/mach-o/macro-vararg.d | 14 ++++++++++
gas/testsuite/gas/mach-o/redef2.d | 17 ++++++++++++
gas/testsuite/gas/mach-o/redef3.d | 17 ++++++++++++
gas/testsuite/gas/macros/irp.d | 2 +
gas/testsuite/gas/macros/repeat.d | 2 +
gas/testsuite/gas/macros/rept.d | 2 +
gas/testsuite/gas/macros/test2.d | 2 +
gas/testsuite/gas/macros/vararg.d | 2 +
15 files changed, 142 insertions(+), 2 deletions(-)
diff --git a/gas/testsuite/gas/all/redef2.d b/gas/testsuite/gas/all/redef2.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*
.*: .*
diff --git a/gas/testsuite/gas/all/redef3.d b/gas/testsuite/gas/all/redef3.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*
.*: .*
diff --git a/gas/testsuite/gas/all/weakref1.d b/gas/testsuite/gas/all/weakref1.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*
#...
RELOCATION RECORDS FOR \[(\.text|\$CODE\$)\]:
diff --git a/gas/testsuite/gas/mach-o/macro-irp.d b/gas/testsuite/gas/mach-o/macro-irp.d
new file mode 100644
index 0000000..c7737fa
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/macro-irp.d
@@ -0,0 +1,14 @@
+#objdump: -r
+#name: macro irp
+#source: ../macros/irp.s
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR .*
+OFFSET[ ]+TYPE[ ]+VALUE.*
+0+14[ ]+[a-zA-Z0-9_]+[ ]+bar3
+0+10[ ]+[a-zA-Z0-9_]+[ ]+bar2
+0+0c[ ]+[a-zA-Z0-9_]+[ ]+bar1
+0+08[ ]+[a-zA-Z0-9_]+[ ]+foo3
+0+04[ ]+[a-zA-Z0-9_]+[ ]+foo2
+0+00[ ]+[a-zA-Z0-9_]+[ ]+foo1
diff --git a/gas/testsuite/gas/mach-o/macro-repeat.d b/gas/testsuite/gas/mach-o/macro-repeat.d
new file mode 100644
index 0000000..db215a4
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/macro-repeat.d
@@ -0,0 +1,44 @@
+#objdump: -r
+#name: nested irp/irpc/rept
+#source: ../macros/repeat.s
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR .*
+OFFSET[ ]+TYPE[ ]+VALUE.*
+0+8c[ ]+[a-zA-Z0-9_]+[ ]+rept_rept
+0+88[ ]+[a-zA-Z0-9_]+[ ]+rept_rept
+0+84[ ]+[a-zA-Z0-9_]+[ ]+rept_rept
+0+80[ ]+[a-zA-Z0-9_]+[ ]+rept_rept
+0+7c[ ]+[a-zA-Z0-9_]+[ ]+rept_irpc_8
+0+78[ ]+[a-zA-Z0-9_]+[ ]+rept_irpc_9
+0+74[ ]+[a-zA-Z0-9_]+[ ]+rept_irpc_8
+0+70[ ]+[a-zA-Z0-9_]+[ ]+rept_irpc_9
+0+6c[ ]+[a-zA-Z0-9_]+[ ]+rept_irp_8
+0+68[ ]+[a-zA-Z0-9_]+[ ]+rept_irp_9
+0+64[ ]+[a-zA-Z0-9_]+[ ]+rept_irp_8
+0+60[ ]+[a-zA-Z0-9_]+[ ]+rept_irp_9
+0+5c[ ]+[a-zA-Z0-9_]+[ ]+irpc_rept_2
+0+58[ ]+[a-zA-Z0-9_]+[ ]+irpc_rept_2
+0+54[ ]+[a-zA-Z0-9_]+[ ]+irpc_rept_1
+0+50[ ]+[a-zA-Z0-9_]+[ ]+irpc_rept_1
+0+4c[ ]+[a-zA-Z0-9_]+[ ]+irpc_irpc_28
+0+48[ ]+[a-zA-Z0-9_]+[ ]+irpc_irpc_29
+0+44[ ]+[a-zA-Z0-9_]+[ ]+irpc_irpc_18
+0+40[ ]+[a-zA-Z0-9_]+[ ]+irpc_irpc_19
+0+3c[ ]+[a-zA-Z0-9_]+[ ]+irpc_irp_28
+0+38[ ]+[a-zA-Z0-9_]+[ ]+irpc_irp_29
+0+34[ ]+[a-zA-Z0-9_]+[ ]+irpc_irp_18
+0+30[ ]+[a-zA-Z0-9_]+[ ]+irpc_irp_19
+0+2c[ ]+[a-zA-Z0-9_]+[ ]+irp_rept_2
+0+28[ ]+[a-zA-Z0-9_]+[ ]+irp_rept_2
+0+24[ ]+[a-zA-Z0-9_]+[ ]+irp_rept_1
+0+20[ ]+[a-zA-Z0-9_]+[ ]+irp_rept_1
+0+1c[ ]+[a-zA-Z0-9_]+[ ]+irp_irpc_28
+0+18[ ]+[a-zA-Z0-9_]+[ ]+irp_irpc_29
+0+14[ ]+[a-zA-Z0-9_]+[ ]+irp_irpc_18
+0+10[ ]+[a-zA-Z0-9_]+[ ]+irp_irpc_19
+0+0c[ ]+[a-zA-Z0-9_]+[ ]+irp_irp_28
+0+08[ ]+[a-zA-Z0-9_]+[ ]+irp_irp_29
+0+04[ ]+[a-zA-Z0-9_]+[ ]+irp_irp_18
+0+00[ ]+[a-zA-Z0-9_]+[ ]+irp_irp_19
diff --git a/gas/testsuite/gas/mach-o/macro-rept.d b/gas/testsuite/gas/mach-o/macro-rept.d
new file mode 100644
index 0000000..7ac212a
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/macro-rept.d
@@ -0,0 +1,11 @@
+#objdump: -r
+#name: macro rept
+#source: ../macros/rept.s
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR .*
+OFFSET[ ]+TYPE[ ]+VALUE.*
+0+08[ ]+[a-zA-Z0-9_]+[ ]+foo1
+0+04[ ]+[a-zA-Z0-9_]+[ ]+foo1
+0+00[ ]+[a-zA-Z0-9_]+[ ]+foo1
diff --git a/gas/testsuite/gas/mach-o/macro-test2.d b/gas/testsuite/gas/mach-o/macro-test2.d
new file mode 100644
index 0000000..30a2b2f
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/macro-test2.d
@@ -0,0 +1,11 @@
+#objdump: -r
+#name: macro test 2
+#source: ../macros/test2.s
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR .*
+OFFSET[ ]+TYPE[ ]+VALUE.*
+0+08[ ]+[a-zA-Z0-9_]+[ ]+foo3
+0+04[ ]+[a-zA-Z0-9_]+[ ]+foo2
+0+00[ ]+[a-zA-Z0-9_]+[ ]+foo1
diff --git a/gas/testsuite/gas/mach-o/macro-vararg.d b/gas/testsuite/gas/mach-o/macro-vararg.d
new file mode 100644
index 0000000..da6c0af
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/macro-vararg.d
@@ -0,0 +1,14 @@
+#objdump: -r
+#name: macro vararg
+#source: ../macros/vararg.s
+
+.*: +file format .*
+
+RELOCATION RECORDS FOR .*
+OFFSET[ ]+TYPE[ ]+VALUE.*
+0+14[ ]+[a-zA-Z0-9_]+[ ]+foo6
+0+10[ ]+[a-zA-Z0-9_]+[ ]+foo5
+0+0c[ ]+[a-zA-Z0-9_]+[ ]+foo4
+0+08[ ]+[a-zA-Z0-9_]+[ ]+foo3
+0+04[ ]+[a-zA-Z0-9_]+[ ]+foo2
+0+00[ ]+[a-zA-Z0-9_]+[ ]+foo1
diff --git a/gas/testsuite/gas/mach-o/redef2.d b/gas/testsuite/gas/mach-o/redef2.d
new file mode 100644
index 0000000..5e76d50
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/redef2.d
@@ -0,0 +1,17 @@
+#objdump: -rs -j .data -j "\$DATA\$"
+#name: .equ redefinitions (2)
+# identical to ../all, we just need to reverse the relocs.
+#source: ../all/redef2.s
+
+.*: .*
+
+RELOCATION RECORDS FOR .*
+.*
+0+10.*(sym|(\.data|\$DATA\$)(\+0x0+10)?)
+0+08.*xtrn
+0+00.*(here|\.data|\$DATA\$)
+#...
+Contents of section (\.data|\$DATA\$):
+ 0000 00000000 11111111 00000000 22222222[ ]+................[ ]*
+ 0010 [01]00000[01]0 .*
+#pass
diff --git a/gas/testsuite/gas/mach-o/redef3.d b/gas/testsuite/gas/mach-o/redef3.d
new file mode 100644
index 0000000..3f61a3f
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/redef3.d
@@ -0,0 +1,17 @@
+#objdump: -rsj .data
+#name: .equ redefinitions (3)
+#identical to ../all/redef, we just need to reverse the relocs.
+#source: ../all/redef3.s
+
+.*: .*
+
+RELOCATION RECORDS FOR .*
+.*
+0+10.*sym
+0+08.*xtrn
+0+00.*(here|\.data)
+#...
+Contents of section \.data:
+ 0000 00000000 11111111 00000000 22222222[ ]+................[ ]*
+ 0010 00000000 .*
+#pass
diff --git a/gas/testsuite/gas/macros/irp.d b/gas/testsuite/gas/macros/irp.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*
.*: +file format .*
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*
.*: +file format .*
diff --git a/gas/testsuite/gas/macros/rept.d b/gas/testsuite/gas/macros/rept.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*
.*: +file format .*
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*
.*: +file format .*
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*
.*: +file format .*
[-- Attachment #3: Type: text/plain, Size: 4 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Patch mach-o/gas] reverse reloc lists
2012-01-13 14:53 [Patch mach-o/gas] reverse reloc lists Iain Sandoe
@ 2012-01-13 14:57 ` Tristan Gingold
0 siblings, 0 replies; 2+ messages in thread
From: Tristan Gingold @ 2012-01-13 14:57 UTC (permalink / raw)
To: Iain Sandoe; +Cc: binutils Development
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.
>
> Here is (Tristan's) code to do this.
>
> To this are added my modifications to the test-suite to deal with tests that are expecting relocs in normal order.
>
> 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.
>
> OK?
Yes.
Tristan.
> Iain
>
> <Tristan>
>
> gas:
>
> * 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.
>
> <Iain>
>
> gas/testsuite:
>
> * 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.
>
> =====
>
> gas/config/obj-macho.c | 17 +++++++++++++++++
> gas/config/obj-macho.h | 5 +++++
> 2 files changed, 22 insertions(+), 0 deletions(-)
>
> 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, (char *) 0);
> }
>
> +/* Reverse relocations order to make ld happy. */
> +
> +void
> +obj_mach_o_reorder_section_relocs (asection *sec, arelent **rels, unsigned int n)
> +{
> + unsigned int i;
> + unsigned int max = n / 2;
> +
> + for (i = 0; i < max; i++)
> + {
> + arelent *r = rels[i];
> + rels[i] = rels[n - i - 1];
> + rels[n - i - 1] = r;
> + }
> + bfd_set_reloc (stdoutput, sec, rels, n);
> +}
> +
> /* Support stabs for mach-o. */
>
> 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);
>
> +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
>
> #define OBJ_PROCESS_STAB(SEG,W,S,T,O,D) obj_mach_o_process_stab(W,S,T,O,D)
>
> ====
>
> diff --git a/gas/testsuite/gas/all/redef2.d b/gas/testsuite/gas/all/redef2.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*
>
> .*: .*
>
> diff --git a/gas/testsuite/gas/all/redef3.d b/gas/testsuite/gas/all/redef3.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*
>
> .*: .*
>
> diff --git a/gas/testsuite/gas/all/weakref1.d b/gas/testsuite/gas/all/weakref1.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*
>
> #...
> RELOCATION RECORDS FOR \[(\.text|\$CODE\$)\]:
> diff --git a/gas/testsuite/gas/macros/irp.d b/gas/testsuite/gas/macros/irp.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*
>
> .*: +file format .*
>
> 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*
>
> .*: +file format .*
>
> diff --git a/gas/testsuite/gas/macros/rept.d b/gas/testsuite/gas/macros/rept.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*
>
> .*: +file format .*
>
> 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*
>
> .*: +file format .*
>
> 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*
>
> .*: +file format .*
>
> <12011314-rev-relocs-tests.txt>
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-13 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13 14:53 [Patch mach-o/gas] reverse reloc lists Iain Sandoe
2012-01-13 14:57 ` Tristan Gingold
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).