public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86
@ 2010-11-26 18:45 Rainer Orth
  2010-11-26 19:15 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Rainer Orth @ 2010-11-26 18:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: java-patches, Anthony Green, Jakub Jelinek

While trying to make the libgcc unwinder use dl_iterate_phdr on Solaris
11, I ran into a gld bug (PR ld/12253) that broke libffi unwind tests
and all libjava execution tests: while Solaris 2/x86 uses
DW_EH_PE_datarel encoding for .eh_frame in 32-bit PIC code,
src/x86/sysv.S uses DW_EH_PE_pcrel.  Due to the above bug, .eh_frame_hdr
isn't sorted correctly with gld before 2.22.  To work around this issue
for older gld versions, I'd like to use the following workaround to
avoid the issue, namely also use datarel encoding on Solaris 2/x86.

Bootstrapped on i386-pc-solaris2.11 with CVS gas and gld (before the
fix) and i386-pc-solaris2.10 with Sun as and ld.  It fixes all the
testsuite regressions with gld and works without issues with Sun ld.

Ok for mainline?

	Rainer


2010-01-18  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* src/x86/sysv.S (.eh_frame) [__PIC__ && __sun__ && __svr4__]: Use
	datarel encoding.
	(.LASFDE1) [__PIC__ && __sun__ && __svr4__]: Use @GOTOFF for FDE
	initial location.
	(.LASFDE2, LASFDE3): Likewise.

diff -r 36d43c8e1be5 libffi/src/x86/sysv.S
--- a/libffi/src/x86/sysv.S	Sat Nov 20 22:10:07 2010 +0100
+++ b/libffi/src/x86/sysv.S	Sat Nov 20 22:10:57 2010 +0100
@@ -354,8 +354,15 @@
 	.byte	0x8	/* CIE RA Column */
 #ifdef __PIC__
 	.byte	0x1	/* .uleb128 0x1; Augmentation size */
+#ifdef __sun__ && __svr4__
+	/* 32-bit Solaris 2/x86 uses datarel encoding for PIC.  GNU ld
+	   doesn't correctly sort .eh_frame_hdr with mixed encodings, so
+	   match this.  */
+	.byte	0x30	/* FDE Encoding (datarel) */
+#else
 	.byte	0x1b	/* FDE Encoding (pcrel sdata4) */
 #endif
+#endif
 	.byte	0xc	/* DW_CFA_def_cfa */
 	.byte	0x4	/* .uleb128 0x4 */
 	.byte	0x4	/* .uleb128 0x4 */
@@ -367,10 +374,14 @@
 	.long	.LEFDE1-.LASFDE1	/* FDE Length */
 .LASFDE1:
 	.long	.LASFDE1-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB1-.	/* FDE initial location */
-#elif defined __PIC__
-	.long	.LFB1@rel
+#ifdef __PIC__
+#if defined __sun__ && defined __svr4__
+	.long	.LFB1@GOTOFF	/* FDE initial location */
+#elif defined HAVE_AS_X86_PCREL
+	.long	.LFB1-.		/* FDE initial location */
+#else
+	.long	.LFB1@rel	/* FDE initial location */
+#endif
 #else
 	.long	.LFB1
 #endif
@@ -394,10 +405,14 @@
 	.long	.LEFDE2-.LASFDE2	/* FDE Length */
 .LASFDE2:
 	.long	.LASFDE2-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB2-.	/* FDE initial location */
-#elif defined __PIC__
-	.long	.LFB2@rel
+#ifdef __PIC__
+#if defined __sun__ && defined __svr4__
+	.long	.LFB2@GOTOFF	/* FDE initial location */
+#elif defined HAVE_AS_X86_PCREL
+	.long	.LFB2-.		/* FDE initial location */
+#else
+	.long	.LFB2@rel	/* FDE initial location */
+#endif
 #else
 	.long	.LFB2
 #endif
@@ -430,10 +445,14 @@
 	.long	.LEFDE3-.LASFDE3	/* FDE Length */
 .LASFDE3:
 	.long	.LASFDE3-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB3-.	/* FDE initial location */
