xiaoxiang781216 commented on code in PR #10470:
URL: https://github.com/apache/nuttx/pull/10470#discussion_r1314376294


##########
libs/libc/dlfcn/lib_dlclose.c:
##########
@@ -125,33 +125,46 @@ static inline int dlremove(FAR void *handle)
 
   /* Release resources held by the module */
 
-  if (modp->textalloc != NULL)
+  /*
+   * Dynamic shared objects have text and data allocated in one
+   * operation to keep the relative positions between the two
+   * areas relative otherwise references to the GOT will fail
+   */
+  if (!modp->dynamic)
     {
-      /* Free the module memory */
-
-      lib_free((FAR void *)modp->textalloc);
-
-      /* Nullify so that the memory cannot be freed again */
-
-      modp->textalloc = NULL;
-#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE)
-      modp->textsize  = 0;
+      if (modp->textalloc != NULL)
+        {
+          /* Free the module memory */
+    
+          lib_free((FAR void *)modp->textalloc);

Review Comment:
   why free twice



##########
build-globals.sh:
##########
@@ -4,62 +4,6 @@
 # the API names and addresses we will export for resolving symbols in
 # dynamic loaded shared objects. Typically these are libc APIs.

Review Comment:
   please move build_globals.sh to tools folder and add copyright.



##########
libs/libc/modlib/modlib_bind.c:
##########
@@ -765,7 +804,6 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
                                 loadinfo->datasec + loadinfo->datastart;
         }
     }
-

Review Comment:
   revert the change



##########
libs/libc/modlib/modlib_bind.c:
##########
@@ -578,14 +581,17 @@ static int modlib_relocatedyn(FAR struct module_s *modp,
       return ret;
     }
 
-  rels = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT * sizeof(Elf_Rel));
+  /* Assume DT_RELA to get maximum size required */
+  rels = lib_malloc(CONFIG_MODLIB_RELOCATION_BUFFERCOUNT * sizeof(Elf_Rela));
   if (!rels)
     {
       berr("Failed to allocate memory for elf relocation rels\n");
       lib_free(dyn);
       return -ENOMEM;
     }
 
+  relas = (Elf_Rela *) rels;

Review Comment:
   ```suggestion
     relas = (FAR Elf_Rela *)rels;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to