[PATCH 1/3] libdl: RAP format fixes.

Chris Johns chrisj at rtems.org
Thu Apr 12 04:57:14 UTC 2018


- Do not error if a RAP section is not found.

- Free a symbol table via the RTL allocator interface.

- Add the symbols to the global symbol table.

Update #2769
---
 cpukit/libdl/rtl-rap.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/cpukit/libdl/rtl-rap.c b/cpukit/libdl/rtl-rap.c
index 2fe9c6b13f..59b3801f76 100644
--- a/cpukit/libdl/rtl-rap.c
+++ b/cpukit/libdl/rtl-rap.c
@@ -246,11 +246,7 @@ rtems_rtl_rap_relocate (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
     targetsect = rtems_rtl_obj_find_section (obj, rap_sections[section].name);
 
     if (!targetsect)
-    {
-      rtems_rtl_set_error (EINVAL, "no target section found");
-      free (symname_buffer);
-      return false;
-    }
+      continue;
 
     if (!rtems_rtl_rap_read_uint32 (rap->decomp, &header))
     {
@@ -592,7 +588,10 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
                  (rap->symbols * sizeof (rtems_rtl_obj_sym_t)));
 
   if (!rtems_rtl_obj_comp_read (rap->decomp, rap->strtab, rap->strtab_size))
+  {
+    rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table);
     return false;
+  }
 
   for (sym = 0, gsym = obj->global_table; sym < rap->symbols; ++sym)
   {
@@ -605,7 +604,7 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
         !rtems_rtl_rap_read_uint32 (rap->decomp, &name) ||
         !rtems_rtl_rap_read_uint32 (rap->decomp, &value))
     {
-      free (obj->global_table);
+      rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table);
       obj->global_table = NULL;
       obj->global_syms = 0;
       obj->global_size = 0;
@@ -629,7 +628,7 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
     {
       rtems_rtl_set_error (EINVAL,
                            "duplicate global symbol: %s", rap->strtab + name);
-      free (obj->global_table);
+      rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table);
       obj->global_table = NULL;
       obj->global_syms = 0;
       obj->global_size = 0;
@@ -639,7 +638,7 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
     symsect = rtems_rtl_obj_find_section_by_index (obj, data >> 16);
     if (!symsect)
     {
-      free (obj->global_table);
+      rtems_rtl_alloc_del (RTEMS_RTL_ALLOC_SYMBOL, obj->global_table);
       obj->global_table = NULL;
       obj->global_syms = 0;
       obj->global_size = 0;
@@ -662,6 +661,9 @@ rtems_rtl_rap_load_symbols (rtems_rtl_rap_t* rap, rtems_rtl_obj_t* obj)
     ++gsym;
   }
 
+  if (obj->global_syms)
+    rtems_rtl_symbol_obj_add (obj);
+
   return true;
 }
 
-- 
2.15.1




More information about the devel mailing list