This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Miscompilation of glibc by GCC 3.5?


glibc cannot be compiled by current 3.5 mainline on AMD64 (but same
situation on ia64).  I've reduced the error to the following example:

extern int __internal_getnetgrent_r (void);

static int
internal_getnetgrent_r (void)
{
  return 1;
}

extern __typeof (internal_getnetgrent_r) __internal_getnetgrent_r __attribute__ ((alias ("internal_getnetgrent_r")));

int
test (void)
{
  return internal_getnetgrent_r ();
  
}

With GCC 3.5 of today I get internal_getnetgrent_r undefined:

reger:/tmp:[0]$ /opt/gcc/3.5-devel/bin/gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
                 U internal_getnetgrent_r
0000000000000000 T test
reger:/tmp:[0]$ /opt/gcc/3.5-devel/bin/gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
                 U internal_getnetgrent_r
0000000000000000 T test

But older GCC versions (3.3 and 3.4.0) produce:

reger:/tmp:[0]$ gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
0000000000000000 T __internal_getnetgrent_r
0000000000000000 t internal_getnetgrent_r
0000000000000010 T test
reger:/tmp:[0]$ /opt/gcc/3.4-devel/bin/gcc -O2 -c test.c
reger:/tmp:[0]$ nm test.o
0000000000000000 T __internal_getnetgrent_r
0000000000000000 t internal_getnetgrent_r
0000000000000010 T test

Is this a bug in glibc or in GCC?

3.5 inlines the code but 3.4 not, the difference in the assembler is:

--- test-3.5.s      2004-05-27 17:40:11.255202552 +0200
+++ test-3.4.s  2004-05-27 17:39:51.789864313 +0200
@@ -2,14 +2,20 @@
 .globl __internal_getnetgrent_r
        .set    __internal_getnetgrent_r,internal_getnetgrent_r
        .text
-       .align 4
+       .p2align 4,,15
+       .type   internal_getnetgrent_r, @function
+internal_getnetgrent_r:
+.LFB2:
+       movl    $1, %eax
+       ret
+.LFE2:
+       .size   internal_getnetgrent_r, .-internal_getnetgrent_r
        .p2align 4,,15
 .globl test
        .type   test, @function
 test:
 .LFB3:
-       movl    $1, %eax
-       ret
+       jmp     internal_getnetgrent_r
 .LFE3:
        .size   test, .-test
        .section        .eh_frame,"a",@progbits


It seems the following statement:
.set    __internal_getnetgrent_r,internal_getnetgrent_r

should not be emitted if the function is inlined.

Should I file a bugreport for 3.5?

Andreas
-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SUSE Linux AG, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]