https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63691

--- Comment #10 from Aaro Koskinen <aaro.koskinen at iki dot fi> ---
(In reply to Andreas Schwab from comment #9)
> You don't need a link test, you only need to check whether there is a
> reference to abort.

A simple test:

$ cat pr63691.c
void foo (int a, char *p)
{
        if (a == 0)
                return;
        *p = 1;
}
int main (int argc, char **argv)
{
        foo(argc, 0);
        return 0;
}
$ hppa-linux-gnu-gcc -nostdlib -O2 pr63691.c
/home/aaro/los/work/parisc/toolchain/lib/gcc/hppa-linux-gnu/4.9.2/../../../../hppa-linux-gnu/bin/ld:
warning: cannot find entry symbol _start; defaulting to 0000000000010054
/tmp/ccWAW31H.o: In function `main':
(.text.startup+0x14): undefined reference to `abort'
collect2: error: ld returned 1 exit status

abort() reference is gone if you compile GCC with the patch
Dave posted here:

https://www.sourceware.org/ml/libc-alpha/2014-10/msg00823.html

BTW, I think this optimization also breaks PALO (PA-RISC bootloader). There the
program actually wants to access page zero.

Reply via email to