-#elif defined __PIC__
-	.long	.LFB3@rel
+#ifdef __PIC__
+#if defined __sun__ && defined __svr4__
+	.long	.LFB3@GOTOFF	/* FDE initial location */
+#elif defined HAVE_AS_X86_PCREL
+	.long	.LFB3-.		/* FDE initial location */
+#else
+	.long	.LFB3@rel	/* FDE initial location */
+#endif
 #else
 	.long	.LFB3
 #endif


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86
  2010-11-26 18:45 [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86 Rainer Orth
@ 2010-11-26 19:15 ` Richard Henderson
  2010-11-26 19:19   ` Rainer Orth
  2010-11-29 10:23   ` Rainer Orth
  0 siblings, 2 replies; 5+ messages in thread
From: Richard Henderson @ 2010-11-26 19:15 UTC (permalink / raw)
  To: Rainer Orth; +Cc: gcc-patches, java-patches, Anthony Green, Jakub Jelinek

On 11/26/2010 10:45 AM, Rainer Orth wrote:
> 	* src/x86/sysv.S (.eh_frame) [__PIC__ && __sun__ && __svr4__]: Use
> 	datarel encoding.
> 	(.LASFDE1) [__PIC__ && __sun__ && __svr4__]: Use @GOTOFF for FDE
> 	initial location.
> 	(.LASFDE2, LASFDE3): Likewise.

This is getting complex enough that I think we should not 
replicate this logic 4 times.  Would you please pull this
out into a set of macros near the top of the file?  E.g.

#if defined __PIC__
# if defined __sun__ && defined __svr4__
#  define FDE_ENCODING		0x30	/* datarel */
#  define FDE_ENCODE(X)		X@GOTOFF
# else
#  define FDE_ENCODING		0x1b	/* pcrel sdata4 */
#  if defined HAVE_AS_X86_PCREL
#   define FDE_ENCODE(X)	X-.
#  else
#   define FDE_ENCODE(X)	X@rel
#  endif
# endif
#else
# define FDE_ENCODING		0	/* absolute */
# define FDE_ENCODE(X)		X
#endif

And, frankly, for gcc 4.7 we ought to consider requiring a
recent version of binutils and scrap all of this explicit
unwind info in favor of CFI directives.



r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86
  2010-11-26 19:15 ` Richard Henderson
@ 2010-11-26 19:19   ` Rainer Orth
  2010-11-29 10:23   ` Rainer Orth
  1 sibling, 0 replies; 5+ messages in thread
From: Rainer Orth @ 2010-11-26 19:19 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, java-patches, Anthony Green, Jakub Jelinek

Richard Henderson <rth@redhat.com> writes:

> On 11/26/2010 10:45 AM, Rainer Orth wrote:
>> 	* src/x86/sysv.S (.eh_frame) [__PIC__ && __sun__ && __svr4__]: Use
>> 	datarel encoding.
>> 	(.LASFDE1) [__PIC__ && __sun__ && __svr4__]: Use @GOTOFF for FDE
>> 	initial location.
>> 	(.LASFDE2, LASFDE3): Likewise.
>
> This is getting complex enough that I think we should not 
> replicate this logic 4 times.  Would you please pull this
> out into a set of macros near the top of the file?  E.g.
>
> #if defined __PIC__
> # if defined __sun__ && defined __svr4__
> #  define FDE_ENCODING		0x30	/* datarel */
> #  define FDE_ENCODE(X)		X@GOTOFF
> # else
> #  define FDE_ENCODING		0x1b	/* pcrel sdata4 */
> #  if defined HAVE_AS_X86_PCREL
> #   define FDE_ENCODE(X)	X-.
> #  else
> #   define FDE_ENCODE(X)	X@rel
> #  endif
> # endif
> #else
> # define FDE_ENCODING		0	/* absolute */
> # define FDE_ENCODE(X)		X
> #endif

Sure, I'll give this a try.

> And, frankly, for gcc 4.7 we ought to consider requiring a
> recent version of binutils and scrap all of this explicit
> unwind info in favor of CFI directives.

We have to be very careful here: libffi is used by several other
projects and is supposed to be buildable with vendor compilers and
assemblers also.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86
  2010-11-26 19:15 ` Richard Henderson
  2010-11-26 19:19   ` Rainer Orth
@ 2010-11-29 10:23   ` Rainer Orth
  2010-11-29 16:09     ` Anthony Green
  1 sibling, 1 reply; 5+ messages in thread
From: Rainer Orth @ 2010-11-29 10:23 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches, java-patches, Anthony Green, Jakub Jelinek

Richard Henderson <rth@redhat.com> writes:

> This is getting complex enough that I think we should not 
> replicate this logic 4 times.  Would you please pull this
> out into a set of macros near the top of the file?  E.g.
>
> #if defined __PIC__
> # if defined __sun__ && defined __svr4__
> #  define FDE_ENCODING		0x30	/* datarel */
> #  define FDE_ENCODE(X)		X@GOTOFF
> # else
> #  define FDE_ENCODING		0x1b	/* pcrel sdata4 */
> #  if defined HAVE_AS_X86_PCREL
> #   define FDE_ENCODE(X)	X-.
> #  else
> #   define FDE_ENCODE(X)	X@rel
> #  endif
> # endif
> #else
> # define FDE_ENCODING		0	/* absolute */
> # define FDE_ENCODE(X)		X
> #endif

Worked like a charm :-)  Bootstrapped without regressions on
i386-pc-solaris2.11 with both as and gas.

