[cfe-dev] Can the .rodata section be avoided?

ORiordan, Martin via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 26 02:43:22 PDT 2017


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:cfe-dev-bounces at lists.llvm.org] On Behalf Of Divya Muthukumaran via cfe-dev
Sent: Tuesday, September 26, 2017 10:03 AM
To: Clang Dev <cfe-dev at lists.llvm.org>
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170926/cc8094aa/attachment.html>


More information about the cfe-dev mailing list