Output section type (READONLY)

Fangrui Song i@maskray.me
Tue Feb 1 03:39:30 GMT 2022


On 2022-01-31, Nick Clifton wrote:
>Hi Fangrui,
>
>>Well, READONLY has another behavior that it forces non-SHF_WRITE output
>>even if an input section has the SHF_WRITE flag.
>
>>I find this quite dangerous if an input section has the SHF_WRITE flag.
>>I do not see in what circumstances a user may want this behavior.
>>This just seems very dangerous to use in general.
>
>So basically what you are saying is that if a input section is assigned
>to an output sections with incompatible attributes (presumably because of a
>linker script declaration) then the linker should issue a warning message,
>yes ?
>
>By extension then, this feature should cover not just the readonly section
>attribute, but the NOLOAD attribute as well.

For NOLOAD, .noload (NOLOAD) : { *(.noload) } makes the output .noload
SHT_NOBITS even if there is a non-empty SHT_PROGBITS .noload section.
I don't know whether the linker should issue a warning.

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.

>This sounds like it might be an interesting feature to implement for someone
>looking to gain experience with the binutils.

Ah, sure:)

>Cheers
>  Nick
>
>
>
>


More information about the Binutils mailing list