Ok for mainline?

	Rainer


2010-11-27  Richard Henderson  <rth@redhat.com>
	    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	libffi:
	* src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define.
	(.eh_frame): Use FDE_ENCODING.
	(.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE.

diff -r 82d3ec096908 libffi/src/x86/sysv.S
--- a/libffi/src/x86/sysv.S	Sat Nov 27 11:15:48 2010 +0100
+++ b/libffi/src/x86/sysv.S	Sat Nov 27 11:35:38 2010 +0100
@@ -328,6 +328,25 @@
 	.size	ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
 #endif
 
+#if defined __PIC__
+# if defined __sun__ && defined __svr4__
+/* 32-bit Solaris 2/x86 uses datarel encoding for PIC.  GNU ld before 2.22
+   doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this.  */
+#  define FDE_ENCODING		0x30	/* datarel */
+#  define FDE_ENCODE(X)		X@GOTOFF
+# else
+#  define FDE_ENCODING		0x1b	/* pcrel sdata4 */
+#  if defined HAVE_AS_X86_PCREL
+#   define FDE_ENCODE(X)	X-.
+#  else
+#   define FDE_ENCODE(X)	X@rel
+#  endif
+# endif
+#else
+# define FDE_ENCODING		0	/* absolute */
+# define FDE_ENCODE(X)		X
+#endif
+
 	.section	.eh_frame,EH_FRAME_FLAGS,@progbits
 .Lframe1:
 	.long	.LECIE1-.LSCIE1	/* Length of Common Information Entry */
@@ -354,7 +373,7 @@
 	.byte	0x8	/* CIE RA Column */
 #ifdef __PIC__
 	.byte	0x1	/* .uleb128 0x1; Augmentation size */
-	.byte	0x1b	/* FDE Encoding (pcrel sdata4) */
+	.byte	FDE_ENCODING
 #endif
 	.byte	0xc	/* DW_CFA_def_cfa */
 	.byte	0x4	/* .uleb128 0x4 */
@@ -367,14 +386,8 @@
 	.long	.LEFDE1-.LASFDE1	/* FDE Length */
 .LASFDE1:
 	.long	.LASFDE1-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB1-.	/* FDE initial location */
-#elif defined __PIC__
-	.long	.LFB1@rel
-#else
-	.long	.LFB1
-#endif
-	.long	.LFE1-.LFB1	/* FDE address range */
+	.long	FDE_ENCODE(.LFB1)	/* FDE initial location */
+	.long	.LFE1-.LFB1		/* FDE address range */
 #ifdef __PIC__
 	.byte	0x0	/* .uleb128 0x0; Augmentation size */
 #endif
@@ -394,14 +407,8 @@
 	.long	.LEFDE2-.LASFDE2	/* FDE Length */
 .LASFDE2:
 	.long	.LASFDE2-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB2-.	/* FDE initial location */
-#elif defined __PIC__
-	.long	.LFB2@rel
-#else
-	.long	.LFB2
-#endif
-	.long	.LFE2-.LFB2	/* FDE address range */
+	.long	FDE_ENCODE(.LFB2)	/* FDE initial location */
+	.long	.LFE2-.LFB2		/* FDE address range */
 #ifdef __PIC__
 	.byte	0x0	/* .uleb128 0x0; Augmentation size */
 #endif
@@ -430,14 +437,8 @@
 	.long	.LEFDE3-.LASFDE3	/* FDE Length */
 .LASFDE3:
 	.long	.LASFDE3-.Lframe1	/* FDE CIE offset */
-#if defined __PIC__ && defined HAVE_AS_X86_PCREL
-	.long	.LFB3-.	/* FDE initial location */
-#elif defined __PIC__
-	.long	.LFB3@rel
-#else
-	.long	.LFB3
-#endif
-	.long	.LFE3-.LFB3	/* FDE address range */
+	.long	FDE_ENCODE(.LFB3)	/* FDE initial location */
+	.long	.LFE3-.LFB3		/* FDE address range */
 #ifdef __PIC__
 	.byte	0x0	/* .uleb128 0x0; Augmentation size */
 #endif

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86
  2010-11-29 10:23   ` Rainer Orth
@ 2010-11-29 16:09     ` Anthony Green
  0 siblings, 0 replies; 5+ messages in thread
From: Anthony Green @ 2010-11-29 16:09 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Richard Henderson, gcc-patches, java-patches, Jakub Jelinek

Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Richard Henderson <rth@redhat.com> writes:
>
>> This is getting complex enough that I think we should not 
>> replicate this logic 4 times.  Would you please pull this
>> out into a set of macros near the top of the file?  E.g.
>>
>> #if defined __PIC__
>> # if defined __sun__ && defined __svr4__
>> #  define FDE_ENCODING		0x30	/* datarel */
>> #  define FDE_ENCODE(X)		X@GOTOFF
>> # else
>> #  define FDE_ENCODING		0x1b	/* pcrel sdata4 */
>> #  if defined HAVE_AS_X86_PCREL
>> #   define FDE_ENCODE(X)	X-.
>> #  else
>> #   define FDE_ENCODE(X)	X@rel
>> #  endif
>> # endif
>> #else
>> # define FDE_ENCODING		0	/* absolute */
>> # define FDE_ENCODE(X)		X
>> #endif
>
> Worked like a charm :-)  Bootstrapped without regressions on
> i386-pc-solaris2.11 with both as and gas.
>
> Ok for mainline?


