<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=koi8-r">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">Thanks for commens, David ! Let me answer from the end.</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><br>
</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">>It seems strange to me that the linker would special
 case the debug_* sections </span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">>(& that that special casing would limit how they can
 be used) given the discussion we were </span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">>having about the linker wanting to treat debug info as
 just normal sections.</span><br>
</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">There are two different things about handing such sections in
 linker.</span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">We are talking about multiple .debug_info*, where there
 is some main .debug_info and</span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">multiple COMDAT .debug_info* section with types.</span></span></p>
<p><span style="color: rgb(33, 33, 33);">Linker </span><span style="color: rgb(33, 33, 33);">do deduplication of COMDATs
</span><span style="color: rgb(33, 33, 33);">and </span><span style="color: rgb(33, 33, 33);">does</span><span style="color: rgb(33, 33, 33);"> </span><span style="color: rgb(33, 33, 33);">not care about section names, flags etc,</span><br>
</p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">so it handles debug_* sections just as normal sections
 and that is already works as expected.</span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Issue my patch trying to address is a different case and comes
 from llvm::DWARFObject class. We use it when</span></span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">LLD do error reporting </span></span><span style="color: rgb(33, 33, 33);">(to
 get information about source lines) and for --gdb-index. In both cases it relies on current</span></p>
<p><span style="color: rgb(33, 33, 33);">DWARFObject API </span><span style="color: rgb(33, 33, 33);">that among other things assumes that th</span><span style="color: rgb(33, 33, 33);">ere are single .debug_info, .debug_abbrev and .debug_line.</span></p>
<p><span style="color: rgb(33, 33, 33);">(https://github.com/llvm-mirror/llvm/blob/master/include/llvm/DebugInfo/DWARF/DWARFObject.h#L36)</span></p>
<p><span style="color: rgb(33, 33, 33);"><br>
</span></p>
<p>What I really wanted to do in this patch is to error out when this class is used in case multiple of above sections are present. Because<br>
</p>
<p>with current implementation result would be just a mess, we would use the last debug section with a given name only and result would be<br>
</p>
<p>undefined.<br>
</p>
<p>My approach was not entirelly correct, as you mentioned it would not work in case of multiple .debug_types. Honestly I forgot<br>
</p>
<p>about them when tried to sim<span style="font-size: 12pt;">plify code</span><span style="font-size: 12pt;">, we do not use this sections there and had no test to fail, I`ll add it.</span></p>
<p><br>
</p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">>What's the error handling case you mention? </span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;"><br>
</span></p>
<p><font color="#212121">One of use cases I mentioned above (for reference our code is <a href="https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L73">https://github.com/llvm-mirror/lld/blob/master/ELF/InputFiles.cpp#L73</a>​),</font></p>
<p><font color="#212121">in short we use .debug_line​ for reporting error locations and scan ​.debug_info for variables to report them for reporting duplicate </font></p>
<p><font color="#212121">declarations.</font></p>
<p><font color="#212121">​</font></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">>Presumably it works for multiple debug_types sections, so perhaps that support could be generalized to multiple</span></p>
<p><span style="color: rgb(33, 33, 33); font-size: 12pt;">>debug_info sections as well? Then this failure could be restricted to only multiple debug_info sections when using gdb-index?</span><br>
</p>
<div style="color: rgb(33, 33, 33);">
<div>
<div dir="ltr">></div>
<div dir="ltr">>That way DWARF5 type units (that use debug_info sections) would just work? (except when using gdb-index)<br>
<br>
</div>
<div dir="ltr">I do not see way it could be restricted to only --gdb-index case. We discussed multiple .debug_info case only I think,<br>
</div>
<div dir="ltr">but looks important point that DWARF5 spec at p366<span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> (</span><a href="http://dwarfstd.org/doc/DWARF5.pdf" class="remarkup-link" target="_blank" rel="noreferrer" style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; text-decoration-line: none; color: rgb(19, 108, 178); cursor: pointer;">http://dwarfstd.org/doc/DWARF5.pdf</a><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">)
 also mentions it can be multiple of <span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">.debug_abrev, </span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">.debug_info,
 .debug_line</span><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"> sections. </span></span>We use
 them for error reporting as well. (not we, but llvm::DWARFObject<span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"> we re</span><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">l</span><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">y
 on </span><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;">actually).</span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><br>
</span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Given all above
 I see 2 solutions.</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"></span>1)
<span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">
As far I can tell there is no producers of multiple .debug_info/.debug_abbrev/.debug_line yet. And at least basing on our</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">discussions
 looks we do not plan to support it in closest future (and it is actually unclear we will).</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">That
 is why I prepared patch using less intrusive approach to restrict multiple debug sections. What can I do for it</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">is
 to fix/update it so it will just black list </span></span></span>sections we do not expect to be not unique.</div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">2)
 We could teach <span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">llvm::DWARFObject</span> to handle multiple <span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"> .debug_info/.debug_abbrev/.debug_line</span>.
 That would be helpful</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">for
 tools like llvm-dwarfdump (in case they be used for some wild object with such sections) and would allow LLD to work with such objects. </span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">Given
 our discussion I am not sure it is useful/worth to do, </span></span></span>but I will be happy to try to implement it if such way be chosen.</div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">What
 do you guys think, what should we do ?</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><span style="color: rgb(33, 33, 33); font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);"><br>
</span></span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">George.</span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><br>
</span></span></div>
<div dir="ltr"><span style="font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px;"><span style="color: rgb(33, 33, 33); font-family: "Segoe UI", "Segoe UI Emoji", "Segoe UI Symbol", Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><br>
</span></span></div>
</div>
</div>
</body>
</html>