Merge "Clean up __stack_chk_fail_local slightly."
This commit is contained in:
commit
433293dbc9
3 changed files with 12 additions and 25 deletions
|
@ -28,30 +28,21 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*
|
||||
__stack_chk_fail routine is runtime part of stack protector compiler
|
||||
feature. It's implemented in libc and represents die routine when stack
|
||||
corruption is detected.
|
||||
#if defined(__i386__)
|
||||
|
||||
Calls are generated by compiler and injected into user functions when
|
||||
-fstack-protector* options are used.
|
||||
// __stack_chk_fail() is called when a check emitted by -fstack-protector
|
||||
// fails.
|
||||
//
|
||||
// But because 32-bit x86 PIC code is so awful, for x86 the compiler uses
|
||||
// local calls to __stack_chk_fail_local() instead. Unfortunately that means
|
||||
// that __stack_chk_fail_local() has to be in every executable or library.
|
||||
//
|
||||
// TODO: it seems like only GCC does this, not clang, so this is obsolete?
|
||||
|
||||
__stack_chk_fail_local is wrapper for __stack_chk_fail. Compiler generates
|
||||
wrapper calls instead for PIC code only and only on IA32 for optimization
|
||||
purpose (see gcc/config/i386/i386.c). Wrapper body is always included into
|
||||
executable or library. This is the idea of optimization.
|
||||
|
||||
Glibc is doing this via libc_nonshared.a which is linked automatically
|
||||
everytime with libc.so. In bionic we have to bring it within crtfiles
|
||||
because libc.so is real library and not a link script like libc.so at glibc.
|
||||
|
||||
For x86_64 or non-PIC code compiler always generates __stack_chk_fail calls.
|
||||
*/
|
||||
|
||||
#ifdef __i386__
|
||||
extern void __stack_chk_fail();
|
||||
|
||||
__LIBC_HIDDEN__ void __stack_chk_fail_local() {
|
||||
__stack_chk_fail();
|
||||
}
|
||||
|
||||
#endif
|
|
@ -87,8 +87,6 @@ asm(" .section .tdata,\"awT\",@progbits\n"
|
|||
#endif
|
||||
|
||||
#include "__dso_handle.h"
|
||||
#include "__stack_chk_fail_local.h"
|
||||
#include "atexit.h"
|
||||
#include "pthread_atfork.h"
|
||||
#ifdef __i386__
|
||||
# include "../../arch-x86/bionic/__stack_chk_fail_local.h"
|
||||
#endif
|
||||
|
|
|
@ -72,7 +72,5 @@ static void __on_dlclose_late(void) {
|
|||
# include "__dso_handle_so.h"
|
||||
# include "atexit.h"
|
||||
#endif
|
||||
#include "__stack_chk_fail_local.h"
|
||||
#include "pthread_atfork.h"
|
||||
#ifdef __i386__
|
||||
# include "../../arch-x86/bionic/__stack_chk_fail_local.h"
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue