Board: EK-TM4C1294XL
AppEnv: TI_RTOS+NDK
The goal I had set for my commandline (CLI) subsystem was to be able to have link-time determination of which commands are included in the exec build (unlike some of the example code where a table as to be defined in C).
Here is how individual commands are compiled
In PdbCli.h:
// From processors.wiki.ti.com/.../Pragmas_in_C%2B%2B
#define PRAGMA(x) _Pragma(#x)
#ifdef __cplusplus
#define DSPRAGMA(f,s) PRAGMA(DATA_SECTION(s))
#else
#define DSPRAGMA(f,s) PRAGMA(DATA_SECTION(f, s))
#endif
#define PDBCLI_REG(NAME, FUNC, ARGS...) \
DSPRAGMA(pdbcli_reg_ ## NAME, ".data_pdbcli") \
PRAGMA(RETAIN(pdbcli_reg_ ## NAME)) \
cliEntry_T pdbcli_reg_ ## NAME = { #NAME , FUNC ,##ARGS }
In various C modules:
#include "PdbCli.h"
static int PdbCliHi(CliCtxt_T ctxt, int argc, char *argv[])
{
PdbCliPrintf(ctxt, "ho\n");
return PDBCLI_RET_OK;
}
PDBCLI_REG(testcmd, PdbCliHi, "Greet the CLI",
"This is your chance for deep conversation with the\n"
"command line interface. You say \"Hi\", the response\n"
"will astound you\n");
I modified linker command file as follows (orig comments removed):
--retain=g_pfnVectors
MEMORY
{
FLASH (RX) : origin = 0x00000000, length = 0x00100000
SRAM (RWX) : origin = 0x20000000, length = 0x00040000
}
SECTIONS
{
.intvecs: > 0x00000000
.text : > FLASH
.const : > FLASH
.cinit : > FLASH
.pinit : > FLASH
.init_array : > FLASH
.vtable : > 0x20000000
.data : > SRAM
.data_pdbcli : > SRAM,
LOAD_START(PdbCli_Commands_start),
LOAD_SIZE(PdbCli_Commands_len)
.bss : > SRAM
.sysmem : > SRAM
.stack : > SRAM
}
__STACK_TOP = __stack + 512;
- When I build a monolithic executable - all works fine (all pdb_cli_reg_* structs are in the final map file)
- When I place commands in an executable (directly referenced C module) that is otherwise referenced - all works fine
- When I place commands in the lib, within an object file that is otherwise referenced - all works fine
- When I place commands in the lib, within an object file that is NOT otherwise referenced, the symbols are not retained regardless of the above pragma
I confirmed, using `objdump` that the pdbcli_reg_* variables are in the
library, marked with 'retain'
What I have tried:
- Tried adding --retain='*(.data_pdbcli)' to the linker command file
- Tried adding --retain='*<*>(.data_pdbcli)' to the linker command file
- Tried adding --retain='pdbcli_reg*' to the linker command file
- Tried other variations and flags to no avail
Reproduced in Linux and WIndows CCS environments
Link line from build log:
"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/bin/armcl" -mv7M4 --code_state=16 --float_support=FPv4SPD16 --abi=eabi -me -g --gcc --define=ccs="ccs" --define=PART_TM4C1294NCPDT --define=ccs --define=TIVAWARE --display_error_number --diag_warning=225 --diag_wrap=off --gen_func_subsections=on -z -m"CommonFWLibTest.map" --heap_size=0 --stack_size=512 -i"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/lib" -i"C:/ti/ccsv6/tools/compiler/ti-cgt-arm_5.2.4/include" --reread_libs --warn_sections --display_error_number --diag_wrap=off --xml_link_info="CommonFWLibTest_linkInfo.xml" --rom_model -o "CommonFWLibTest.out" "./PdbCli_Test.obj" "../EK_TM4C1294XL.cmd" -l"./configPkg/linker.cmd" -l"libc.a" -l"C:/cygwin64/home/nhed/Projects/TI_CommonFW/libtest/proj/../../lib/proj/Debug/CommonFWLib.lib" -l"C:/ti/tirtos_tivac_2_12_01_33/products/TivaWare_C_Series-2.1.0.12573c/driverlib/ccs/Debug/driverlib.lib" -l"C:/ti/tirtos_tivac_2_12_01_33/products/TivaWare_C_Series-2.1.0.12573c/usblib/ccs/Debug/usblib.lib"
I saw other posts with similar issues but no clear answer
Thanks
--Nevo