This is the mail archive of the gdb-prs@sourceware.org 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]
Other format: [Raw text]

breakpoints/2051: cannot set breakpoint in ELF executable with .rel.* sections


>Number:         2051
>Category:       breakpoints
>Synopsis:       cannot set breakpoint in ELF executable with .rel.* sections
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 19 04:58:02 GMT 2005
>Closed-Date:
>Last-Modified:
>Originator:     danielhe99@gmail.com
>Release:        0
>Organization:
>Environment:
i686 GNU/Linux
>Description:
When an ELF executable is generated with '--emit-relocs' option, GDB 6.x and cvs version cannot debug the executable, but gdb 5.3 can debug it. NO ERROR in the debug infomation of the output executable is found while I used other tools, such as objdump, nm, and readelf, to check it. 

>How-To-Repeat:
Test case:

$ cat test.c
int func(void)
{ return 0; }

int main(void)
{
  func();
  return 0;
}

$ gcc -Wl,--emit-relocs -g test.c -o test

The following is the basic info of the execuatble:

$ readelf -h test
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x8048244
  Start of program headers:          52 (bytes into file)
  Start of section headers:          7796 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         43
  Section header string table index: 40

$ readelf -S test
There are 43 section headers, starting at offset 0x1e74:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        080480f4 0000f4 000013 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            08048108 000108 000020 00   A  0   0  4
  [ 3] .hash             HASH            08048128 000128 000024 04   A  4   0  4
  [ 4] .dynsym           DYNSYM          0804814c 00014c 000040 10   A  5   1  4
  [ 5] .dynstr           STRTAB          0804818c 00018c 000045 00   A  0   0  1
  [ 6] .gnu.version      VERSYM          080481d2 0001d2 000008 02   A  4   0  2
  [ 7] .gnu.version_r    VERNEED         080481dc 0001dc 000020 00   A  5   1  4
  [ 8] .rel.dyn          REL             080481fc 0001fc 000008 08   A  4   0  4
  [ 9] .rel.plt          REL             08048204 000204 000008 08   A  4   c  4
  [10] .init             PROGBITS        0804820c 00020c 000017 00  AX  0   0  4
  [11] .rel.init         REL             00000000 00252c 000018 08     41   a  4
  [12] .plt              PROGBITS        08048224 000224 000020 04  AX  0   0  4
  [13] .text             PROGBITS        08048244 000244 000160 00  AX  0   0  4
  [14] .rel.text         REL             00000000 002544 0000d0 08     41   d  4
  [15] .fini             PROGBITS        080483a4 0003a4 00001b 00  AX  0   0  4
  [16] .rel.fini         REL             00000000 002614 000010 08     41   f  4
  [17] .rodata           PROGBITS        080483c0 0003c0 000008 00   A  0   0  4
  [18] .eh_frame         PROGBITS        080483c8 0003c8 000004 00   A  0   0  4
  [19] .data             PROGBITS        080493cc 0003cc 00000c 00  WA  0   0  4
  [20] .rel.data         REL             00000000 002624 000008 08     41  13  4
  [21] .dynamic          DYNAMIC         080493d8 0003d8 0000c8 08  WA  5   0  4
  [22] .ctors            PROGBITS        080494a0 0004a0 000008 00  WA  0   0  4
  [23] .dtors            PROGBITS        080494a8 0004a8 000008 00  WA  0   0  4
  [24] .jcr              PROGBITS        080494b0 0004b0 000004 00  WA  0   0  4
  [25] .got              PROGBITS        080494b4 0004b4 000014 04  WA  0   0  4
  [26] .bss              NOBITS          080494c8 0004c8 000004 00  WA  0   0  4
  [27] .comment          PROGBITS        00000000 0004c8 000132 00      0   0  1
  [28] .debug_aranges    PROGBITS        00000000 000600 000098 00      0   0  8
  [29] .rel.debug_arange REL             00000000 00262c 000058 08     41  1c  4
  [30] .debug_pubnames   PROGBITS        00000000 000698 000049 00      0   0  1
  [31] .rel.debug_pubnam REL             00000000 002684 000010 08     41  1e  4
  [32] .debug_info       PROGBITS        00000000 0006e1 000adf 00      0   0  1
  [33] .rel.debug_info   REL             00000000 002694 000568 08     41  20  4
  [34] .debug_abbrev     PROGBITS        00000000 0011c0 00016e 00      0   0  1
  [35] .debug_line       PROGBITS        00000000 00132e 0002b2 00      0   0  1
  [36] .rel.debug_line   REL             00000000 002bfc 000038 08     41  23  4
  [37] .debug_frame      PROGBITS        00000000 0015e0 000058 00      0   0  4
  [38] .rel.debug_frame  REL             00000000 002c34 000020 08     41  25  4
  [39] .debug_str        PROGBITS        00000000 001638 0006ec 01  MS  0   0  1
  [40] .shstrtab         STRTAB          00000000 001d24 00014f 00      0   0  1
  [41] .symtab           SYMTAB          00000000 002c54 000750 10     42  5d  4
  [42] .strtab           STRTAB          00000000 0033a4 0003e4 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)
...
When I used nm to check symbols 'main' and 'func' in the executable,  both symbols are ok.

$ nm test |grep main
         U __libc_start_main@@GLIBC_2.0
080482fe T main

$ nm test |grep func
080482f4 T func

BUT when I used gdb-cvs to debug the executable, the breakpoints can not be set in this case. I also found that the symbol values of 'main' and 'func' are changed in GDB6.x version, but not changed in GDB 5.3 version. 

============ GDB 6.x version ==================
$ gdb test
GNU gdb 6.4.50.20051219-cvs
Copyright (C) 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) b main
Cannot access memory at address 0x10090542   <=== ERROR!
(gdb) b func
Cannot access memory at address 0x10090538   <=== ERROR!
(gdb)

============ GDB 5.3 version ==================
$ gdb test
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) b main
Breakpoint 1 at 0x804830e: file test.c, line 6.   <=== OK
(gdb) b func
Breakpoint 2 at 0x80482f7: file test.c, line 2.   <=== OK
(gdb)
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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