From 541e57af0b09cc226f89cc33027d9b9daf47812e Mon Sep 17 00:00:00 2001 From: trasz Date: Tue, 3 Sep 2019 19:48:23 +0000 Subject: [PATCH] Unbreak Linux binaries linked against new glibc, such as the ones from recent Ubuntu versions. Without it they segfault on startup. Reviewed by: emaste MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20687 --- sys/amd64/linux/linux_sysvec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/amd64/linux/linux_sysvec.c b/sys/amd64/linux/linux_sysvec.c index caef96cffa19..368b5196fba4 100644 --- a/sys/amd64/linux/linux_sysvec.c +++ b/sys/amd64/linux/linux_sysvec.c @@ -343,6 +343,12 @@ linux_copyout_strings(struct image_params *imgp) */ vectp -= imgp->args->argc + 1 + imgp->args->envc + 1; + /* + * Starting with 2.24, glibc depends on a 16-byte stack alignment. + * One "long argc" will be prepended later. + */ + vectp = (char **)((((uintptr_t)vectp + 8) & ~0xF) - 8); + /* vectp also becomes our initial stack base. */ stack_base = (register_t *)vectp;