[PATCH v4 0/5] AArch64 tests: remove RWX permissions on segments in tests using custom linker scripts

Matthieu Longo matthieu.longo@arm.com
Thu May 22 14:35:18 GMT 2025
Several custom linker scripts for AArch64 tests don't provide information enough to the linker to assess the right set of permisssions on segments (i.e. Read/Write/Execute). It resulted in the bundling of all the sections in a same segment with the union of all the required permissions: RWX.
A segment with such lax permissions constitutes a security hole, so the linker emits the following warning message:
   <ELF file> has a LOAD segment with RWX permissions.
This warning message is noisy in the tests, and has no reason to exist.

This issue can be addressed in two ways:
- either by providing the right set of permissions on a section so that the linker assigns them to a segment with compatible permissions.
- or by providing alignment information so that the linker can move automatically to a new segment and set the right permission for non-executable data.

The second option specifying the alignment constraints seems to be the preferred approach, even if not explicitly recommended. Examples of linker scripts for AArch64 are available at [1].

This patch series contains the following changes:
  - fixing of typos present in AArch64, Arm, and TIC6x testsuites.
  - relaxing some matching patterns to allow more flexibility in the section ordering.
  - removing of RWX permissions on segments in AArch64 tests. Those fixes were splitted in 3 independent patches: one per linker script and impacted tests.
  
The Arm testsuite also contains the warning for RWX permissions on segments. I will hopefully publish ulteriorly a patch series to fix the issues.

## References:
[1]: https://developer.arm.com/documentation/dui0474/m/gnu-ld-script-support-in-armlink/default-gnu-ld-scripts-used-by-armlink/default-ld-script-when-building-an-executable?lang=en

## Testing  

Regression testing on:
  - arm-none-eabi
  - aarch64-unknown-linux-gnu
  - tic6x-none-elf
showed no failures, and the warning message was eliminated for all the tests under ld/testsuite/ld-aarch64*.

Regards,
Matthieu.


Matthieu Longo (5):
  Arm tests: relax some matching patterns
  AArch64, Arm and TIC6x tests: fix typo in linker scripts
  AArch64 tests: remove RWX permissions on segments
  AArch64 BTI/PAC PLT tests: remove RWX permissions on segments
  AArch64 variant PCS tests: remove RWX permissions on segments

 ld/testsuite/ld-aarch64/aarch64.ld            | 20 ++--
 ld/testsuite/ld-aarch64/gc-got-relocs.d       | 15 ++-
 ld/testsuite/ld-aarch64/gc-plt-relocs.d       | 60 ++++++------
 ld/testsuite/ld-aarch64/gc-relocs-257-dyn.d   |  4 +-
 ld/testsuite/ld-aarch64/gc-relocs-257.d       |  4 +-
 ld/testsuite/ld-aarch64/gc-tls-relocs.d       | 14 +--
 .../protections/bti-and-memory-seal-plt-1-a.d | 10 +-
 .../ld-aarch64/protections/bti-far-1.d        |  4 +-
 .../ld-aarch64/protections/bti-far-opt.d      |  4 +-
 .../ld-aarch64/protections/bti-far.ld         | 26 +++--
 .../ld-aarch64/protections/bti-pac-plt-1-a.d  |  6 +-
 .../ld-aarch64/protections/bti-pac-plt-1-b.d  |  6 +-
 .../ld-aarch64/protections/bti-pac-plt-2-a.d  |  6 +-
 .../ld-aarch64/protections/bti-pac-plt-2-b.d  |  6 +-
 .../ld-aarch64/protections/bti-pac-plt-3-a.d  |  6 +-
 .../ld-aarch64/protections/bti-pac-plt-3-b.d  |  6 +-
 .../ld-aarch64/protections/bti-plt-1-a.d      |  6 +-
 .../ld-aarch64/protections/bti-plt-1-b.d      |  6 +-
 .../ld-aarch64/protections/bti-plt-1-c.d      |  6 +-
 .../ld-aarch64/protections/bti-plt-3.d        |  6 +-
 .../ld-aarch64/protections/bti-plt.ld         | 25 +++--
 .../ld-aarch64/protections/pac-plt-1-a.d      |  6 +-
 .../ld-aarch64/protections/pac-plt-1-b.d      |  6 +-
 .../ld-aarch64/protections/pac-plt-2.d        |  4 +-
 ld/testsuite/ld-aarch64/relocs-ilp32.ld       |  2 +-
 ld/testsuite/ld-aarch64/relocs.ld             |  2 +-
 ld/testsuite/ld-aarch64/variant_pcs-now.d     | 98 +++++++++----------
 ld/testsuite/ld-aarch64/variant_pcs-r.d       | 10 +-
 ld/testsuite/ld-aarch64/variant_pcs-shared.d  | 98 +++++++++----------
 ld/testsuite/ld-aarch64/variant_pcs.ld        | 32 +++---
 ld/testsuite/ld-arm/arm.ld                    |  2 +-
 ld/testsuite/ld-arm/arm_purecode.ld           |  2 +-
 ld/testsuite/ld-arm/discard-unwind.ld         |  2 +-
 ld/testsuite/ld-arm/script-type.ld            |  4 +-
 ld/testsuite/ld-arm/unwind-1.d                |  2 +-
 ld/testsuite/ld-arm/unwind-2.d                |  2 +-
 ld/testsuite/ld-arm/unwind-3.d                |  2 +-
 ld/testsuite/ld-arm/unwind-4.d                |  2 +-
 ld/testsuite/ld-tic6x/discard-unwind.ld       |  2 +-
 ld/testsuite/ld-tic6x/unwind.ld               |  2 +-
 40 files changed, 284 insertions(+), 242 deletions(-)

-- 
2.49.0



More information about the Binutils mailing list