This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [APPROVE?] Fix MIPS and PowerPC with GCC 3.x


On Thu, 2003-02-27 at 15:01, Bart Veer wrote:
> 1) make the C structures completely opaque, i.e. just a packed array
>    of the appropriate number of bytes. Of course we now need a way of
>    figuring out what that number of bytes should be. I suspect the
>    best way is to have a custom build step which compiles a special
>    C++ file containing stuff like:
> 
>        int sizeof_thread = sizeof(Cyg_Thread);
> 
>    The resulting assembler would then be processed by a Tcl script
>    which generates an appropriate kapidata.h.

Maybe an easier solution consists of having a C++ source file like:

#include <...>

extern "C" {
char TYPE_XXX_SIZE[sizeof (XXX)];
...
}

and a template C header template with lines like this:

#define WHATEVER_TYPE_XXX_SIZE @TYPE_XXX_SIZE@
...

and then a simple shell script that creates an instance of the header
file out of the object file resulting from compilation of the C++ file:

objdump=$1
template=$2
symfile=$3

eval `${objdump} -t ${symfile} | awk '
	$6 ~ "TYPE_XXX_SIZE" { print($6"=0x"$5) }
	...
	$6 ~ "TYPE_ZZZ_SIZE" { print($6"=0x"$5) }'`

cat ${template} | sed \
-e "s,@TYPE_XXX_SIZE@,${TYPE_XXX_SIZE},g" \
-e ... \
-e "s,@TYPE_ZZZ_SIZE@,${TYPE_ZZZ_SIZE},g"


I don't know however if the output of objdump is consistent between
architectures, but I think so.

-- 
rnf



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]