rtos: removed chSysInit from detection of ChibiOS (#121)

Using the presence of the 'chSysInit' symbol for detection of
ChibiOS is dangerous because this symbol may not be available
if link-time optimisation is used.

This patch removes this reliance, so the symbols 'ch' and 'ch_debug'
are the only things required for ChibiOS detection.

If 'ch' is present but 'ch_debug' is not, an info message suggests
that Chibios might be present without its registry being enabled.
This message has been reworded a little to make it slightly more
equivocal because the chances of a false positive message are
increased.

Addresses bug #121, "ChibiOS rtos detection fails with LTO enabled".

Change-Id: I5ef224735c06446751adee010ce75be4f30f0403
Signed-off-by: Andy Pomfret <cooperised@gmail.com>
Reviewed-on: http://openocd.zylin.com/3381
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
__archive__
Andy Pomfret 2016-03-08 13:52:36 +00:00 committed by Andreas Fritiofson
parent 02f17f0ba3
commit 4b11548748
1 changed files with 4 additions and 7 deletions

View File

@ -128,15 +128,13 @@ struct rtos_type ChibiOS_rtos = {
enum ChibiOS_symbol_values { enum ChibiOS_symbol_values {
ChibiOS_VAL_rlist = 0, ChibiOS_VAL_rlist = 0,
ChibiOS_VAL_ch = 1, ChibiOS_VAL_ch = 1,
ChibiOS_VAL_ch_debug = 2, ChibiOS_VAL_ch_debug = 2
ChibiOS_VAL_chSysInit = 3
}; };
static symbol_table_elem_t ChibiOS_symbol_list[] = { static symbol_table_elem_t ChibiOS_symbol_list[] = {
{ "rlist", 0, true}, /* Thread ready list */ { "rlist", 0, true}, /* Thread ready list */
{ "ch", 0, true}, /* System data structure */ { "ch", 0, true}, /* System data structure */
{ "ch_debug", 0, false}, /* Memory Signature containing offsets of fields in rlist */ { "ch_debug", 0, false}, /* Memory Signature containing offsets of fields in rlist */
{ "chSysInit", 0, false}, /* Necessary part of API, used for ChibiOS detection */
{ NULL, 0, false} { NULL, 0, false}
}; };
@ -518,12 +516,11 @@ static int ChibiOS_detect_rtos(struct target *target)
{ {
if ((target->rtos->symbols != NULL) && if ((target->rtos->symbols != NULL) &&
((target->rtos->symbols[ChibiOS_VAL_rlist].address != 0) || ((target->rtos->symbols[ChibiOS_VAL_rlist].address != 0) ||
(target->rtos->symbols[ChibiOS_VAL_ch].address != 0)) && (target->rtos->symbols[ChibiOS_VAL_ch].address != 0))) {
(target->rtos->symbols[ChibiOS_VAL_chSysInit].address != 0)) {
if (target->rtos->symbols[ChibiOS_VAL_ch_debug].address == 0) { if (target->rtos->symbols[ChibiOS_VAL_ch_debug].address == 0) {
LOG_INFO("It looks like the target is running ChibiOS without " LOG_INFO("It looks like the target may be running ChibiOS "
"ch_debug."); "without ch_debug.");
return 0; return 0;
} }