Skip to contentSkip to conversation

libssp-nonshared: Use a different implementation for __stack_chk_fail

PATCH In review Khem Raj 2 participants 3 messages Jun 11, 2021 RISC-V

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/2 libssp-nonshared: Use a different implementation for __stack_chk_fail

---
 meta/recipes-core/musl/libssp-nonshared.bb    | 11 ++---
 .../musl/libssp-nonshared/ssp-local.c         | 45 -------------------
 .../musl/libssp-nonshared/stack_chk.c         | 40 +++++++++++++++++
 3 files changed, 46 insertions(+), 50 deletions(-)
 delete mode 100644 meta/recipes-core/musl/libssp-nonshared/ssp-local.c
 create mode 100644 meta/recipes-core/musl/libssp-nonshared/stack_chk.c
meta/recipes-core/musl/libssp-nonshared.bb +6 -5
index bae8c81cc7..81c87e8e8d 100644
@@ -2,11 +2,12 @@
 # Released under the MIT license (see COPYING.MIT for the terms)
 
 SUMMARY = "Minimal libssp_nonshared.a must needed for ssp to work with gcc on musl"
-LICENSE = "GPL-3.0-with-GCC-exception"
-LIC_FILES_CHKSUM = "file://ssp-local.c;beginline=1;endline=32;md5=c06d391208c0cfcbc541a6728ed65cc4"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://stack_chk.c;beginline=1;endline=30;md5=97e59d9deee678a9332c9ddb2ab6360d"
 SECTION = "libs"
 
-SRC_URI = "file://ssp-local.c"
+# Sourced from https://github.com/intel/linux-sgx/blob/master/sdk/compiler-rt/stack_chk.c
+SRC_URI = "file://stack_chk.c"
 
 INHIBIT_DEFAULT_DEPS = "1"
 
@@ -19,8 +20,8 @@ do_configure[noexec] = "1"
 S = "${WORKDIR}"
 
 do_compile() {
-	${CC} ${CPPFLAGS} ${CFLAGS} -fPIE -c ssp-local.c -o ssp-local.o
-	${AR} r libssp_nonshared.a ssp-local.o
+	${CC} ${CPPFLAGS} ${CFLAGS} -fPIE -c stack_chk.c -o stack_chk.o
+	${AR} r libssp_nonshared.a stack_chk.o
 }
 do_install() {
 	install -Dm 0644 ${B}/libssp_nonshared.a ${D}${base_libdir}/libssp_nonshared.a
meta/recipes-core/musl/libssp-nonshared/ssp-local.c deleted +0 -45

45 lines not on this page · raw message

meta/recipes-core/musl/libssp-nonshared/stack_chk.c new file +40 -0
new file mode 100644
index 0000000000..097aae24b6
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011-2021 Intel Corporation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *   * Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ *   * 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.
+ *   * Neither the name of Intel Corporation nor the names of its
+ *     contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT
+ * OWNER 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.
+ *
+ */
+
+extern void __attribute__((noreturn)) __stack_chk_fail(void);
+
+void
+__attribute__((noreturn))
+__attribute__((visibility ("hidden")))
+__stack_chk_fail_local (void)
+{
+    __stack_chk_fail ();
+}
Signature · 1 line
2.32.0
author
#1 lore raw

PATCH 2/2 qemuriscv: Enable 4 core emulation

Helps in running tests a bit faster

---
 meta/conf/machine/include/riscv/qemuriscv.inc | 1 +
 1 file changed, 1 insertion(+)
meta/conf/machine/include/riscv/qemuriscv.inc +1 -0
index 428d28bde1..20e2d465a1 100644
@@ -26,6 +26,7 @@ UBOOT_ENTRYPOINT_riscv32 = "0x80400000"
 UBOOT_ENTRYPOINT_riscv64 = "0x80200000"
 
 # qemuboot options
+QB_SMP = "-smp 4"
 QB_KERNEL_CMDLINE_APPEND = "earlycon=sbi"
 QB_MACHINE = "-machine virt"
 QB_DEFAULT_BIOS = "fw_jump.elf"
Signature · 1 line
2.32.0
Reviewed-by on v1 2/2
#2 lore raw

Re: [OE-core] [PATCH 2/2] qemuriscv: Enable 4 core emulation

Quoted 4 lines · Khem Raj

Helps in running tests a bit faster

Alistair

Quoted 22 lines
---
 meta/conf/machine/include/riscv/qemuriscv.inc | 1 +
 1 file changed, 1 insertion(+)
meta/conf/machine/include/riscv/qemuriscv.inc +1 -1
index 428d28bde1..20e2d465a1 100644
@@ -26,6 +26,7 @@ UBOOT_ENTRYPOINT_riscv32 = "0x80400000"
 UBOOT_ENTRYPOINT_riscv64 = "0x80200000"
 
 # qemuboot options
+QB_SMP = "-smp 4"
 QB_KERNEL_CMDLINE_APPEND = "earlycon=sbi"
 QB_MACHINE = "-machine virt"
 QB_DEFAULT_BIOS = "fw_jump.elf"
--

2.32.0