Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3628556rdb; Wed, 13 Sep 2023 19:20:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmEBlqXvdHBTUboKPO2KPI+HwrowAQOFMBK8vsc6k16BfeA1l3ToxG6BY1HXY26bQrqT24 X-Received: by 2002:a0d:d911:0:b0:568:d586:77c4 with SMTP id b17-20020a0dd911000000b00568d58677c4mr4772760ywe.4.1694658049135; Wed, 13 Sep 2023 19:20:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694658049; cv=none; d=google.com; s=arc-20160816; b=Vw+HX5/Eo0N0NN4Fu8PsA1ofkpqa/qit1Ni2FdwI69oPnutY2gavz3hd4pDcqaDX9L Z2oC6Q7V2Hdwf+Pl+BD1duv2JLqUfLKyRJZJBzqUjIO+M6DCd1tG3TwY/yvldI2Awixj SDZKRidxyFOkUW0fJjs/ZD8e6+BEyBjCd00y7bI3HhtYBI9d9GVtNhegheYvOxOiOWs3 3EHJF3IYIYwbKNOtKLdpc31Wzlbe4WP0jd4o5JbGVw3NoQXIqGsrVUoi6imU1P0ZdYuE kdMn+EaQ1sIVxtdKShKQE2Cit7qsQDBbC3AN1xzCUji/jLZRa87xwEYDyu+MZjYp5DlE VXdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:subject:cc:to:from:date :dkim-signature; bh=ALiHg2DAm4CrjO+rrzTcSb1Bg2Fsn7RTODm9WaHRVnw=; fh=pKDqOTmD1LxLzo72ewCJmD2Jrs3VmHuRrLG79ACPp4U=; b=nmUXUHDt4j5uHHznNW5A/5FU+VtjNlmRKwBWqgNGly8qsEgveMNWeLhy695IydzxPu 6iJf6eLzoUzghg5AwtxTlyhliJweY98lvTKxh/uVN19jo22f/IVGnUfZ6tPDhA4ZxXmW H3IRpkLnvfbeUYHBxn2gc9Mo38uGO8PEvNhR03j9bpEp5d9veO4c8O9/cakkmgOjuQ51 eP3iHAaF/qQvyHaCMgFsVC0gZixPjVqhhdCEiQsXGLVsvcLLH36uHmGiGXyvs1jNG8pt hGs2ewyGtmDaOc0ZUv/5Tw7qdgxl73L5KtSS7XLbseqgdtzhanAxUy+wyjJB30TFU3ls H48A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h5+9z+DQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id n25-20020a637219000000b0056c297d163asi464441pgc.523.2023.09.13.19.20.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 19:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h5+9z+DQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 88B0880B5A23; Wed, 13 Sep 2023 11:46:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232066AbjIMSqA (ORCPT + 99 others); Wed, 13 Sep 2023 14:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231989AbjIMSpy (ORCPT ); Wed, 13 Sep 2023 14:45:54 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E5E8A3 for ; Wed, 13 Sep 2023 11:45:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694630703; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=ALiHg2DAm4CrjO+rrzTcSb1Bg2Fsn7RTODm9WaHRVnw=; b=h5+9z+DQ2MaQhIc/YJ4DP2eDFhGnrZmNA3x0RHMa9HkD5Qo8s6rMImSbeNQs1ytngrP7xC 6gZPWK+/X6gXS1qex2S6flywDA6ccoybOWni2FosyIBF8KrlHxb0h2dv0QHk6Te5CKzoNb SBB/XALYbbnV2pnzqxmT6Rw8xInFJ8o= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-580-8olHctt7OlCbuBdBcA6eBw-1; Wed, 13 Sep 2023 14:45:02 -0400 X-MC-Unique: 8olHctt7OlCbuBdBcA6eBw-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4030ae94fedso895735e9.1 for ; Wed, 13 Sep 2023 11:45:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694630700; x=1695235500; h=mime-version:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ALiHg2DAm4CrjO+rrzTcSb1Bg2Fsn7RTODm9WaHRVnw=; b=oMFB/lJRR3jRmI5WVKWptLITFMWg2FWtgqmJxmBHi0++2C+NTwKgrROKJSgZEe1BfZ Z41pLl+24jUhDoRkFBCsFw5B4r1sxM1C1GIhQtqgFqOaqYrN9zNeqmkb7cYztK2AAhhD Izui6Lrc0H2hQyGetZ9ls9NI49Rd8GqsmZqzOWEpUvwf+hhxZjqzHIlfeEd327ZXj0KJ 0YdJeyPoHSZzXD7UXSvVT3a8jHO3zugwcMaVU6vsNN64m4uEMf3KgA5/jw5UXVLorM/n brcALkncAOX2rz3HhkZwP7vEqQiGTY9I9/86g6JIrSbC332PIfAAgoAFeyKqD45dXfsC jjJw== X-Gm-Message-State: AOJu0Yyc0SpFs6JVvo6FrTxq9yiH2e9ivy/kCgNBcWljMBDfRnL8IHXQ shAJDR9kT6jRTF/KE2ch1sFA38hxlei1DLRodV8snj22YipBBVHn/Nydj6i2/NQWCpOL+kaA89z HFyFBlgkER9V8nUUWIOpfmppZkMLpzM1kTkM= X-Received: by 2002:adf:f20c:0:b0:317:cdc4:762e with SMTP id p12-20020adff20c000000b00317cdc4762emr3180533wro.63.1694630700634; Wed, 13 Sep 2023 11:45:00 -0700 (PDT) X-Received: by 2002:adf:f20c:0:b0:317:cdc4:762e with SMTP id p12-20020adff20c000000b00317cdc4762emr3180521wro.63.1694630700232; Wed, 13 Sep 2023 11:45:00 -0700 (PDT) Received: from rh (p200300c93f1ec600a890fb4d684902d4.dip0.t-ipconnect.de. [2003:c9:3f1e:c600:a890:fb4d:6849:2d4]) by smtp.gmail.com with ESMTPSA id r17-20020adfce91000000b003198a9d758dsm16297341wrn.78.2023.09.13.11.44.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 11:44:59 -0700 (PDT) Date: Wed, 13 Sep 2023 20:44:59 +0200 (CEST) From: Sebastian Ott To: Mark Brown , Willy Tarreau , =?ISO-8859-15?Q?Thomas_Wei=DFschuh?= cc: linux-kernel@vger.kernel.org Subject: aarch64 binaries using nolibc segfault before reaching the entry point Message-ID: <5d49767a-fbdc-fbe7-5fb2-d99ece3168cb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 13 Sep 2023 11:46:24 -0700 (PDT) Hi, the tpidr2 selftest on an arm box segfaults before reaching the entry point. I have no clue what is to blame for this or how to debug it but for a statically linked binary there shouldn't be much stuff going on besides the elf loader? I can reproduce this with a program using an empty main function. Also checked for other nolibc users - same result for init.c from rcutorture. tools/testing/selftests/arm64/fp/za-fork is working though - the only difference I could spot here is that it is linked together with another object file. I also looked at the elf headers but didn't find anything obvious (but I'm a bit out of my comfort zone here..) After playing around with linker options I found that using -static-pie lets the binaries run successful. [root@arm abi]# cat test.c int main(void) { return 1; } [root@arm abi]# gcc -Os -static -Wall -lgcc -nostdlib -ffreestanding -include ../../../../include/nolibc/nolibc.h test.c [root@arm abi]# ./a.out Segmentation fault [root@arm abi]# gcc -Os -static -Wall -lgcc -nostdlib -ffreestanding -static-pie -include ../../../../include/nolibc/nolibc.h test.c [root@arm abi]# ./a.out [root@arm abi]# All on aarch64 running fedora37 + upstream kernel. Any hints on what could be borken here or how to actually fix it? Sebastian