|
Message
From: Syed Faisal Akber<faisal@a...>
Date: Thu May 19 01:42:33 CEST 2005
Subject: [openrisc] gcc 3.4.2 problem
var1 shows up in the .data section because it has initialized data. var2 shows up in the .bss section because it has been initialized with the value of zero (0). Also any variables not initialized also show up in .bss.
This is a feature of GCC and you changing that would break the way everyone expects it to work.
Faisal
On Wed, 18 May 2005, [big5] ®}°ê¥ wrote:
> Dear All, > I had a problem about the GCC 3.4.2 for the OpenRISC. For the > following C program, why does the GCC generate the 'var1' in the '.data' > section and 'var2' in the '.bss' section. I test the C program on the > Linux, both of two variables are put in the '.data' section. Does it a > bug on the GCC 3.4.2 of OpenRISC? > > <<compiler version>>: gcc 3.4.2 > <<compiling option>>: or32-elf-gcc -O3 -o test test.c -Ttext=0x300 -nostdlib > > ===== test.c ====================================================== > int test(int k) { > static int var1 = 3; > static int var2 = 0; > > return k+var1+var2; > } > > ===== test.s ====================================================== > .file "test.c" > .section .data > .align 4 > .type var1.0, @object > .size var1.0, 4 > var1.0: > .long 3 > .local var2.1 > .comm var2.1,4,4 > .section .text > .align 4 > .proc _test > .global _test > .type _test, @function > _test: > > # gpr_save_area 0 vars 0 current_function_outgoing_args_size 0 > l.addi r1,r1,-4 > l.sw 0(r1),r2 > l.addi r2,r1,4 > l.movhi r6,hi(var1.0) # move immediate (high) > l.ori r6,r6,lo(var1.0) # move immediate (low) > l.movhi r5,hi(var2.1) # move immediate (high) > l.ori r5,r5,lo(var2.1) # move immediate (low) > l.lwz r11,0(r6) # SI load > l.lwz r4,0(r5) # SI load > l.add r3,r3,r11 > l.add r11,r3,r4 > l.lwz r2,0(r1) > l.jr r9 > l.addi r1,r1,4 > .size _test, .-_test > .ident "GCC: (GNU) 3.4.2" > > ===== symbol table ====================================================== > ELF Header: > Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 > Class: ELF32 > Data: 2's complement, big endian > Version: 1 (current) > OS/ABI: UNIX - System V > ABI Version: 0 > Type: EXEC (Executable file) > Machine: OpenRISC > Version: 0x1 > Entry point address: 0x300 > Start of program headers: 52 (bytes into file) > Start of section headers: 912 (bytes into file) > Flags: 0x0 > Size of this header: 52 (bytes) > Size of program headers: 32 (bytes) > Number of program headers: 2 > Size of section headers: 40 (bytes) > Number of section headers: 10 > Section header string table index: 7 > > 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 00000300 000300 000038 00 AX 0 0 4 > [ 2] .rel.text REL 00000000 000624 000000 08 8 1 4 > [ 3] .data PROGBITS 00002338 000338 000004 00 WA 0 0 4 > [ 4] .sbss PROGBITS 0000233c 00033c 000000 00 W 0 0 1 > [ 5] .bss NOBITS 0000233c 00033c 000004 00 WA 0 0 4 > [ 6] .comment PROGBITS 00000000 00033c 000012 00 0 0 1 > [ 7] .shstrtab STRTAB 00000000 00034e 00003f 00 0 0 1 > [ 8] .symtab SYMTAB 00000000 000520 0000d0 10 9 9 4 > [ 9] .strtab STRTAB 00000000 0005f0 000034 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)
>
> Program Headers:
> Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
> LOAD 0x000000 0x00000000 0x00000000 0x00338 0x00338 R E 0x2000
> LOAD 0x000338 0x00002338 0x00002338 0x00004 0x00008 RW 0x2000
>
> Section to Segment mapping:
> Segment Sections...
> 00 .text
> 01 .data .bss
>
> There is no dynamic segment in this file.
>
> There are no relocations in this file.
>
> There are no unwind sections in this file.
>
> Symbol table '.symtab' contains 13 entries:
> Num: Value Size Type Bind Vis Ndx Name
> 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
> 1: 00000000 0 FILE LOCAL DEFAULT ABS test.c
> 2: 00000300 0 SECTION LOCAL DEFAULT 1
> 3: 00002338 0 SECTION LOCAL DEFAULT 3
> 4: 0000233c 0 SECTION LOCAL DEFAULT 5
> 5: 00002338 4 OBJECT LOCAL DEFAULT 3 var1.0
> 6: 0000233c 4 OBJECT LOCAL DEFAULT 5 var2.1
> 7: 00000000 0 SECTION LOCAL DEFAULT 6
> 8: 0000233c 0 SECTION LOCAL DEFAULT 4
> 9: 00000300 56 FUNC GLOBAL DEFAULT 1 _test
> 10: 0000233c 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
> 11: 0000233c 0 NOTYPE GLOBAL DEFAULT ABS _edata
> 12: 00002340 0 NOTYPE GLOBAL DEFAULT ABS _end
>
> No version information found in this file.
>
>
|
 |