lkml.org 
[lkml]   [2000]   [Aug]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: exporting struct offsets to assembler
Back when I worked on the HPRT (HPs PA risk real time system) I solved
this problem by embedding a C program in the asm code. To asm it looked
like macros so ccp stripped it out. The make rule (a real monster)
stripped out the C program, ran it and set its output down as an xxx.h
file which the asm code then included. The result was fresh symbol
offsets, etc. but it was UGLY.

There are two draw backs to these proposals/ implementations, that I
see:

1. They require one or more extra sources that must track the using
code. HPUX had (has?) an OS wide C program that defines all the symbols
for asm. Same problem, as symbols come and go it becomes hard to
maintain this code.

2. The symbols are defined as globals. This means we need to be very
careful in how we name them to managed the global name pool. It also
tends to push one toward the one file approach to prevent/control dups.

The i386 branch of the tree has only one or two *.S files so I don't see
any of this as a big drawback here, however, other branches have a lot
more *.S files, leading to more confusion.

I assume OFFSETOF is evaluated by cc and not ccp. If it were otherwise,
we could get ccp to lay down the needed constants.

That said, I suspect that the C folks have hidden something in the
compiler that makes all this go away. If only we knew where/what it is.

Philipp Rumpf wrote:
>
> On Sat, Aug 05, 2000 at 10:09:11AM -0400, Michael Meissner wrote:
> > On Sat, Aug 05, 2000 at 05:21:51AM +0100, Philipp Rumpf wrote:
> > > On Sat, Aug 05, 2000 at 12:27:42PM +1000, Andrew Morton wrote:
> > > > It uses some compiler tricks to export the structure offset
> > > > into a global absolute symbol and uses that symbol in the
> > > > assembly code.
> > >
> > > So it introduces bogus symbols into System.map.
> >
> > Well use symbols that assembler will normally throw away (on most ELF ports,
> > these symbols begin with .L, on most coff/a.out ports, these symbols begin with
> > just L).
>
> Uhm, so you actually want to change entry.S lines like:
> movl %eax,EAX(%esp) # save the return value
> to:
> movl %eax,.LEAX(%esp) # save the return value
> ? That sounds seriously ugly.
>
> > > Or it can be avoided by using a header file that #defines the offsets -
> > > which is exactly what mips does and other architectures did until some
> > > time ago. See arch/mips/tools/offset.c.
> > >
> > > I think it would be a better idea to generate the offsets automatically
> > > and possibly in an architecture-independent way without falling back to
> > > using symbols.
> >
> > However, you don't want to write a program that prints out the offsets, since
> > then you are prohibiting building Linux with a cross compiler.
>
> Have you actually looked at offset.c ? It works fine with a cross-compiler,
> and so does the $(NM) and sed solution, I suspect.
>
> Philipp Rumpf

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:1.113 / U:0.132 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site