From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by sourceware.org (Postfix) with ESMTPS id B682B3858CDB for ; Tue, 9 Jan 2024 02:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B682B3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B682B3858CDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704768964; cv=none; b=HUbFwzIter2Jgw5+cD2SIh+uIetRyfBh7uQ4i8vUnaUlPTVnipFLwdrvL78Tpqqqyksd3hkmFMDFMkQmqODm2/pH61ruDHV0/QsjTnS4nMyXpG49NJqgcADxSPb/LQuLtWJ4hLEiI8hL+cvhdghdRrVq5Bprqb9C/pDOjz3GFX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704768964; c=relaxed/simple; bh=ah1v55mv2Y50uaKRUVUCeDLotzFnJoRaO71UdOla5SE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=QGUHKq2VWMjlFOdQrBKsAvJo405iVTdChI6hiG3rxx5Q6PhiO/aGRCk6Ldio22TyDiXLyH9+Ks0VWZ7Drx/XsBDr5KGXDQRjo9QKVJf8fvKcJAzAakL6eiF67KF4NixPj5jm5+tsMAibAajp7cFko55MubxDi9XRuWwUPOL0z/w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-40e500a71d5so403415e9.0 for ; Mon, 08 Jan 2024 18:56:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704768961; x=1705373761; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=CyON8xZGng1CZkDRa+8BV36Ox5Lq78pRG6dfrn1SZXM=; b=RZnqRO9flj0gK8xgc0nfwfKqQjzmbdn9/O+LGATWGvtg3t27D+GB/HHNnc0dQn51A6 9217LbWRBTIlCRMoyzUf5re2XYVjFssX6IGvLa8EXKZpWiY+7Cu5r9U4M6IKPAQmZ7iW uQtfrbN/xZSKhTOhPsdR1xV66oQfIYr7jsDd65l6wQBYTsHQ9SgXzNe+FFBxwLoNHbGE s9ygeIuflHHCNbeI4VQIFEw47AUeJoOB+rB5CraCKNVvL8KIgPQ9SAcgAXNeSGQN+xqN pnFLMqi7PAg+aOsihXsSm2wlS3eK8IKO3mUNZfkIK6xMN+mY1HiAbz4/9YIawRor7/r+ CeuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704768961; x=1705373761; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CyON8xZGng1CZkDRa+8BV36Ox5Lq78pRG6dfrn1SZXM=; b=Gc3phxBCKDF/h6qGNSS8FRfmzFvAD7wmqL9hnX0uo4fcbybuq8hCjyccUOLiAqfZjI s7FpU336tsXIrXrzywrCYtdVlcDs1pQHmvb/pDu/kMN5gbUli2EWoQPFn/Y8qrjw9M8M 0lYeD47u8LFYVHgjo/ylvmAycePXgBfh0r5gWduj2LjLyct/DlAIvm2dDK68YjN5hozc Q6yVQ30067xA5fTSzisT7yIJamA92Kly8jeV5qWC3tcbnEok1Ss+B55gyA3q+HquE8zl Q5YdLqOK53CWe6iui7xrDOrOWdQhG5mVEk8vfE+JmzNK9OToLX9Zg1sW/d81YndQ5AGo 9tmw== X-Gm-Message-State: AOJu0YzMCjMSdNYqThUveMiMBOJOVuFwzkXfzJV8s33+Kd6NUFhgZeO+ MHNCn28sNHH3wNZNOp1JA16GXw+SDZ/b0wHev3idlS+M X-Google-Smtp-Source: AGHT+IFQahMQEIqv/er66u3KOIYu5ox9+pZ8qCZwDtxYY/lZjrZUUB8mdgD+XYxBeayuSAoL8sheCUR2Va1DP4vUTcU= X-Received: by 2002:a05:600c:501e:b0:40d:5ce8:d3e0 with SMTP id n30-20020a05600c501e00b0040d5ce8d3e0mr21225wmr.11.1704768961127; Mon, 08 Jan 2024 18:56:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: richard clark Date: Tue, 9 Jan 2024 10:55:50 +0800 Message-ID: Subject: Re: undefined reference to `__aarch64_cas4_sync' error on arm64 native build To: Xi Ruoyao Cc: Mark Rutland , gcc-help@gcc.gnu.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SCC_BODY_URI_ONLY,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Jan 8, 2024 at 6:56=E2=80=AFPM Xi Ruoyao wrote= : > > 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 __aa= rch64_cas4 > > > 0000000000130950 l F .text 0000000000000034 __aarch64_cas4_relax > > > 0000000000130a10 l F .text 0000000000000034 __aarch64_cas4_rel > > > 0000000000130990 l F .text 0000000000000034 __aarch64_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? > > > > This is due to a difference in default options between the two compiler= s; 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. Actually you can call those builtin atomic functions in you normal application without link time error, even execute the output binary in the target machine in case of cross-compile, only if the linked .so is in your target environment. > > -- > Xi Ruoyao > School of Aerospace Science and Technology, Xidian University