[compiler-rt] 1d891a3 - Support powerpc and sparc when building without init_array.
Sterling Augustine via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 27 13:02:31 PST 2019
Author: Sterling Augustine
Date: 2019-12-27T13:02:11-08:00
New Revision: 1d891a32cf433e205b5d30697beb265dc0e1f248
URL: https://github.com/llvm/llvm-project/commit/1d891a32cf433e205b5d30697beb265dc0e1f248
DIFF: https://github.com/llvm/llvm-project/commit/1d891a32cf433e205b5d30697beb265dc0e1f248.diff
LOG: 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
Added:
Modified:
compiler-rt/lib/crt/crtbegin.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/crt/crtbegin.c b/compiler-rt/lib/crt/crtbegin.c
index 5b56ea3df757..b2b62798d033 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\", at progbits\n\t"
"call " __USER_LABEL_PREFIX__ "__do_init\n\t"
".popsection");
@@ -57,8 +56,18 @@ __asm__(".pushsection .init,\"ax\", at 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\", at progbits\n\t"
+ "bl " __USER_LABEL_PREFIX__ "__do_init\n\t"
+ "nop\n\t"
+ ".popsection");
+#elif defined(__sparc__)
+__asm__(".pushsection .init,\"ax\", at 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\", at progbits\n\t"
"call " __USER_LABEL_PREFIX__ "__do_fini\n\t"
".popsection");
@@ -97,5 +105,15 @@ __asm__(".pushsection .fini,\"ax\", at 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\", at progbits\n\t"
+ "bl " __USER_LABEL_PREFIX__ "__do_fini\n\t"
+ "nop\n\t"
+ ".popsection");
+#elif defined(__sparc__)
+__asm__(".pushsection .fini,\"ax\", at 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
More information about the llvm-commits
mailing list