<div dir="ltr"><div>I think the arguments are largely compatibility for software that's already deployed and can't easily upgrade, and wanting to ensure a larger time frame for migration with a fallback if things go wrong. A bridge basically from what we had to where we'd like to be.</div><div><br></div><div>I think we also need to make the change in mainline lld as well - as you might know it's occasionally easier to upgrade a linker than to upgrade a debugger. I don't have any strong opinions on what we should name the command line option, but something that makes it unnecessary to actually know the values you want to put in would make it easier. -debug-comdat-relocation-filler=compat, bfd, <something> (yes, that's not great, but it's at least a start :)</div><div><br></div><div>-eric</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 28, 2020 at 10:00 PM Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Created <a href="https://reviews.llvm.org/D84825" rel="noreferrer" target="_blank">https://reviews.llvm.org/D84825</a> to be used for release/11.x<br>
<br>
I haven't seen a strong argument for changing other .debug_* but in<br>
any case I don't want to continue debating on this topic.<br>
<br>
* .debug_ranges & .debug_loc: -2 (lld<11: 0+addend)<br>
* .debug_*: 0 (lld<11: 0+addend, lld HEAD: -1)<br>
<br>
On Mon, Jul 27, 2020 at 12:47 PM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br>
><br>
><br>
><br>
> On Mon, Jul 27, 2020 at 9:11 AM Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>> wrote:<br>
>><br>
>> > I still think that we do bfd locs with a decent option to change for at least the current release and sources and then, once we're a little more certain we have everything that might want to parse dwarf (say by working with dwarf-discuss), we can change the default.<br>
>><br>
>><br>
>><br>
>> Given what’s been found, I think Eric/Dave are correct, use bfd behavior by default with an option to do the new thing. The option can be coded to let Sony (SCE debugger tuning) have it on by default.<br>
>><br>
>><br>
>><br>
>> Bringing it up on dwarf-discuss seems like a good idea too, you can refer to <a href="http://dwarfstd.org/ShowIssue.php?issue=200609.1" rel="noreferrer" target="_blank">http://dwarfstd.org/ShowIssue.php?issue=200609.1</a> as part of that.<br>
><br>
><br>
> Thanks for the pointer! Posted here: <a href="http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2020-July/004683.html" rel="noreferrer" target="_blank">http://lists.dwarfstd.org/pipermail/dwarf-discuss-dwarfstd.org/2020-July/004683.html</a><br>
><br>
>><br>
>> --paulr<br>
>><br>
>><br>
>><br>
>> From: Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>><br>
>> Sent: Saturday, July 25, 2020 12:56 AM<br>
>> To: Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>><br>
>> Cc: Hans Wennborg <<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>>; <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>; Alexey Lapshin <<a href="mailto:a.v.lapshin@mail.ru" target="_blank">a.v.lapshin@mail.ru</a>>; George Rimar <<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>>; Robinson, Paul <<a href="mailto:paul.robinson@sony.com" target="_blank">paul.robinson@sony.com</a>>; Adrian Prantl <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>>; Jonas Devlieghere <<a href="mailto:jdevlieghere@apple.com" target="_blank">jdevlieghere@apple.com</a>>; James Henderson <<a href="mailto:jh7370.2008@my.bristol.ac.uk" target="_blank">jh7370.2008@my.bristol.ac.uk</a>>; Peter Smith <<a href="mailto:Peter.Smith@arm.com" target="_blank">Peter.Smith@arm.com</a>>; David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>; Pavel Labath <<a href="mailto:pavel@labath.sk" target="_blank">pavel@labath.sk</a>><br>
>> Subject: Re: [llvm-dev] Switch to ld.bfd tombstone behavior by default<br>
>><br>
>><br>
>><br>
>> Hi Ray :)<br>
>><br>
>><br>
>><br>
>> While I understand the desire to say "we've updated everything we've found" the problem is that we don't know that we've found even much of the uses or can guarantee that people can upgrade, say their gdb or breakpad, as fast as their compiler. Even worse it's a change in behavior without much notice at all or even a particularly friendly way to recognize what they should do to fix it.<br>
>><br>
>><br>
>><br>
>> I still think that we do bfd locs with a decent option to change for at least the current release and sources and then, once we're a little more certain we have everything that might want to parse dwarf (say by working with dwarf-discuss), we can change the default.<br>
>><br>
>><br>
>><br>
>> -eric<br>
>><br>
>><br>
>><br>
>> On Fri, Jul 24, 2020 at 7:33 PM Fāng-ruì Sòng <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br>
>><br>
>> From my understanding the breakpad bug was also only related to .debug_line and has been fixed by <a href="https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2317730" rel="noreferrer" target="_blank">https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2317730</a><br>
>><br>
>><br>
>><br>
>> > a) .debug_ranges&.debug_loc => -2, .debug_line => 0, other .debug_* -> -1<br>
>> > b) .debug_ranges&.debug_loc => -2, other .debug_* => 0<br>
>><br>
>><br>
>><br>
>> I am still of the opinion that we should just do a), not b).<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> On Fri, Jul 24, 2020 at 9:33 AM Hans Wennborg <<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>> wrote:<br>
>><br>
>> On Fri, Jul 24, 2020 at 5:12 PM Fangrui Song <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br>
>> ><br>
>> > On 2020-07-24, Hans Wennborg via llvm-dev wrote:<br>
>> > >Sounds good to me from a release perspective.<br>
>> ><br>
>> > I think we need more input from the triage of<br>
>> > <a href="https://chromium-review.googlesource.com/c/chromium/src/+/2291352" rel="noreferrer" target="_blank">https://chromium-review.googlesource.com/c/chromium/src/+/2291352</a><br>
>> > whether it is just .debug_line or .debug_*<br>
>><br>
>> The issue we hit in Chromium is tracked here:<br>
>> <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1105559" rel="noreferrer" target="_blank">https://bugs.chromium.org/p/chromium/issues/detail?id=1105559</a> Doesn't<br>
>> look like it has any more info at the moment.<br>
>><br>
>> ><br>
>> > >On Fri, Jul 24, 2020 at 7:53 AM Eric Christopher via llvm-dev<br>
>> > ><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> > >><br>
>> > >> Hi All,<br>
>> > >><br>
>> > >> In general I think we should adopt Dave's plan here. The number of consumers that can (and have) been caught off guard by this change is just too high.<br>
>> > >><br>
>> > >> At the very least I think we should move this to opt in to the new tombstoning behavior by default and at most migrate to bfd's behavior for both the current release and in the current tree. If we want to make this sort of change in the future by default I think we're going to need to provide release notes about this and do aggressive outreach towards the consumers we do know before making the change. If anyone wants to drive that effort I'll happily provide any help or assistance in getting you in touch with at least the consumers I know about.<br>
>> > >><br>
>> > >> This change and the need for it is also probably worth a quick message to <a href="mailto:dwarf-discuss@dwarfstd.org" target="_blank">dwarf-discuss@dwarfstd.org</a> as well. Most of the major consumers and producers are on that list and it's probably one of the easiest ways to get this change out there.<br>
>> > >><br>
>> > >> Any strong objections to this path in the meantime?<br>
>> > >><br>
>> > >> Thanks!<br>
>> > >><br>
>> > >> -eric<br>
>> > >><br>
>> > >> On Tue, Jul 21, 2020 at 12:18 PM David Blaikie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> > >>><br>
>> > >>> On Tue, Jul 21, 2020 at 5:34 AM Alexey Lapshin<br>
>> > >>> <<a href="mailto:alapshin@accesssoftek.com" target="_blank">alapshin@accesssoftek.com</a>> wrote:<br>
>> > >>> ><br>
>> > >>> ><br>
>> > >>> > >On Mon, Jul 20, 2020 at 10:32 AM Alexey Lapshin<br>
>> > >>> > ><<a href="mailto:alapshin@accesssoftek.com" target="_blank">alapshin@accesssoftek.com</a>> wrote:<br>
>> > >>> > >><br>
>> > >>> > >> >On Fri, Jul 17, 2020 at 1:55 PM Alexey Lapshin <<a href="mailto:a.v.lapshin@mail.ru" target="_blank">a.v.lapshin@mail.ru</a>> wrote:<br>
>> > >>> > >> >><br>
>> > >>> > >> >> >Пятница, 17 июля 2020, 19:42 +03:00 от David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>>:<br>
>> > >>> > >> >> ><br>
>> > >>> > >> >> >On Fri, Jul 17, 2020 at 12:03 AM Fangrui Song <<a href="mailto:maskray@google.com" target="_blank">maskray@google.com</a>> wrote:<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> Thanks for the write-up!<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> On 2020-07-16, David Blaikie wrote:<br>
>> > >>> > >> >> >> >In short: Perhaps we should switch lld to the bfd-style tombstoning<br>
>> > >>> > >> >> >> >behavior for a release or two, letting users opt-in to testing with the new<br>
>> > >>> > >> >> >> >-1/-2 tombstoning in the interim, before switching to the new tombstone by<br>
>> > >>> > >> >> >> >default (while still having the flag to switch back when users find<br>
>> > >>> > >> >> >> >surprise places that can't handle the new behavior).<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >In long:<br>
>> > >>> > >> >> >> ><a href="https://reviews.llvm.org/D81784" rel="noreferrer" target="_blank">https://reviews.llvm.org/D81784</a> and follow-on patches modified the behavior<br>
>> > >>> > >> >> >> >of lld with regards to resolving relocations from debug sections to dead<br>
>> > >>> > >> >> >> >code (either comdat deduplicated, or gc-sections use).<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >A very quick summary of the situation:<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >Original Behavior:<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> > - bfd: 1 for debug_ranges(0 would prematurely terminate the list), 0<br>
>> > >>> > >> >> >> > elsewhere<br>
>> > >>> > >> >> >> > - gold/lld: 0+addend everywhere<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >Limitations/bugs:<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> > - bfd/gold/lld<br>
>> > >>> > >> >> >> > - doesn't support 0 as a valid executable address without ambiguities<br>
>> > >>> > >> >> >> > - gold/lld<br>
>> > >>> > >> >> >> > - ambiguities with large gc'd functions combined with a .text mapping<br>
>> > >>> > >> >> >> > that starts in relative low addresses<br>
>> > >>> > >> >> >> > - premature debug_range termination with zero-length functions (Clang<br>
>> > >>> > >> >> >> > produces these with __builtin_unreachable or non-void return<br>
>> > >>> > >> >> >> >type functions<br>
>> > >>> > >> >> >> > without a return statement)<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >New behavior:<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> > - -2 for DWARFv4 debug_loc, debug_ranges (-1 is a base address specifier<br>
>> > >>> > >> >> >> > there)<br>
>> > >>> > >> >> >> > - -1 elsewhere<br>
>> > >>> > >> >> >> > - linker flag to customize to other values if desired<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >Known issues:<br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> > - lldb's line table parsing can't handle -1 well at all (essentially<br>
>> > >>> > >> >> >> > unusable)<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> Pavel Labath will fix this soon <a href="https://reviews.llvm.org/D83957" rel="noreferrer" target="_blank">https://reviews.llvm.org/D83957</a><br>
>> > >>> > >> >> >> This is an unhandled address-space wraparound problem.<br>
>> > >>> > >> >> >> This pattern is potentially common - and other downstream DWARF<br>
>> > >>> > >> >> >> consumers might make similar line table handling mistakes.<br>
>> > >>> > >> >> ><br>
>> > >>> > >> >> >That's the thing - I'm not sure we can really classify them as<br>
>> > >>> > >> >> >"mistakes". I think bfd.ld's tombstoning behavior is about the only<br>
>> > >>> > >> >> >thing we can reasonably say DWARF consumers should /probably/ be<br>
>> > >>> > >> >> >expected to handle - and I'd imagine in many cases they haven't been<br>
>> > >>> > >> >> >written intentionally to handle it, but whatever behavior they have<br>
>> > >>> > >> >> >has accidentally been sufficient for their needs.<br>
>> > >>> > >> >><br>
>> > >>> > >> >> >> > - gdb's line table parsing ends up with different handling when breaking<br>
>> > >>> > >> >> >> > on gc'd functions (minor functionality issue)<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> This is just a behavior difference, not affecting users.<br>
>> > >>> > >> >> >> It did break a test if linked with LLD (gdb intrinsically has lots of<br>
>> > >>> > >> >> >> failing tests even if built with GCC+GNU ld).<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> Previous behavior (when an address is zero): a breakpoint on a<br>
>> > >>> > >> >> >> --gc-sections discarded function will be redirected to a larger line<br>
>> > >>> > >> >> >> number with debug info, even if that line can be an unrelated different<br>
>> > >>> > >> >> >> function.<br>
>> > >>> > >> >> >> New behavior is that the breakpoint is on a wrapped-around small address.<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> GDB 9.3 will restore the previous behavior<br>
>> > >>> > >> >> >> (<a href="https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=a8caed5d7faa639a1e6769eba551d15d8ddd9510" rel="noreferrer" target="_blank">https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=a8caed5d7faa639a1e6769eba551d15d8ddd9510</a>)<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> ><br>
>> > >>> > >> >> >> >I think there's enough risk in this work (even given the small number of<br>
>> > >>> > >> >> >> >bugs found so far), given there's a pretty wide array of debug info<br>
>> > >>> > >> >> >> >consumers out there, that we should change lld's default to match the<br>
>> > >>> > >> >> >> >long-lived bfd strategy. This would address my original motivation for<br>
>> > >>> > >> >> >> >raising all this (empty functions prematurely terminating the list), while<br>
>> > >>> > >> >> >> >letting users who want to experiment with it, or need it (like Alexey), can<br>
>> > >>> > >> >> >> >opt-in to the -1/-2 behavior.<br>
>> > >>> > >> >> >><br>
>> > >>> > >> >> >> I think we can only confidently say that there is enough risk in using<br>
>> > >>> > >> >> >> tombstone value -1 in .debug_line, but I'd not say tombstone value -1 in<br>
>> > >>> > >> >> >> other .debug_* can cause problems.<br>
>> > >>> > >> >><br>
>> > >>> > >> >> >Given how many DWARF parsers we've had to cleanup or migrate off in<br>
>> > >>> > >> >> >transitioning to DWARFv5 inside Google, I think that's a fair bit of<br>
>> > >>> > >> >> >evidence the set of parsers isn't as narrow/closed as we'd like and<br>
>> > >>> > >> >> >thus the number of places that might have issues isn't known/easily<br>
>> > >>> > >> >> >exhaustively tested. So I'm not so concerned about the bugs we've<br>
>> > >>> > >> >> >seen, but what that might indicate about the things that we don't know<br>
>> > >>> > >> >> >about and can't test (because we don't know about them). (of course,<br>
>> > >>> > >> >> >the flipside of that is that if we don't know about them, we can't<br>
>> > >>> > >> >> >tell people who own them to go check if they work with this opt-in<br>
>> > >>> > >> >> >feature - so they'll break whenever we turn this on by default - but<br>
>> > >>> > >> >> >perhaps in the interim we can get at least a few big LLD customers to<br>
>> > >>> > >> >> >deploy the feature and flush out some of the issues - happy for Google<br>
>> > >>> > >> >> >to use this internally, hopefully we can encourage Apple folks, Sony<br>
>> > >>> > >> >> >of course already has this semantic so nothing to find there most<br>
>> > >>> > >> >> >likely - Chromium, maybe Firefox, etc)<br>
>> > >>> > >> >><br>
>> > >>> > >> >> From the other side — when we already switched new behavior ON as default —<br>
>> > >>> > >> >> then it is easier to discover all these unknown cases. We have an option restoring<br>
>> > >>> > >> >> old behavior(which should be fine for all of the current users). Thus, everybody<br>
>> > >>> > >> >> who needs old behavior is able to continue using it.<br>
>> > >>> > >><br>
>> > >>> > >> >The cost to those users figuring out that it's a problem and finding<br>
>> > >>> > >> >the flags/adding them, etc, is non-zero.<br>
>> > >>> > >> >But, yes, as I said - eventually some of that will happen, sooner or<br>
>> > >>> > >> >later. But reducing how much of it happens is valuable too.<br>
>> > >>> > >><br>
>> > >>> > >> I agree. Reducing the impact on customers is important.<br>
>> > >>> > >> Though in this case, as you said, it would be done anyway(sooner or later).<br>
>> > >>> > >> Finally, I do not know what is more important: a) get feedback faster with<br>
>> > >>> > >> the cost of involved users and requiring them to make efforts<br>
>> > >>> > >> to figure out the problem. or b) test with a smaller set of users,<br>
>> > >>> > >> find more problematic cases, make new tombstone value to be default later.<br>
>> > >>> > >> I am kind of preferring a). But, b) is more safe and is OK.<br>
>> > >>> > >><br>
>> > >>> > >><br>
>> > >>> > >> >> That makes transition more understandable. All problems would be explicitly seen. Then,<br>
>> > >>> > >> >> If we will know about new problems - we could adapt the current solution. Similar to this >suggestion:<br>
>> > >>> > >> >><br>
>> > >>> > >> >> a) .debug_ranges&.debug_loc => -2, .debug_line => 0, other .debug_* -> -1<br>
>> > >>> > >><br>
>> > >>> > >> >The issue I have with this is that it's reflective of the known<br>
>> > >>> > >> >breakage in some tools that happen to have a quick turnaround/feedback<br>
>> > >>> > >> >- and assumes all the other sections are significantly less likely to<br>
>> > >>> > >> >have problems with this format - and I don't think we have enough data<br>
>> > >>> > >> >to make that estimate.<br>
>> > >>> > >><br>
>> > >>> > >> We could extend that rule when/if new problems become known.<br>
>> > >>> > >> Or, customers could fix their code or use option returning old behavior<br>
>> > >>> > >> and it would probably not be necessary to extend the rule.<br>
>> > >>> > >><br>
>> > >>> > >> >I think having a clear flag for bfd behavior or new behavior would be<br>
>> > >>> > >> >good, keeping it bfd-by-default for now, evangelizing (patch notes,<br>
>> > >>> > >> >outreach to other projects and tool developers) the new functionality<br>
>> > >>> > >> >& then changing the default shortly after an LLVM release (perhaps 12<br>
>> > >>> > >> >- but perhaps longer) to give it time to bake for trunk-following<br>
>> > >>> > >> >users (ample time for them to pick it up on their schedule, see what<br>
>> > >>> > >> >other tools might break, whether they're isolated enough to expect a<br>
>> > >>> > >> >quick turnaround or whether we should get them updated and then wait a<br>
>> > >>> > >> >while longer.<br>
>> > >>> > >><br>
>> > >>> > >> yes, doing clear flag for bfd behavior or new behavior,<br>
>> > >>> > >> and keep it bfd-by-default for now would be OK and is more safe.<br>
>> > >>> > >><br>
>> > >>> > >><br>
>> > >>> > >> >> This would help while dwarf users are preparing their code to the new solution.<br>
>> > >>> > >> >><br>
>> > >>> > >> >> Is option restoring old behavior not enough to solve problems caused by new tombstone >value?<br>
>> > >>> > >><br>
>> > >>> > >> >I don't personally think it is enough - given some of the known<br>
>> > >>> > >> >breakage - I think that points to a fair bit of reasonably possible<br>
>> > >>> > >> >unknown breakage. Having a few big (like Apple and Google) users<br>
>> > >>> > >> >switch over by default & potentially flush out a few more issues (or<br>
>> > >>> > >> >not -but build confidence that there aren't more issues) I think is an<br>
>> > >>> > >> >appropriate way to roll out a change like this.<br>
>> > >>> > >><br>
>> > >>> > >> >(minor doubt: I wonder how well the bfd tombstoning works in DWARFv5<br>
>> > >>> > >> >(rnglists/loclists) or in debug_range/debug_loc that uses base address<br>
>> > >>> > >> >specifiers, where the zero-without-addend doesn't have a chance to<br>
>> > >>> > >> >make an empty range (because it's not a start/end pair, it's a<br>
>> > >>> > >> >start+offset pair - so the offset remains non-zero)... if bfd<br>
>> > >>> > >> >tombstoning breaks DWARFv5 parsing (or base address specifiers in<br>
>> > >>> > >> >range/loc) in common consumers I might be more inclined to support<br>
>> > >>> > >> >enabling new tombstoning by default sooner (though if we could enable<br>
>> > >>> > >> >it just for DWARFv5 that might be nice - but not practical, since the<br>
>> > >>> > >> >linker doesn't know what DWARF it's linking & could be linking<br>
>> > >>> > >> >multiple versions))<br>
>> > >>> > >><br>
>> > >>> > >> - From the point of view overlapping address ranges,<br>
>> > >>> > >> both bfd-solution(using 1) and old lld solution(using 0) are equal.<br>
>> > >>> ><br>
>> > >>> > >gold and lld's solution was a bit more complicated than using zero (&<br>
>> > >>> > >bfd's solution uses 1 in debug_ranges, but not in other debug<br>
>> > >>> > >sections). lld and gold use 0+addend in ranges.<br>
>> > >>> ><br>
>> > >>> > right. I am talking about the same(though assumed that context<br>
>> > >>> > instead of detailed explanation). it should be "bfd-solution(using 1<br>
>> > >>> > for debug_ranges) and lld/gold solution(using 0+addend)".<br>
>> > >>> > Thank you for pointing into that.<br>
>> > >>> ><br>
>> > >>> > >0 alone in ranges<br>
>> > >>> > >would be more problematic than any of the other deployed solutions,<br>
>> > >>> > >because it would lead to the debug_ranges contributions being<br>
>> > >>> > >terminated early (0, 0 terminates the list - so debug_ranges for a CU<br>
>> > >>> > >with one gc'd function mid-way through the range list would drop the<br>
>> > >>> > >rest of the range lit) - that's why bfd uses 1 for debug_ranges rather<br>
>> > >>> > >than 0 which it uses elsewhere (though the same fix should,<br>
>> > >>> > >technically, be applied to debug_loc too for the same reasons as<br>
>> > >>> > >debug_ranges). the 0+addend approach of gold/lld works OK (except for<br>
>> > >>> > >the low address overlap) except when there's a zero-length function,<br>
>> > >>> > >then 0+addend == 0 for the end of the range, andy ou get a 0,0 entry<br>
>> > >>> > >with the premature range list termination issues.<br>
>> > >>> > ><br>
>> > >>> > >> for the "start+offset pair" case they could result in overlapping address ranges.<br>
>> > >>> ><br>
>> > >>> > >Not quite - the way bfd does things, at least in debug_ranges without<br>
>> > >>> > >base address specifiers (bit hard to isolate for a consumer, really -<br>
>> > >>> > >though they could special case zero base addresses... sort of) the<br>
>> > >>> > >empty ranges are (1, 1) - they're actually empty. Whereas lld's<br>
>> > >>> > >approach ends up with (0+addend, 0+addend) which is usually (0, size)<br>
>> > >>> > >which has issues with overlap on systems that have a valid low address<br>
>> > >>> > >range (or if you have sufficiently large functions).<br>
>> > >>> > ><br>
>> > >>> ><br>
>> > >>> > There is a case when size of address range is set not by relocated value but by constant value:<br>
>> > >>> ><br>
>> > >>> > DWARF5:<br>
>> > >>> > DW_RLE_startx_length<br>
>> > >>> > DW_RLE_start_length<br>
>> > >>> ><br>
>> > >>> > {address of deleted code, length}<br>
>> > >>> > {address of existing code, length}<br>
>> > >>> ><br>
>> > >>> > DWARF4:<br>
>> > >>> > base address selection entry: {-1, address of deleted code}<br>
>> > >>> > following range list entry: {0, length}<br>
>> > >>> > base address selection entry: {-1, address of existing code}<br>
>> > >>> > following range list entry: {0, length}<br>
>> > >>> ><br>
>> > >>> > In these cases linker do not see the length of address range<br>
>> > >>> > and could not change it(using 1, or 0, or 0+addend) to be zero length<br>
>> > >>> > address range. Thus address ranges could overlap.<br>
>> > >>> ><br>
>> > >>> > So in both DWARF5 and DWARF4 there are cases when address ranges<br>
>> > >>> > could be overlapped and it could not be solved without new meaning for tombstone value.<br>
>> > >>> ><br>
>> > >>> > >> - From the point of view correct parsing of DWARF 5 - it looks like they are equally good.<br>
>> > >>> > ><br>
>> > >>> > >Yep, DWARFv5 is more complicated - bfd's approach would be marginally<br>
>> > >>> > >better even for addr+offset encodings in debug_rnglists - since it'd<br>
>> > >>> > >always produce a 0 for the addr, whereas gold/lld's behavior can in<br>
>> > >>> > >some cases (eg: "void f1() { } __attribute__((nodebug)) void f2() { }<br>
>> > >>> > >void f3() { }" with -fno-function-sections - you'll end up with the<br>
>> > >>> > >range for f3 starting at a non-zero addend - this debug info will be<br>
>> > >>> > >worse for bfd/ld (if the DWARF for this object was included, but the<br>
>> > >>> > >whole .text section was discarded (eg: maybe there's a global variable<br>
>> > >>> > >in this object which is linked in, but -gc-section is still able to<br>
>> > >>> > >discard the whole .text section as unreferenced) then gold/lld's<br>
>> > >>> > >approach would make f3 unidentifiable as dead code (because it doesn't<br>
>> > >>> > >have a tombstone start) but bfd's approach would work (assuming zero<br>
>> > >>> > >isn't a valid address))<br>
>> > >>> ><br>
>> > >>> > I see. thanks.<br>
>> > >>> ><br>
>> > >>> > ><br>
>> > >>> > >> - From the point of view correct parsing of DWARF 4 - it looks bfd-solution(using 1)<br>
>> > >>> > >> is better than the old lld solution(using 0). When range list entry contains<br>
>> > >>> > >> addresses(start+end) which should be relocated and for the zero-length functions,<br>
>> > >>> > >> bfd-solution would result in range list entry: {1, 1}, while old lld solution<br>
>> > >>> > >> would result in {0, 0}, and match with the end of list entry.<br>
>> > >>> > >> That is the original problem that started this thread.<br>
>> > >>> > ><br>
>> > >>> > >Only comes up for zero-length functions, because gold/lld's approach<br>
>> > >>> > >was 0+addend, not straight 0.<br>
>> > >>> > ><br>
>> > >>> ><br>
>> > >>> > right. for zero-length functions.<br>
>> > >>> ><br>
>> > >>> > >> Though it looks like there still exist case when range list could be terminated earlier:<br>
>> > >>> > >><br>
>> > >>> > >> base address selection entry: {-1, address of deleted code}<br>
>> > >>> > >> following range list entry: {0, 0} << points to the same address as set by base address selection entry and has zero size.<br>
>> > >>> > ><br>
>> > >>> > >That's a bug in the producer (though a good point - I've probably made<br>
>> > >>> > >that bug in LLVM) - the linker can't solve that problem, since the<br>
>> > >>> > >linker can't touch the literal unrelocated 0, 0.<br>
>> > >>> > ><br>
>> > >>> > >> after linker resolved relocations it would look like this, for bfd case:<br>
>> > >>> > >><br>
>> > >>> > >> base address selection entry: {-1, 1}<br>
>> > >>> > >> following range list entry: {0, 0} <<<<<<<<<<<<br>
>> > >>> > >><br>
>> > >>> > >> So there still exists {0,0} entry which could be considered as the end of list entry.<br>
>> > >>> > >><br>
>> > >>> > >> But old lld solution has the same problem, thus it would not be new.<br>
>> > >>> > >><br>
>> > >>> > >> - Additionally, AFAIK gdb has special processing for overlapped address<br>
>> > >>> > >> ranges starting from 0. Using bfd tombstone value could break that processing - I would check it.<br>
>> > >>> > ><br>
>> > >>> > >Not sure I understand - presumably gdb's special processing is<br>
>> > >>> > >intended to work with bfd's tombstoning, since it's been the most<br>
>> > >>> > >common/prolific unix linker, the one intended to work with gdb (they<br>
>> > >>> > >exist in the same repository) for decades, right?<br>
>> > >>> ><br>
>> > >>> > I think I misunderstood this: "I wonder how well the bfd tombstoning works in DWARFv5<br>
>> > >>> > (rnglists/loclists)". I read it as we would like to use bfd tombstoning(1 for ranges)<br>
>> > >>> > for rnglists/loclists also.<br>
>> > >>> ><br>
>> > >>> > So, right. bfd's tombstoning works correctly with gdb until 1 is not used<br>
>> > >>> > for rnglists/loclists as tombstone value.<br>
>> > >>><br>
>> > >>> Not quite parsing this, but I think we're on the same page - that<br>
>> > >>> bfd's tombstoning "1 for debug_ranges/debug_loc, 0 (not 0+addend, but<br>
>> > >>> absolute 0) for everything else (including debug_loclists and<br>
>> > >>> debug_rnglists)" is probably the most likely to work for gdb, since<br>
>> > >>> it's been deployed for a long time.<br>
>> > >>><br>
>> > >>> - Dave<br>
>> > >>><br>
>> > >>> PS: Fair point about base address specifiers being able to produce 0,0<br>
>> > >>> entries - wouldn't mind fixing that in LLVM if I knew of an easy way<br>
>> > >>> to test at compile-time whether the difference between two labels was<br>
>> > >>> zero, then skip that entry in the lists entirely. Would save space and<br>
>> > >>> address the original issue I had with debug_ranges terminating early.<br>
>> > >>> (should've thought about that much earlier than my more alarmist "oh<br>
>> > >>> deer, we need to fundamentally change how linkers resolve relocations<br>
>> > >>> because everything's been broken and we just didn't realize it" -<br>
>> > >>> fixing the compiler not to produce zero-length ranges would've been<br>
>> > >>> less risky & probably still worth doing - though addressing the<br>
>> > >>> broader issue to help with your situation of 0 as a valid address I<br>
>> > >>> think is still good too)<br>
>> > >>><br>
>> > >>> ><br>
>> > >>> > Alexey.<br>
>> > >>> ><br>
>> > >>> > > > >> With consideration for satefy for the upcoming release/11.x, we can make<br>
>> > >>> > > > >> two choices:<br>
>> > >>> > > > >><br>
>> > >>> > > > >> a) .debug_ranges&.debug_loc => -2, .debug_line => 0, other .debug_* -> -1<br>
>> > >>> > > > >> b) .debug_ranges&.debug_loc => -2, other .debug_* => 0<br>
>> > >>> > > > >><br>
>> > >>> > > > >> Delaying .debug_line => -1 for one or two release sounds good to me.<br>
>> > >>> > > > >> So LLD 11 or 12 linked binaries can be debugged by LLDB 10. This is a<br>
>> > >>> > > > >> nice property.<br>
>> > >>> > > > >><br>
>> > >>> > > > >> This write-up proposes b), but I'd say a) is likely sufficient. With the<br>
>> > >>> > > > >> available information, I cannot yet say that a) will have more risk.<br>
>> > >>> > > > ><br>
>> > >>> > > > >Risk is about the unknowns - and it still seems like a lot of<br>
>> > >>> > > > >unknowns. While there are probably many more consumers that read<br>
>> > >>> > > > >.debug_line than other sections, reading debug_info (for instance) is<br>
>> > >>> > > > >necessary for inline frames in symbolizing - still probably one of the<br>
>> > >>> > > > >most common uses of DWARF I'd guess. (what about stack unwinding using<br>
>> > >>> > > > >debug_frame? that'd worry me a bit if anyone got /that/ wrong because<br>
>> > >>> > > > >of this change)<br>
>> > >>> > > > ><br>
>> > >>> > > > >> > - chromium/firefox have some tools that were broken:<br>
>> > >>> > > > >> > <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=1102223#c5" rel="noreferrer" target="_blank">https://bugs.chromium.org/p/chromium/issues/detail?id=1102223#c5</a><br>
>> > >>> > > > >><br>
>> > >>> > > > >> This is potentially related to other .debug_* (not .debug_line)<br>
>> > >>> > > > >> I hope Chromium developers can chime in here:) The breakage was<br>
>> > >>> > > > >> unfortunate but I don't know how we could have avoided that. IMHO this<br>
>> > >>> > > > >> is no different from "clang started to emit a new DW_FORM_* and a<br>
>> > >>> > > > >> postprocessing tool of .debug chokes on that" Whether we want to<br>
>> > >>> > > > >> suppress that particular DW_FORM_* definitely should depend on how<br>
>> > >>> > > > >> likely it can cause problems, but we can't yet say we have to hold off<br>
>> > >>> > > > >> on a feature for a solved (precisely, mitigated) problem.<br>
>> > >>> > > > ><br>
>> > >>> > > > >LLVM has no custom forms and I'd be super cautious about adding any<br>
>> > >>> > > > >that were on by default because of how bad that breakage would be.<br>
>> > >>> > > > ><br>
>> > >>> > > > >I'm not so concerned about the problems we know - but what they tell<br>
>> > >>> > > > >us about the problems that might arise from use cases we don't know.<br>
>> > >>> > > > >All the other projects out there that might have custom DWARF parsers<br>
>> > >>> > > > >to do some ad-hoc things.<br>
>> > >>> > > > ><br>
>> > >>> > > > >(also, ultimately - given how far-reaching this is, I think we'll want<br>
>> > >>> > > > >some tidier flags that are more user-focussed. I'd hope for a flag<br>
>> > >>> > > > >that gives BFD-like semantics (though I'd be OK with fixing debug_loc<br>
>> > >>> > > > >(using 1 instead of 0) to work the same as debug_ranges while we're<br>
>> > >>> > > > >there - a minor divergence from BFD, but highly likely to not cause<br>
>> > >>> > > > >problems/fall out naturally from a simple implementation of parsing<br>
>> > >>> > > > >that section) - something that's been in-use and tested by basically<br>
>> > >>> > > > >everyone for decades. And another flag for the new semantics (-2 for<br>
>> > >>> > > > >debug_loc/debug_ranges, -1 everywhere else). Customizable per-section<br>
>> > >>> > > > >expression-based support I think is a recipe for platform divergence &<br>
>> > >>> > > > >I'd rather it not be available/supported at all, but if you really<br>
>> > >>> > > > >want to keep it in, I'd at least rather it not be the feature we<br>
>> > >>> > > > >promote to users about how they can test/opt in/out of the behavior<br>
>> > >>> > > > >when they're seeing breakages or want to test the future semantics)<br>
>> > >>> > > > ><br>
>> > >>> > > > >> >I'm not sure how to get the word out to DWARF consumers that they should<br>
>> > >>> > > > >> >consider this new experimental behavior. Ray's done a good job<br>
>> > >>> > > > >> >evangelizing/discussing this with gdb and lldb at least - and of course<br>
>> > >>> > > > >> >having turned it on by default briefly has found some users (like Chromium)<br>
>> > >>> > > > >> >that we probably wouldn't have found no matter how long we left this as an<br>
>> > >>> > > > >> >experimental option... so some things are going to break when we switch no<br>
>> > >>> > > > >> >matter what.<br>
>> > >>> > > > >><br>
>> > >>> > > > >> Thank you for following up with some GNU folks on their lists!<br>
>> > >>> > > > >> If folks want to follow along the thread:<br>
>> > >>> > > > >> <a href="https://sourceware.org/pipermail/binutils/2020-June/111376.html" rel="noreferrer" target="_blank">https://sourceware.org/pipermail/binutils/2020-June/111376.html</a><br>
>> > >>> > > > >><br>
>> > >>> > > > >> We have informed binutils, elfutils-devel (elfutils has a few debug<br>
>> > >>> > > > >> tools) and gdb. I don't recall that anyone has thought about problems<br>
>> > >>> > > > >> with a tombstone value.<br>
>> > >>> > > > >><br>
>> > >>> > > > >> ><br>
>> > >>> > > > >> >P.S: Sony's already been using the -1 technique with their debugger and<br>
>> > >>> > > > >> >linker for a while, so they may want to keep this on by default for SCE -<br>
>> > >>> > > > >> >but I'm not sure how to do that in-tree.<br>
>> > >>> > > > >> ><br>
>> > >>> > > > >> ><br>
>> > >>> > > > >> >Clang doesn't know which lld<br>
>> > >>> > > > >> >version it's running, so whether the flag can be specified, I would think?<br>
>> > >>> > > > >> >(so it'd be hard to have Clang go "if SCE and LLD, pass the flag to use<br>
>> > >>> > > > >> >-1", I think) - if there is a way to make that decision in the compiler<br>
>> > >>> > > > >.> >driver+linker, then we'd have a question of "default new behavior except<br>
>> > >>> > > > >> >when tuning for LLDB and GDB" or "default bfd behavior except when tuning<br>
>> > >>> > > > >> >for SCE".<br>
>> > >>> > > > >><br>
>> > >>> > > > >> I've been involed in another thread on SHF_LINK_ORDER (<a href="https://sourceware.org/pipermail/binutils/2020-" rel="noreferrer" target="_blank">https://sourceware.org/pipermail/binutils/2020-</a><br>
>> > >>> > > > >July/112415.html ).<br>
>> > >>> > > > >> We may need a way to tell codegen about the used linker.<br>
>> > >>> > > > >><br>
>> > >>> > > > >> pcc proposed -mbinutils-version= - This is nice in that some MC<br>
>> > >>> > > > >> decisions related to -fno-integrated-as can use this option as well.<br>
>> > >>> > > > >> jyknight proposed -mlinker-version= and syntax like -fuse-ld=bfd:2.34<br>
>> > >>> > > > >><br>
>> > >>> > > > >> This may get more complex if the generated object file want to be linked<br>
>> > >>> > > > >> with more than one linker. This discussion probably deserves its own<br>
>> > >>> > > > >> thread.<br>
>> > >>> > > ><br>
>> > >>> > > ><br>
>> > >>> > > > --<br>
>> > >>> > > > Alexey Lapshin<br>
>> > >>> > > ><br>
>> > >>> > > _______________________________________________<br>
>> > >>> > > LLVM Developers mailing list<br>
>> > >>> > > <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> > >>> > > <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>> > >>> _______________________________________________<br>
>> > >>> LLVM Developers mailing list<br>
>> > >>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> > >>> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>> > >><br>
>> > >> _______________________________________________<br>
>> > >> LLVM Developers mailing list<br>
>> > >> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> > >> <a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>> > >_______________________________________________<br>
>> > >LLVM Developers mailing list<br>
>> > ><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> > ><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>><br>
>><br>
>><br>
>><br>
>> --<br>
>><br>
>> 宋方睿<br>
<br>
<br>
<br>
-- <br>
宋方睿<br>
</blockquote></div></div>