From ece719c7f6b6ec43062e99a836418d18675c5797 Mon Sep 17 00:00:00 2001 From: Andrew Hsieh Date: Tue, 26 May 2015 12:47:21 +0800 Subject: [PATCH] Fix end pointer size/alignment of crtend_* for mips64 and x86_64 Change-Id: I16fec92826cb42a2f68e2b910b8a67301d3eae28 --- ndk/platforms/android-21/arch-mips/libr2 | 1 + ndk/platforms/android-21/arch-mips/libr6 | 1 + .../arch-mips64/src/asm_multiarch.h | 36 +++++++++++++++++++ .../arch-mips64/src/crtend_android.S | 17 +++++---- .../android-21/arch-mips64/src/crtend_so.S | 8 +++-- .../android-9/arch-x86/src/asm_multiarch.h | 36 +++++++++++++++++++ ndk/platforms/android-9/arch-x86/src/crtend.S | 11 ++++-- .../android-9/arch-x86/src/crtend_so.S | 12 ++++--- 8 files changed, 107 insertions(+), 15 deletions(-) create mode 120000 ndk/platforms/android-21/arch-mips/libr2 create mode 120000 ndk/platforms/android-21/arch-mips/libr6 create mode 100644 ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h create mode 100644 ndk/platforms/android-9/arch-x86/src/asm_multiarch.h diff --git a/ndk/platforms/android-21/arch-mips/libr2 b/ndk/platforms/android-21/arch-mips/libr2 new file mode 120000 index 000000000..7951405f8 --- /dev/null +++ b/ndk/platforms/android-21/arch-mips/libr2 @@ -0,0 +1 @@ +lib \ No newline at end of file diff --git a/ndk/platforms/android-21/arch-mips/libr6 b/ndk/platforms/android-21/arch-mips/libr6 new file mode 120000 index 000000000..22de3c971 --- /dev/null +++ b/ndk/platforms/android-21/arch-mips/libr6 @@ -0,0 +1 @@ +../arch-mips64/libr6 \ No newline at end of file diff --git a/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h b/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h new file mode 100644 index 000000000..91cb8af4b --- /dev/null +++ b/ndk/platforms/android-21/arch-mips64/src/asm_multiarch.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef __LP64__ +# define ASM_PTR_SIZE(x) .quad x +# define ASM_ALIGN_TO_PTR_SIZE .balign 8 +#else +# define ASM_PTR_SIZE(x) .long x +# define ASM_ALIGN_TO_PTR_SIZE .balign 4 +#endif + diff --git a/ndk/platforms/android-21/arch-mips64/src/crtend_android.S b/ndk/platforms/android-21/arch-mips64/src/crtend_android.S index 8a3cc6c85..c7bab47f3 100644 --- a/ndk/platforms/android-21/arch-mips64/src/crtend_android.S +++ b/ndk/platforms/android-21/arch-mips64/src/crtend_android.S @@ -25,25 +25,30 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ - + +#include "asm_multiarch.h" + .section .preinit_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .init_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .fini_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .ctors, "aw" .type __CTOR_END__, @object __CTOR_END__: - .long 0 + ASM_PTR_SIZE(0) .section .dtors, "aw" .type __DTOR_END__, @object __DTOR_END__: - .long 0 + ASM_PTR_SIZE(0) .section .eh_frame,"a",@progbits .align 4 diff --git a/ndk/platforms/android-21/arch-mips64/src/crtend_so.S b/ndk/platforms/android-21/arch-mips64/src/crtend_so.S index f09c42708..490af3ccc 100644 --- a/ndk/platforms/android-21/arch-mips64/src/crtend_so.S +++ b/ndk/platforms/android-21/arch-mips64/src/crtend_so.S @@ -1,5 +1,9 @@ +#include "asm_multiarch.h" + .section .init_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .fini_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) diff --git a/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h b/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h new file mode 100644 index 000000000..91cb8af4b --- /dev/null +++ b/ndk/platforms/android-9/arch-x86/src/asm_multiarch.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef __LP64__ +# define ASM_PTR_SIZE(x) .quad x +# define ASM_ALIGN_TO_PTR_SIZE .balign 8 +#else +# define ASM_PTR_SIZE(x) .long x +# define ASM_ALIGN_TO_PTR_SIZE .balign 4 +#endif + diff --git a/ndk/platforms/android-9/arch-x86/src/crtend.S b/ndk/platforms/android-9/arch-x86/src/crtend.S index 68447e7db..9796ea024 100644 --- a/ndk/platforms/android-9/arch-x86/src/crtend.S +++ b/ndk/platforms/android-9/arch-x86/src/crtend.S @@ -1,11 +1,16 @@ +#include "asm_multiarch.h" + .section .preinit_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .init_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .fini_array, "aw" - .long 0 + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .eh_frame,"a",@progbits .align 4 diff --git a/ndk/platforms/android-9/arch-x86/src/crtend_so.S b/ndk/platforms/android-9/arch-x86/src/crtend_so.S index 63e58b970..6ef493b94 100644 --- a/ndk/platforms/android-9/arch-x86/src/crtend_so.S +++ b/ndk/platforms/android-9/arch-x86/src/crtend_so.S @@ -1,8 +1,12 @@ -.section .init_array, "aw" - .long 0 +#include "asm_multiarch.h" -.section .fini_array, "aw" - .long 0 + .section .init_array, "aw" + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) + + .section .fini_array, "aw" + ASM_ALIGN_TO_PTR_SIZE + ASM_PTR_SIZE(0) .section .eh_frame,"a",@progbits .align 4