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


##########
libs/libc/elf/elf_bind.c:
##########
@@ -968,23 +960,20 @@ int libelf_bind(FAR struct module_s *modp,
                 loadinfo->dsymtabidx = i;
                 break;
               case SHT_INIT_ARRAY:
-                loadinfo->initarr = loadinfo->shdr[i].sh_addr -
-                                    loadinfo->datasec +
-                                    loadinfo->datastart;
+                loadinfo->initarr = libelf_addr(loadinfo,
+                                              loadinfo->shdr[i].sh_addr);
                 loadinfo->ninit = loadinfo->shdr[i].sh_size /
                                   sizeof(uintptr_t);
                 break;
               case SHT_FINI_ARRAY:
-                loadinfo->finiarr = loadinfo->shdr[i].sh_addr -
-                                    loadinfo->datasec +
-                                    loadinfo->datastart;
+                loadinfo->finiarr = libelf_addr(loadinfo,
+                                              loadinfo->shdr[i].sh_addr);

Review Comment:
   ditto



##########
libs/libc/elf/elf_bind.c:
##########
@@ -968,23 +960,20 @@ int libelf_bind(FAR struct module_s *modp,
                 loadinfo->dsymtabidx = i;
                 break;
               case SHT_INIT_ARRAY:
-                loadinfo->initarr = loadinfo->shdr[i].sh_addr -
-                                    loadinfo->datasec +
-                                    loadinfo->datastart;
+                loadinfo->initarr = libelf_addr(loadinfo,
+                                              loadinfo->shdr[i].sh_addr);
                 loadinfo->ninit = loadinfo->shdr[i].sh_size /
                                   sizeof(uintptr_t);
                 break;
               case SHT_FINI_ARRAY:
-                loadinfo->finiarr = loadinfo->shdr[i].sh_addr -
-                                    loadinfo->datasec +
-                                    loadinfo->datastart;
+                loadinfo->finiarr = libelf_addr(loadinfo,
+                                              loadinfo->shdr[i].sh_addr);
                 loadinfo->nfini = loadinfo->shdr[i].sh_size /
                                   sizeof(uintptr_t);
                 break;
               case SHT_PREINIT_ARRAY:
-                loadinfo->preiarr = loadinfo->shdr[i].sh_addr -
-                                    loadinfo->datasec +
-                                    loadinfo->datastart;
+                loadinfo->preiarr = libelf_addr(loadinfo,
+                                              loadinfo->shdr[i].sh_addr);

Review Comment:
   align to (



##########
include/nuttx/lib/elf.h:
##########
@@ -44,6 +44,16 @@
 #  define CONFIG_LIBC_ELF_MAXDEPEND  0
 #endif
 
+/* Holding an XIP pin past the load means holding the file itself: the pin is
+ * released when the module is unloaded, which happens on a task other than
+ * the one that loaded it, so a descriptor from that task's group cannot
+ * serve.  That needs the file interface, which only the flat build has here.
+ */
+
+#if defined(CONFIG_FDPIC) && defined(CONFIG_BUILD_FLAT)

Review Comment:
   but how about kernel/protect mode



##########
libs/libc/elf/elf_bind.c:
##########
@@ -968,23 +960,20 @@ int libelf_bind(FAR struct module_s *modp,
                 loadinfo->dsymtabidx = i;
                 break;
               case SHT_INIT_ARRAY:
-                loadinfo->initarr = loadinfo->shdr[i].sh_addr -
-                                    loadinfo->datasec +
-                                    loadinfo->datastart;
+                loadinfo->initarr = libelf_addr(loadinfo,
+                                              loadinfo->shdr[i].sh_addr);

Review Comment:
   ditto



##########
libs/libc/elf/elf.h:
##########
@@ -356,4 +356,23 @@ int libelf_addrenv_restore(FAR struct mod_loadinfo_s 
*loadinfo);
 void libelf_addrenv_free(FAR struct mod_loadinfo_s *loadinfo);
 
 #endif /* CONFIG_ARCH_ADDRENV */

Review Comment:
   add blank line



-- 
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