[PATCH] D54361: [ELF] .gdb_index: fix CuOff when a .debug_info section contains more than 1 CU
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 13 10:07:01 PST 2018
MaskRay added inline comments.
================
Comment at: lld/trunk/ELF/SyntheticSections.cpp:2432
+ //
+ // We assume both CUs[*].CuOff and Set.Offset are increasing.
+ while (I < CUs.size() && CUs[I].CuOffset < Set.Offset)
----------------
dblaikie wrote:
> Could you fix this? This assumption seems pretty subtle/likely to break valid DWARF in surprising/hard to diagnose ways.
>
> Moving the declaration of I into the for(Set) loop (ie: putting it just before this while loop) should suffice - and a test case with 2 pubnames in the reverse order to CUs would demonstrate the fix?
>
> (would be nice to do a binary search rather than a linear one on the CU offsets, since they are naturally sorted by offset)
>
>
I used `std::lower_bound(CUs.begin(), CUs.end(), ...) - CUs.begin())` in a former version but @ruiu thought it was too complicated...
Repository:
rL LLVM
https://reviews.llvm.org/D54361
More information about the llvm-commits
mailing list