]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
elf: Add PT_GNU_MUTABLE azanella/pt_gnu_mutable
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 4 Mar 2025 14:39:30 +0000 (11:39 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 7 Mar 2025 11:48:50 +0000 (08:48 -0300)
commit03b4f972f3f509d2d39c1126830811180ed66359
treed1ab97636cfec956f2d5fcebc6be3497d395c7e6
parent6f5e2c066bac9ad51d89f159925f9760423be2f7
elf: Add PT_GNU_MUTABLE

The section mark a memory region that should not be sealed if
GNU_PROPERTY_MEMORY_SEAL attribute is present.  PT_GNU_MUTABLE
section names start with ".gnu.mutable" and are maximum page
aligned and have a size of maximum page size.

For instance the code:

unsigned char mutable_array1[64]
__attribute__ ((section (GNU_MUTABLE_SECTION_NAME)))
   = { 0 };
unsigned char mutable_array2[32]
__attribute__ ((section (GNU_MUTABLE_SECTION_NAME)))
   = { 0 };

places both 'mutable_array1' and 'mutable_array2' on a page
aligned memory region in a size of a page (the alignment and size
can be change with -Wl,-z,max-page-size= linker option).

The linker sets the alignment and size to make it easier to
loader to avoid sealing the area (since mseal only work on
multiple of page size areas), and to simplify the userland
process to change protection of either seal the area after
initialization.

Change-Id: I1304af9ec6b5b2682a1416b2b3d8d5b2c65b9f1c
TODO: add tests.
bfd/elf.c
binutils/readelf.c
include/elf/common.h
ld/ldgram.y
ld/scripttempl/elf.sc
ld/testsuite/ld-aarch64/variant_pcs-r.d
ld/testsuite/ld-x86-64/pr27590.rd
ld/testsuite/ld-x86-64/split-by-file.rd