mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-04 15:40:44 +00:00
linux64: Fix the build on arm64 with bti checking
When we enable checking for BTI on arm64 we need to include an ELF note in all object files linked into a module. As using objcopy from a binary to an ELF object file doesn't add the note switch to using .incbin from an assembly file. This allows us to add the needed note without affecting the included object. Reviewed by: imp, kib, emaste Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D45468
This commit is contained in:
parent
c2e0d56f5e
commit
bed65d85c6
|
@ -26,6 +26,8 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/elf_common.h>
|
||||
|
||||
#include <machine/asm.h>
|
||||
#include <machine/param.h>
|
||||
#include <machine/vmparam.h>
|
||||
|
@ -172,3 +174,5 @@ ENTRY(futex_xorl)
|
|||
str w4, [x2]
|
||||
ret
|
||||
END(futex_xorl)
|
||||
|
||||
GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
|
||||
|
|
39
sys/compat/linux/linux_vdso_inc.S
Normal file
39
sys/compat/linux/linux_vdso_inc.S
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*-
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*
|
||||
* Copyright (C) 2020 Arm Ltd
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
.section .rodata
|
||||
.globl _binary_linux_vdso_so_o_start
|
||||
_binary_linux_vdso_so_o_start:
|
||||
.incbin "linux_vdso.so.o"
|
||||
.globl _binary_linux_vdso_so_o_end
|
||||
_binary_linux_vdso_so_o_end:
|
||||
|
||||
#if defined(__aarch64__)
|
||||
#include <sys/elf_common.h>
|
||||
#include <machine/asm.h>
|
||||
GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
|
||||
#endif
|
|
@ -35,7 +35,8 @@ SRCS= linux_dummy_machdep.c \
|
|||
bus_if.h \
|
||||
device_if.h \
|
||||
vnode_if.h \
|
||||
linux_support.S
|
||||
linux_support.S \
|
||||
linux_vdso_inc.S
|
||||
.if ${MACHINE_CPUARCH} == "amd64"
|
||||
SRCS+= linux_dummy_x86.c
|
||||
.endif
|
||||
|
@ -47,7 +48,6 @@ SRCS+= opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
|
|||
CLEANFILES= linux_assym.h linux_genassym.o linux_locore.o \
|
||||
genassym.o linux_vdso_gtod.o linux_vdso.so.o
|
||||
|
||||
OBJS= linux_vdso.so
|
||||
|
||||
linux_assym.h: linux_genassym.o
|
||||
sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET}
|
||||
|
@ -83,18 +83,7 @@ linux_vdso.so.o: linux_locore.o linux_vdso_gtod.o
|
|||
-T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \
|
||||
-o ${.TARGET} ${.ALLSRC:M*.o}
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "aarch64"
|
||||
OBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aarch64
|
||||
.elif ${MACHINE_CPUARCH} == "amd64"
|
||||
OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64
|
||||
.else
|
||||
.error ${MACHINE_CPUARCH} not yet supported by linux64
|
||||
.endif
|
||||
|
||||
linux_vdso.so: linux_vdso.so.o
|
||||
${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
|
||||
linux_vdso.so.o ${.TARGET}
|
||||
${STRIPBIN} -N _binary_linux_vdso_so_o_size ${.TARGET}
|
||||
linux_vdso_inc.o: linux_vdso.so.o
|
||||
|
||||
linux_support.o: linux_support.S assym.inc linux_assym.h
|
||||
${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
|
||||
|
|
Loading…
Reference in a new issue