When an object file is compiled by arm-elf-gcc 4.1.0, nm -S 2.16.* always shows zero as the size of a static variable. Thanks, Shaun $ cat foo.c int foo; static int static_foo; $ arm-elf-gcc -c foo.c $ arm-elf-readelf -s foo.o | grep foo 1: 00000000 0 FILE LOCAL DEFAULT ABS foo.c 6: 00000000 0 NOTYPE LOCAL DEFAULT 3 static_foo 8: 00000004 4 OBJECT GLOBAL DEFAULT COM foo $ gcc -c foo.c $ readelf -s foo.o | grep foo 1: 00000000 0 FILE LOCAL DEFAULT ABS foo.c 5: 00000000 4 OBJECT LOCAL DEFAULT 3 static_foo 8: 00000004 4 OBJECT GLOBAL DEFAULT COM foo $ arm-elf-gcc --version | head -1 arm-elf-gcc (GCC) 4.1.0 $ arm-elf-readelf --version | head -1 GNU readelf 2.16.91 20060309 $ gcc --version | head -1 gcc (GCC) 4.0.3 20060212 (prerelease) (Debian 4.0.2-9) $ readelf --version | head -1 GNU readelf 2.16.91-multiarch 20060118 Debian GNU/Linux
What does the output of -S show? I bet it is just putting static_foo in a BSS using lcomm but I could be wrong. This might not be a gcc bug.
Subject: Re: Size of static variables always zero on arm-elf On 15 Mar 2006 18:38:46 -0000, pinskia at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org> wrote: > What does the output of -S show? I bet it is just putting static_foo in a BSS > using lcomm but I could be wrong. This might not be a gcc bug. $ arm-elf-readelf -S foo.o There are 8 section headers, starting at offset 0x7c: Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] NULL 00000000 000000 000000 00 0 0 0 [ 1] .text PROGBITS 00000000 000034 000000 00 AX 0 0 1 [ 2] .data PROGBITS 00000000 000034 000000 00 WA 0 0 1 [ 3] .bss NOBITS 00000000 000034 000004 00 WA 0 0 4 [ 4] .comment PROGBITS 00000000 000034 000012 00 0 0 1 [ 5] .shstrtab STRTAB 00000000 000046 000035 00 0 0 1 [ 6] .symtab SYMTAB 00000000 0001bc 000090 10 7 8 4 [ 7] .strtab STRTAB 00000000 00024c 000019 00 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific)
No I mean what is the assembly output from GCC which you get by invoking gcc with -S.
Subject: Re: Size of static variables always zero on arm-elf On 15 Mar 2006 18:53:53 -0000, pinskia at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org> wrote: > No I mean what is the assembly output from GCC which you get by invoking gcc > with -S. It does not appear to use lcomm for static_foo. If it's not a gcc bug, is it a gas bug or a binutils bug? -- sdj $ arm-elf-gcc -S foo.c $ cat foo.s .file "foo.c" .bss .align 2 static_foo: .space 4 .comm foo,4,4 .ident "GCC: (GNU) 4.1.0"
Can you try one more thing: static int static_foo = 1; And then use readelf -s on the object file?
Subject: Re: Size of static variables always zero on arm-elf On 15 Mar 2006 19:07:12 -0000, pinskia at gcc dot gnu dot org > Can you try one more thing: > static int static_foo = 1; > > And then use readelf -s on the object file? $ cat foo.c int foo; static int static_foo = 1; $ arm-elf-gcc -c foo.c $ arm-elf-readelf -s foo.o | grep foo 1: 00000000 0 FILE LOCAL DEFAULT ABS foo.c 5: 00000000 4 OBJECT LOCAL DEFAULT 2 static_foo 8: 00000004 4 OBJECT GLOBAL DEFAULT COM foo $ arm-elf-gcc -S foo.c $ cat foo.s .file "foo.c" .data .align 2 .type static_foo, %object .size static_foo, 4 static_foo: .word 1 .comm foo,4,4 .ident "GCC: (GNU) 4.1.0"
Ok, this is a GCC bug for not outputing .size.
Subject: Re: Size of static variables always zero on arm-elf GCC is not emitting the type or size information for static bss symbols. -- sdj $ echo 'static int foo = 1;' >foo.c $ arm-elf-gcc -S foo.c -odata.s $ echo 'static int foo;' >foo.c $ arm-elf-gcc -S foo.c -obss.s $ diff -u data.s bss.s --- data.s 2006-03-15 13:08:17.000000000 -0700 +++ bss.s 2006-03-15 13:08:17.000000000 -0700 @@ -1,8 +1,6 @@ .file "foo.c" - .data + .bss .align 2 - .type foo, %object - .size foo, 4 foo: - .word 1 + .space 4 .ident "GCC: (GNU) 4.1.0"
This appears today with trunk and eabi at r146638.
While getting the size right is useful, it's not something that can be relied on by users, so this is really an enhancement.
Author: ramana Date: Thu Apr 23 14:49:45 2015 New Revision: 222371 URL: https://gcc.gnu.org/viewcvs?rev=222371&root=gcc&view=rev Log: Fix PR target/26702 For Kwok Cheung Yeung. Added: trunk/gcc/testsuite/gcc.target/arm/pr26702.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/arm/unknown-elf.h trunk/gcc/testsuite/ChangeLog
Fixed -
Author: ramana Date: Thu May 21 09:23:14 2015 New Revision: 223473 URL: https://gcc.gnu.org/viewcvs?rev=223473&root=gcc&view=rev Log: Fix PR target/26702 For Kwok Cheung Yeung. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gcc.target/arm/pr26702.c