Thanks Rainer and Richard.  Please go ahead and commit this to the GCC tree.

AG


>
> 	Rainer
>
>
> 2010-11-27  Richard Henderson  <rth@redhat.com>
> 	    Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
> 	libffi:
> 	* src/x86/sysv.S (FDE_ENCODING, FDE_ENCODE): Define.
> 	(.eh_frame): Use FDE_ENCODING.
> 	(.LASFDE1, .LASFDE2, LASFDE3): Simplify with FDE_ENCODE.
>
> diff -r 82d3ec096908 libffi/src/x86/sysv.S
> --- a/libffi/src/x86/sysv.S	Sat Nov 27 11:15:48 2010 +0100
> +++ b/libffi/src/x86/sysv.S	Sat Nov 27 11:35:38 2010 +0100
> @@ -328,6 +328,25 @@
>  	.size	ffi_closure_raw_SYSV, .-ffi_closure_raw_SYSV
>  #endif
>  
> +#if defined __PIC__
> +# if defined __sun__ && defined __svr4__
> +/* 32-bit Solaris 2/x86 uses datarel encoding for PIC.  GNU ld before 2.22
> +   doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this.  */
> +#  define FDE_ENCODING		0x30	/* datarel */
> +#  define FDE_ENCODE(X)		X@GOTOFF
> +# else
> +#  define FDE_ENCODING		0x1b	/* pcrel sdata4 */
> +#  if defined HAVE_AS_X86_PCREL
> +#   define FDE_ENCODE(X)	X-.
> +#  else
> +#   define FDE_ENCODE(X)	X@rel
> +#  endif
> +# endif
> +#else
> +# define FDE_ENCODING		0	/* absolute */
> +# define FDE_ENCODE(X)		X
> +#endif
> +
>  	.section	.eh_frame,EH_FRAME_FLAGS,@progbits
>  .Lframe1:
>  	.long	.LECIE1-.LSCIE1	/* Length of Common Information Entry */
> @@ -354,7 +373,7 @@
>  	.byte	0x8	/* CIE RA Column */
>  #ifdef __PIC__
>  	.byte	0x1	/* .uleb128 0x1; Augmentation size */
> -	.byte	0x1b	/* FDE Encoding (pcrel sdata4) */
> +	.byte	FDE_ENCODING
>  #endif
>  	.byte	0xc	/* DW_CFA_def_cfa */
>  	.byte	0x4	/* .uleb128 0x4 */
> @@ -367,14 +386,8 @@
>  	.long	.LEFDE1-.LASFDE1	/* FDE Length */
>  .LASFDE1:
>  	.long	.LASFDE1-.Lframe1	/* FDE CIE offset */
> -#if defined __PIC__ && defined HAVE_AS_X86_PCREL
> -	.long	.LFB1-.	/* FDE initial location */
> -#elif defined __PIC__
> -	.long	.LFB1@rel
> -#else
> -	.long	.LFB1
> -#endif
> -	.long	.LFE1-.LFB1	/* FDE address range */
> +	.long	FDE_ENCODE(.LFB1)	/* FDE initial location */
> +	.long	.LFE1-.LFB1		/* FDE address range */
>  #ifdef __PIC__
>  	.byte	0x0	/* .uleb128 0x0; Augmentation size */
>  #endif
> @@ -394,14 +407,8 @@
>  	.long	.LEFDE2-.LASFDE2	/* FDE Length */
>  .LASFDE2:
>  	.long	.LASFDE2-.Lframe1	/* FDE CIE offset */
> -#if defined __PIC__ && defined HAVE_AS_X86_PCREL
> -	.long	.LFB2-.	/* FDE initial location */
> -#elif defined __PIC__
> -	.long	.LFB2@rel
> -#else
> -	.long	.LFB2
> -#endif
> -	.long	.LFE2-.LFB2	/* FDE address range */
> +	.long	FDE_ENCODE(.LFB2)	/* FDE initial location */
> +	.long	.LFE2-.LFB2		/* FDE address range */
>  #ifdef __PIC__
>  	.byte	0x0	/* .uleb128 0x0; Augmentation size */
>  #endif
> @@ -430,14 +437,8 @@
>  	.long	.LEFDE3-.LASFDE3	/* FDE Length */
>  .LASFDE3:
>  	.long	.LASFDE3-.Lframe1	/* FDE CIE offset */
> -#if defined __PIC__ && defined HAVE_AS_X86_PCREL
> -	.long	.LFB3-.	/* FDE initial location */
> -#elif defined __PIC__
> -	.long	.LFB3@rel
> -#else
> -	.long	.LFB3
> -#endif
> -	.long	.LFE3-.LFB3	/* FDE address range */
> +	.long	FDE_ENCODE(.LFB3)	/* FDE initial location */
> +	.long	.LFE3-.LFB3		/* FDE address range */
>  #ifdef __PIC__
>  	.byte	0x0	/* .uleb128 0x0; Augmentation size */
>  #endif

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-11-29 16:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-26 18:45 [libffi] Use datarel encoding in libffi .eh_frame on Solaris 2/x86 Rainer Orth
2010-11-26 19:15 ` Richard Henderson
2010-11-26 19:19   ` Rainer Orth
2010-11-29 10:23   ` Rainer Orth
2010-11-29 16:09     ` Anthony Green

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).