[PATCH] D36097: Prototype fix for lld DWARF parsing of base address selection entries in range lists

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 3 07:02:30 PDT 2017


grimar added a comment.

After debugging I found place which looks will not allow this patch to work properly.
See. Output from testcase you provided is:

  	.section	.debug_ranges,"", at progbits
  .Ldebug_ranges0:
  	.quad	-1
  	.quad	.Lfunc_begin0
  	.quad	.Lfunc_begin0-.Lfunc_begin0
  	.quad	.Lfunc_end0-.Lfunc_begin0
  	.quad	.Lfunc_begin2-.Lfunc_begin0
  	.quad	.Lfunc_end2-.Lfunc_begin0
  	.quad	0
  	.quad	0

And here is relocations produced:

  Relocation section '.rela.debug_ranges' at offset 0x4c8 contains 1 entries:
    Offset          Info           Type           Sym. Value    Sym. Name + Addend
  000000000008  000200000001 R_X86_64_64       0000000000000000 .text + 0

Noticable thing here is that single relocation produced has offset 8. That points on a second quad
of base address entry of .debug_ranges. But problem is that code that takes SectionIndex assumed
that relocation pointing on a StartAddress (LowPC, first quad) will exist, so code takes section index from it
and ignores section index from second quad:

  bool DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
                                    uint32_t *offset_ptr) {
  ...
      entry.StartAddress =
          data.getRelocatedAddress(offset_ptr, &entry.SectionIndex);
      entry.EndAddress = data.getRelocatedAddress(offset_ptr);

What I think we should do here is either take section index from relocation pointing on EndAddress(HighPC), or
what is probably more preferable, take it from both HighPC/LowPC, and check that section index is equal for both 
or not exist for both or exist for only one of addresses.


https://reviews.llvm.org/D36097





More information about the llvm-commits mailing list