Conversation
philipc
left a comment
There was a problem hiding this comment.
This is a bit too basic. When adding support for an ELF architecture, I prefer for there to be enough support so that it can be added to the test in
object/tests/round_trip/mod.rs
Line 260 in 975587b
|
Ok I've added a little reloc support so that the test passes. How do people normally develop the reloc support? I don't see a ton of info about SuperH relocs, this it the best doc I've found but it's missing a decent amount of them. https://www.st.com/resource/en/reference_manual/rm0197-sh4-generic-and-c-specific-application-binary-interface-stmicroelectronics.pdf |
|
The best way is to do it in parallel with something that uses this crate and needs the support. Usually architectures have been added here because rustc needs them to compile for that target, so the relocation support is tested as part of that. Tests that use object-testfiles are more for regression testing, and don't do much to check that you got it right in the first place. The relocation support you've added looks correct to me. I'm not very familiar with SuperH, so I have a couple of questions. Is this support only for SH-4? Should we use that as the architecture name instead so that other SuperH variants can be added later if needed? Is big-endian the most common byte ordering that is used? |
|
I dumped the file I'm looking at with objdump and this PR and it seems like the current implementation is good enough for the file I'm currently looking at: https://gist.github.com/sozud/b5eb8fd740810dc7b056c5de0a73d32d So I've been looking at SH2 support for objdiff https://github.com/encounter/objdiff |
|
After looking more, I see that SH2 vs SH4 etc is distinguished using the ELF flags ( |
No, the commonly used byte ordering on SuperH is little-endian. Both the Sega 32X and Saturn are rather obscure targets. Both little- and big-endian should be supported. PowerPC is similar in this regard and it just commented out the endianess parts in |


I'm not sure how correct this is but this seems to be enough to allow SuperH architecture ELFs to be opened.