|Compiler independent symbol tables which preserve offsets firstname.lastname@example.org (1989-05-25)|
|From:||email@example.com (Rick 'Transputer' Stein)|
|Keywords:||symbol tables, offsets, psects, real-time monitor|
|Date:||25 May 89 18:40:19 GMT|
|Organization:||Ohio Supercomputer Center|
I have some questions about how a compiler constructs a symbol table.
My first question is:
1) Will a compiler "arbitrarily" move structure elements to enforce
alignment on a boundary?
2) If the compiler does move a structure element, does this imply that
the element no longer maintains the same offset value from the beginning
of the structure? Are all the other elements moved (rearranged) as well?
3) Is there a way, or even some general guidelines, for creating a
portable image of the symbol table, in the sense of knowing where
the variables are located in memory? By portable I mean that I can
create a data structure which contains sufficient elements and information
to describe the physical layout of a data psect without having detailed
or explicit knowledge of the compiler internals.
I'm asking these questions because I'd like to build a real-time monitor
for poking/peeking at global data. To do this, I believe that I must build
a data dictionary, where each entry is inserted into a psect. If I explicitly
organize the psect in this way, I know the byte offset of each variable,
its type, dimension, etc. from the psect head. When the psect is loaded
into memory, I can take the address of the psect head to determine the
physical address of the each psect member with some simple address arithmetic.
Can this monitor process, and the symbol table structure be built in a
compiler and machine portable way?
Richard M. Stein (aka Rick 'Transputer' Stein)
Concurrent Software Specialist @ The Ohio Supercomputer Center
Ghettoblaster vacuum cleaner architect and Trollius semi-guru
[C compilers have the right to lay out structures any way they see fit,
unless the ANSI committee changed the rules. In reality, I've never seen
a compiler do more than leave a hole in the structure to move up an element
that would otherwise be misaligned. All instances of a given kind of
structure are laid out the same way. You could probably make your code
somewhat parameterized to deal with machines that do or do not have alignment
rules, but I suspect you'll end up having to know more about what's going
on than you'd like. By the way, I assume that by psect you mean a writable
data segment. -John]
Return to the
Search the comp.compilers archives again.