Skip to content

Commit

Permalink
Fix nasa#1505, accept "NULL" as entry point
Browse files Browse the repository at this point in the history
Recognize the special string "NULL" to indicate no entry point
should be called for the library.  Equivalent to leaving the
field empty.
  • Loading branch information
jphickey committed May 13, 2021
1 parent 82c1bd4 commit 798c05b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/es/fsw/src/cfe_es_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ int32 CFE_ES_LoadModule(CFE_ResourceId_t ParentResourceId, const char *ModuleNam
/*
* If the Load was OK, then lookup the address of the entry point
*/
if (ReturnCode == CFE_SUCCESS && LoadParams->InitSymbolName[0] != 0)
if (ReturnCode == CFE_SUCCESS && LoadParams->InitSymbolName[0] != 0 &&
strcmp(LoadParams->InitSymbolName, "NULL") != 0)
{
StatusCode = OS_ModuleSymbolLookup(ModuleId, &InitSymbolAddress, LoadParams->InitSymbolName);
if (StatusCode != OS_SUCCESS)
Expand Down
17 changes: 17 additions & 0 deletions modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,23 @@ void TestLibs(void)
Return = CFE_ES_LoadLibrary(&Id, "TST_LIB", &LoadParams);
UtAssert_INT32_EQ(Return, CFE_STATUS_EXTERNAL_RESOURCE_FAIL);

/*
* Test shared library loading and initialization where the library
* entry point symbol is the special string "NULL". This should skip
* symbol lookup.
*/
ES_ResetUnitTest();
ES_UT_SetupModuleLoadParams(&LoadParams, "nullep", "NULL");
Return = CFE_ES_LoadLibrary(&Id, "TST_LIB1", &LoadParams);
UtAssert_INT32_EQ(Return, CFE_SUCCESS);
UtAssert_STUB_COUNT(OS_ModuleSymbolLookup, 0); /* should NOT have been called */

/* Likewise for a entry point where the string is empty */
LoadParams.InitSymbolName[0] = 0;
Return = CFE_ES_LoadLibrary(&Id, "TST_LIB2", &LoadParams);
UtAssert_INT32_EQ(Return, CFE_SUCCESS);
UtAssert_STUB_COUNT(OS_ModuleSymbolLookup, 0); /* should NOT have been called */

/* Test shared library loading and initialization where the library
* initialization function fails and then must be cleaned up
*/
Expand Down

0 comments on commit 798c05b

Please sign in to comment.