[PATCH] D71670: Support powerpc when builing without init_array.

Sterling Augustine via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 11:26:21 PST 2019


saugustine created this revision.
Herald added subscribers: llvm-commits, Sanitizers, shchenz, jsji, nemanjai.
Herald added projects: Sanitizers, LLVM.
saugustine added reviewers: jgorbe, rdhindsa.
Herald added a subscriber: wuzish.

Also add an error case when targetting an unimplement architecture.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71670

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
@@ -57,8 +57,15 @@
 __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");
+#else
+#error "crtbegin without .init_fini array unimplemented for this architecture"
+#endif // defined(various architectures)
+#endif // CRT_HAS_INITFINI_ARRAY
 
 #ifndef CRT_HAS_INITFINI_ARRAY
 static fp __DTOR_LIST__[]
@@ -97,5 +104,12 @@
 __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");
+#else
+#error "crtbegin without .init_fini array unimplemented for this architecture"
+#endif  // defined(various architectures)
 #endif  // CRT_HAS_INIT_FINI_ARRAY


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71670.234585.patch
Type: text/x-patch
Size: 1278 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191218/2c252fee/attachment.bin>


More information about the llvm-commits mailing list