Read as many ELF sections as possible.#35
Conversation
pydgin/elf.py
Outdated
|
|
||
| if section_name not in ['.sbss', '.bss']: | ||
| if (shdr.type == ElfSectionHeader.TYPE_NULL or | ||
| section_name == '.comment' or |
There was a problem hiding this comment.
Is it necessary to check against section names? I believe these sections have their ALLOC flag unset, and it would be better to use that to prevent them from loading. You can check the ALLOC flags of the sections using readelf -a.
There was a problem hiding this comment.
Good question. The section I needed was loader_cfg which, bafflingly, didn't have its ALLOC flag set.
There was a problem hiding this comment.
Hmm, I'm a bit worried this might break other ISAs since they sometimes have other sections which shouldn't be loaded and can corrupt other sections if loaded. Unfortunately Travis might not catch these since assembly tests we use in Travis might not have those ELF sections. I'm not an expert on ELF format but maybe this is a bug in their cross-compiler and ISS? Is this section supposed to be executable or just data?
There was a problem hiding this comment.
It could well be a bug in their format. I'm pretty sure this location contains some data. I'll try reporting this as an issue on one of the Epiphany repos and see what happens.
There was a problem hiding this comment.
I think in the meanwhile, you can hard-code this exception (with a good comment) and still check against FLAGS_ALLOC. Maybe change this with something like:
if (not (shdr.flags & ElfSectionHeader.FLAGS_ALLOC) and
section_name != 'loader_cfg'):
continue|
This approach doesn't seem to work for other ISAs as indicated by Travis. I'll try to figure out how to do this correctly one of these days but haven't gotten the chance yet. Did this patch fix the issue in Revelation? |
|
I did a bit more digging around the e-loader code from Adapteva, and it looks like the So, the short story is that I have a work-around for all this in Revelation, so no need to change the Pydgin code upstream. Thanks for checking though! |
This worked with the Revelation simulator, but I have not tested it with the other Pydin simulators.
Reading in the
.debug,.commentor.stabsections caused problems with Epiphany ELFs, and I did find an "unknown" section type, so the check for that was necessary. Uncommenting the later code to read in the symbol table worked fine, but I haven't included that in this PR.