[llvm-dev] ELF string table access in backend

Dmitri Botcharnikov via llvm-dev llvm-dev at lists.llvm.org
Thu Nov 28 23:06:43 PST 2019


Thank you for help, Paul!

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 J

 

Best regards,

Dmitri Botcharnikov

 

 

From: Robinson, Paul [mailto:paul.robinson at sony.com] 
Sent: 27 ноября 2019 г. 18:03
To: dmitry.b at samsung.com
Cc: 'llvm-dev at lists.llvm.org' <llvm-dev at lists.llvm.org>
Subject: RE: [llvm-dev] ELF string table access in backend

 

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.

 

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.

--paulr

 

From: llvm-dev <llvm-dev-bounces at lists.llvm.org <mailto:llvm-dev-bounces at lists.llvm.org> > On Behalf Of Dmitri Botcharnikov via llvm-dev
Sent: Wednesday, November 27, 2019 2:44 AM
To: llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> 
Subject: Re: [llvm-dev] ELF string table access in backend

 

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?

 

--------- Original Message ---------

Sender : David Blaikie <dblaikie at gmail.com <mailto:dblaikie at gmail.com> >

Date : 2019-11-27 05:08 (GMT+3)

Title : Re: [llvm-dev] ELF string table access in backend

 

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)

 

On Tue, Nov 26, 2019 at 9:17 AM Dmitri Botcharnikov via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> > wrote:

Hello,

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.

For this I have two questions:

- How can I get a section index in the section table from within target ELF streamer? Is it possible? 

- How can I get access to the string table section, put some string and get back its offset in string table?

If it is not possible maybe there is a way to somehow post-process ELF for this before actually writing to file?

 

Best regards,

Dmitri Botcharnikov

 

 


 

 


  

_______________________________________________
LLVM Developers mailing list
llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> 
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev <https://protect2.fireeye.com/url?k=b547b669-e889b7dd-b5463d26-000babdfecba-a5c89ecab318fefb&u=https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev> 

Best regards,

Dmitri Botcharnikov

 


 

 


  

  <http://ext.w1.samsung.net/mail/ext/v1/external/status/update?userid=dmitry.b&do=bWFpbElEPTIwMTkxMTI3MDc0NDI5ZXVjbXMxcDJlOWE2OGNlNzU4YzgxNjNjY2U4OTJiZDAxNmQxYzVhMSZyZWNpcGllbnRBZGRyZXNzPWxsdm0tZGV2QGxpc3RzLmxsdm0ub3Jn> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191129/a509047f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 13168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191129/a509047f/attachment-0001.gif>


More information about the llvm-dev mailing list