Can the .rodata section be avoided?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Can the .rodata section be avoided?

David Chisnall via cfe-dev
I have to develop a research prototype where I want to avoid having the .rodata section. Is there any way of allocating string literals in .data instead? 



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can the .rodata section be avoided?

David Chisnall via cfe-dev
On Tue, Sep 26, 2017 at 10:02:55AM +0100, Divya Muthukumaran via cfe-dev wrote:
> I have to develop a research prototype where I want to avoid having the
> .rodata section. Is there any way of allocating string literals in .data
> instead?

Why do you want to do that?

Joerg
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can the .rodata section be avoided?

David Chisnall via cfe-dev
In reply to this post by David Chisnall via cfe-dev

What I usually do in this kind of situation, is adapt the linker scripts to also collect ‘.rodata’ input sections into the ‘.data’ output section, for example by changing:

 

SECTIONS

{

  ...

  .rodata 0 : { *(.rodata .rodata.*) }

  .data 0 : { *(.data .data.*) }

  ...

}

to:

SECTIONS

{

  ...

  /* .rodata 0 : { *(.rodata .rodata.*) } */

  .data 0 : { *(.data .data.* .rodata .rodata.*) }

  ...

}

 

Alternatively, you could use ‘objcopy’ to rename the ‘.rodata’ sections to the equivalent ‘.data’ sections.

 

            MartinO

 

From: cfe-dev [mailto:[hidden email]] On Behalf Of Divya Muthukumaran via cfe-dev
Sent: Tuesday, September 26, 2017 10:03 AM
To: Clang Dev <[hidden email]>
Subject: [cfe-dev] Can the .rodata section be avoided?

 

I have to develop a research prototype where I want to avoid having the .rodata section. Is there any way of allocating string literals in .data instead? 

 

 

--------------------------------------------------------------
Intel Research and Development Ireland Limited
Registered in Ireland
Registered Office: Collinstown Industrial Park, Leixlip, County Kildare
Registered Number: 308263

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev