Skip to content

Commit

Permalink
Fix bti support (libffi#830)
Browse files Browse the repository at this point in the history
* bti: add identifier to ffi_closure_SYSV_V_alt

This was missing BTI_C identifier.

Old Code:
ffi_closure_SYSV_V_alt:
0000fffff7f70500:   ldr     x17, [sp, libffi#8]

Signed-off-by: Bill Roberts <[email protected]>

* testsuite: fix whitespace in Makefile.am

Signed-off-by: Bill Roberts <[email protected]>

* aarch64: correct comment describing BTI

The comment is incorrect, BTI is enabled per mapping via mprotect with
PROT_BTI flag set, not per-process. When the loader loads the library,
if the GNU Notes section is missing this, PROT_BTI will not be enabled
for that mapping, but is independent of other mappings.

Signed-off-by: Bill Roberts <[email protected]>

---------

Signed-off-by: Bill Roberts <[email protected]>
  • Loading branch information
billatarm authored Mar 19, 2024
1 parent 3d0ce1e commit f64141e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/aarch64/sysv.S
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#define BTI_J hint #36
/*
* The ELF Notes section needs to indicate if BTI is supported, as the first ELF loaded that doesn't
* declare this support disables it for the whole process.
* declare this support disables it for memory region containing the loaded library.
*/
# define GNU_PROPERTY_AARCH64_BTI (1 << 0) /* Has Branch Target Identification */
.text
Expand Down Expand Up @@ -527,6 +527,7 @@ L(do_closure):
#if defined(FFI_EXEC_STATIC_TRAMP)
.align 4
CNAME(ffi_closure_SYSV_V_alt):
BTI_C
/* See the comments above trampoline_code_table. */
ldr x17, [sp, #8] /* Load closure in x17 */
add sp, sp, #16 /* Restore the stack */
Expand All @@ -541,6 +542,7 @@ CNAME(ffi_closure_SYSV_V_alt):

.align 4
CNAME(ffi_closure_SYSV_alt):
BTI_C
/* See the comments above trampoline_code_table. */
ldr x17, [sp, #8] /* Load closure in x17 */
add sp, sp, #16 /* Restore the stack */
Expand Down
2 changes: 1 addition & 1 deletion testsuite/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CLEANFILES = *.exe core* *.log *.sum

EXTRA_DIST = config/default.exp emscripten/build.sh emscripten/conftest.py \
emscripten/node-tests.sh emscripten/test.html emscripten/test_libffi.py \
emscripten/build-tests.sh lib/libffi.exp lib/target-libpath.exp \
emscripten/build-tests.sh lib/libffi.exp lib/target-libpath.exp \
lib/wrapper.exp libffi.bhaible/Makefile libffi.bhaible/README \
libffi.bhaible/alignof.h libffi.bhaible/bhaible.exp libffi.bhaible/test-call.c \
libffi.bhaible/test-callback.c libffi.bhaible/testcases.c libffi.call/align_mixed.c \
Expand Down

0 comments on commit f64141e

Please sign in to comment.