<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
Hi Fangrui,</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
> It is safe. The comment is about the references (isd->sections; script->orphanSections).<span></span></div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
Thanks for the confirmation.</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
> <span>(I can fix it after one week if I haven't seen a patch yet:) )</span><br>
</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
I've posted a patch this morning.</div>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
<a href="https://reviews.llvm.org/D106427" id="LPlnk">https://reviews.llvm.org/D106427</a><br>
</div>
<div class="_Entity _EType_OWALinkPreview _EId_OWALinkPreview _EReadonly_1"></div>
<br>
<div style="font-family: "Courier New", monospace; font-size: 10pt; color: rgb(0, 0, 0);">
Thank you,
<div>Amilendra<br>
</div>
</div>
<div>
<div id="appendonsend"></div>
<div style="font-family:"Courier New",monospace; font-size:10pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Fangrui Song <maskray@google.com><br>
<b>Sent:</b> Wednesday, July 21, 2021 8:34 PM<br>
<b>To:</b> Amilendra Kodithuwakku <Amilendra.Kodithuwakku@arm.com><br>
<b>Cc:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm-dev] [lld][ELF] Regarding removeUnusedSyntheticSections()</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="PlainText"><br>
On 2021-07-17, Amilendra Kodithuwakku via llvm-dev wrote:<br>
>Hi,<br>
><br>
>I am working on an LLD port for a research project based on the AARCH64 based architecture which requires adding a new SyntheticSection to InStruct, but doing so gives me 2 failed x86 tests:<br>
>  lld :: ELF/shuffle-sections-init-fini.s<br>
>  lld :: ELF/shuffle-sections.s<br>
>This new SyntheticSection is empty for X86, so in principle those tests should be unaffected.<br>
><br>
>The immediate reason is that the shuffle implementation, maybeShuffle(), is dependent on inputSections. I think the real cause is that removeUnusedSyntheticSections() does not remove empty sections from the inputSections vector (although there is a comment
 that says that it does that). AFAICT elements are removed only from isd->sections and script->orphanSections.<br>
><br>
>I could not find any uses of empty sections after this point, but you never know so thought of asking here. Is there a reason empty SyntheticSections in inputSections is preserved after removeUnusedSyntheticSections()? Or is there another approach that will
 not require maintaining the shuffle tests everytime a Synthetic section is added/removed?<br>
><br>
>If it is safe to remove empty SyntheticSections from inputSections I can send out a patch to do that. Locally I have a simple patch that confirms that the shuffle tests do not fail after adding a new SyntheticSection. I can't think of new regression tests
 to add because this behavior cannot be demonstrated without adding a new SyntheticSection to InStruct.<br>
<br>
It is safe. The comment is about the references (isd->sections; script->orphanSections).<br>
<br>
(I can fix it after one week if I haven't seen a patch yet:) )<br>
<br>
>Thanks<br>
>Amilendra<br>
</div>
</span></font></div>
</div>
</body>
</html>