Re: Relocating Static Local Variables BUG?

Richard Schmitt
2004-04-23T16:37:31Z

The version of GCC is 3.3.1
The version of GDB is 6.1 (downloaded latest release)

The commands to generate the elf are:

gcc -o test.exe -g test.c
objcopy -O elf32-little test.exe test.elf

Built this way, the code is not relocatable, so there is no output of the
-r command to readelf. I've done it this way just to demonstrate the
issue that gdb has with relocating symbols, which is independent of code
generated as relocatable. The -s output is shown below.

Symbol table '.dynsym' contains 4 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 08048234 251 FUNC GLOBAL DEFAULT UND
__libc_start_main@GLIBC_2.0 (2)
2: 08048454 4 OBJECT GLOBAL DEFAULT 14 _IO_stdin_used
3: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__

Symbol table '.symtab' contains 111 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 00000000 0 NOTYPE LOCAL DEFAULT UND
1: 080480f4 0 SECTION LOCAL DEFAULT 1
2: 08048108 0 SECTION LOCAL DEFAULT 2
3: 08048128 0 SECTION LOCAL DEFAULT 3
4: 0804814c 0 SECTION LOCAL DEFAULT 4
5: 0804818c 0 SECTION LOCAL DEFAULT 5
6: 080481d2 0 SECTION LOCAL DEFAULT 6
7: 080481dc 0 SECTION LOCAL DEFAULT 7
8: 080481fc 0 SECTION LOCAL DEFAULT 8
9: 08048204 0 SECTION LOCAL DEFAULT 9
10: 0804820c 0 SECTION LOCAL DEFAULT 10
11: 08048224 0 SECTION LOCAL DEFAULT 11
12: 08048250 0 SECTION LOCAL DEFAULT 12
13: 08048434 0 SECTION LOCAL DEFAULT 13
14: 08048450 0 SECTION LOCAL DEFAULT 14
15: 08049458 0 SECTION LOCAL DEFAULT 15
16: 08049464 0 SECTION LOCAL DEFAULT 16
17: 08049468 0 SECTION LOCAL DEFAULT 17
18: 08049530 0 SECTION LOCAL DEFAULT 18
19: 08049538 0 SECTION LOCAL DEFAULT 19
20: 08049540 0 SECTION LOCAL DEFAULT 20
21: 08049544 0 SECTION LOCAL DEFAULT 21
22: 08049558 0 SECTION LOCAL DEFAULT 22
23: 00000000 0 SECTION LOCAL DEFAULT 23
24: 00000000 0 SECTION LOCAL DEFAULT 24
25: 00000000 0 SECTION LOCAL DEFAULT 25
26: 00000000 0 SECTION LOCAL DEFAULT 26
27: 00000000 0 SECTION LOCAL DEFAULT 27
28: 00000000 0 SECTION LOCAL DEFAULT 28
29: 00000000 0 SECTION LOCAL DEFAULT 29
30: 00000000 0 SECTION LOCAL DEFAULT 30
31: 00000000 0 SECTION LOCAL DEFAULT 31
32: 00000000 0 SECTION LOCAL DEFAULT 32
33: 00000000 0 SECTION LOCAL DEFAULT 33
34: 00000000 0 SECTION LOCAL DEFAULT 34
35: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
36: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
37: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
38: 00000000 0 FILE LOCAL DEFAULT ABS <built-in>
39: 00000000 0 FILE LOCAL DEFAULT ABS abi-note.S
40: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
41: 00000000 0 FILE LOCAL DEFAULT ABS abi-note.S
42: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
43: 00000000 0 FILE LOCAL DEFAULT ABS abi-note.S
44: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
45: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
46: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
47: 00000000 0 FILE LOCAL DEFAULT ABS <built-in>
48: 00000000 0 FILE LOCAL DEFAULT ABS abi-note.S
49: 00000000 0 FILE LOCAL DEFAULT ABS init.c
50: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
51: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
52: 00000000 0 FILE LOCAL DEFAULT ABS initfini.c
53: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
54: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
55: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
56: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
57: 00000000 0 FILE LOCAL DEFAULT ABS <built-in>
58: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
59: 08048274 0 FUNC LOCAL DEFAULT 12 call_gmon_start
60: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
61: 08049530 0 OBJECT LOCAL DEFAULT 18 __CTOR_LIST__
62: 08049538 0 OBJECT LOCAL DEFAULT 19 __DTOR_LIST__
63: 08049540 0 OBJECT LOCAL DEFAULT 20 __JCR_LIST__
64: 08049460 0 OBJECT LOCAL DEFAULT 15 p.0
65: 08049558 1 OBJECT LOCAL DEFAULT 22 completed.1
66: 080482a0 0 FUNC LOCAL DEFAULT 12 __do_global_dtors_aux
67: 080482e0 0 FUNC LOCAL DEFAULT 12 frame_dummy
68: 00000000 0 FILE LOCAL DEFAULT ABS crtstuff.c
69: 08049534 0 OBJECT LOCAL DEFAULT 18 __CTOR_END__
70: 0804953c 0 OBJECT LOCAL DEFAULT 19 __DTOR_END__
71: 08049464 0 OBJECT LOCAL DEFAULT 16 __FRAME_END__
72: 08049540 0 OBJECT LOCAL DEFAULT 20 __JCR_END__
73: 08048410 0 FUNC LOCAL DEFAULT 12 __do_global_ctors_aux
74: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
75: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
76: 00000000 0 FILE LOCAL DEFAULT ABS initfini.c
77: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
78: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
79: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
80: 00000000 0 FILE LOCAL DEFAULT ABS <command line>
81: 00000000 0 FILE LOCAL DEFAULT ABS <built-in>
82: 00000000 0 FILE LOCAL DEFAULT ABS /usr/src/packages/BUILD/g
83: 00000000 0 FILE LOCAL DEFAULT ABS test.c
84: 0804955c 4 OBJECT LOCAL DEFAULT 22 test.0
85: 08049560 4 OBJECT LOCAL DEFAULT 22 test3
86: 00000000 0 FILE LOCAL DEFAULT ABS elf-init.c
87: 08049468 0 OBJECT GLOBAL DEFAULT 17 _DYNAMIC
88: 08048450 4 OBJECT GLOBAL DEFAULT 14 _fp_hw
89: 08049458 0 NOTYPE GLOBAL DEFAULT ABS __fini_array_end
90: 0804945c 0 OBJECT GLOBAL HIDDEN 15 __dso_handle
91: 080483a0 96 FUNC GLOBAL DEFAULT 12 __libc_csu_fini
92: 0804820c 0 FUNC GLOBAL DEFAULT 10 _init
93: 08048250 0 FUNC GLOBAL DEFAULT 12 _start
94: 08049458 0 NOTYPE GLOBAL DEFAULT ABS __fini_array_start
95: 08048340 88 FUNC GLOBAL DEFAULT 12 __libc_csu_init
96: 08049558 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
97: 0804830c 43 FUNC GLOBAL DEFAULT 12 main
98: 08048234 251 FUNC GLOBAL DEFAULT UND __libc_start_main@@GLIBC_
99: 08049458 0 NOTYPE GLOBAL DEFAULT ABS __init_array_end
100: 08049458 0 NOTYPE WEAK DEFAULT 15 data_start
101: 08048434 0 FUNC GLOBAL DEFAULT 13 _fini
102: 08049558 0 NOTYPE GLOBAL DEFAULT ABS _edata
103: 08048400 0 FUNC GLOBAL HIDDEN 12 __i686.get_pc_thunk.bx
104: 08049544 0 OBJECT GLOBAL DEFAULT 21 _GLOBAL_OFFSET_TABLE_
105: 08049564 0 NOTYPE GLOBAL DEFAULT ABS _end
106: 08049458 0 NOTYPE GLOBAL DEFAULT ABS __init_array_start
107: 08048454 4 OBJECT GLOBAL DEFAULT 14 _IO_stdin_used
108: 08049458 0 NOTYPE GLOBAL DEFAULT 15 __data_start
109: 00000000 0 NOTYPE WEAK DEFAULT UND _Jv_RegisterClasses
110: 00000000 0 NOTYPE WEAK DEFAULT UND __gmon_start__

> - how did you create the ELF object?
> - What to readelf -r and readelf -s have to say about the ELF object?
>
> --
> Daniel Jacobowitz
> MontaVista Software Debian GNU/Linux Developer
>