casaroli commented on code in PR #19938:
URL: https://github.com/apache/nuttx/pull/19938#discussion_r3842104418
##########
binfmt/elf.c:
##########
@@ -286,6 +290,28 @@ static int elf_loadbinary(FAR struct binary_s *binp,
}
#endif
+#ifdef CONFIG_BINFMT_CONSTRUCTORS
+ /* Run the constructors, as libelf_insert() does for dlopen(). A module
+ * with a PIC base is skipped: this task holds its own base, not the
+ * module's.
+ */
+
+ if (binp->picbase == NULL)
+ {
+ array = (FAR void (**)(void))loadinfo.preiarr;
Review Comment:
cortex-m cannot use crt0. `CONFIG_BINFMT_ELF_EXECUTABLE` depends on
`ARCH_HAVE_ELF_EXECUTABLE`, and no armv7-m or armv8-m chip selects it. only 13
chips do, and almost all of them have an MMU: mpfs, qemu-rv, k230, eic7700x,
two litex cores, qemu and goldfish cortex-a7, four arm64 chips, x86_64.
so crt0 is the address environment case. i already skip it: `ET_EXEC` is
skipped, and so is any build with `CONFIG_ARCH_ADDRENV`.
what is left is flat and relocatable. no crt0, no _start, binfmt jumps to
`e_entry`, nothing runs `.init_array`. I think that is the case
`CONFIG_BINFMT_CONSTRUCTORS` was written for, but it does not work today.
a startup object in the relocatable output would work, and binfmt would
enter it instead of main. i can do that if you want (in separate PR?), should
relocatable elf lose its constructors until then?
--
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]