From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,edf564ae009c8992 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-01-17 20:02:19 PST Path: gmd.de!newsserver.jvnc.net!darwin.sura.net!jhunix.hcf.jhu.edu!jhunix.hcf.jhu.edu!not-for-mail From: philippe@jhunix.hcf.jhu.edu (Philippe Pouliquen) Newsgroups: comp.unix.osf.osf1 Subject: Re: Alpha Assmebly question: LDQ_U r31_zero,0(r30_sp) showing up?! Date: 17 Jan 1994 22:20:36 -0500 Organization: Homewood Academic Computing, Johns Hopkins University, Baltimore, Md, USA Distribution: world Message-ID: <2hfki4INNj0h@jhunix.hcf.jhu.edu> References: NNTP-Posting-Host: jhunix.hcf.jhu.edu In article asah@cs.Berkeley.EDU (Adam Sah) writes: > >What does the following alpha assembly instruction _do_? > >LDQ_U r31_zero,0(r30_sp) > >According to the manual, it reads the memory address out of stack pointer, > masking over misalignment, and drops it off in the bit bucket, without > changing r30_sp. > >In other words, nothing. > >And yet, I see this pop up all the time when I examine code output from the > C compiler, both gcc as well as native cc. > >What am I missing? > > >-- >Thanks again, >-A.Sah'94 ...Adam Sah...asah@cs.Berkeley.EDU... > Only ask yourself questions that you can find answers to. I don't know. :-) But I do have a some guesses. The instruction may be an expensive NOP. Or it could be some technique required to flush a buffer of some sort on the CPU. Or it might be a way of testing the stack pointer to make sure its valid (not pointing to 'invalid' space). Consider the following: - User program messes with the stack pointer. - User program does a system call. - Kernel uses user stack to get system call arguments and ends up making the user program uid root (because the stack pointer pointed to where the kernel stores the user programs uid in the user space.) A quick test of the stack pointer before a system call would prevent this. (However, if you coded things up in assembler, bypassing cc and libc, you could get around it.) As far as 'gcc' goes, it uses 'cc' to generate code for things that 'it doesn't already know how to do'. Therefore, 'gcc' might simply be incorporating code produced by 'cc'. Philippe Pouliquen philippe@zeus.ece.jhu.edu