diff --git a/compiler-rt/lib/crt/crtbegin.c b/compiler-rt/lib/crt/crtbegin.c index 5b56ea3df757f7..b2b62798d0333c 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