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


##########
libs/libc/elf/elf_bind.c:
##########
@@ -909,7 +970,37 @@ static int libelf_relocatedyn(FAR struct module_s *modp,
                       addr += rela->r_addend;
                     }
 
-                  *(FAR uintptr_t *)addr = (uintptr_t)ep;
+                  if (loadinfo->fdpic)
+                    {
+                      /* Under FDPIC an import may be a descriptor,
+                       * which is built rather than assigned, so let the
+                       * relocation type decide what to write.
+                       */
+
+                      Elf_Sym extsym =
+                      {
+                        0
+                      };
+
+                      extsym.st_value = (uintptr_t)ep;
+
+                      ret = up_relocate(rel, &extsym, addr,
+                                        ARCH_ELFDATA_PARM);
+                      if (ret < 0)
+                        {
+                          berr("ERROR: Section %d reloc %d: "
+                               "Relocation failed: %d\n",
+                               relidx, i, ret);
+                          lib_free(sym);
+                          lib_free(rels);
+                          lib_free(dyn);
+                          return ret;
+                        }
+                    }
+                  else
+                    {
+                      *(FAR uintptr_t *)addr = (uintptr_t)ep;
+                    }
                 }
               else if (loadinfo->fdpic)

Review Comment:
   but no change here?



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