-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
picotool crashes when given an ELF built with embedded rust #39
Comments
$ readelf --sections pico_blinky.elf
There are 24 section headers, starting at offset 0x323f38:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .vector_table PROGBITS 10000100 000114 0000a8 00 A 0 0 4
[ 2] .boot2 PROGBITS 10000000 0001bc 000100 00 A 0 0 1
[ 3] .text PROGBITS 100001a8 0002bc 00d4f4 00 AX 0 0 4
[ 4] .rodata PROGBITS 1000d6a0 00d7b0 000f08 00 AM 0 0 16
[ 5] .data PROGBITS 20000000 00e6b8 000000 00 A 0 0 4
[ 6] .gnu.sgstubs PROGBITS 1000e5c0 00e6c0 000000 00 A 0 0 32
[ 7] .bss NOBITS 20000000 00e6c0 000004 00 WA 0 0 4
[ 8] .uninit NOBITS 20000004 00e6c0 000000 00 WA 0 0 4
[ 9] .debug_abbrev PROGBITS 00000000 00e6c0 00c97e 00 0 0 1
[10] .debug_info PROGBITS 00000000 01b03e 0d83ab 00 0 0 1
[11] .debug_aranges PROGBITS 00000000 0f33e9 00bae8 00 0 0 1
[12] .debug_str PROGBITS 00000000 0feed1 0e4805 01 MS 0 0 1
[13] .debug_pubnames PROGBITS 00000000 1e36d6 02ffd0 00 0 0 1
[14] .debug_pubtypes PROGBITS 00000000 2136a6 03c60d 00 0 0 1
[15] .ARM.attributes ARM_ATTRIBUTES 00000000 24fcb3 000032 00 0 0 1
[16] .debug_frame PROGBITS 00000000 24fce8 0215ec 00 0 0 4
[17] .debug_line PROGBITS 00000000 2712d4 07dc33 00 0 0 1
[18] .debug_loc PROGBITS 00000000 2eef07 000e33 00 0 0 1
[19] .debug_ranges PROGBITS 00000000 2efd3a 01e8b8 00 0 0 1
[20] .comment PROGBITS 00000000 30e5f2 00006d 01 MS 0 0 1
[21] .symtab SYMTAB 00000000 30e660 006570 10 23 1194 4
[22] .shstrtab STRTAB 00000000 314bd0 0000fd 00 0 0 1
[23] .strtab STRTAB 00000000 314ccd 00f268 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
y (purecode), p (processor specific) |
If it's asserting in |
I think it's an ordering issue. You always check against the lowest item in the map. |
I can confirm that sorting our sections fixes the crash. But you should probably tolerate sections that aren't in order (or at least give a better error than an assertion). |
yup this is a bug in the checking code, you can comment it out for now as a workaround - will fix it pretty soon |
@jonathanpallant Do you want to test the latest |
This is caused by the ELF binaries containing non-contiguous ranges which end / begin in the same flash erase page. Eg.:
Adding some diagnostic output printing the range_map entries shows:
Notice that there's a hole between When writing the last range, the code at https://github.com/raspberrypi/picotool/blob/master/main.cpp#L1854-L1860 will zero the whole erase block, causing the flash contents from This matches what I can see after dumping the resulting flash contents. |
Possibly a similar problem to raspberrypi/pico-sdk#762 ?
Hmmm, perhaps picotool contains a similar bug to pico-bootrom ? |
Just as a note: I wondered why the ELF files had those gaps between sections at all. |
@jannic any chance you can attach an ELF/UF2 with holes |
Sure: Flashing that file
|
merged into develop |
The text was updated successfully, but these errors were encountered: