[Patch, LD]Fix GDB crash caused by discarding the grouped debug sections

Terry Guo terry.guo@arm.com
Mon Dec 8 03:47:00 GMT 2014


Hi there,

One of my prebuilt library (produced by non-gnu tool chain) groups  debug
sections into two ways, some debug sections exist as individual sections
while some are grouped together to form section groups. For example:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk
Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0
0  0
  [ 1] .text             PROGBITS        00000000 000034 000378 00  AX  0
0  4
  [ 2] .arm_vfe_header   PROGBITS        00000000 0003ac 000004 00      0
0  4
  [ 3] .bss              NOBITS          00000000 0003b0 000044 00  WA  0
0  1
  [ 4] .comment          PROGBITS        00000000 0003b0 000d68 00      0
0  1
  [ 5] .data             PROGBITS        00000000 001118 000024 00  WA  0
0  4
  [ 6] .debug_frame      PROGBITS        00000000 00113c 0001e4 00      0
0  1
  [ 7] .debug_info       PROGBITS        00000000 001320 0000b0 00      0
0  1
  [ 8] .debug_info       PROGBITS        00000000 0013d0 000178 00      0
0  1
  [ 9] .debug_info       PROGBITS        00000000 001548 000634 00      0
0  1
  [10] .debug_line       PROGBITS        00000000 001b7c 000094 00      0
0  1
  [11] .debug_line       PROGBITS        00000000 001c10 000394 00      0
0  1
  [12] .debug_loc        PROGBITS        00000000 001fa4 0004d0 00      0
0  1
  [13] .debug_macinfo    PROGBITS        00000000 002474 000350 00      0
0  1
  [14] .debug_pubnames   PROGBITS        00000000 0027c4 000034 00      0
0  1
  [15] .debug_pubnames   PROGBITS        00000000 0027f8 0000a2 00      0
0  1
  [16] __ARM_grp.tmFlags GROUP           00000000 00289c 000010 04     169
99  4
  [17] .debug_info       PROGBITS        00000000 0028ac 0000b4 00   G  0
0  1
  [18] .debug_line       PROGBITS        00000000 002960 00009c 00   G  0
0  1
  [19] .debug_macinfo    PROGBITS        00000000 0029fc 001ff8 00   G  0
0  1

Section 7 is an individual section while section 16/17/18/19 are grouped
debug sections. Current LD always keeps the individual debug section like
section 7 and discards grouped debug sections like 16/17/18/19. The problem
is caused when there is a relocation from individual section 7 to grouped
section 17. Since section 17 is discarded, such kind of relocation can't be
properly resolved in final elf file. This causes GDB crash when try to parse
debug sections in such elf file. The attached patch tries to fix the issue
by keeping all debug sections. Giving we can compress the debug section, I
think the increased size isn't a big deal.

Tested with Binutils regression test and no regression. Is it OK? Any
comments are welcomed.

BR,
Terry
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ld-keeps-all-debug-section-v2.txt
URL: <https://sourceware.org/pipermail/binutils/attachments/20141208/376ff493/attachment.txt>


More information about the Binutils mailing list