[PATCH] D31464: [ELF] - Stop producing broken entries in .debug_ranges section

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 08:08:37 PDT 2017


grimar created this revision.
Herald added a subscriber: aprantl.

Address range lists are contained in a separate section called .debug_ranges.
In short it contains start/end address range pairs.
zero/zero pair means the end of range list. Values of this section
in object files are relocatable.

Perviously LLD would generate wrong output if relocation applied
was against discarded section. LLD would write addend of relocation in that case,
what produced broken ranges, like (0x00000000 - [Addend value]), for example.

According to DWARF specification, it is safe to produce range entries with
same begining and end address: "A range list entry (but not a base address selection or end of list entry) whose beginning and
ending addresses are equal has no effect because the size of the range covered by such an
entry is zero"

GNU LD in such case produces stub entry with start/end = 1.
(https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=e4067dbb2a3368dbf908b39c5435c84d51abc9f3)

I suggest to do the same. I am planning to use it for .gdb_index, https://reviews.llvm.org/D31424 description contains information about issue I faced,
this patch should fix it and that allows to use relocated output for generating .gdb_index section in final without additional parsing
of relocations.

Probably we want to do the same for other debug sections (but place zero instead of 1, that is what ld do, though I did not investigate that deeper),
 but now I faced problems only with .debug_ranges, so patch changes behavior for that section only.


https://reviews.llvm.org/D31464

Files:
  ELF/InputSection.cpp
  ELF/InputSection.h
  test/ELF/debug-ranges-reloc.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31464.93374.patch
Type: text/x-patch
Size: 5888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170329/cf6843e7/attachment.bin>


More information about the llvm-commits mailing list