[RTEMS Project] #4750: Linker discards RTEMS_SYSINIT_ITEM object
RTEMS trac
trac at rtems.org
Fri Nov 4 13:40:35 UTC 2022
#4750: Linker discards RTEMS_SYSINIT_ITEM object
---------------------+--------------------
Reporter: dsa93 | Owner: (none)
Type: defect | Status: new
Priority: normal | Milestone: 6.1
Component: rtems | Version: 6
Severity: normal | Keywords:
Blocked By: | Blocking:
---------------------+--------------------
Hi
I am developing device driver in custom BSP in RTEMS.
I applied my BSP on top of master branch.
My driver code looks like this:
{{{
/* driver logic in "static" functions (omitted) */
void custom_driver_init(void);
RTEMS_SYSINIT_ITEM(
custom_driver_init,
RTEMS_SYSINIT_DEVICE_DRIVERS,
RTEMS_SYSINIT_ORDER_SEVENTH
);
}}}
It is discarded by linker. custom_driver_init is never called. I
discovered hack how to make linker not discard this: if I put at least one
extern linkage function and call it in other file then linker dont discard
"custom_driver_init"
{{{
/* driver logic in "static" functions (omitted) */
/* Call this function for example from main function */
int workaraound(void) {
return 5;
}
void custom_driver_init(void);
RTEMS_SYSINIT_ITEM(
custom_driver_init,
RTEMS_SYSINIT_DEVICE_DRIVERS,
RTEMS_SYSINIT_ORDER_SEVENTH
);
}}}
Driver file compilation arguments:
{{{
-MMD,
-Wall,
-Wmissing-prototypes,
-Wimplicit-function-declaration,
-Wstrict-prototypes,
-Wnested-externs,
-O2,
-g,
-fdata-sections,
-ffunction-sections,
-mthumb,
-mcpu=cortex-m7,
-mfpu=fpv5-d16,
-mfloat-abi=hard,
-save-temps,
-Icpukit/include,
-I../../../cpukit/include,
-Icpukit/score/cpu/arm/include,
-I../../../cpukit/score/cpu/arm/include,
-Ibsps/include,
-I../../../bsps/include,
-Ibsps/arm/include,
-I../../../bsps/arm/include,
../../../bsps/arm/someplatform/console/console.c,
-c,
-DHAVE_CONFIG_H=1,
-DBOARD_MAINCK_FREQ_HZ=10000000
}}}
Application linkage files
{{{
/home/dsa/rtems/rsb-6/bin/arm-rtems6-gcc
-g
-mthumb
-mcpu=cortex-m7
-mfpu=fpv5-d16
-mfloat-abi=hard
-DBOARD_MAINCK_FREQ_HZ=10000000
-I/home/dsa/arm-rtems6/someplatform/lib/include
-B/home/dsa/arm-rtems6/someplatform/lib
-qrtems
-Wl,--gc-sections
-Wl,-Map=ecu-app.map,--print-memory-usage,--cref
CMakeFiles/ecu-app.dir/src/main.c.obj
-o ecu-app.elf
-lrtemsbsp
-lrtemscpu
}}}
I tried to research this topic and I am not sure if there is a way to
prevent this optimisation, so I decided to post it here. I can provide you
some more details or perform some tests
--
Ticket URL: <http://devel.rtems.org/ticket/4750>
RTEMS Project <http://www.rtems.org/>
RTEMS Project
More information about the bugs
mailing list