2.5.2 __rt_entry
The symbol __rt_entry is the starting point for a program using the ARM C library.
Control passes to __rt_entry after all scatter-load regions have been relocated to their
execution addresses.
Usage
The default implementation of __rt_entry :
1. Sets up the heap and stack.
2. Initializes the C library, by calling __rt_lib_init .
3. Calls main() .
4. Shuts down the C library, by calling __rt_lib_shutdown .
5. Exits.
__rt_entry must end with a call to one of the following functions:
exit() Calls atexit()- registered functions and shuts down the library.
__rt_exit() Shuts down the library but does not call atexit() functions.
_sys_exit() Exits directly to the execution environment. It does not shut down the
library and does not call atexit() functions. See _sys_exit() on
page 2-60.
2.5.3 Exiting from the program
The program can exit normally at the end of main() or it can exit prematurely because
of an error.
Exiting from an assert
The behavior of the assert macro depends on the conditions in operation at the most
recent occurrence of #include <assert.h> :
1. If the NDEBUG macro is defined (on the command line or as part of a source file),
the assert macro has no effect.
2. If the NDEBUG macro is not defined, the assert expression (the expression given to
the assert macro) is evaluated. If the result is TRUE , that is != 0 , the assert macro
has no more effect.
3. If the assert expression evaluates to FALSE , the assert macro calls the
__aeabi_assert() function if any of the following are true:
• you are compiling with --strict
• you are using - O0 or - O1
• you are compiling with --library_interface=aeabi_clib or
--library_interface=aeabi_glibc
• __ASSERT_MSG is defined
• _AEABI_PORTABILITY_LEVEL is defined and not 0.
4. Otherwise, if the assert expression evaluates to FALSE and the conditions
in point 3 do not apply, the assert macro calls abort() . Then:
a. abort() calls __rt_raise() .
b. If __rt_raise() returns, abort() tries to finalize the library.
If you are creating an application that does not use the library, __aeabi_assert()
if you reimplement abort() and the stdio functions.
Another solution for retargeting is to reimplement the __aeabi_assert() function
The function prototype is:
void __aeabi_assert( const char * expr , const char * file , int line );
where:
• expr points to the string representation of the expression that was not TRUE
• file and line identify the source location of the assertion.
The behavior for __aeabi_assert() supplied in the ARM C library is to print a message
on stderr and call abort() .
You can restore the default behavior for __aeabi_assert() at higher optimization levels
by defining __ASSERT_MSG .
2.5.4 __rt_exit()
This function shuts down the library but does not call functions registered with
atexit() .
Syntax
void __rt_exit( int code )
Where code is not used by the standard function.
Usage
Shuts down the C library by calling __rt_lib_shutdown , and then calls _sys_exit to
terminate the application. Reimplement _sys_exit rather than __rt_exit . See
_sys_exit() on page 2-60 for more information.
Return
The function does not return.
2.5.5 __rt_lib_init()
This is the library initialization function and is the companion to __rt_lib_shutdown() .
Syntax
extern value_in_regs struct __argc_argv __rt_lib_init( unsigned heapbase ,
unsigned heaptop )
where:
heapbase The start of the heap memory block.
heaptop The end of the heap memory block.
Usage
This is the library initialization function. It is called immediately after
__rt_stackheap_init() and passed an initial chunk of memory to use as a heap. This
function is the standard ARM library initialization function and must not be
reimplemented.
Return
The function returns argc and argv ready to be passed to main() . The structure is
returned in the registers as:
struct __argc_argv
{ int argc;
char **argv;
int r2, r3;
};
2.5.6 __rt_lib_shutdown()
This is the library shutdown function and is the companion to __rt_lib_init() .
Syntax
void __rt_lib_shutdown( void )
Usage
This is the library shutdown function and is provided in case a user must call it directly.
This is the standard ARM library shutdown function and must not be reimplemented.
--strict , --no_strict
This option enforces or relaxes strict C or strict C++, depending on the choice of source language used.
When --strict
is
selected:
· features that conflict with ISO C or ISO C++ are disabled
· error messages are returned when nonstandard features are used.
Default
The default is --no_strict
.
Usage
--strict
enforces compliance with:
ISO C90
· ISO/IEC 9899:1990, the 1990 International Standard for C.
· ISO/IEC 9899 AM1, the 1995 Normative Addendum 1.
ISO C99
ISO/IEC 9899:1999, the 1999 International Standard for C.
ISO C++
ISO/IEC 14822:2003, the 2003 International Standard for C++.
Errors
When --strict
is in
force and a violation of the relevant ISO standard occurs, the compiler issues
an error message.
The severity of diagnostic messages can be controlled in the usual way.
Example
void foo(void)
{
long long i; /* okay in nonstrict C90 */
}
Compiling this code with --strict
generates an error.
Reference :
RealView® Compilation ToolsVersion 4.0-Libraries and Floating Point Support Guide
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0349bc/Chdeehge.html