Fix jlink-nuttx build with GCC 10.2

The packed-attribute on the tcb_info_s type was misplaced, which caused
incompatible memory layout between host and target.  According to
current GCC documentation:

> You may specify type attributes in an enum, struct or union type
> declaration or definition by placing them immediately after the struct,
> union or enum keyword.  You can also place them just past the closing
> curly brace of the definition, but this is less preferred because
> logically the type should be fully defined at the closing brace.

I also added jlink-nuttx.so to the .gitignore list and updated nxstyle
to ignore the camel case function names required by JLinkGDBServer.

Signed-off-by: Michael Jung <mijung@gmx.net>
This commit is contained in:
Michael Jung 2022-02-14 20:29:52 +01:00 committed by Petro Karashchenko
parent 34cf6949ac
commit 0a37744826
4 changed files with 46 additions and 4 deletions

View File

@ -781,11 +781,13 @@ begin_packed_struct struct tcbinfo_s
* value 0: This regsiter was not priovided by NuttX
*/
begin_packed_struct
union
{
uint8_t u[8];
FAR const uint16_t *p;
} reg_off;
}
end_packed_struct reg_off;
} end_packed_struct;
#endif

1
tools/.gitignore vendored
View File

@ -19,3 +19,4 @@
/incdir
/.k2h-body.dat
/.k2h-apndx.dat
/jlink-nuttx.so

View File

@ -59,6 +59,25 @@
#define PERROR g_plugin_priv.jops->erroroutf
#define PLOG g_plugin_priv.jops->logoutf
/* GCC specific definitions */
#ifdef __GNUC__
/* The packed attribute informs GCC that the structure elements are packed,
* ignoring other alignment rules.
*/
# define begin_packed_struct
# define end_packed_struct __attribute__ ((packed))
#else
# warning "Unsupported compiler"
# define begin_packed_struct
# define end_packed_struct
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@ -72,20 +91,22 @@ enum symbol_e
NSYMBOLS
};
__attribute__ ((packed)) struct tcbinfo_s
begin_packed_struct struct tcbinfo_s
{
uint16_t pid_off;
uint16_t state_off;
uint16_t pri_off;
uint16_t name_off;
uint16_t reg_num;
begin_packed_struct
union
{
uint8_t u[8];
uint16_t *p;
} reg_off;
}
end_packed_struct reg_off;
uint16_t reg_offs[0];
};
} end_packed_struct;
struct symbols_s
{

View File

@ -324,6 +324,24 @@ static const char *g_white_list[] =
"__asan_loadN_noabort",
"__asan_storeN_noabort",
/* Ref:
* tools/jlink-nuttx.c
*/
"RTOS_Init",
"RTOS_GetVersion",
"RTOS_GetSymbols",
"RTOS_GetNumThreads",
"RTOS_GetCurrentThreadId",
"RTOS_GetThreadId",
"RTOS_GetThreadDisplay",
"RTOS_GetThreadReg",
"RTOS_GetThreadRegList",
"RTOS_GetThreadRegList",
"RTOS_SetThreadReg",
"RTOS_SetThreadRegList",
"RTOS_UpdateThreads",
NULL
};