[X86] Test for MACH-O before HAVE_AS_GOTOFF_IN_DATA

Message ID BC060955-537C-4169-94BE-C50A81CDC95E@sandoe.co.uk
State New
Headers show
Series
  • [X86] Test for MACH-O before HAVE_AS_GOTOFF_IN_DATA
Related show

Commit Message

Iain Sandoe Aug. 18, 2018, 12:40 p.m.
Hi,

If we use an assembler which supports HAVE_AS_GOTOFF_IN_DATA,
(e.g. a modern GAS) on Darwin, we produce wrong code because the
gotoff-in-data test is conducted before the mach-o case.

This should be a no-op on non-Darwin targets, since the Darwin test is guarded
on #ifdef TARGET_MACHO.

Bootstrapped on x86_64-linux-gnu (with 32 multilib) and on x86_64-apple-darwin10 and 16.

OK for trunk?
Iain

gcc/

	* config/i386/i386.c (ix86_output_addr_diff_elt): Move the MACH-O
	specific test before the one for HAVE_AS_GOTOFF_IN_DATA.


---
 gcc/config/i386/i386.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

Richard Biener Aug. 18, 2018, 3:02 p.m. | #1
On August 18, 2018 2:40:01 PM GMT+02:00, Iain Sandoe <iain@sandoe.co.uk> wrote:
>Hi,

>

>If we use an assembler which supports HAVE_AS_GOTOFF_IN_DATA,

>(e.g. a modern GAS) on Darwin, we produce wrong code because the

>gotoff-in-data test is conducted before the mach-o case.

>

>This should be a no-op on non-Darwin targets, since the Darwin test is

>guarded

>on #ifdef TARGET_MACHO.

>

>Bootstrapped on x86_64-linux-gnu (with 32 multilib) and on

>x86_64-apple-darwin10 and 16.

>

>OK for trunk?


OK. 

Richard. 

>Iain

>

>gcc/

>

>	* config/i386/i386.c (ix86_output_addr_diff_elt): Move the MACH-O

>	specific test before the one for HAVE_AS_GOTOFF_IN_DATA.

>

>

>---

> gcc/config/i386/i386.c | 4 ++--

> 1 file changed, 2 insertions(+), 2 deletions(-)

>

>diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c

>index 3548de2169..9c8a1f0ee9 100644

>--- a/gcc/config/i386/i386.c

>+++ b/gcc/config/i386/i386.c

>@@ -19768,8 +19768,6 @@ ix86_output_addr_diff_elt (FILE *file, int

>value, int rel)

>   if (TARGET_64BIT || TARGET_VXWORKS_RTP)

>     fprintf (file, "%s%s%d-%s%d\n",

> 	     directive, LPREFIX, value, LPREFIX, rel);

>-  else if (HAVE_AS_GOTOFF_IN_DATA)

>-    fprintf (file, ASM_LONG "%s%d@GOTOFF\n", LPREFIX, value);

> #if TARGET_MACHO

>   else if (TARGET_MACHO)

>     {

>@@ -19778,6 +19776,8 @@ ix86_output_addr_diff_elt (FILE *file, int

>value, int rel)

>       putc ('\n', file);

>     }

> #endif

>+  else if (HAVE_AS_GOTOFF_IN_DATA)

>+    fprintf (file, ASM_LONG "%s%d@GOTOFF\n", LPREFIX, value);

>   else

>     asm_fprintf (file, ASM_LONG "%U%s+[.-%s%d]\n",

> 		 GOT_SYMBOL_NAME, LPREFIX, value);

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 3548de2169..9c8a1f0ee9 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -19768,8 +19768,6 @@  ix86_output_addr_diff_elt (FILE *file, int value, int rel)
   if (TARGET_64BIT || TARGET_VXWORKS_RTP)
     fprintf (file, "%s%s%d-%s%d\n",
 	     directive, LPREFIX, value, LPREFIX, rel);
-  else if (HAVE_AS_GOTOFF_IN_DATA)
-    fprintf (file, ASM_LONG "%s%d@GOTOFF\n", LPREFIX, value);
 #if TARGET_MACHO
   else if (TARGET_MACHO)
     {
@@ -19778,6 +19776,8 @@  ix86_output_addr_diff_elt (FILE *file, int value, int rel)
       putc ('\n', file);
     }
 #endif
+  else if (HAVE_AS_GOTOFF_IN_DATA)
+    fprintf (file, ASM_LONG "%s%d@GOTOFF\n", LPREFIX, value);
   else
     asm_fprintf (file, ASM_LONG "%U%s+[.-%s%d]\n",
 		 GOT_SYMBOL_NAME, LPREFIX, value);