internal error: pc 0x0 in read in psymtab, but not in symtab

Turny Dávid
2006-11-10T00:27:45Z

Hi!

I try to debug a program on a remote ARM target. I use the openOCD and the
arm-elf-gdb (GNUARM) or the arm-none-eabi-gdb (SOURCERY). I have got
an error message:

internal error: pc 0x0 in read in psymtab, but not in symtab

I have got is a lot of times... If I can reach somehow the main then
it is working, but if I like to use the arm-elf-insight then these
messages come in windows and I have to click on the ok button and I
cant reach the main.
How can I avoid this?
Thank you!

Oh, and I think there is something wrong with the .data
section...please check the corresponding part of the main.dmp file.
/the size of that is not ok I think.../
Thank You very much!!!

David

*******************************************************************************
This is the output of the compile process:
*******************************************************************************

make -k all
...assembling
arm-elf-as -march=armv4t -mcpu=arm7tdmi --gdwarf2 -EL -ahls -mapcs-32
crt.s -o crt.o > crt.lst
arm-elf-gcc -march=armv4t -mcpu=arm7tdmi -g -gdwarf-2 -LE -c -O0 -o
main.o main.c
arm-elf-gcc -march=armv4t -mcpu=arm7tdmi -g -gdwarf-2 -LE -S -O0 -o
main.s main.c
...linking
arm-elf-ld -T linker_script -Map main.map crt.o main.o -o main.elf
...copying
...dumping
arm-elf-objcopy -O binary main.elf main.bin
arm-elf-objdump -h -t -s -d main.elf > main.dmp

****************************************************************************
My startup code:
****************************************************************************
.text
.arm

.equ usr_mode, 0x000000D0
.equ fiq_mode, 0x000000D1
.equ irq_mode, 0x000000D2
.equ superv_mode, 0x000000D3
.equ abort_mode, 0x000000D7
.equ und_mode, 0x000000DB
.equ sys_mode, 0x000000DF

.equ usr_stack_size , 0x000000ff
.equ fiq_stack_size , 0x0000000f
.equ irq_stack_size , 0x0000000f
.equ superv_stack_size , 0x0000000f
.equ abort_stack_size , 0x0000000f
.equ und_stack_size , 0x0000000f
.equ sys_stack_size , 0x00000000

_startup:
.global _startup

LDR PC, reset_addr
LDR PC, reset_addr
LDR PC, reset_addr
LDR PC, reset_addr
LDR PC, reset_addr
NOP
LDR PC, reset_addr
LDR PC, reset_addr

reset_addr: .word reset_handler

reset_handler:
.global reset_handler
LDR R0, =_etext /*copy .data section */
LDR R1, =_end_data
LDR R2, =_start_data
copy_data:
LDR R3, [R0]
ADD R0, R0,#0x04
STR R3, [R2]
ADD R2, R2,#0x04
CMP R1,R2
BHI copy_data

LDR R0, =_start_bss /* fill bss section with zero-s*/
LDR R1, =_end_bss
EOR R3,R3,R3
bss_init:
STR R3, [R0]
ADD R0, R0, #0x04
CMP R1, R0
BHI bss_init

/* set up the stacks */

LDR R0, =0x002FFFFF
MOV R13, R0
SUB R0, R0, #superv_stack_size

MSR CPSR_c, #fiq_mode
MOV R13, R0
SUB R0, R0, #fiq_satck_size

MSR CPSR_c, #irq_mode
MOV R13, R0
SUB R0, R0, #irq_satck_size

MSR CPSR_c, #abort_mode
MOV R13, R0
SUB R0, R0, #abort_satck_size

MSR CPSR_c, #und_mode
MOV R13, R0
SUB R0, R0, #und_satck_size

MSR CPSR_c, #usr_mode
MOV R13, R0

/* jump to main */

B main

****************************************************************************
the rubish C code:
****************************************************************************
main () {
int a=2;
int b=5;
b+=a;
int i=13;
int alma=43;
int akarmi=56;
int y,x,c,v,m,n;
while (1) {
a++;
b+=a;
y=x=c=v=m=n=b;

}

}

*****************************************************************************
the linker script:
******************************************************************************
ENTRY(_startup)

stack_start = 0x00200000;

