This is the mail archive of the gcc-bugs@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]

[Bug c/16470] New: violation of `-ffreestanding' rules


?-ffreestanding 
 
? ?Assert that compilation takes place in a freestanding environment. 
? ?This implies -fno-builtin. ?A freestanding environment is one in 
? ?which the standard library may not exist, and program startup may 
? ?^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
? ?not necessarily be at "main". ?The most obvious example is an OS 
? ?kernel. ?This is equivalent to -fno-hosted. 
 
$ cat switch64.c 
 
#include "/usr/src/linux/include/linux/types.h" 
__u64 test(__u64 val) 
{ 
? ? switch (val) 
? ? { 
? ? ? ? case 0: 
? ? ? ? ? ? return 0; 
? ? ? ? ? ? break; 
? ? ? ? case 1: 
? ? ? ? ? ? return 1; 
? ? ? ? ? ? break; 
? ? ? ? default: 
? ? ? ? ? ? return -1; 
? ? } 
} 
 
$ gcc switch64.c -c -ffreestanding 
$ objdump -t switch64.o 
 
switch64.o: ? ? file format elf32-sparc 
 
SYMBOL TABLE: 
00000000 l ? ?df *ABS* ?00000000 switch64.c 
00000000 l ? ?d ?.text ?00000000 
00000000 l ? ?d ?.data ?00000000 
00000000 l ? ?d ?.bss ? 00000000 
00000000 l ? ?d ?.note.GNU-stack ? ? ? ?00000000 
00000000 l ? ?d ?.comment ? ? ? 00000000 
00000000 ? ? ? ? *UND* ?00000000 __ucmpdi2 
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?^^^^^^^^^ 
00000000 g ? ? F .text ?0000009c test 
 
$ objdump -T /lib/libgcc_s.so|grep __uc 
0000181c g ? ?DF .text ?00000038 ?GCC_3.0 ? ? __ucmpdi2 
 
$ ldd /lib/libgcc_s.so 
? ? ? ? libc.so.6 => /lib/libc.so.6 (0x70028000) 
? ? ? ? /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x08000000) 
 
In the kernel sources such situations happen very often. 
In the case of __ucmpdi2, it appears to be a combination of kernel 
and compiler stupidity - there's no reason why __ucmpdi2 should 
not be done inline by the compiler, but at the same time there 
is probably also little reason to use a slow "long long" comparison 
in the kernel. Of course I can force a static linking with libgcc.a 
but in the above case gcc should report an error or do inline and warn user.

-- 
           Summary: violation of `-ffreestanding' rules
           Product: gcc
           Version: 3.3.4
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pluto at pld-linux dot org
                CC: gcc-bugs at gcc dot gnu dot org,qboosh at pld-linux dot
                    org
 GCC build triplet: sparc-pld-linux
  GCC host triplet: sparc-pld-linux
GCC target triplet: sparc-pld-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16470


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