Update X86 Bionic CRT files for unwind/exceptions

Several updates to Bionic crt*.o files to implement Linux/x86
stack unwind/exception handling.
Mark __dso_handle as hidden.
Note: Requires complete rebuild due to CRT changes. Google will
need to regenerate and check-in all the prebuilt x86 CRT object
files and libraries which link to them.

Change-Id: I191ce1afb0dee7bbc28dcd9694e5919226dbd070
Signed-off-by: Bruce J Beare <bruce.j.beare@intel.com>
Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
Author: Lu, Hongjiu <hongjiu.lu@intel.com>
diff --git a/libc/arch-x86/bionic/crtbegin_so.S b/libc/arch-x86/bionic/crtbegin_so.S
index b3a01b5..a789ba0 100644
--- a/libc/arch-x86/bionic/crtbegin_so.S
+++ b/libc/arch-x86/bionic/crtbegin_so.S
@@ -1,16 +1,10 @@
-# This function is to be called when the shared library
-# is unloaded through dlclose()
-_on_dlclose:
-    lea __dso_handle, %eax
-    call __cxa_finalize
-    ret
-
 .section .init_array, "aw"
 .align 4
 .type __INIT_ARRAY__, @object
 .globl __INIT_ARRAY__
 __INIT_ARRAY__:
     .long -1
+    .long frame_dummy
 
 .section .fini_array, "aw"
 .align 4
@@ -18,6 +12,86 @@
 .globl __FINI_ARRAY__
 __FINI_ARRAY__:
     .long -1
-    .long _on_dlclose
+    .long __do_global_dtors_aux
+
+	.section	.eh_frame,"a",@progbits
+	.align 4
+	.type	__EH_FRAME_BEGIN__, @object
+__EH_FRAME_BEGIN__:
+	.text
+	.p2align 4,,15
+	.type	__do_global_dtors_aux, @function
+__do_global_dtors_aux:
+	pushl	%ebp
+	movl	%esp, %ebp
+	pushl	%ebx
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+	subl	$20, %esp
+	cmpb	$0, completed.4454@GOTOFF(%ebx)
+	jne	.L5
+	movl	__dso_handle@GOTOFF(%ebx), %eax
+	movl	%eax, (%esp)
+	call	__cxa_finalize@PLT
+	movl	__deregister_frame_info_bases@GOT(%ebx), %eax
+	testl	%eax, %eax
+	je	.L4
+	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
+	movl	%eax, (%esp)
+	call	__deregister_frame_info_bases@PLT
+.L4:
+	movb	$1, completed.4454@GOTOFF(%ebx)
+.L5:
+	addl	$20, %esp
+	popl	%ebx
+	popl	%ebp
+	ret
+	.text
+	.p2align 4,,15
+	.type	frame_dummy, @function
+frame_dummy:
+	pushl	%ebp
+	movl	%esp, %ebp
+	pushl	%ebx
+	call	__x86.get_pc_thunk.bx
+	addl	$_GLOBAL_OFFSET_TABLE_, %ebx
+	subl	$20, %esp
+	movl	__register_frame_info_bases@GOT(%ebx), %eax
+	testl	%eax, %eax
+	je	.L8
+	leal	object.4469@GOTOFF(%ebx), %eax
+	movl	%eax, 4(%esp)
+	leal	__EH_FRAME_BEGIN__@GOTOFF(%ebx), %eax
+	movl	%ebx, 12(%esp)
+	movl	$0, 8(%esp)
+	movl	%eax, (%esp)
+	call	__register_frame_info_bases@PLT
+.L8:
+	addl	$20, %esp
+	popl	%ebx
+	popl	%ebp
+	ret
+	.local	completed.4454
+	.comm	completed.4454,1,1
+	.local	object.4469
+	.comm	object.4469,24,4
+	.weak	__register_frame_info_bases
+	.weak	__deregister_frame_info_bases
+
+	.section	.text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
+	.globl	__x86.get_pc_thunk.bx
+	.hidden	__x86.get_pc_thunk.bx
+	.type	__x86.get_pc_thunk.bx, @function
+__x86.get_pc_thunk.bx:
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	nop
+	movl	(%esp), %ebx
+	ret
 
 #include "__dso_handle.S"