MEMORY
{

flash : ORIGIN = 0x0 , LENGTH = 256K
freeRAM : ORIGIN = 0x00200000, LENGTH = 64K - 0x14A

}

SECTIONS {
. = 0;
.text : {
*(.text)
*(.glue_7)
*(.glue_7t)
LONG(0);
_etext = .;

} >flash

.data : {
_start_data = . ;
*(.data)
LONG(0);
_end_data = . ;

} >freeRAM AT>flash

.bss : {
_start_bss = . ;
*(.bss)

} >freeRAM
. = ALIGN(4);
_end_bss = . ;
}

******************************************************************************
the make file:
******************************************************************************

C_SOURCES = main.c
OBJECTS = main.o

#CC = arm-none-eabi-gcc
#AS = arm-none-eabi-as
#LD = arm-none-eabi-ld
#CP = arm-none-eabi-objcopy
#OD = arm-none-eabi-objdump

CC = arm-elf-gcc
AS = arm-elf-as
LD = arm-elf-ld
CP = arm-elf-objcopy
OD = arm-elf-objdump

OPTLEVEL = 0
CC_FLAGS = -march=armv4t -mcpu=arm7tdmi -g -gdwarf-2 -LE -c
-O$(OPTLEVEL) -o main.o
CC_FLAGS_S = -march=armv4t -mcpu=arm7tdmi -g -gdwarf-2 -LE -S
-O$(OPTLEVEL) -o main.s

AS_FLAGS = -march=armv4t -mcpu=arm7tdmi --gdwarf2 -EL -ahls -mapcs-32
LD_FLAGS = -T linker_script -Map main.map
CP_FLAGS = -O binary
OD_FLAGS = -h -t -s -d

CRT_FILE = crt.s

.SUFFIXES: .c .o

.c.o:
$(CC) $(CC_FLAGS) $+
$(CC) $(CC_FLAGS_S) $+

clean:
-rm $(OBJECTS) crt.o crt.lst main.dmp main.bin
all: test

test: main.elf
@ echo "...copying"
@ echo "...dumping"
$(CP) $(CP_FLAGS) main.elf main.bin
$(OD) $(OD_FLAGS) main.elf > main.dmp

main.elf: crt.o $(OBJECTS)
@ echo "...linking"
$(LD) $(LD_FLAGS) crt.o $(OBJECTS) -o main.elf

crt.o: $(CRT_FILE)
@ echo "...assembling"
$(AS) $(AS_FLAGS) $(CRT_FILE) -o crt.o > crt.lst

******************************************************************************
main.dmp
******************************************************************************

main.elf: file format elf32-littlearm

Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000014c 00000000 00000000 00008000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000004 00200000 0000014c 00010000 2**0
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000000 00200004 00000150 00010004 2**0
ALLOC
3 .debug_line 00000095 00000000 00000000 00010004 2**0
CONTENTS, READONLY, DEBUGGING
4 .debug_info 0000014e 00000000 00000000 00010099 2**0
CONTENTS, READONLY, DEBUGGING
5 .debug_abbrev 00000059 00000000 00000000 000101e7 2**0
CONTENTS, READONLY, DEBUGGING
6 .debug_aranges 00000040 00000000 00000000 00010240 2**3
CONTENTS, READONLY, DEBUGGING
7 .debug_frame 00000030 00000000 00000000 00010280 2**2
CONTENTS, READONLY, DEBUGGING
8 .debug_pubnames 0000001b 00000000 00000000 000102b0 2**0
CONTENTS, READONLY, DEBUGGING
9 .comment 00000012 00000000 00000000 000102cb 2**0
CONTENTS, READONLY
SYMBOL TABLE:
00000000 l d .text 00000000
00200000 l d .data 00000000
00200004 l d .bss 00000000
00000000 l d .debug_line 00000000
00000000 l d .debug_info 00000000
00000000 l d .debug_abbrev 00000000
00000000 l d .debug_aranges 00000000
00000000 l d .debug_frame 00000000
00000000 l d .debug_pubnames 00000000
00000000 l d .comment 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 l d *ABS* 00000000
00000000 l F .text 00000000 $a
000000d0 l *ABS* 00000000 usr_mode
000000d1 l *ABS* 00000000 fiq_mode
000000d2 l *ABS* 00000000 irq_mode
000000d3 l *ABS* 00000000 superv_mode
000000d7 l *ABS* 00000000 abort_mode
000000db l *ABS* 00000000 und_mode
000000df l *ABS* 00000000 sys_mode
000000ff l *ABS* 00000000 usr_stack_size
0000000f l *ABS* 00000000 fiq_stack_size
0000000f l *ABS* 00000000 irq_stack_size
0000000f l *ABS* 00000000 superv_stack_size
0000000f l *ABS* 00000000 abort_stack_size
0000000f l *ABS* 00000000 und_stack_size
00000000 l *ABS* 00000000 sys_stack_size
00000020 l .text 00000000 reset_addr
00000020 l O .text 00000000 $d
00000024 l F .text 00000000 $a
00000030 l .text 00000000 copy_data
00000054 l .text 00000000 bss_init
000000ac l O .text 00000000 $d
00000000 l df *ABS* 00000000 main.c
000000c4 l F .text 00000000 $a
00000024 g .text 00000000 reset_handler
00000000 *UND* 00000000 irq_satck_size
00200000 g .data 00000000 _start_data
00000000 *UND* 00000000 abort_satck_size
0000014c g .text 00000000 _etext
00200004 g .data 00000000 _end_data
00000000 g .text 00000000 _startup
00000000 *UND* 00000000 fiq_satck_size
00200000 g *ABS* 00000000 stack_start
000000c4 g F .text 00000084 main
00000000 *UND* 00000000 und_satck_size
00200004 g *ABS* 00000000 _end_bss
00200004 g .bss 00000000 _start_bss

