<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style id="mysingle_style">v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style id="knox_style"><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        margin-top:3.75pt;
        margin-right:0in;
        margin-bottom:3.75pt;
        margin-left:0in;
        font-size:10.0pt;
        font-family:"Arial",sans-serif;}
p.search-word, li.search-word, div.search-word
        {mso-style-name:search-word;
        margin-top:3.75pt;
        margin-right:0in;
        margin-bottom:3.75pt;
        margin-left:0in;
        background:#FFEE94;
        font-size:10.0pt;
        font-family:"Arial",sans-serif;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="overflow:auto">
<div class="WordSection1">
<p class="MsoNormal">Usually a cross-section reference is done with a symbolic label, not directly using section indexes, because the indexes aren’t determined until very late.  A symbolic cross-section reference would turn into an ELF relocation, which would
 automatically have the correct section index in it.  Hopefully you’re not trying to encode the section index of the referencing section into the string.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">To put a string into a string section, I would set the correct section, create a temp symbol, use the streamer’s EmitLabel() method to define it, and emit the string as bytes.  To reference the string from elsewhere, I’d use an MCExpr (probably
 MCSymbolRefExpr) to emit a reference to the symbol created previously.  You can see this sort of thing in lib/MC/MCDwarf.cpp, I hope without needing to know too much about how DWARF itself works.<o:p></o:p></p>
<p class="MsoNormal">--paulr<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of
</b>Dmitri Botcharnikov via llvm-dev<br>
<b>Sent:</b> Wednesday, November 27, 2019 2:44 AM<br>
<b>To:</b> llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] ELF string table access in backend<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Thank you for suggestion. But anyway I have no access to section index so I need ELF post-processing pass. Is there any way to do it in current framework?<o:p></o:p></p>
<p> <o:p></o:p></p>
<p>--------- <b>Original Message</b> ---------<o:p></o:p></p>
<p><b>Sender</b> : David Blaikie <dblaikie@gmail.com><o:p></o:p></p>
<p><b>Date</b> : 2019-11-27 05:08 (GMT+3)<o:p></o:p></p>
<p><b>Title</b> : Re: [llvm-dev] ELF string table access in backend<o:p></o:p></p>
<p> <o:p></o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">When you say "the string table" - are you referring to a particular section? There can be multiple/any section that contains strings that can be deduplicated by the linker (see
 debug_str for example) - and you can create your own sections that have that kind of functionality if you like (again, debug_str might be a goode xample to look at)<o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">On Tue, Nov 26, 2019 at 9:17 AM Dmitri Botcharnikov via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">Hello,<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">While developing a backend for the custom target I need to create a custom ELF section and put there some mapping of
 other ELF sections to strings.<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">For this I have two questions:<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">- How can I get a section index in the section table from within target ELF streamer? Is it possible?
<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">- How can I get access to the string table section, put some string and get back its offset in string table?<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">If it is not possible maybe there is a way to somehow post-process ELF for this before actually writing to file?<o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> <o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">Best regards,</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#1F497D">Dmitri Botcharnikov</span><span style="font-size:10.0pt;font-family:"Arial",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> <o:p></o:p></span></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:10.0pt;font-family:"Arial",sans-serif"> <o:p></o:p></span></p>
</div>
<table class="MsoNormalTable" border="0" cellspacing="3" cellpadding="0" id="gmail-m_-848084837941684508bannersignimg">
<tbody>
<tr>
<td style="padding:.75pt .75pt .75pt .75pt">
<p> <o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;display:none"><o:p> </o:p></span></p>
<table class="MsoNormalTable" border="0" cellspacing="3" cellpadding="0" id="gmail-m_-848084837941684508confidentialsignimg">
<tbody>
<tr>
<td style="padding:.75pt .75pt .75pt .75pt">
<p> <img border="0" width="520" height="144" style="width:5.4166in;height:1.5in" id="_x0000_i1025" src="cid:image001.gif@01D5A506.C98A0470"> <o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
</div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif">_______________________________________________<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://protect2.fireeye.com/url?k=b547b669-e889b7dd-b5463d26-000babdfecba-a5c89ecab318fefb&u=https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></span></p>
</blockquote>
</div>
<p>Best regards,<o:p></o:p></p>
<p>Dmitri Botcharnikov<o:p></o:p></p>
<p> <o:p></o:p></p>
<table class="MsoNormalTable" border="0" cellspacing="3" cellpadding="0" id="bannersignimg">
<tbody>
<tr>
<td style="padding:.75pt .75pt .75pt .75pt">
<p> <o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial",sans-serif;display:none"><o:p> </o:p></span></p>
<table class="MsoNormalTable" border="0" cellspacing="3" cellpadding="0" id="confidentialsignimg">
<tbody>
<tr>
<td style="padding:.75pt .75pt .75pt .75pt">
<p> <img border="0" width="520" height="144" style="width:5.4166in;height:1.5in" id="_x0000_i1026" src="cid:image001.gif@01D5A506.C98A0470"> <o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><img border="0" id="_x0000_i1027" src="http://ext.w1.samsung.net/mail/ext/v1/external/status/update?userid=dmitry.b&do=bWFpbElEPTIwMTkxMTI3MDc0NDI5ZXVjbXMxcDJlOWE2OGNlNzU4YzgxNjNjY2U4OTJiZDAxNmQxYzVhMSZyZWNpcGllbnRBZGRyZXNzPWxsdm0tZGV2QGxpc3RzLmxsdm0ub3Jn"><o:p></o:p></p>
</div>
</body>
</html>