This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Detecting wrong linkage on mips PIC code
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: Atsushi Nemoto <anemo at mba dot ocn dot ne dot jp>
- Cc: binutils at sources dot redhat dot com
- Date: Thu, 23 Jun 2005 18:01:37 +0100 (BST)
- Subject: Re: Detecting wrong linkage on mips PIC code
- References: <20050624.013244.93017716.anemo@mba.ocn.ne.jp>
On Fri, 24 Jun 2005, Atsushi Nemoto wrote:
> This simple queer program does not work on mips-linux if compiled with
> -O2 option. It works if compiled with -O. I'm using gcc 3.4.4 and
> binutils 2.16.1.
>
> int main(int argc, char **argv)
> {
> static long int random(void);
> random();
> return 0;
> }
>
> Declaring random() as a static function is definitely wrong, but I
> wonder why none of gcc, as, or ld give me any error or warning.
[...]
> Is it possible to detect this sort of error when compiling or linking?
It is. With GCC 4.0.0 I get:
static.c: In function 'main':
static.c:3: error: invalid storage class for function 'random'
Also this program, which is similarly incorrect:
long int random(void);
int main(void)
{
random();
return 0;
}
static long int random(void)
{
return 0;
}
compiles to bad code with GCC 3.4.x and is rejected by 4.0.0.
Maciej