aarch64: Fix BTI support in libgcc [PR96001]
lse.S did not have the GNU property note markup and the BTI c instructions that are necessary when it is built with branch protection. The notes are only added when libgcc is built with branch protection, because old linkers mishandle the note (merge them incorrectly or emit warnings), the BTI instructions are added unconditionally. Note: BTI c is only necessary at function entry if the function may be called indirectly, currently lse functions are not called indirectly, but BTI is added for ABI reasons e.g. to allow linkers later to emit stub code with indirect jump. 2020-07-09 Szabolcs Nagy <szabolcs.nagy@arm.com> libgcc/ChangeLog: PR target/96001 * config/aarch64/lse.S: Add BTI marking and related definitions, and add BTI c to function entries.
This commit is contained in:
parent
e73ec75548
commit
f0f62fa032
|
@ -136,6 +136,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
#define tmp1 17
|
#define tmp1 17
|
||||||
#define tmp2 15
|
#define tmp2 15
|
||||||
|
|
||||||
|
#define BTI_C hint 34
|
||||||
|
|
||||||
/* Start and end a function. */
|
/* Start and end a function. */
|
||||||
.macro STARTFN name
|
.macro STARTFN name
|
||||||
.text
|
.text
|
||||||
|
@ -145,6 +147,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
.type \name, %function
|
.type \name, %function
|
||||||
.cfi_startproc
|
.cfi_startproc
|
||||||
\name:
|
\name:
|
||||||
|
BTI_C
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
.macro ENDFN name
|
.macro ENDFN name
|
||||||
|
@ -275,6 +278,29 @@ STARTFN NAME(LDNM)
|
||||||
ENDFN NAME(LDNM)
|
ENDFN NAME(LDNM)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
|
||||||
|
#define FEATURE_1_AND 0xc0000000
|
||||||
|
#define FEATURE_1_BTI 1
|
||||||
|
#define FEATURE_1_PAC 2
|
||||||
|
|
||||||
|
/* Add a NT_GNU_PROPERTY_TYPE_0 note. */
|
||||||
|
#define GNU_PROPERTY(type, value) \
|
||||||
|
.section .note.gnu.property, "a"; \
|
||||||
|
.p2align 3; \
|
||||||
|
.word 4; \
|
||||||
|
.word 16; \
|
||||||
|
.word 5; \
|
||||||
|
.asciz "GNU"; \
|
||||||
|
.word type; \
|
||||||
|
.word 4; \
|
||||||
|
.word value; \
|
||||||
|
.word 0;
|
||||||
|
|
||||||
#if defined(__linux__) || defined(__FreeBSD__)
|
#if defined(__linux__) || defined(__FreeBSD__)
|
||||||
.section .note.GNU-stack, "", %progbits
|
.section .note.GNU-stack, "", %progbits
|
||||||
|
|
||||||
|
/* Add GNU property note if built with branch protection. */
|
||||||
|
# ifdef __ARM_FEATURE_BTI_DEFAULT
|
||||||
|
GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI)
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue