<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On May 5, 2010, at 6:44 PM, Nathan Jeffords wrote:</div><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; "><div style="word-wrap:break-word"><div><div class="im"><div>...</div></div><div>Thanks, applied in r103150!  llvm-mc -filetype=obj probably needs a similar patch.</div>
<div class="im"><div><br></div></div></div></div></blockquote><div><br></div><div>cool!, I will make that change and submit it too. </div></div></blockquote><div><br></div>Thanks!</div><div><br><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">
<div style="word-wrap:break-word"><div><div class="im"><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
</div></div></div></blockquote></div></blockquote><div>Also, w.r.t. section handling stuff, there is this fixme in the asmprinter:</div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div><div><br></div><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">    } <span style="color:#b50da1">else</span> <span style="color:#b50da1">if</span> (<span style="color:#b50da1">const</span> <span style="color:#b50da1">char</span> *LinkOnce = MAI->getLinkOnceDirective()) {</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(20, 135, 11)"><span style="color:#000000">      </span>// .globl _foo</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
      OutStreamer.EmitSymbolAttribute(GVSym, MCSA_Global);</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(20, 135, 11)"><span style="color:#000000">      </span>// FIXME: linkonce should be a section attribute, handled by COFF Section</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(20, 135, 11)"><span style="color:#000000">      </span>// assignment.</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(58, 0, 252)">
<span style="color:#000000">      </span><span style="color:#14870b">// <a href="http://sourceware.org/binutils/docs-2.20/as/Linkonce.html#Linkonce" target="_blank"><span style="color:#3a00fc">http://sourceware.org/binutils/docs-2.20/as/Linkonce.html#Linkonce</span></a></span></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(20, 135, 11)"><span style="color:#000000">      </span>// .linkonce discard</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(20, 135, 11)">
<span style="color:#000000">      </span>// FIXME: It would be nice to use .linkonce samesize for non-common</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px;color:rgb(20, 135, 11)"><span style="color:#000000">      </span>// globals.</div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">      OutStreamer.EmitRawText(StringRef(LinkOnce));</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">    } <span style="color:#b50da1">else</span> {</div>
<div><font face="Inconsolata"><br></font></div><div><font face="Inconsolata">Basically, it seems like the MCSectionCOFF implementation should get the linkonce bit.  I'm not an expert on COFF, but I think that's the right place for it.  ".linkonce" will also have to be added as a new MCStreamer api, which would set the bit.</font></div>
<div><font face="Inconsolata"><br></font></div></div></div></div></blockquote><div><br></div><div>linkonce is one option for COFF COMDAT sections. I think that this call should not exist at all, instead, when the AsmPrinter asks the TLOF what section to use for the global, TLOF should create a new unique section with the bit set already.</div></div></blockquote><div><br></div><div>Yeah, I completely agree.  That's what I was thinking when I wrote that comment :).  However, doing it that way would break .s emission, which is "bad" :)</div><div><br></div><div>Also, to implement a COFF assembler, we'd need to support the .linkonce directive.  To me, it seems most straight-forward to just support .linkonce as a MCStreamer callback.</div><br><blockquote type="cite"><div class="gmail_quote">
<div></div></div><div>One thing that I don't understand is why common symbols do not get sections assigned to them. I ended up assigning them to the '.bss' section in my streamer (which I now know was wrong) but it still seems like they should be part of some section. At least in COFF, they will be handled as a COMDAT just like symbols with the linkonce linkage type.</div>
<div><br></div><div>I guess this all goes back to the assembly language view of things. I think I have enough information to handle these things correctly now.</div></blockquote></div><br><div>I'm not sure (all I know about COFF is what's on this page: <a href="http://www.nondot.org/sabre/os/articles/ExecutableFileFormats/">http://www.nondot.org/sabre/os/articles/ExecutableFileFormats/</a>) but you can find out by making a .s file, running it through a coff assembler (like gas) and seeing what bits it produces.  When working on the macho assembler, we found it very very useful to produce bitwise identical output to the system assembler, allowing us to just diff the .o files.</div><div><br></div><div>-Chris</div></body></html>