score: Add CPU_USE_LIBC_INIT_FINI_ARRAY

This introduces the CPU_USE_LIBC_INIT_FINI_ARRAY define for use by CPU
ports to determine which global constructor and destructor methods are
used instead of placing architecture defines where they shouldn't be.

Close #4018
This commit is contained in:
Kinsey Moore
2020-06-29 14:35:08 -05:00
committed by Sebastian Huber
parent 37c36def7a
commit 48dd7b8c2e
20 changed files with 49 additions and 6 deletions

View File

@@ -17,11 +17,8 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
/* FIXME: These defines are a blatant hack */
#if defined(__USE_INIT_FINI__) #if defined(__USE_INIT_FINI__)
#if defined(__ARM_EABI__) || defined(__riscv) \ #if CPU_USE_LIBC_INIT_FINI_ARRAY == TRUE
|| defined(__or1k__) || defined(__or1knd__)
#define FINI_SYMBOL __libc_fini_array #define FINI_SYMBOL __libc_fini_array
#else #else
#define FINI_SYMBOL _fini #define FINI_SYMBOL _fini

View File

@@ -153,6 +153,8 @@
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
#define CPU_MAXIMUM_PROCESSORS 32 #define CPU_MAXIMUM_PROCESSORS 32
#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER #ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER

View File

@@ -507,6 +507,8 @@ void _CPU_Context_Initialize(
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* functions */ /* functions */
/** /**

View File

@@ -445,6 +445,8 @@ void _CPU_Context_Initialize(
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
#endif /* ASM */ #endif /* ASM */
/** /**

View File

@@ -503,6 +503,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t error)
/* end of Fatal Error manager macros */ /* end of Fatal Error manager macros */
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* /*
* Bitfield handler macros * Bitfield handler macros
* *

View File

@@ -628,6 +628,8 @@ extern char _gp[];
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* functions */ /* functions */
/** /**

View File

@@ -433,6 +433,8 @@ void *_CPU_Thread_Idle_body( uintptr_t ignored );
/* end of Fatal Error manager macros */ /* end of Fatal Error manager macros */
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* /*
* Bitfield handler macros * Bitfield handler macros
* *

View File

@@ -740,6 +740,8 @@ extern void mips_break( int error );
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* functions */ /* functions */
/* /*

View File

@@ -427,6 +427,8 @@ uint32_t _CPU_ISR_Get_level( void );
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* functions */ /* functions */
/* /*

View File

@@ -90,6 +90,8 @@ extern "C" {
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
#define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0 #define CPU_MPCI_RECEIVE_SERVER_EXTRA_STACK 0
#define CPU_MAXIMUM_PROCESSORS 32 #define CPU_MAXIMUM_PROCESSORS 32

View File

@@ -249,6 +249,13 @@ extern "C" {
*/ */
#define CPU_MAXIMUM_PROCESSORS 32 #define CPU_MAXIMUM_PROCESSORS 32
/**
* The following define determines whether or not this CPU port will use
* libc global constructors and destructors instead of _init/_fini functions
* depending on .ctors and .dtors linker sections.
*/
#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
/* /*
* Processor defined structures required for cpukit/score. * Processor defined structures required for cpukit/score.
* *

View File

@@ -435,6 +435,8 @@ void _CPU_Context_Initialize(
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
#endif /* ASM */ #endif /* ASM */
#define CPU_SIZEOF_POINTER 4 #define CPU_SIZEOF_POINTER 4

View File

@@ -805,6 +805,9 @@ void _CPU_Context_Initialize(
#endif /* ASM */ #endif /* ASM */
#ifndef ASM #ifndef ASM
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* Bitfield handler macros */ /* Bitfield handler macros */
#define CPU_USE_GENERIC_BITFIELD_CODE FALSE #define CPU_USE_GENERIC_BITFIELD_CODE FALSE

View File

@@ -219,6 +219,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t error) RTEMS_NO_RETURN;
#define CPU_USE_GENERIC_BITFIELD_DATA TRUE #define CPU_USE_GENERIC_BITFIELD_DATA TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY TRUE
#define CPU_MAXIMUM_PROCESSORS 32 #define CPU_MAXIMUM_PROCESSORS 32
typedef uint16_t Priority_bit_map_Word; typedef uint16_t Priority_bit_map_Word;

View File

@@ -535,6 +535,8 @@ void _CPU_Context_Initialize(
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* functions */ /* functions */
/* /*

View File

@@ -917,6 +917,8 @@ extern void _CPU_Fatal_halt(uint32_t source, uint32_t error)
/* end of Fatal Error manager macros */ /* end of Fatal Error manager macros */
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* Bitfield handler macros */ /* Bitfield handler macros */
#if ( SPARC_HAS_BITSCAN == 0 ) #if ( SPARC_HAS_BITSCAN == 0 )

View File

@@ -801,6 +801,8 @@ void _CPU_Context_Initialize(
/* end of Fatal Error manager macros */ /* end of Fatal Error manager macros */
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* Bitfield handler macros */ /* Bitfield handler macros */
/* /*

View File

@@ -493,6 +493,8 @@ void _CPU_Context_Initialize(
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* functions */ /* functions */
/** /**

View File

@@ -242,6 +242,8 @@ void _CPU_Context_Initialize(
/* end of Fatal Error manager macros */ /* end of Fatal Error manager macros */
#define CPU_USE_LIBC_INIT_FINI_ARRAY FALSE
/* Bitfield handler macros */ /* Bitfield handler macros */
#define CPU_USE_GENERIC_BITFIELD_CODE TRUE #define CPU_USE_GENERIC_BITFIELD_CODE TRUE

View File

@@ -28,9 +28,13 @@
* Conditional magic to determine what style of C++ constructor * Conditional magic to determine what style of C++ constructor
* initialization this target and compiler version uses. * initialization this target and compiler version uses.
*/ */
RTEMS_STATIC_ASSERT(
CPU_USE_LIBC_INIT_FINI_ARRAY == TRUE
|| CPU_USE_LIBC_INIT_FINI_ARRAY == FALSE,
CPU_USE_LIBC_INIT_FINI_ARRAY
);
#if defined(__USE_INIT_FINI__) #if defined(__USE_INIT_FINI__)
#if defined(__ARM_EABI__) || defined(__riscv) \ #if CPU_USE_LIBC_INIT_FINI_ARRAY == TRUE
|| defined(__or1k__) || defined(__or1knd__)
#define INIT_NAME __libc_init_array #define INIT_NAME __libc_init_array
#else #else
#define INIT_NAME _init #define INIT_NAME _init