Related articles |
---|
C code validation service derek@knosof.co.uk (1996-07-15) |
Re: C code validation service egbert@torch.timeplex.com (1996-07-19) |
getting symbolic C structure offsets (was: Re: C code validation servi thornbur@theory.physics.ubc.ca (Jonathan Thornburg) (1996-07-27) |
Re: getting symbolic C structure offsets (was: Re: C code validation s rfg@monkeys.com (1996-07-31) |
From: | Jonathan Thornburg <thornbur@theory.physics.ubc.ca> |
Newsgroups: | comp.compilers |
Date: | 27 Jul 1996 21:42:50 -0400 |
Organization: | U of British Columbia / Physics |
References: | 96-07-102 96-07-124 |
Summary: | c2ph (comes with perl) gives nice access to C structures |
Keywords: | C, assembler |
Stephen Egbert <egbert@torch.timeplex.com> asked for an
| [...] extended preprocessor (GNU cpp or otherwise) that
| can translate the C-styled structure offset for uses with assembly code
| using symbolic offset.
and our esteemed moderator commented
| I'd think you could hack something up by running the structure def
| through cc -g -S and using a perl script to extract the info from the
| .stabs entries into defines for your assembler code. [...]
I'm not quite sure if this is what Stephen was looking for, but the
very hack our moderator suggested comes as a standard utility with
perl, under the name 'c2ph', a.k.a. 'pstruct'.
As 'pstruct', this prints a nicely formatted table of C structure
types, member names, offsets, and lengths. As 'c2ph', it provides
pack/unpack formats and metainformation so perl code can easily
manipulate in-memory C structures.
From here, it's an SMOP (presumably in perl) to generate symbol
definitions, cpp #defines, or <your favorite syntax> to pass this
information to assembly programs.
- Jonathan Thornburg <bkis@island.net> (personal E-mail)
U of British Columbia / Physics Dept / <thornbur@theory.physics.ubc.ca>
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.