Opened on 09/12/23 at 13:48:38
Last modified on 09/18/23 at 05:24:12
#4953 reopened defect
Use of symbol addresses for arbitrary values may not work for some code models
Reported by: | Sebastian Huber | Owned by: | Sebastian Huber |
---|---|---|---|
Priority: | normal | Milestone: | 6.1 |
Component: | score | Version: | 6 |
Severity: | normal | Keywords: | qualification |
Cc: | Blocked By: | ||
Blocking: |
Description
The _ISR_Stack_size is defined by the application configuration like this:
/** * @ingroup RTEMSAPIBaseDefs * * @brief Defines a global symbol with the name and value. * * @param _name is the user defined name of the symbol. The name shall be a * valid designator. On the name a macro expansion is performed and * afterwards it is stringified. * * @param _value is the value of the symbol. On the value a macro expansion is * performed and afterwards it is stringified. It shall expand to an integer * expression understood by the assembler. * * This macro shall be placed at file scope. */ #if defined(__USER_LABEL_PREFIX__) #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ __asm__( \ "\t.globl " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ "\n\t.set " RTEMS_XSTRING( RTEMS_SYMBOL_NAME( _name ) ) \ ", " RTEMS_STRING( _value ) "\n" \ ) #else #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) #endif RTEMS_DEFINE_GLOBAL_SYMBOL( _ISR_Stack_size, CONFIGURE_INTERRUPT_STACK_SIZE );
Firstly, the RTEMS_DEFINE_GLOBAL_SYMBOL() is broken. It should depend on GNUC and not USER_LABEL_PREFIX.
Secondly, setting a symbol to an arbitrary absolute address may not work with all code models, see:
https://sourceware.org/pipermail/binutils/2023-September/129448.html
The _ISR_Stack_size should be changed to point to the end of the ISR stack of processor 0:
RTEMS_DEFINE_GLOBAL_SYMBOL( _ISR_Stack_0_end, RTEMS_SYMBOL_NAME( _ISR_Stack_area_begin ) + CONFIGURE_INTERRUPT_STACK_SIZE );
The tests for RTEMS_DEFINE_GLOBAL_SYMBOL() should be changed to use values relative to another symbol.
Change History (9)
comment:1 Changed on 09/13/23 at 05:28:52 by Sebastian Huber <sebastian.huber@…>
comment:3 Changed on 09/13/23 at 05:44:16 by Sebastian Huber
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Since the start files are written in assembly, they can use the right instructions to load an arbitrary absolute address. A review of the uses of _ISR_Stack_size showed that there is actually no issue right now. Adjusting the tests for RTEMS_DEFINE_GLOBAL_SYMBOL() should be enough.
comment:4 Changed on 09/13/23 at 08:52:29 by Sebastian Huber
Resolution: | fixed |
---|---|
Status: | closed → reopened |
The spconfig01 test fails on aarch64 with:
testsuites/sptests/spconfig01/init.c: 89 rtems_configuration_get_interrupt_stack_size() == CPU_STACK_MINIMUM_SIZE
The rtems_configuration_get_interrupt_stack_size() needs to be fixed.
comment:5 Changed on 09/13/23 at 08:57:43 by Sebastian Huber
Summary: | Definition of _ISR_Stack_size may not work for some code models → Use of symbol addresses for arbitrary values may not work for some code models |
---|
The use of _TLS_BSS_size and _TLS_Data_begin may also not work on some code models. I really wonder why the TLS related tests pass on aarch64.
comment:6 Changed on 09/13/23 at 09:02:33 by Sebastian Huber
There are also issues with _TLS_Size and _TLS_Alignment.
In 0add2d2/rtems: