This is the mail archive of the gdb@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Regression caused by elfread.c patch


Hi,

The problem due to which I patched elfread.c is as follows: Linux kernel
modules are loaded using insmod which uses its own relocation scheme.
If we load a module file in gdb using add-symbol-file and specify .text address
only, addresses of symbols in .data and .bss sections are calculated
incorrectly.

objdump -h:
.......
  0 .text         0017b6f5  00000000  00000000  00000040  2**4
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE 
......
  5 .data         0000c3d4  00000000  00000000  0019d3e0  2**5
                  CONTENTS, ALLOC, LOAD, RELOC, DATA
.......        
objdump -t:
.......
00004508 g     F .text  0000000f foo
.......
00002364 g     O .data  00000050 bar
........
Module load map produced by insmod:
.....
.text           0017b6f5  d002c050  2**4
......
.data           0000c3d4  d01c9400  2**5
.......
d0030558 T foo
.......
d01cb764 D bar
......

(gdb) .......
add symbol table from file "...." at
	.text_addr = 0xd002c050
	.data_addr = 0xd01c9400
	.bss_addr = 0xd01dd420
(gdb) p &foo
$1 = .... 0xd0030558 ......
(gdb) p &bar
$2 = (<data variable, no debug info> *) 0xd002e3b4

You can see that address of text symbol 'foo' is calculated correctly
Whereas that of data symbol 'bar' is calculated incorrectly.
gdb added 0x00002364 to address of text segment to get address of 'bar'.

Can anyone guess the problem?
Thanks.
-- 
Amit Kale
Veritas Software ( http://www.veritas.com )

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]