Android is all-PIC/PIE.

Clean up the x86/x86_64 assembler. The motivator (other than reducing
confusion) was that asm.h incorrectly checked PIC rather than __PIC__.

Bug: 16823325

(cherry picked from commit 6b6364a7fc)

Change-Id: I89ca57fa0eb34a36de6cb11ea85f71054fce709d
This commit is contained in:
Elliott Hughes 2014-08-07 10:51:32 -07:00
parent 3e7b8e2a8b
commit 43227c0b40
7 changed files with 2 additions and 50 deletions

View File

@ -26,6 +26,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <sys/cdefs.h>
/* /*
__stack_chk_fail routine is runtime part of stack protector compiler __stack_chk_fail routine is runtime part of stack protector compiler
@ -48,13 +49,9 @@
*/ */
#ifdef __i386__ #ifdef __i386__
#ifdef __PIC__
extern void __stack_chk_fail(); extern void __stack_chk_fail();
__attribute__ ((visibility ("hidden"))) __LIBC_HIDDEN__ void __stack_chk_fail_local() {
void __stack_chk_fail_local()
{
__stack_chk_fail(); __stack_chk_fail();
} }
#endif #endif
#endif

View File

@ -46,11 +46,7 @@
ENTRY(setjmp) ENTRY(setjmp)
PIC_PROLOGUE PIC_PROLOGUE
pushl $0 pushl $0
#ifdef PIC
call PIC_PLT(sigblock) call PIC_PLT(sigblock)
#else
call sigblock
#endif
addl $4,%esp addl $4,%esp
PIC_EPILOGUE PIC_EPILOGUE
@ -71,11 +67,7 @@ ENTRY(longjmp)
movl 4(%esp),%edx movl 4(%esp),%edx
PIC_PROLOGUE PIC_PROLOGUE
pushl 24(%edx) pushl 24(%edx)
#ifdef PIC
call PIC_PLT(sigsetmask) call PIC_PLT(sigsetmask)
#else
call sigsetmask
#endif
addl $4,%esp addl $4,%esp
PIC_EPILOGUE PIC_EPILOGUE

View File

@ -42,11 +42,7 @@ ENTRY(sigsetjmp)
PIC_PROLOGUE PIC_PROLOGUE
pushl $0 pushl $0
#ifdef PIC
call PIC_PLT(sigblock) call PIC_PLT(sigblock)
#else
call sigblock
#endif
addl $4,%esp addl $4,%esp
PIC_EPILOGUE PIC_EPILOGUE
@ -70,11 +66,7 @@ ENTRY(siglongjmp)
PIC_PROLOGUE PIC_PROLOGUE
pushl 24(%edx) pushl 24(%edx)
#ifdef PIC
call PIC_PLT(sigsetmask) call PIC_PLT(sigsetmask)
#else
call sigsetmask
#endif
addl $4,%esp addl $4,%esp
PIC_EPILOGUE PIC_EPILOGUE

View File

@ -37,7 +37,6 @@
#ifndef _I386_ASM_H_ #ifndef _I386_ASM_H_
#define _I386_ASM_H_ #define _I386_ASM_H_
#ifdef PIC
#define PIC_PROLOGUE \ #define PIC_PROLOGUE \
pushl %ebx; \ pushl %ebx; \
call 1f; \ call 1f; \
@ -49,13 +48,6 @@
#define PIC_PLT(x) x@PLT #define PIC_PLT(x) x@PLT
#define PIC_GOT(x) x@GOT(%ebx) #define PIC_GOT(x) x@GOT(%ebx)
#define PIC_GOTOFF(x) x@GOTOFF(%ebx) #define PIC_GOTOFF(x) x@GOTOFF(%ebx)
#else
#define PIC_PROLOGUE
#define PIC_EPILOGUE
#define PIC_PLT(x) x
#define PIC_GOT(x) x
#define PIC_GOTOFF(x) x
#endif
/* let kernels and others override entrypoint alignment */ /* let kernels and others override entrypoint alignment */
#if !defined(_ALIGN_TEXT) && !defined(_KERNEL) #if !defined(_ALIGN_TEXT) && !defined(_KERNEL)

View File

@ -52,11 +52,7 @@
ENTRY(setjmp) ENTRY(setjmp)
pushq %rdi pushq %rdi
xorq %rdi,%rdi xorq %rdi,%rdi
#ifdef __PIC__
call PIC_PLT(sigblock) call PIC_PLT(sigblock)
#else
call sigblock
#endif
popq %rdi popq %rdi
movq %rax,(_JB_SIGMASK * 8)(%rdi) movq %rax,(_JB_SIGMASK * 8)(%rdi)
@ -80,11 +76,7 @@ ENTRY(longjmp)
movq (_JB_SIGMASK * 8)(%rdi),%rdi movq (_JB_SIGMASK * 8)(%rdi),%rdi
pushq %r8 pushq %r8
#ifdef __PIC__
call PIC_PLT(sigsetmask) call PIC_PLT(sigsetmask)
#else
call sigsetmask
#endif
popq %r8 popq %r8
movq (_JB_RBX * 8)(%r12),%rbx movq (_JB_RBX * 8)(%r12),%rbx
movq (_JB_RBP * 8)(%r12),%rbp movq (_JB_RBP * 8)(%r12),%rbp

View File

@ -57,11 +57,7 @@ ENTRY(sigsetjmp)
pushq %rdi pushq %rdi
xorq %rdi,%rdi xorq %rdi,%rdi
#ifdef __PIC__
call PIC_PLT(sigblock) call PIC_PLT(sigblock)
#else
call sigblock
#endif
popq %rdi popq %rdi
movq %rax,(_JB_SIGMASK * 8)(%rdi) movq %rax,(_JB_SIGMASK * 8)(%rdi)
@ -86,11 +82,7 @@ ENTRY(siglongjmp)
jz 2f jz 2f
movq (_JB_SIGMASK * 8)(%rdi),%rdi movq (_JB_SIGMASK * 8)(%rdi),%rdi
#ifdef __PIC__
call PIC_PLT(sigsetmask) call PIC_PLT(sigsetmask)
#else
call sigsetmask
#endif
2: popq %rax 2: popq %rax
movq (_JB_RBX * 8)(%r12),%rbx movq (_JB_RBX * 8)(%r12),%rbx
movq (_JB_RBP * 8)(%r12),%rbp movq (_JB_RBP * 8)(%r12),%rbp

View File

@ -37,13 +37,8 @@
#ifndef _AMD64_ASM_H_ #ifndef _AMD64_ASM_H_
#define _AMD64_ASM_H_ #define _AMD64_ASM_H_
#ifdef __PIC__
#define PIC_PLT(x) x@PLT #define PIC_PLT(x) x@PLT
#define PIC_GOT(x) x@GOTPCREL(%rip) #define PIC_GOT(x) x@GOTPCREL(%rip)
#else
#define PIC_PLT(x) x
#define PIC_GOT(x) x
#endif
/* let kernels and others override entrypoint alignment */ /* let kernels and others override entrypoint alignment */
#ifndef _ALIGN_TEXT #ifndef _ALIGN_TEXT