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 #1220 Implement OS_ModuleGetInfo_Impl for RTEMS #1221

Merged
merged 2 commits into from
Mar 16, 2022
Merged
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
47 changes: 42 additions & 5 deletions src/os/rtems/src/os-impl-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "os-impl-loader.h"
#include "os-shared-module.h"
#include "os-shared-idmap.h"
#include <rtems/rtl/rtl.h>

/****************************************************************************************
GLOBAL DATA
Expand Down Expand Up @@ -216,10 +217,46 @@ int32 OS_ModuleUnload_Impl(const OS_object_token_t *token)
*-----------------------------------------------------------------*/
int32 OS_ModuleGetInfo_Impl(const OS_object_token_t *token, OS_module_prop_t *module_prop)
{
/*
** RTEMS does not specify a way to get these values
** Everything left at zero
*/
return (OS_SUCCESS);
rtems_rtl_obj * obj;
OS_impl_module_internal_record_t *impl;
int32 status = OS_ERROR;

impl = OS_OBJECT_TABLE_GET(OS_impl_module_table, *token);

/* Lock RTEMS runtime loader */
if (rtems_rtl_lock() != NULL)
{
/* Get RTL object from handle and populate section info */
obj = rtems_rtl_check_handle(impl->dl_handle);

if (obj != NULL)
{
module_prop->addr.valid = true;
module_prop->addr.code_address = obj->text_base;
module_prop->addr.code_size = rtems_rtl_obj_text_size(obj);
module_prop->addr.data_address = obj->data_base;
module_prop->addr.data_size = rtems_rtl_obj_data_size(obj);
module_prop->addr.bss_address = obj->bss_base;
module_prop->addr.bss_size = rtems_rtl_obj_bss_size(obj);

status = OS_SUCCESS;
}

/* Unlock RTEMS runtime loader, report error if applicable */
rtems_rtl_unlock();

if (obj == NULL)
{
OS_DEBUG("Error getting object information from handle\n");
module_prop->addr.valid = false;
}
}
else
{
OS_DEBUG("Error locking RTEMS runtime loader\n");
module_prop->addr.valid = false;
}

return status;

} /* end OS_ModuleGetInfo_Impl */