Skip to content

Commit

Permalink
Merge pull request #1221 from ezpollack/fix1220-os_modulegetinfo_impl…
Browse files Browse the repository at this point in the history
…-rtems

Fix #1220 Implement OS_ModuleGetInfo_Impl for RTEMS
  • Loading branch information
astrogeco committed Mar 8, 2022
2 parents a173f30 + 7f049e5 commit 75fe674
Showing 1 changed file with 42 additions and 5 deletions.
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 */

0 comments on commit 75fe674

Please sign in to comment.