From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Wed, 8 May 1996 15:15:09 -0500 (CDT) From: Richard Henderson Subject: Re: gdb [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~