@Dave, I need debug help. Could you please run foo.pdx.zip (4.8 KB) with debugger and tell me where it crashes and maybe why. Pleeeeeese
on-device only, no sim build there
@Dave, I need debug help. Could you please run foo.pdx.zip (4.8 KB) with debugger and tell me where it crashes and maybe why. Pleeeeeese
on-device only, no sim build there
For some reason the values in the relocation table are incorrect. The first entry actually points to itself. Later values point to other entries, corrupting their values, which then leads to crashing when the bad values are taken as offsets to apply the relocation to. So, first thing is we need to be validating the values in the relocation table and throwing an error if they don't point to actual code. Next is figuring out where those values came from in the first place. Can you send me the pdex.elf this was compiled from? It must be another elf format thing that we're not dealing with properly.
I can't find exactly that elf, but I can build new and it could be reproducible
What I mean:
This is not exactly that elf (source of previously attached pdex.bin),
but it built from that code, so mostly highly probably the same. Anyway I've attached entire build - elf + pdc's output: foo.pdx.zip (12.4 KB)
Thank you so much. Probably that's my wrong and not a pdc problem. I don't know. I just tried to build "executable" elf from rust with rustc+ld+arm-gcc-stdlib and it looks like bad idea but interesting case.
Anyway I can build correct binaries with your latest patched pdc - it work awesome! Espetially if not experimenting more
I just looking for a way to minimise size, it needed because LTO and stripping are suffer from relocations requirement. Not so heavy. But I know potentially best option - just to build executable using one toolchain including linker and std, not to mix lime me
So, it's not critical at this point now.
I agree with what you said about needing an input/output validation tool.
Input (elf, that goes to pdc) needs more validation and proper errors output.
Output of pdc needs validation to avoid regular testing on the hardware for example. It can be something like simulator or loader. It could be really useful on CI-testing too.
Also, what tools you are using to analyse relocation tables? "Just hands and head" is ok answer if it so, just interesting.
Thanks for the pdex.elf, and sorry it took me a while to check this out. My previous fix for pdex.elfs with multiple segments was to just look for the first segment with data in it, but somehow this pdex.elf has the text and data sections in different segments. So that's why the relocations were all outside of the output binary, we didn't copy the data section to the output.
Here's an updated build that copies all non-empty sections to the output binary: pdc.zip (793.9 KB) When I run the resulting pdx the screen is black, but it doesn't crash or hang. When I show and dismiss the menu I get "Paused!" and "Resumed!" in the console. It crashes when I quit to the launcher, with a message like "It's finally working!" Well, sort of..
Wow! Thank you so much!
Thatās the little test of allocations and relocations and thatās works finally! If so, thatās awesome I see a sea of opportunities.
Currently Iām in a little vacation because of health but later in a week Iāll test new pdc and improve build system. And then Iāll report about results here as soon as possible. Thank you Dave!
Dave, we are (I mean community) need a test plan for any produced elf, that could show validity without testing on hardware or disturbing you.
Also, what you think about opening source of pdc and pdex.bin format? It could be helpful for others. Is it possible at all?
Hi @dave, by any chance do you have a build of this pdc for Linux? I'm trying to help @fzzr test the changes, but I don't have a Mac. Thanks!
sure thing! Here's the Linux build: pdc.zip (248.9 KB)
And here's Windows, just for completeness: pdc.exe.zip (249.6 KB)
The bin folder in the Windows SDK has a bunch of dlls in it, not sure if any of those are required for pdc but I'd guess running this build from that folder would make it work.
Thanks! I see that pdc in SDK 2.0.1 has the segment fix, too.
I think that was the fix for multiple segments, but the 2.0.1 pdc will still break on elf files with text and data in different segments. I wonder how you wind up with an elf like that..
@Dave thank you so much! You're saving the rusty crab :))
Probably you could describe in details low-level requirements for elf structure such as sections, ordering, positions, reloc-table(s) format, etc... And so I and everyone can build exactly what needed to pass through pdc. Or maybe somehow release latest patched pdc from this thread?.. That would be incredibly cool!
By "build elf" I mean break apart and assemble what the pdc needs but better way would be your official support multi-sectioned elfs definitely .
No so, partially. It works for binaries that produced by current version of crank, but that isn't optimal. Better way is build exactly one bin with rustc/llvm and only one linker like it in my latest elf in the thread. So we're need (I mean we're very want and will be awesome if it happens) that latest patch with support various multiple sections/segments.
Also, I just put two little screencasts here
First one presents build & run bin (executable) using latest pathed pdc from this thread:
Second is same but about build & run in simulator:
I'm not a pro video editor, so pardon the quality
@dave I wrote you in a private message, please take a look.
Got it, sent a reply!
Right now that latest pdc patch is targeted for 2.1.3, which is gonna be a while. As far as I remember, the current pdc version needs all data and text in the same segment, but it doesn't need to be the first segment like it did in 2.0.
Unfortunately I do not see your reply. Perhaps I donāt understand how DM works in this forum engineā¦
Here it is.
About pdc - thatās awesome news. I will wait so much as needed and will play more with current version.
looks like I forgot to hit the send button
@dave
Dave, could you explain what changes are in the pdc related to this topic? I mean is there multisectioned elfs support in the 2.0.3 pdc ?
2.0.1 introduced a fix for elf files with multiple segments, but it still doesn't work if text and data sections are in different segments. I have a fix for that in the queue, but it's marked low priority so it's not schedule to show up for a while.
Thank you!
Dave, could you tell me what would influence the prioritization of this task?
@dave
Finally! Seems to I've fixed it!
Attached elf linked with attached modified linker-script where I added just one PH.
So actual PDC (2.4.2
) can deal with it. And it works!
I'm not sure that link-map is optimal.
I don't know where to put relocation table, so I've commented RELOC_TABLE_START
and tell linker "just put it somewhere after". That's not good.
Well, ideally I need to defy RELOC_TABLE_START
or replace it with a real fixed address.
Currently (without it) reloc-table placed randomelly after everything including BSS, and also there will bunch of zeros in the binary .
Also BSS I would place after everything of course, and address set it to overwrite the relocation area after they are worked out.
All of it depends on what loader expecting and how it works of course. So Dave, I ask your recomendations. Please.
solution.zip (6.0 KB)
ā
And anyway Iām sure that this my āmerge all PH in oneā is terrible solution. So could be better in some far future to have āfullā support of multi-sectional multi-segmental elf in PDC and loader.