]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld: fix alignment issue for ARM thumb long branch stub using PureCode section
authorTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Tue, 17 Dec 2024 17:56:10 +0000 (18:56 +0100)
committerTorbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Thu, 23 Jan 2025 09:36:03 +0000 (10:36 +0100)
commit014a7c0fa36ecc41918e5793052dd3ae8372efe5
treec7096278373a77de515d75acbc18cba99c4d4b86
parent3097045a18a8878bc40548bd0995f9bad5609c43
ld: fix alignment issue for ARM thumb long branch stub using PureCode section

When pure-code option is activated. The linker creates for M-profile architecures
a 2-bytes branch instruction. This causes the section alignment to be set to 2-byte
alignment instead of 4-byte alignment. This is a problem for long branch stub
without pure-code section as it contains a 32-bit address as data, which is expected
to be 4-byte aligned. Hence creating a long branch stub for PureCode section followed
by a long branch stub will result in a misalignment for the 32-bit address.

An easy fix is to add a nop instruction after the branch to keep the section alignment
to 4 bytes.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
Co-authored-by: Guillaume VACHERIAS <guillaume.vacherias@st.com>
bfd/elf32-arm.c
ld/testsuite/ld-arm/arm-elf.exp
ld/testsuite/ld-arm/farcall-thumb2-purecode-consecutive-veneer.d [new file with mode: 0644]
ld/testsuite/ld-arm/farcall-thumb2-purecode-consecutive-veneer.s [new file with mode: 0644]
ld/testsuite/ld-arm/farcall-thumb2-purecode.d