modify gcc to handle byteorder issue automatically
Georgy Yunayev
Georgy.Yunayev@kaspersky.com
Mon Jul 21 16:35:00 GMT 2003
Hello Theodore,
TP> I'm using something like the following...
TP> Very crude but may serve as a basis.
Well, probably I need to clarify my question.
It is not a problem to _write_ a code, which will work on any-endian
architecture. However it _is_ a problem when you already have a lot of
written code, and just need to make it running on different-endian
arch. Moreover, sometime it would be wiser not to alter anything in
existing code, but in just a compiler. Not only because a lot of
required work, but because the existing code is stable, working (at
least on some arch), and modification will introduce new bugs,
difficult to fix.
I've thought a lot about it. Note that such change will mean that ANY
word/dword will be put in converted order. Here are some possible
problems:
1. Storing a DWORD in void*, and obtaining it via DWORD*. Value will
be converted. union { void * a; dword * b } is an another example.
2. Getting (via dereferencing) any value set by a system call, or
giving a stored dword value to a system call (3rd argument for
accept(), for example). Probably the most simple example is errno.
In my case, only problem 1 is serious. This code doesn't call any
system calls, so it won't be a problem.
So I need to modify a compiler itself. What is the best way to do
this?
Best regards, Tim
More information about the Gcc
mailing list