[PATCH] D71944: Support powerpc and sparc when building without init_array.

Sterling Augustine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 27 11:58:27 PST 2019


saugustine created this revision.
saugustine added reviewers: rdhindsa, gribozavr.
Herald added subscribers: llvm-commits, Sanitizers, steven.zhang, shchenz, jsji, fedor.sergeev, nemanjai, jyknight.
Herald added projects: Sanitizers, LLVM.

Support powerpc and sparc when building without init_array.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71944

Files:
  compiler-rt/lib/crt/crtbegin.c


Index: compiler-rt/lib/crt/crtbegin.c
===================================================================
--- compiler-rt/lib/crt/crtbegin.c
+++ compiler-rt/lib/crt/crtbegin.c
@@ -48,8 +48,7 @@
 #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\",%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 @@
 #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\",%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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71944.235441.patch
Type: text/x-patch
Size: 2299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191227/ff7a4dd7/attachment.bin>


More information about the llvm-commits mailing list