> -----Original Message-----
> From: Byron Ellacott <b...@the-wanderers.org>
> Sent: Friday, March 12, 2021 9:02 PM
> To: dev@nuttx.apache.org
> Subject: Symbol tables, ELF binaries, and mksymtab
> 
> Hi,
> 
> I've been working on ELF binary loading for the eZ80. I'm compiling with 
> CONFIG_SYSTEM_NSH=m to produce a stand-alone nsh binary.
> 
> I'm finding the symbol tables (both the one generated in libs/libc with 
> CONFIG_EXECFUNCS_SYSTEM_SYMTAB=y and the one generated in
> apps) to be wrong when it comes to C functions having a prepended underscore 
> - the system symtab doesn't prepend an underscore, so all
> symbol lookups fail.
> The apps symtab does prepend an underscore to its "extern" definitions, so 
> any use of that symbol table fails with undefined external
> references.
> 
> Is this a configuration issue on my end?
> 

No, it seem that mksymtab forget to handle the case you described.

> I've modified tools/mksymtab to (a) prepend an underscore to the symbol's 
> name, and (b) prepend an "&" to the symbol's value. The latter
> change allows exporting global variables like optarg and optind - I've also 
> added a number of missing symbols to syscall/syscall.csv and
> libs/libc/libc.csv.
> 
> I can now boot a NuttX kernel with no shell and successfully execute nsh from 
> SD card after my changes, but before I start making PRs I'd
> like to understand if the difficulties I've faced are a PEBKAC issue or 
> something others encounter.
> 

Most people try ELF loader on ARM and RISCV platform, both don't pretend an 
underscore to the symbol's name. So you may the first people encounter this 
mismatch issue☹.

> (I'll also be contributing the Z80 elf loader, but it's not useful if you're 
> using ZDS-II.)
> 
> --
> Byron

Reply via email to