Skip to content

tools/mkimport: Add system map to mkimport script.#1816

Merged
xiaoxiang781216 merged 1 commit intoapache:masterfrom
motec-research:pr/fix-system-map
Jun 30, 2023
Merged

tools/mkimport: Add system map to mkimport script.#1816
xiaoxiang781216 merged 1 commit intoapache:masterfrom
motec-research:pr/fix-system-map

Conversation

@g2gps
Copy link
Copy Markdown
Contributor

@g2gps g2gps commented Jun 29, 2023

Summary

The make export target from the Nuttx repository correctly packs the System.map file. This change ensure that ./tools/mkimport.sh extracts this file correctly into the importcorrectly.

Impact

The System.map file is now available in the import directory for applications to build against.

Testing

$ cd nuttx
$ ./tools/configure.sh rv-virt:knsh32:knsh
$ make
$ make export
$ cd ../apps
$ ./tools/mkimport.sh -z -x ../nuttx/nuttx-export-*.tar.gz
$ ls import
include  libs  Make.defs  Makefile  scripts  startup  System.map  tools

Notice the addition of the System.map file.

The `make export` target from the Nuttx repository correctly packs the
System.map file. This change ensure that ./tools/mkimport.sh extracts
this file correctly into the `import`correctly.
Copy link
Copy Markdown
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thanks @g2gps :-)

@patacongo
Copy link
Copy Markdown
Contributor

I am wondering. The export package for a FLAT build contains only libraries, header files, and misc. build files. True? I does not contained the fully linked executable, does it? The System.map provides addresses for some linked binary that is not included in export package.

If all of that is true, then when you link your files to create a custom application, that old System.map may not be valid. I feel like I am missing something.

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Jun 29, 2023

I am wondering. The export package for a FLAT build contains only libraries, header files, and misc. build files. True? I does not contained the fully linked executable, does it? The System.map provides addresses for some linked binary that is not included in export package.

If all of that is true, then when you link your files to create a custom application, that old System.map may not be valid. I feel like I am missing something.

Greg, your original "make export" used to export the System.map, please take a look at the Makefile from elfprog-nosymtab.tar.gz : https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629542

Maybe the functions map could be loaded using another approach, what do you suggest?

@acassis
Copy link
Copy Markdown
Contributor

acassis commented Jun 29, 2023

@g2gps this is the error when loading the elf-nosym hello example:

NuttShell (NSH) NuttX-12.1.0
nsh> ls /dev
/dev:
 console
 null
 sda
 ttyS0
nsh> hello
Hello, World!!


nsh> mount -t vfat /dev/sda /bin
nsh> ls /bin
/bin:
 Testing/
 hello.txt
 hello
nsh> hello
elf_symname: Symbol has no name
elf_symvalue: SHN_UNDEF: Failed to get symbol name: -3
elf_relocate: Section 2 reloc 0: Undefined symbol[0] has no name: -3
_assert: Current Version: NuttX  12.1.0 9603288c80-dirty Jun 26 2023 20:01:55 arm
_assert: Assertion failed panic: at file: :0 task: hello 0x200033c8
up_dump_register: R0: 00000001 R1: 20004948 R2: 20004948  R3: 00000001
up_dump_register: R4: 200033c8 R5: 00000001 R6: 20004948  FP: 00000000
up_dump_register: R8: 00000000 SB: 00000000 SL: 00000000 R11: 00000000
up_dump_register: IP: 00000000 SP: 20005120 LR: 0800508f  PC: 200033c8
up_dump_register: xPSR: 80000000 PRIMASK: 00000000 CONTROL: 00000000
up_dump_register: EXC_RETURN: fffffff9
dump_stack: User Stack:
dump_stack:   base: 0x20004958
dump_stack:   size: 00002008
dump_stack:     sp: 0x20005120
dump_tasks:    PID GROUP PRI POLICY   TYPE    NPX STATE   EVENT      SIGMASK          STACKBASD
dump_task:       0     0   0 FIFO     Kthread N-- Ready              0000000000000000 0x20000dk
dump_task:       1     1 224 RR       Kthread --- Waiting Semaphore  0000000000000000 0x200021c
dump_task:       3     3 100 RR       Kthread --- Waiting Semaphore  0000000000000000 0x200039t
dump_task:       4     4 100 RR       Task    --- Waiting Semaphore  0000000000000000 0x200041n
dump_task:       6     6 100 RR       Task    --- Running            0000000000000000 0x200049

If you go back to 7.25 and follow my video you will see that it works

@patacongo
Copy link
Copy Markdown
Contributor

Greg, your original "make export" used to export the System.map, please take a look at the Makefile from elfprog-nosymtab.tar.gz : https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=139629542

I suppose this depends on how you are using the export. If you export the libaries, headers, and build files and then build a new FLASH image, the old System.map is useless.

In that case, you should run nm against to the new binary to generate the System.map.

But you all are right. If you build the FLASH image then just want to build ELF modules later to match the symbols in the FLASH image, then the System.map is still valuable and useful.

I concede that. I had the first use case in mind when I commented.

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

So, let's merge this patch.

@xiaoxiang781216 xiaoxiang781216 merged commit 3e8f7e3 into apache:master Jun 30, 2023
@g2gps g2gps deleted the pr/fix-system-map branch July 21, 2023 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants