Clean up __stack_chk_fail_local slightly.

Motivated by the fact that bazel doesn't like #include "../", but this
feels like it could use a deeper clean.

In fact, even after this change, I think we should remove this entirely,
since as far as I can tell Clang never implemented this GCC workaround
for 32-bit x86's awful PIC code.

Test: treehugger
Change-Id: I72715ee46f873f42d5707712aebe246ef78fcde1
diff --git a/libc/arch-x86/bionic/__stack_chk_fail_local.h b/libc/arch-common/bionic/__stack_chk_fail_local.h
similarity index 62%
rename from libc/arch-x86/bionic/__stack_chk_fail_local.h
rename to libc/arch-common/bionic/__stack_chk_fail_local.h
index 0b0fd7f..99e2f92 100644
--- a/libc/arch-x86/bionic/__stack_chk_fail_local.h
+++ b/libc/arch-common/bionic/__stack_chk_fail_local.h
@@ -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
diff --git a/libc/arch-common/bionic/crtbegin.c b/libc/arch-common/bionic/crtbegin.c
index f2b6638..3e5bb90 100644
--- a/libc/arch-common/bionic/crtbegin.c
+++ b/libc/arch-common/bionic/crtbegin.c
@@ -87,8 +87,6 @@
 #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
diff --git a/libc/arch-common/bionic/crtbegin_so.c b/libc/arch-common/bionic/crtbegin_so.c
index cf369cc..7b4057b 100644
--- a/libc/arch-common/bionic/crtbegin_so.c
+++ b/libc/arch-common/bionic/crtbegin_so.c
@@ -72,7 +72,5 @@
 # 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