[elfcopy] Support unordered .debug_info references to .debug_ranges
authorJim Huang <jserv@0xlab.org>
Thu, 26 May 2011 03:29:37 +0000 (11:29 +0800)
committerKan-Ru Chen <kanru@0xlab.org>
Thu, 26 May 2011 03:29:37 +0000 (11:29 +0800)
commit5b3900f2f9afced8cdbfe09770fdd59a1965bc1d
tree4cbfae42088c624fcbe0086036a13f0e9fbe4a6c
parent62c1bed1c4505369cac2e72fbe30452a598fb690
[elfcopy] Support unordered .debug_info references to .debug_ranges

While trying to create shared libraries, libelfcopy always complains:
libelfcopy: Error: Range lists in .debug_info section aren't in ascending
order!
libelfcopy: Warning: Range lists in .debug_ranges section start at 0x60

Introduce the support of unordered .debug_info references to
.debug_ranges is known to resolve.

Close Issue #20 :
    http://code.google.com/p/0xdroid/issues/detail?id=20

Inspired by the contributed of Jan Kratochvil to binutils.

--
C++ source reproducer:
class A {
public:
  A();
  void f(){}
};
class C {
  C();
};
C::C() {
  A* p = new A;
  p->f();
}

Contents of the .debug_info section:
 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <29>   DW_AT_ranges      : 0x60
 <1><dc>: Abbrev Number: 15 (DW_TAG_subprogram)
 <2><102>: Abbrev Number: 17 (DW_TAG_lexical_block)
    <103>   DW_AT_ranges      : 0x0
 <1><111>: Abbrev Number: 19 (DW_TAG_subprogram)
 <2><133>: Abbrev Number: 17 (DW_TAG_lexical_block)
    <134>   DW_AT_ranges      : 0x30

Checked GCC dwarf2out_finish() it is natural there to produce it that way.
--
dwarf.c