Contents of section .text:
0000 18f09fe5 14f09fe5 10f09fe5 0cf09fe5 ................
0010 08f09fe5 0000a0e1 00f09fe5 04f01fe5 ................
0020 24000000 80009fe5 80109fe5 80209fe5 $............ ..
0030 003090e5 040080e2 003082e5 042082e2 .0.......0... ..
0040 020051e1 f9ffff8a 68009fe5 68109fe5 ..Q.....h...h...
0050 033023e0 003080e5 040080e2 000051e1 .0#..0........Q.
0060 fbffff8a 54009fe5 00d0a0e1 0f0040e2 ....T.........@.
0070 d1f021e3 00d0a0e1 000040e2 d2f021e3 ..!.......@...!.
0080 00d0a0e1 000040e2 d7f021e3 00d0a0e1 ......@...!.....
0090 000040e2 dbf021e3 00d0a0e1 000040e2 ..@...!.......@.
00a0 d0f021e3 00d0a0e1 050000ea 4c010000 ..!.........L...
00b0 04002000 00002000 04002000 04002000 .. ... ... ... .
00c0 ffff2f00 0dc0a0e1 00d82de9 04b04ce2 ../.......-...L.
00d0 2cd04de2 0230a0e3 10300be5 0530a0e3 ,.M..0...0...0..
00e0 14300be5 14201be5 10301be5 033082e0 .0... ...0...0..
00f0 14300be5 0d30a0e3 18300be5 2b30a0e3 .0...0...0..+0..
0100 1c300be5 3830a0e3 20300be5 10301be5 .0..80.. 0...0..
0110 013083e2 10300be5 14201be5 10301be5 .0...0... ...0..
0120 033082e0 14300be5 14301be5 38300be5 .0...0...0..80..
0130 34300be5 30300be5 2c300be5 28300be5 40..00..,0..(0..
0140 24300be5 f0ffffea 00000000 $0..........
Contents of section .data:
200000 00000000 ....
Contents of section .debug_line:
0000 57000000 02001900 00000201 fb0e0a00 W...............
0010 01010101 00000001 00637274 2e730000 .........crt.s..
0020 00000000 05020000 00000317 012c2c2c .............,,,
0030 2c2c2c2c 4e2c2c2d 2c2c2c2c 2c2e2c2c ,,,,N,,-,,,,,.,,
0040 2d2c2c2c 2d2c2c2d 2c2c2d2c 2c2e2c2c -,,,-,,-,,-,,.,,
0050 2e2c2c2e 2c2f020e 00010136 00000002 .,,.,/.....6....
0060 001a0000 000201fb 0e0a0001 01010100 ................
0070 00000100 6d61696e 2e630000 00000000 ....main.c......
0080 0502c400 00000f80 48488048 484a6480 ........HH.HHJd.
0090 02100001 01 .....
Contents of section .debug_info:
0000 4b000000 02000000 00000401 00000000 K...............
0010 00000000 c4000000 6372742e 73002f72 ........crt.s./r
0020 6f6f742f 534f5552 43455259 2f776f72 oot/SOURCERY/wor
0030 6b737061 63652f41 524d5f66 69727374 kspace/ARM_first
0040 00474e55 20415320 322e3135 000180fb .GNU AS 2.15....
0050 00000002 00140000 0004015b 00000048 ...........[...H
0060 010000c4 00000047 4e552043 20332e34 .......GNU C 3.4
0070 2e330001 6d61696e 2e63002f 726f6f74 .3..main.c./root
0080 2f534f55 52434552 592f776f 726b7370 /SOURCERY/worksp
0090 6163652f 41524d5f 66697273 740002f7 ace/ARM_first...
00a0 00000001 6d61696e 000101f7 000000c4 ....main........
00b0 00000048 01000001 5b036100 0102f700 ...H....[.a.....
00c0 00000291 70036200 0103f700 00000291 ....p.b.........
00d0 6c036900 0105f700 00000291 6803616c l.i.........h.al
00e0 6d610001 06f70000 00029164 03616b61 ma.........d.aka
00f0 726d6900 0107f700 00000291 60037900 rmi.........`.y.
0100 0108f700 00000291 5c037800 0108f700 ........\.x.....
0110 00000291 58036300 0108f700 00000291 ....X.c.........
0120 54037600 0108f700 00000291 50036d00 T.v.........P.m.
0130 0108f700 00000291 4c036e00 0108f700 ........L.n.....
0140 00000291 48000469 6e740004 0500 ....H..int....
Contents of section .debug_abbrev:
0000 01110010 06110112 0103081b 08250813 .............%..
0010 05000000 01110110 06120111 01250813 .............%..
0020 0b03081b 08000002 2e010113 3f0c0308 ............?...
0030 3a0b3b0b 49131101 1201400a 00000334 :.;.I.....@....4
0040 0003083a 0b3b0b49 13020a00 00042400 ...:.;.I......$.
0050 03080b0b 3e0b0000 00 ....>....
Contents of section .debug_aranges:
0000 1c000000 02000000 00000400 00000000 ................
0010 00000000 c4000000 00000000 00000000 ................
0020 1c000000 02004f00 00000400 00000000 ......O.........
0030 c4000000 84000000 00000000 00000000 ................
Contents of section .debug_frame:
0000 0c000000 ffffffff 0100017c 0e0c0d00 ...........|....
0010 1c000000 00000000 c4000000 84000000 ................
0020 440d0c44 8e028d03 8b04440c 0b040000 D..D......D.....
Contents of section .debug_pubnames:
0000 17000000 02004f00 0000ff00 00004f00 ......O.......O.
0010 00006d61 696e0000 000000 ..main.....
Contents of section .comment:
0000 00474343 3a202847 4e552920 332e342e .GCC: (GNU) 3.4.
0010 3300 3.
Disassembly of section .text:

00000000 <_startup>:
0: e59ff018 ldr pc, [pc, #24] ; 20 <reset_addr>
4: e59ff014 ldr pc, [pc, #20] ; 20 <reset_addr>
8: e59ff010 ldr pc, [pc, #16] ; 20 <reset_addr>
c: e59ff00c ldr pc, [pc, #12] ; 20 <reset_addr>
10: e59ff008 ldr pc, [pc, #8] ; 20 <reset_addr>
14: e1a00000 nop (mov r0,r0)
18: e59ff000 ldr pc, [pc, #0] ; 20 <reset_addr>
1c: e51ff004 ldr pc, [pc, #-4] ; 20 <reset_addr>

00000020 <reset_addr>:
20: 00000024 andeq r0, r0, r4, lsr #32

00000024 <reset_handler>:
24: e59f0080 ldr r0, [pc, #128] ; ac <.text+0xac>
28: e59f1080 ldr r1, [pc, #128] ; b0 <.text+0xb0>
2c: e59f2080 ldr r2, [pc, #128] ; b4 <.text+0xb4>

00000030 <copy_data>:
30: e5903000 ldr r3, [r0]
34: e2800004 add r0, r0, #4 ; 0x4
38: e5823000 str r3, [r2]
3c: e2822004 add r2, r2, #4 ; 0x4
40: e1510002 cmp r1, r2
44: 8afffff9 bhi 30 <copy_data>
48: e59f0068 ldr r0, [pc, #104] ; b8 <.text+0xb8>
4c: e59f1068 ldr r1, [pc, #104] ; bc <.text+0xbc>
50: e0233003 eor r3, r3, r3

00000054 <bss_init>:
54: e5803000 str r3, [r0]
58: e2800004 add r0, r0, #4 ; 0x4
5c: e1510000 cmp r1, r0
60: 8afffffb bhi 54 <bss_init>
64: e59f0054 ldr r0, [pc, #84] ; c0 <.text+0xc0>
68: e1a0d000 mov sp, r0
6c: e240000f sub r0, r0, #15 ; 0xf
70: e321f0d1 msr CPSR_c, #209 ; 0xd1
74: e1a0d000 mov sp, r0
78: e2400000 sub r0, r0, #0 ; 0x0
7c: e321f0d2 msr CPSR_c, #210 ; 0xd2
80: e1a0d000 mov sp, r0
84: e2400000 sub r0, r0, #0 ; 0x0
88: e321f0d7 msr CPSR_c, #215 ; 0xd7
8c: e1a0d000 mov sp, r0
90: e2400000 sub r0, r0, #0 ; 0x0
94: e321f0db msr CPSR_c, #219 ; 0xdb
98: e1a0d000 mov sp, r0
9c: e2400000 sub r0, r0, #0 ; 0x0
a0: e321f0d0 msr CPSR_c, #208 ; 0xd0
a4: e1a0d000 mov sp, r0
a8: ea000005 b c4
ac: 0000014c andeq r0, r0, ip, asr #2
b0: 00200004 eoreq r0, r0, r4
b4: 00200000 eoreq r0, r0, r0
b8: 00200004 eoreq r0, r0, r4
bc: 00200004 eoreq r0, r0, r4
c0: 002fffff streqd pc, [pc], -pc

000000c4 :
c4: e1a0c00d mov ip, sp
c8: e92dd800 stmdb sp!, {fp, ip, lr, pc}
cc: e24cb004 sub fp, ip, #4 ; 0x4
d0: e24dd02c sub sp, sp, #44 ; 0x2c
d4: e3a03002 mov r3, #2 ; 0x2
d8: e50b3010 str r3, [fp, #-16]
dc: e3a03005 mov r3, #5 ; 0x5
e0: e50b3014 str r3, [fp, #-20]
e4: e51b2014 ldr r2, [fp, #-20]
e8: e51b3010 ldr r3, [fp, #-16]
ec: e0823003 add r3, r2, r3
f0: e50b3014 str r3, [fp, #-20]
f4: e3a0300d mov r3, #13 ; 0xd
f8: e50b3018 str r3, [fp, #-24]
fc: e3a0302b mov r3, #43 ; 0x2b
100: e50b301c str r3, [fp, #-28]
104: e3a03038 mov r3, #56 ; 0x38
108: e50b3020 str r3, [fp, #-32]
10c: e51b3010 ldr r3, [fp, #-16]
110: e2833001 add r3, r3, #1 ; 0x1
114: e50b3010 str r3, [fp, #-16]
118: e51b2014 ldr r2, [fp, #-20]
11c: e51b3010 ldr r3, [fp, #-16]
120: e0823003 add r3, r2, r3
124: e50b3014 str r3, [fp, #-20]
128: e51b3014 ldr r3, [fp, #-20]
12c: e50b3038 str r3, [fp, #-56]
130: e50b3034 str r3, [fp, #-52]
134: e50b3030 str r3, [fp, #-48]
138: e50b302c str r3, [fp, #-44]
13c: e50b3028 str r3, [fp, #-40]
140: e50b3024 str r3, [fp, #-36]
144: eafffff0 b 10c <usr_stack_size+0xd>
148: 00000000 andeq r0, r0, r0

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.