eerimoq / bincopy

Mangling of various file formats that conveys binary information (Motorola S-Record, Intel HEX, TI-TXT, Verilog VMEM, ELF and binary files).
MIT License
109 stars 38 forks source link

Invalid section from ELF file #32

Closed Gargy007 closed 1 year ago

Gargy007 commented 1 year ago

The BINCOPY create invalid section from ELF file. The ELF file is created in NXP MCUXpresso compiler.

The SREC from BINCOPY contains additional (probably irrelevant) data Observation: the output contains some data at 0x8000000, while the image is located at 0x80002000.

Used OBJCOPY to validate result: arm-none-eabi-objcopy.exe -O srec evkbimxrt1050_iled_blinky_sdram.axf evkbimxrt1050_iled_blinky_sdram.srec Use BINCOPY to unify S record output to simplify comparison: bincopy convert -i srec -o srec .\evkbimxrt1050_iled_blinky_sdram.srec .\evkbimxrt1050_iled_blinky_sdram.s19

Observation: no data at 0x8000000, the code starts at 0x80002000

Procedure to reproduce:

eerimoq commented 1 year ago

Should be fixed now. Version 17.14.2.

Gargy007 commented 1 year ago

Hello, great, it works. One more time - THANK you.

Petr

po 13. 2. 2023 v 19:12 odesílatel Erik Moqvist @.***> napsal:

Should be fixed now. Version 17.14.2.

— Reply to this email directly, view it on GitHub https://github.com/eerimoq/bincopy/issues/32#issuecomment-1428426609, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS2LTGXHB7EJFTDIRK7UKTWXJ2PZANCNFSM6AAAAAAU2GIDQA . You are receiving this because you authored the thread.Message ID: @.***>

Gargy007 commented 1 year ago

Hi Erik, bad news , I run other tests and some other ELF files became problematics.

Please check for example file in attachment, bincopy adds to result Srec or binary RAM section:

[image: image.png]

This part should not be here :-(

Thank you for your look.

Petr

út 14. 2. 2023 v 6:51 odesílatel Petr Gargulak @.***> napsal:

Hello, great, it works. One more time - THANK you.

Petr

po 13. 2. 2023 v 19:12 odesílatel Erik Moqvist @.***> napsal:

Should be fixed now. Version 17.14.2.

— Reply to this email directly, view it on GitHub https://github.com/eerimoq/bincopy/issues/32#issuecomment-1428426609, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABS2LTGXHB7EJFTDIRK7UKTWXJ2PZANCNFSM6AAAAAAU2GIDQA . You are receiving this because you authored the thread.Message ID: @.***>

eerimoq commented 1 year ago

The image is missing. Also, please add a problematic elf-file and correct corresponding srec so I can add a test.

Gargy007 commented 1 year ago

Sorry , I reply by email and this way remove as picture as attachment :-(

Problematic section in srec: image

gcc.zip

eerimoq commented 1 year ago
$ readelf -S -W gcc.elf
...
  [ 7] .data             PROGBITS        1fff0000 020000 00006c 00  WA  0   0  4
...

Looks like that part should be included in the srec.

Gargy007 commented 1 year ago

This part cannot be included in programming script - those addresses are in RAM. And top of that bincopy-17.14.0 doesn't do that. In this version the Bincopy handle this file correctly.

eerimoq commented 1 year ago

Please try latest commit on master branch. I implemented it in a hurry, so it is probably not correct. Feel free to submit a PR if you can figure out how to fix it.

Gargy007 commented 1 year ago

Something gets better , something is worse :-(

I created golden set and examples of elf file and it binary images, maybe it's helps ... gold_samples_bincopy.zip

Test case is easy just convert provided ELF file to binary and compare to provided "good" results.

eerimoq commented 1 year ago

Did youu test with latest master?

Den tis 14 feb. 2023 12:53Gargy007 @.***> skrev:

Something gets better , something is worse :-(

I created golden set and examples of elf file and it binary images, maybe it's helps ... gold_samples_bincopy.zip https://github.com/eerimoq/bincopy/files/10732035/gold_samples_bincopy.zip

Test case is easy just convert provided ELF file to binary and compare to provided "good" results.

— Reply to this email directly, view it on GitHub https://github.com/eerimoq/bincopy/issues/32#issuecomment-1429618114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABLFKWU5K6QI4ILA6CFJ23WXNW4JANCNFSM6AAAAAAU2GIDQA . You are receiving this because you commented.Message ID: @.***>

Gargy007 commented 1 year ago

Yes I did :-( Just take a look at sizes of binary - *_bincopy.bin versus golden samples that I already sent:

image

eerimoq commented 1 year ago

gcc and iar looks good in latest release (17.14.3). Not sure about keil. Seems like a data section is missing in the output file.

Gargy007 commented 1 year ago

Hello, as you wrote, IAR, GCC is OK but KEIL is not :-( .

I retest BINCOPY 17.14.0 version and under that all three compilers works fine. It will be great to find combination that all those three golden samples works fine and also the original use case from this issue.

https://github.com/eerimoq/bincopy/files/10732035/gold_samples_bincopy.zip https://github.com/eerimoq/bincopy/files/10722283/bincopy.zip

eerimoq commented 1 year ago

Any chance you can help out trying to fix the issue? It's just a few lines of code to extract data from elf-files, so should be easy to understand and edit. Just have a look at the changes in the last couple of commits. I think more test cases are key to making this work. Also, reading the ELF specification and possibly compiler/linker quirks. Maybe KEIL has some section that is not according to ELF spec. Not sure.

Gargy007 commented 1 year ago

Let me solve some own issues :-) and I try to look at it

eerimoq commented 1 year ago

Give 17.14.5 a try.

Gargy007 commented 1 year ago

Today morning I wanted to try to find the issue, but you was faster.

This version works on all my samples. Thanks

eerimoq commented 1 year ago

I'm sure more issues will appear. It's probably impossible to make it work for all toolchains and linker scripts.