<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>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:Wingdings;
panose-1:5 0 0 0 0 0 0 0 0 0;}
@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:0cm;
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
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
margin-top:3.75pt;
margin-right:0cm;
margin-bottom:3.75pt;
margin-left:0cm;
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:0cm;
margin-bottom:3.75pt;
margin-left:0cm;
background:#FFEE94;
font-size:10.0pt;
font-family:"Arial",sans-serif;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle21
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>Thank you for help, Paul!<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>I finally decided that it would be more convenient to make this ELF post-processing as a separate utility which is quite easy thanks to LLVM </span><span style='font-family:Wingdings;color:#1F497D'>J</span><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='color:#1F497D'>Best regards,<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'>Dmitri Botcharnikov</span><span style='color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p></div><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b>From:</b> Robinson, Paul [mailto:paul.robinson@sony.com] <br><b>Sent:</b> 27 ноября 2019 г. 18:03<br><b>To:</b> dmitry.b@samsung.com<br><b>Cc:</b> 'llvm-dev@lists.llvm.org' <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 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 0cm 0cm 0cm'><p class=MsoNormal><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org">llvm-dev-bounces@lists.llvm.org</a>> <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> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><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 <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>><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:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt'><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"><tr><td style='padding:.75pt .75pt .75pt .75pt'><p> <o:p></o:p></p></td></tr></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"><tr><td style='padding:.75pt .75pt .75pt .75pt'><p> <img border=0 width=520 height=144 id="_x0000_i1025" src="cid:image001.gif@01D5A69C.B2C23A40"> <o:p></o:p></p></td></tr></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><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Arial",sans-serif;display:none'><o:p> </o:p></span></p><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><table id=bannersignimg data-cui-lock="true" namo_lock><tr><td><p> </p>
</td></tr></table><table id=confidentialsignimg data-cui-lock="true" namo_lock><tr><td><p> <img style="border: 0px solid currentColor; border-image: none; width: 520px; height: 144px; display: inline-block;" unselectable="on" data-cui-image="true" src="cid:cafe_image_0@s-core.co.kr"> </p>
</td></tr></table></body></html><img src='http://ext.w1.samsung.net/mail/ext/v1/external/status/update?userid=dmitry.b&do=bWFpbElEPTIwMTkxMTI5MDcwNjQ0ZXVjYXMxcDJmOWQ5MWYyMDYxMzYyNzE1YmQ1NGUzNDVhMGZlYzNhMSZyZWNpcGllbnRBZGRyZXNzPWxsdm0tZGV2QGxpc3RzLmxsdm0ub3Jn' border=0 width=0 height=0 style='display:none'>