Development on Big-Endian Platforms
Development on Big-Endian Platforms
I discovered a minor issue with bin2o, bin2c, and bin2s. While a great tool, they are written solely for little-endian use. So, when you use these tools on a big-endian system, such as PPC, it creates a byte swapped version of the IRX, which is wrong. Because of this, no IRX merged into an ELF on a PPC system will load on the PS2. I have made a couple of changes to bin2s which makes it platform neutral (but the resulting .s file is much larger, since it simply defines a series of bytes, rather than words). I am doing a couple of things to get the size back down a little, but retain the platform neutrality. Also, I am working on similar patches for bin2o and bin2c.
Also, there are a few module calls in the IOP section of PS2SDK which aren't entirely wired up yet (import stub missing declaration in a header, or vice versa). I have wired up a few of these, and would also like to submit the patch for these as well.
Who should I send the patch to for submission into CVS if it is useful? ;)
Also, there are a few module calls in the IOP section of PS2SDK which aren't entirely wired up yet (import stub missing declaration in a header, or vice versa). I have wired up a few of these, and would also like to submit the patch for these as well.
Who should I send the patch to for submission into CVS if it is useful? ;)
As a fellow PPC'er (and there are quite a few of us around) I feel for ya, I run into the same thing alot too. ;)
The main thing is, the x86 architecture is the more common development platform, and it fortunately it is already little-endian. So when people write little utilities that are intended to execute *on* the dev platform, endianness isn't always realized as an important consideration while coding.
Us PPC'ers need to stand tall and beat up the little guys. :)
The main thing is, the x86 architecture is the more common development platform, and it fortunately it is already little-endian. So when people write little utilities that are intended to execute *on* the dev platform, endianness isn't always realized as an important consideration while coding.
Us PPC'ers need to stand tall and beat up the little guys. :)
Oh, Oopo didn't mention that thick skin is required on the irc channel. The people on #ps2dev are actually very nice folx, in a playfully trolling sort of way. ;)ooPo wrote:... you can pop by the irc channel (#ps2dev on efnet) and either ask for cvs write access or for someone to test/merge for you.
GRrouummpff?gorim wrote:Oh, Oopo didn't mention that thick skin is required on the irc channel. The people on #ps2dev are actually very nice folx, in a playfully trolling sort of way. ;)
Okay, seriously, post your patch here, or give it to some random cvs-writer guy in IRC, that'll be commited asap.
But, that doesn't affect bin2c, does it ? Only bin2s should be affected.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
Heh, whadda know, it is. Hmm, seems like there was something else interfering, or I was using the wrong nm (dear god, I realized I have over 8 gcc toolchains on this machine, with only ONE per platform, *shudder*). bin2o seems to be working again... odd. Ignore my bin2o complaints. :)
bin2s is still borked, but not for long. It was a pretty simple patch. ;)
Anyways, the patches of work I have done so far... isn't much:
bin2s diff
iop sources diff
bin2s is still borked, but not for long. It was a pretty simple patch. ;)
Anyways, the patches of work I have done so far... isn't much:
bin2s diff
iop sources diff
Code: Select all
fprintf(dest, "\n\t.byte 0x%02x,0x%02x,0x%02x,0x%02x",
buffer[i], buffer[i+1], buffer[i+2], buffer[i+3]);
wrong order.
however this works for me:
Code: Select all
fprintf(dest, "\n\t.byte 0x%02x,0x%02x,0x%02x,0x%02x",
buffer[i+3], buffer[i+2], buffer[i+1], buffer[i]);
perhaps it would be best to use one of the functions from arpa/inet.h?
ok this works great, thanks gorim
Code: Select all
diff -u bin2s.c le32_bin2s.c
--- bin2s.c Wed Apr 13 12:40:10 2005
+++ le32_bin2s.c Wed Apr 13 12:40:49 2005
@@ -19,6 +19,15 @@
unsigned char *buffer;
+/* For endian neutrality */
+u_int32_t le32(u_int32_t bits)
+{
+ u_int8_t *bytes;
+ bytes = (u_int8_t*)&bits;
+ return(bytes[0] | (bytes[1]<<8) | (bytes[2]<<16) | (bytes[3]<<24));
+}
+
+
int main(int argc, char *argv[])
{
int fd_size;
@@ -65,8 +74,8 @@
fprintf(dest, "%s:\n\n",argv[3]);
for(i=0;i<fd_size;i+=4) {
- if((i % 16) == 0) fprintf(dest, "\n\t.word 0x%08x", *(int*)&buffer[i]);
- else fprintf(dest, ", 0x%08x", *(int*)&buffer[i]);
+ if((i % 16) == 0) fprintf(dest, "\n\t.word 0x%08x", le32(*(int*)&buffer[i]));
+ else fprintf(dest, ", 0x%08x", le32(*(int*)&buffer[i]));
}
fprintf(dest, "\n");