Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1505, accept "NULL" as entry point #1520

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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