Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <richard@atheist.tamu.edu>
Subject: Re: gdb
Date: Wed, 8 May 1996 15:15:09 -0500 (CDT)	[thread overview]
Message-ID: <m0uHFde-0001qDC@atheist.tamu.edu> (raw)

[My yall are talkative today -- this is about 5 messages cut up
and pasted back together, hopefully by topic.]

Linus> On Tue, 7 May 1996, Harald Koenig wrote:
Linus> > 
Linus> > does anyone have a patch for gdb which would allow to display the
Linus> > sybmolic destination of a JSR like this
Linus> > 
Linus> >           a77db248        ldq     t12, -19896(gp)
Linus> >           6b5b6c2a        jsr     ra, (t12), 0x12004c0e4
Linus> > 
Linus> > and other accesses via (gp) for the disassebmle or x/i instruction
Linus> > for a running process ?
Linus> 
Linus> Umm, while I agree that it might make it a lot easier to debug things
Linus> on the alpha, I hope nobody writes a patch like that for gdb. The
Linus> reason I hope that is that I hope that it will be unnecessary. The
Linus> _correct_ way to handle it is to never generate those d*mn instructions
Linus> in the first place. We need an optimizing linker that gets rid of them
Linus> and makes it into a single "bsr" instruction instead. 

Well, it would have been usefull for other things as well like

	ldq	t0,-1234(gp)
	stq	v0,0(t0)

What symbol is being modified?  However, I looked at this yesterday
and I do not believe that it is possible for the disassembler to get
hold of enough context to be able to make this work.

EricY> 	This wouldn't be a hard optimization, and in fact it would make
EricY> shared libraries a bit easier for those cases where you can safely call
EricY> without going through a PLT (i.e. we are not using up a valuable .got
EricY> slot for a pointer).  It would tend to be used for things like static
EricY> functions that we would want to do this in shared libs.   For normal
EricY> executables, it is more just a question of whether the branch is in 
EricY> range or not.

Are you thinking of performing the optimization if (1) we're doing
a static executable or (2) dynamic executable and (2a) the symbol is in
the library or (2b) it is out of range?

As Linus already mentioned, The static function call case is
already handled within gcc.

DMT> But if somebody starts to work on the linker optimizations proposed by
DMT> Linus, do keep in mind that the calling convention requires $27 (pv) to
DMT> point to the starting address of the called function.  It is possible to
DMT> avoid having to load $27 but only if the global pointer register has the
DMT> same value in the caller and the callee.  In that case, you'd have to skip
DMT> the prologue code that establishes the gp (normally the first two
DMT> instructions).

The position (and existance) of the gp load can be verified by noticing
the position and existance of the appropriate fixups.

Linus> Yeah, bit me when I did the gcc optimization, which was why I eventually 
Linus> decided that we can't do it with gcc at all for the normal case.

I am thinking that there is still room for the optimization in gcc.
In the form of a flag that forces a single gp and all code to fall
within a 23-bit window (8MB?).  

How are modules handled in the kernel right now?  Surely each module
has to have its own gp?  Is it feasable to have all modules mapped 
into the same 8MB window as the rest of the kernel, or do they need
to have their calls go through a the gp?

EricY> 	Actually, the .lita sections are generated by the assembler,
EricY> so the optimization would basically mean that there are unused portions
EricY> of the file.  The linker is just appending all of the .lita sections
EricY> that the assembler generates without removing duplicates, and without
EricY> compressing it.
EricY> 
EricY> 	Frankly, I have doubts as to whether it is really wise
EricY> to generate .lita at assembly time (it should be generated by the linker
EricY> as required, instead), but I am not yet sure whether it is possible to
EricY> defer creation of this section to the linker.

:-) I was thinking of asking you if you thought adding a new
relocation type to preclude the need for the assembler to
generate the lita section was a good idea.  I was thinking that
something like that was going to be necessary to do the GOT
compression we'd been talking about.

Linus> There are some other optimizations that it would be interesting if gcc
Linus> did: "known alignment byte and word fetch/store". There are cases where
Linus> you know the alignment of a byte or short value (when the access is
Linus> through a structure or union that has guaranteed alignment due to
Linus> other larger members), but gcc creates code for the generic byte load
Linus> case. For example: 

I've been thinking about this one too.  I'd also want to have gcc know how
to do something like

    unsigned long __attribute__((align(2))) * foo;

to say that foo points to a long aligned on a short boundary.  The
Architecture Manual points out that there are simpler ways to do 
loads that are "partially" aligned.

The implementation of this optimization will likely be a bit harder
than the previous though.

r~

             reply	other threads:[~1996-05-08 20:15 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-05-08 20:15 Richard Henderson [this message]
1996-05-09  8:23 ` gdb Harald Koenig
1996-05-09 16:04   ` gdb Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1999-08-29  0:09 gdb Larry Snyder
1999-08-30 12:07 ` gdb Max Weninger
1999-08-30 15:20   ` gdb Michal Jaegermann
1999-08-30 17:12     ` gdb Max Weninger
1999-08-30 18:19       ` gdb Wes Bauske
1999-08-30 20:15         ` gdb Michal Jaegermann
1999-08-31  8:56         ` gdb Max Weninger
     [not found] <m0uM6E7-0001thC@atheist.tamu.edu>
1996-05-22 11:45 ` gdb Jim Nance
     [not found] <Pine.SUN.3.91.960510085342.3960A-100000@edge.edge.net>
1996-05-17 15:56 ` gdb Harald Koenig
     [not found] <Pine.LNX.3.91.960509080842.11981C-100000@linux.cs.Helsinki.FI>
1996-05-09 15:43 ` gdb Richard Henderson
     [not found] <richard@atheist.tamu.edu>
1996-05-09 14:55 ` gdb Eric Youngdale
     [not found] <Pine.LNX.3.91.960508210447.27170G-100000@linux.cs.Helsinki.FI>
1996-05-09  8:16 ` gdb Harald Koenig
1996-05-09  4:34 gdb David Mosberger-Tang
1996-05-09  3:47 gdb Eric Youngdale
1996-05-09  5:29 ` gdb Linus Torvalds
1996-05-08 19:07 gdb Richard Gorton
1996-05-08 18:51 gdb Craig Burley
     [not found] <torvalds@cs.Helsinki.FI>
1996-05-08 17:19 ` gdb Eric Youngdale
1996-05-08 18:24 ` gdb Eric Youngdale
1996-05-08 17:53 gdb David Mosberger
1996-05-08 18:16 ` gdb Linus Torvalds
1996-05-07 14:23 gdb David Mosberger-Tang
1996-05-07 15:48 ` gdb Richard Henderson
1996-05-07  6:32 gdb Harald Koenig
1996-05-08 17:06 ` gdb Linus Torvalds
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox