Hi,
Thank you for reading this message.
I have found problem when debugging my program. It is the problem with bss
section. As normal, the bss section will be zeroed during system restart.
However, the two variables __bss_end and __bss_start in my system both point
to invalid address and cause the system not cleared any bss section in
memory.
I do found these two variables in the .symtab section using readelf in my
elf file. But I don't know how to see whether they are actually allocated
some memory address or not.
Can someone help me for that? Thanks a lot. Following is my elf file infos
and link property.
Regards,
Yi
-----------------------------------------------------------------------------------------------------
Elf file type is EXEC (Executable file)
Entry point 0x40001208
There are 1 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x010000 0x40000000 0x40000000 0x0b188 0x146a0 RWE 0x10000
Section to Segment mapping:
Segment Sections...
00 .rom_vectors .text .rodata .data .bss
-------------------------------------------------------------------------------------------------
There are 16 section headers, starting at offset 0x57384:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk
Inf Al
[ 0] NULL 00000000 000000 000000 00 0
0 0
[ 1] .rom_vectors PROGBITS 40000000 010000 001390 00 AX 0
0 16
[ 2] .text PROGBITS 40001390 011390 00975c 00 AX 0
0 8
[ 3] .fini PROGBITS 4000aaec 01b188 000000 00 W 0
0 1
[ 4] .rodata PROGBITS 4000aaec 01aaec 00027c 00 A 0
0 8
[ 5] .rodata1 PROGBITS 4000ad68 01b188 000000 00 W 0
0 1
[ 6] .fixup PROGBITS 4000ad68 01b188 000000 00 W 0
0 1
[ 7] .gcc_except_table PROGBITS 4000ad68 01b188 000000 00 W 0
0 1
[ 8] .data PROGBITS 4000ad68 01ad68 000420 00 WA 0
0 8
[ 9] .bss NOBITS 4000b188 01b188 009518 00 WA 0
0 16
[10] .stab PROGBITS 00000000 01b188 0153d8 0c 11
0 4
[11] .stabstr STRTAB 00000000 030560 026af5 00 0
0 1
[12] .comment PROGBITS 00000000 057055 0002ac 00 0
0 1
[13] .shstrtab STRTAB 00000000 057301 000081 00 0
0 1
[14] .symtab SYMTAB 00000000 057604 001e50 10 15
173 4
[15] .strtab STRTAB 00000000 059454 0029c9 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)
-----------------------------------------------------------------------------------------------------------
Symbol table '.symtab' contains 485 entries:
Num: Value Size Type Bind Vis Ndx Name
277: 400146a0 0 NOTYPE GLOBAL DEFAULT ABS __bss_end
362: 4000b188 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
-----------------------------------------------------------------------------------------------------------
CFLAGS = -I$(INSTALL_DIR)/include -msoft-float -g -Wall -Q
LDFLAGS
= -L$(INSTALL_DIR)/lib -Ttarget.ld -nostdlib -Wl,--gc-sections -Wl,-static
-Q
LIBS = $(INSTALL_DIR)/lib -Ttarget.ld
ECOS_GLOBAL_LDFLAGS
= -g -nostdlib -fvtable-gc -Wl,--gc-sections -Wl,-static
ttrtest: ttrtest.o uivsr.o
$(XLD) $(LDFLAGS) $(ECOS_GLOBAL_LDFLAGS) -o $@ $@.o uivsr.o
-----------------------------------------------------------------------------------------------------------
my link scripts:
STARTUP(vectors.o)
ENTRY(reset_vector)
INPUT(extras.o)
GROUP(libtarget.a libgcc.a libsupc++.a)
MEMORY
{
ram : ORIGIN = 0x40000000, LENGTH = 0x40000000
}
SECTIONS
{
.rom_vectors 0x40000000 : { . = .; KEEP (*(.vectors)) } > ram
.text ALIGN (0x1) : { _stext = ABSOLUTE(.); *(.text*) *(.gnu.warning)
*(.gnu.linkonce*) *(.init) } > ram _etext = .; PROVIDE (etext = .);
.fini ALIGN (0x1) : { . = .; *(.fini) } > ram
.rodata ALIGN (0x1) : { . = .; *(.rodata*) } > ram
.rodata1 ALIGN (0x1) : { . = .; *(.rodata1) } > ram
.fixup ALIGN (0x1) : { . = .; *(.fixup) } > ram
.gcc_except_table ALIGN (0x1) : { . = .; *(.gcc_except_table) } > ram
.data ALIGN (0x1) : { __ram_data_start = ABSOLUTE (.); *(.data*)
*(.data1) _GOT1_START_ = ABSOLUTE (.); *(.got1) _GOT1_END_ = ABSOLUTE (.);
_GOT2_START_ = ABSOLUTE (.); *(.got2) _GOT2_END_ = ABSOLUTE (.); . = ALIGN
(4); KEEP(*( SORT (.ecos.table.*))) ; __CTOR_LIST__ = ABSOLUTE (.);
KEEP(*(SORT(.ctors*))) __CTOR_END__ = ABSOLUTE (.); __DTOR_LIST__ = ABSOLUTE
(.); KEEP(*(SORT(.dtors*))) __DTOR_END__ = ABSOLUTE (.); _GOT_START =
ABSOLUTE (.); _GLOBAL_OFFSET_TABLE_ = ABSOLUTE (.) + 32768; _SDA_BASE_ =
ABSOLUTE (.); *(.got.plt) *(.got) _GOT_END_ = ABSOLUTE (.); *(.dynamic)
*(.sdata*) *(.sbss*) *(.eh_frame) } > ram __rom_data_start = LOADADDR
(.data); . = ALIGN (8); __ram_data_end = .; PROVIDE (__ram_data_end = .);
_edata = .; PROVIDE (edata = .);
.bss ALIGN (0x8) (NOLOAD) : { __bss_start = ABSOLUTE (.); *(.scommon)
*(.dynbss) *(.bss) *(.bss.*) *(COMMON) __bss_end = ABSOLUTE (.); } > ram
__heap1 = ALIGN (0x8);
. = ALIGN(8); _end = .; PROVIDE (end = .); .debug 0 : { *(.debug) }
.line 0 : { *(.line) } .debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) } .debug_aranges 0 : {
*(.debug_aranges) } .debug_pubnames 0 : { *(.debug_pubnames) } .debug_info 0
: { *(.debug_info) } .debug_abbrev 0 : { *(.debug_abbrev) } .debug_line 0 :
{ *(.debug_line) } .debug_frame 0 : { *(.debug_frame) } .debug_str 0 : {
*(.debug_str) } .debug_loc 0 : { *(.debug_loc) } .debug_macinfo 0 : {
*(.debug_macinfo) } .debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) } .debug_typenames 0 : {
*(.debug_typenames) } .debug_varnames 0 : { *(.debug_varnames) }
}