diff mbox

[libitm] Support Solaris 8 and 9/x86 with Sun as

Message ID yddvcqjud3i.fsf@manam.CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Nov. 16, 2011, 6:38 p.m. UTC
libitm failed to build on Solaris 8 and 9/x86 with the native assembler,
which lacks support for .hidden.  The following patch deals with that by
explicitly using the PIC code sequence, as inspired by
libffi/src/x86/sysv.S.  It allows libitm to build on i386-pc-solaris2.8,
and testsuite results are even better than those using gas, insofar as

PASS: libitm.c++/eh-1.C execution test

now passes while it fails with gas.  The failure with gas may be due to
the fact that 32-bit Solaris/x86 requires datarel encoding in .eh_frame,
while the .cfi* directives generate pcrel encoding instead.

Ok for mainline?

	Rainer


2011-11-14  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* config/generic/asmcfi.h: Fix comment.
	* config/x86/sjlj.S (_ITM_beginTransaction): Provide PIC code
	sequence without .hidden support.
	(GTM_longjmp) [__ELF__]: Only use .hidden if
	HAVE_ATTRIBUTE_VISIBILITY.

Comments

Richard Henderson Nov. 16, 2011, 7:12 p.m. UTC | #1
On 11/16/2011 08:38 AM, Rainer Orth wrote:
> 	* config/generic/asmcfi.h: Fix comment.
> 	* config/x86/sjlj.S (_ITM_beginTransaction): Provide PIC code
> 	sequence without .hidden support.
> 	(GTM_longjmp) [__ELF__]: Only use .hidden if
> 	HAVE_ATTRIBUTE_VISIBILITY.

Nearly ok.

> +	subl	$4, %esp
> +	movl	%ebx, 24(%esp)
> +	call	1f
> +1:	popl	%ebx
> +	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
> +	call	GTM_begin_transaction@PLT
> +	movl	24(%esp), %ebx
> +	addl	$4, %esp

This is overly complicated.  We've saved %ebx at 12(%esp) above.
This should be as simple as

	call	1f
1:	popl	%ebx
	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
	call	GTM_begin_transaction@PLT
	movl	12(%esp), %ebx

It also needs wrapping like

#elif defined(__ELF__)
	...
#else
# error "Unsupported PIC sequence"
#endif

... which will almost certainly immediately fail on Darwin, but
at least not with some reference to @PLT.


r~
Iain Sandoe Nov. 16, 2011, 7:37 p.m. UTC | #2
On 16 Nov 2011, at 19:12, Richard Henderson wrote:

> On 11/16/2011 08:38 AM, Rainer Orth wrote:
>> 	* config/generic/asmcfi.h: Fix comment.
>> 	* config/x86/sjlj.S (_ITM_beginTransaction): Provide PIC code
>> 	sequence without .hidden support.
>> 	(GTM_longjmp) [__ELF__]: Only use .hidden if
>> 	HAVE_ATTRIBUTE_VISIBILITY.
>
> Nearly ok.
>
>> +	subl	$4, %esp
>> +	movl	%ebx, 24(%esp)
>> +	call	1f
>> +1:	popl	%ebx
>> +	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
>> +	call	GTM_begin_transaction@PLT
>> +	movl	24(%esp), %ebx
>> +	addl	$4, %esp
>
> This is overly complicated.  We've saved %ebx at 12(%esp) above.
> This should be as simple as
>
> 	call	1f
> 1:	popl	%ebx
> 	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
> 	call	GTM_begin_transaction@PLT
> 	movl	12(%esp), %ebx
>
> It also needs wrapping like
>
> #elif defined(__ELF__)
> 	...
> #else
> # error "Unsupported PIC sequence"
> #endif
>
> ... which will almost certainly immediately fail on Darwin, but
> at least not with some reference to @PLT.

we have  the equivalent of hidden on Darwin :

         .private_extern

I will try and get back to this .. been busy with other stuff....

at the moment the two things top issues remaining on Darwn are:

1. underscores for the ASM functions.

.. Darwin's asm will not add an underscore to functions .. so we end  
up with unresolved refs to __ITM_beginTransaction/GTM_...

2. providing a section name for .tm_clone_section that is compatible  
with Mach-o section semantics.

I've hacked around this for my tests by making a target macro, but  
maybe you have some other preference.

Iain
diff mbox

Patch

# HG changeset patch
# Parent a4b91d01cafd53f7eb10bf132dea527d85a3e228
Support Solaris 8 and 9/x86 with Sun as

diff --git a/libitm/config/generic/asmcfi.h b/libitm/config/generic/asmcfi.h
--- a/libitm/config/generic/asmcfi.h
+++ b/libitm/config/generic/asmcfi.h
@@ -41,4 +41,4 @@ 
 #define cfi_def_cfa(r,n)
 #define cfi_register(o,n)
 
-#endif /* HAVE_ASM_CFI */
+#endif /* HAVE_AS_CFI_PSEUDO_OP */
diff --git a/libitm/config/x86/sjlj.S b/libitm/config/x86/sjlj.S
--- a/libitm/config/x86/sjlj.S
+++ b/libitm/config/x86/sjlj.S
@@ -60,7 +60,18 @@  _ITM_beginTransaction:
 	movl	%edi, 20(%esp)
 	movl	%ebp, 24(%esp)
 	leal	8(%esp), %edx
+#if defined HAVE_ATTRIBUTE_VISIBILITY || !defined __PIC__
 	call	GTM_begin_transaction
+#else
+	subl	$4, %esp
+	movl	%ebx, 24(%esp)
+	call	1f
+1:	popl	%ebx
+	addl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %ebx
+	call	GTM_begin_transaction@PLT
+	movl	24(%esp), %ebx
+	addl	$4, %esp
+#endif
 	addl	$28, %esp
 	cfi_def_cfa_offset(4)
 	ret
@@ -108,7 +119,9 @@  GTM_longjmp:
 
 #ifdef __ELF__
 	.type	GTM_longjmp, @function
+#ifdef HAVE_ATTRIBUTE_VISIBILITY
 	.hidden	GTM_longjmp
+#endif
 	.size	GTM_longjmp, .-GTM_longjmp
 #endif