Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1549514rdb; Mon, 8 Jan 2024 02:56:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPixwKymA+68ALMQ/skjXD4ejWYYGuaTdfXFD62zNafGPNGeW2QfhT6rx0JNq/LA+MP9qv X-Received: by 2002:a7b:c8d9:0:b0:40e:4748:7af8 with SMTP id f25-20020a7bc8d9000000b0040e47487af8mr632414wml.187.1704711404381; Mon, 08 Jan 2024 02:56:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704711404; cv=none; d=google.com; s=arc-20160816; b=m7VXB3Mq67rk2HujJesfqjZViA1bCTmRnr7nxK7pJtD5ZkhzJTpnbgTvWpY8gLVDvH Ajor4kdeoGQxwRtJBqTXSmnFmJ1H1gHMu+IIyy4ncB18tuoSuTmdUgkyBc1XR6ELuR6r 2hs+rOpZYULhQHeHwXp4qrnCCM13OWNd6l476h45YBlylHsYrc2b+V8cidgoOn16cAfg hXy/FhstyT20R51CP8YboBPnSjBG/fE6lPS4IZOLz9bV9nkatTcdxdxkxsWXZtCL9MpR Kfi6Z3ck/3UgF+/PFUWRyXnAU3nRe9xb0eVZyHW/X8rYwnV9rgbpJZOE2n9Jho45U1Dj tdtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:autocrypt:references :in-reply-to:date:cc:to:from:subject:message-id:dkim-signature; bh=Wsw4VxPsaW9bnZCq+PzKzCKdeWEwZLad9rpv9ZWX5iY=; fh=pvMv0y/pMck2jO/sZ9q06S5KtDJAfKRjDYOowhD5cNw=; b=rnHGNgHtfXnyq8wT08YqeGVwvmpDWAh94fkBqdA4GFoKZ2e03huDH5wm4cQ251v3KC D7zYIPonb2gIe5FhGjXUpCglxpW4rjCpjQB5LcT4KGf3Y3bh+t6BVW09mCUHt9t/8A// FUGcuJy4eHtonr1Wbq7ieW8PDC87zaaOe3BYBTjwRxHJt4+yzd809IR5mLYHBuX5Zt0p ZNfAs13Et9KSCs6372SMItgcbjIBJY6OHSQGwWNhyJkU6UnI2MTYleSUsivB2oBWByhF HMEYBDZz4il1I4bUFh1v3G+ll7YRflx54sR3R2Ii6fr931tsR58HD95zbCdAyM8UMqit bwcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b="iS/ylMPr"; spf=pass (google.com: domain of linux-kernel+bounces-19361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g26-20020a170906595a00b00a27c5d135c3si3093395ejr.855.2024.01.08.02.56.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 02:56:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@xry111.site header.s=default header.b="iS/ylMPr"; spf=pass (google.com: domain of linux-kernel+bounces-19361-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19361-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=xry111.site Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DFB301F2225A for ; Mon, 8 Jan 2024 10:56:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57F4313FF5; Mon, 8 Jan 2024 10:56:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=xry111.site header.i=@xry111.site header.b="iS/ylMPr" X-Original-To: linux-kernel@vger.kernel.org Received: from xry111.site (xry111.site [89.208.246.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D523F13FEE for ; Mon, 8 Jan 2024 10:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1704711386; bh=Wsw4VxPsaW9bnZCq+PzKzCKdeWEwZLad9rpv9ZWX5iY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=iS/ylMPrguoVUcbjljHhfQUC5GBHTmGgdq4kek68sCysVen5Z6sUUr+GJgSyw3DhW ckiePu64UYmWpU43czVDpBUfXs447DXfdHh00EGPAAX1qmRHeCg6EIfVnuTvassgVy sGjR3+tAuo1aehRJiNxaeMwEoJY3LyadsS94YiK8= Received: from [127.0.0.1] (unknown [IPv6:2001:470:683e::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 58CEC66B4F; Mon, 8 Jan 2024 05:56:25 -0500 (EST) Message-ID: Subject: Re: undefined reference to `__aarch64_cas4_sync' error on arm64 native build From: Xi Ruoyao To: Mark Rutland , richard clark Cc: gcc-help@gcc.gnu.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Date: Mon, 08 Jan 2024 18:56:23 +0800 In-Reply-To: References: Autocrypt: addr=xry111@xry111.site; prefer-encrypt=mutual; keydata=mDMEYnkdPhYJKwYBBAHaRw8BAQdAsY+HvJs3EVKpwIu2gN89cQT/pnrbQtlvd6Yfq7egugi0HlhpIFJ1b3lhbyA8eHJ5MTExQHhyeTExMS5zaXRlPoiTBBMWCgA7FiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwMFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQrKrSDhnnEOPHFgD8D9vUToTd1MF5bng9uPJq5y3DfpcxDp+LD3joA3U2TmwA/jZtN9xLH7CGDHeClKZK/ZYELotWfJsqRcthOIGjsdAPuDgEYnkdPhIKKwYBBAGXVQEFAQEHQG+HnNiPZseiBkzYBHwq/nN638o0NPwgYwH70wlKMZhRAwEIB4h4BBgWCgAgFiEEkdD1djAfkk197dzorKrSDhnnEOMFAmJ5HT4CGwwACgkQrKrSDhnnEOPjXgD/euD64cxwqDIqckUaisT3VCst11RcnO5iRHm6meNIwj0BALLmWplyi7beKrOlqKfuZtCLbiAPywGfCNg8LOTt4iMD Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.50.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2024-01-08 at 10:51 +0000, Mark Rutland via Gcc-help wrote: > > AFAIK, the native build for the kernel will not link to the libc.so > > but the userland application does, the builtin atomic primitives are > > implemented in the glibc: > > target-host $ objdump -t /lib/aarch64-linux-gnu/libc.so.6 | grep __aarc= h64_cas4 > > 0000000000130950 l=C2=A0=C2=A0=C2=A0=C2=A0 F .text 0000000000000034 __a= arch64_cas4_relax > > 0000000000130a10 l=C2=A0=C2=A0=C2=A0=C2=A0 F .text 0000000000000034 __a= arch64_cas4_rel > > 0000000000130990 l=C2=A0=C2=A0=C2=A0=C2=A0 F .text 0000000000000034 __a= arch64_cas4_acq > > seems the '__sync_val_compare_and_swap' used in the application will > > be renamed to _aarch64_cas4_{relax, rel, acq}. so the kernel will > > complain it will > > link to an 'undefined reference'. But interesting, why the > > cross-compile kernel will not generate the 'undefined reference', the > > cross-compile/build kernel will link to the glibc? >=20 > This is due to a difference in default options between the two compilers;= the > kernel isn't linked against libc in either case. And even if it's not the kernel but a normal application, it still cannot use these functions from Glibc as the objdump output contains "l", meaning these symbols are local symbols and they cannot referred somewhere out of the libc.so.6 itself. --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University