This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re[2]: modify gcc to handle byteorder issue automatically
- From: Georgy Yunayev <Georgy dot Yunayev at kaspersky dot com>
- To: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- Cc: Gabriel Dos Reis <gdr at integrable-solutions dot net>, gcc at gcc dot gnu dot org
- Date: Mon, 21 Jul 2003 18:25:23 +0400
- Subject: Re[2]: modify gcc to handle byteorder issue automatically
- Organization: Kaspersky Lab
- References: <200307211330.h6LDUmsj031660@mururoa.inria.fr>
- Reply-to: Georgy Yunayev <Georgy dot Yunayev at kaspersky dot com>
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