Output section type (READONLY)

Nick Clifton nickc@redhat.com
Tue Feb 1 11:07:30 GMT 2022


Hi Fangrui,

> For READONLY, I am thinking more in line with "whether we need this
> feature at all"... If no input has SHF_WRITE, the output naturally does
> not have SHF_WRITE; if an input has SHF_WRITE, chancing the output to
> non-SHF_WRITE is weird and error-prone.

I do not know if this counts as a *justified* use of READONLY, but it was
used recently in an attempt to add a new feature to Fedora rawhide:

   https://fedoraproject.org/wiki/Changes/Package_information_on_ELF_objects#New_system:_.note.package

The feature used a custom linker script fragment to add a note section
into the executable being created, and this script used the READONLY
keyword:

   SECTIONS
   {
     .note.package (READONLY) : ALIGN(4) {
         BYTE(0x04) BYTE(0x00) BYTE(0x00) BYTE(0x00) /* Length of Owner including NUL */
  [...]
     }
   }
   INSERT AFTER .note.gnu.build-id;

This turned out to be problematic however as gold does not support the
READONLY attribute, nor the INSERT AFTER directive...

Anyway I think that the point here was that was no input section, so
the author needed another way to tell the linker that the output section
should be readonly.

Cheers
   Nick



More information about the Binutils mailing list