[PATCH] ld: Support customized output section type
Michael Matz
matz@suse.de
Fri Feb 4 16:05:29 GMT 2022
Hello Luca,
On Thu, 3 Feb 2022, Luca Boccassi wrote:
> I understand you don't like it, but as I've already explained again, and
> again, and again, it is needed, and frankly I'm getting exhausted.
But it's not, you are wrong on that account. It once was necessary until
the problem (of generating writable sectons by default) was fixed. There
was only a very short time window when (READONLY) was supported _and_
necessary. The bug (PR26378) got fixed in January 2021 (so 2.36 should
have it), and since then we have:
% cat x.c
int main()
{
return 0;
}
% cat metadata.ld
SECTIONS
{
.note.foobar : ALIGN(4) {
BYTE(0x42)
}
}
INSERT AFTER .note.gnu.build-id;
% gcc x.c -Wl,-T,metadata.ld
% readelf -SW a.out | grep note
[ 2] .note.gnu.property NOTE 0000000000400338 000338 000020
00 A 0 0 8
[ 3] .note.gnu.build-id NOTE 0000000000400358 000358 000024
00 A 0 0 4
[ 4] .note.foobar NOTE 000000000040037c 00037c 000001 00
A 0 0 4
[ 5] .note.ABI-tag NOTE 0000000000400380 000380 000020 00
A 0 0 4
% ld -v
GNU ld (GNU Binutils; openSUSE Tumbleweed) 2.37.20211112-3
As you can see, no "(READONLY)" but still a read-only .note.foobar
section. (Ignore the fact that my contents of .note.foobar isn't a
correct SHT_NOTE content)
That's what I meant with ill-advised: a feature was added to work-around
a bug, instead of the bug being fixed. The bug now is fixed and the
feature is useless but needs to be kept for backward comp, except maybe
it could be removed again if the few users could be convinced to just not
use it anymore; so could you be convinced? :)
Ciao,
Michael.
More information about the Binutils
mailing list