Detecting wrong linkage on mips PIC code
Maciej W. Rozycki
macro@linux-mips.org
Thu Jun 23 17:03:00 GMT 2005
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
More information about the Binutils
mailing list