summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
authorSterling Augustine <saugustine@google.com>2019-12-27 11:52:12 -0800
committerSterling Augustine <saugustine@google.com>2019-12-27 13:02:11 -0800
commit1d891a32cf433e205b5d30697beb265dc0e1f248 (patch)
treead052506fac41b529ef71ace151edf1154e357ec /compiler-rt/lib
parente8c5600de8b43b2ac22a5aab6ce51e3810f8a4a6 (diff)
downloadbcm5719-llvm-1d891a32cf433e205b5d30697beb265dc0e1f248.tar.gz
bcm5719-llvm-1d891a32cf433e205b5d30697beb265dc0e1f248.zip
Support powerpc and sparc when building without init_array.
Summary: Support powerpc and sparc when building without init_array. Reviewers: rdhindsa, gribozavr Subscribers: jyknight, nemanjai, fedor.sergeev, jsji, shchenz, steven.zhang, #sanitizers, llvm-commits Tags: #sanitizers, #llvm Differential Revision: https://reviews.llvm.org/D71944
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/crt/crtbegin.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/compiler-rt/lib/crt/crtbegin.c b/compiler-rt/lib/crt/crtbegin.c
index 5b56ea3df75..b2b62798d03 100644
--- a/compiler-rt/lib/crt/crtbegin.c
+++ b/compiler-rt/lib/crt/crtbegin.c
@@ -48,8 +48,7 @@ static void __attribute__((used)) __do_init() {
#ifdef CRT_HAS_INITFINI_ARRAY
__attribute__((section(".init_array"),
used)) static void (*__init)(void) = __do_init;
-#else // CRT_HAS_INITFINI_ARRAY
-#if defined(__i386__) || defined(__x86_64__)
+#elif defined(__i386__) || defined(__x86_64__)
__asm__(".pushsection .init,\"ax\",@progbits\n\t"
"call " __USER_LABEL_PREFIX__ "__do_init\n\t"
".popsection");
@@ -57,8 +56,18 @@ __asm__(".pushsection .init,\"ax\",@progbits\n\t"
__asm__(".pushsection .init,\"ax\",%progbits\n\t"
"bl " __USER_LABEL_PREFIX__ "__do_init\n\t"
".popsection");
-#endif // CRT_HAS_INITFINI_ARRAY
-#endif
+#elif defined(__powerpc__) || defined(__powerpc64__)
+__asm__(".pushsection .init,\"ax\",@progbits\n\t"
+ "bl " __USER_LABEL_PREFIX__ "__do_init\n\t"
+ "nop\n\t"
+ ".popsection");
+#elif defined(__sparc__)
+__asm__(".pushsection .init,\"ax\",@progbits\n\t"
+ "call " __USER_LABEL_PREFIX__ "__do_init\n\t"
+ ".popsection");
+#else
+#error "crtbegin without .init_fini array unimplemented for this architecture"
+#endif // CRT_HAS_INITFINI_ARRAY
#ifndef CRT_HAS_INITFINI_ARRAY
static fp __DTOR_LIST__[]
@@ -88,8 +97,7 @@ static void __attribute__((used)) __do_fini() {
#ifdef CRT_HAS_INITFINI_ARRAY
__attribute__((section(".fini_array"),
used)) static void (*__fini)(void) = __do_fini;
-#else // CRT_HAS_INITFINI_ARRAY
-#if defined(__i386__) || defined(__x86_64__)
+#elif defined(__i386__) || defined(__x86_64__)
__asm__(".pushsection .fini,\"ax\",@progbits\n\t"
"call " __USER_LABEL_PREFIX__ "__do_fini\n\t"
".popsection");
@@ -97,5 +105,15 @@ __asm__(".pushsection .fini,\"ax\",@progbits\n\t"
__asm__(".pushsection .fini,\"ax\",%progbits\n\t"
"bl " __USER_LABEL_PREFIX__ "__do_fini\n\t"
".popsection");
-#endif
+#elif defined(__powerpc__) || defined(__powerpc64__)
+__asm__(".pushsection .fini,\"ax\",@progbits\n\t"
+ "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t"
+ "nop\n\t"
+ ".popsection");
+#elif defined(__sparc__)
+__asm__(".pushsection .fini,\"ax\",@progbits\n\t"
+ "call " __USER_LABEL_PREFIX__ "__do_fini\n\t"
+ ".popsection");
+#else
+#error "crtbegin without .init_fini array unimplemented for this architecture"
#endif // CRT_HAS_INIT_FINI_ARRAY
OpenPOWER on IntegriCloud