casaroli opened a new pull request, #20807:
URL: https://github.com/apache/nuttx/pull/20807

   ## Summary
   
   crt0 passes the environment to `main()` as its third argument (321105a3b4d), 
so every ELF program refers to `get_environ_ptr()`. The system symbol table 
(`CONFIG_EXECFUNCS_SYSTEM_SYMTAB`), which is made from `libs/libc/libc.csv`, 
does not have it. So no ELF program can be loaded with that table:
   
   ```
   libelf_symvalue: ERROR: SHN_UNDEF: Exported symbol "get_environ_ptr" not 
found
   elf_loadbinary: Failed to bind symbols program binary: -2
   nsh: hello: command not found
   ```
   
   This PR adds `get_environ_ptr()` to libc.csv, and the other functions of the 
environment that were missing too: `clearenv()`, `getenv()`, `putenv()`, 
`secure_getenv()`, `setenv()` and `unsetenv()`. They have the condition that 
builds them, `!defined(CONFIG_DISABLE_ENVIRON)`.
   
   ## Impact
   
   Only builds that use the system symbol table: ELF programs can be loaded 
again, and they can use these functions. Seven more entries in the generated 
table.
   
   ## Testing
   
   `qemu-armv8a:nsh` (flat) under QEMU, with `CONFIG_ELF`, 
`CONFIG_EXECFUNCS_SYSTEM_SYMTAB` and two programs built as modules and loaded 
from a 9p share: `examples/hello`, and a test program that calls `setenv()`, 
`getenv()` and `unsetenv()` and checks the `envp` argument of `main()`.
   
   | | master | this PR |
   |---|---|---|
   | hello | `Exported symbol "get_environ_ptr" not found` | `Hello, World!!` |
   | setenv/getenv/unsetenv test | `Exported symbol "get_environ_ptr" not 
found` | PASS |
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


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