From patchwork Mon Nov 13 16:09:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13454166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 01E2DC4167B for ; Mon, 13 Nov 2023 16:10:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.631765.985452 (Exim 4.92) (envelope-from ) id 1r2ZVv-00010J-5Z; Mon, 13 Nov 2023 16:10:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 631765.985452; Mon, 13 Nov 2023 16:10:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2ZVv-00010C-2D; Mon, 13 Nov 2023 16:10:15 +0000 Received: by outflank-mailman (input) for mailman id 631765; Mon, 13 Nov 2023 16:10:14 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2ZVt-0000kV-Vp for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 16:10:13 +0000 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [2a00:1450:4864:20::333]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1f65707b-823f-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 17:10:11 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4084de32db5so40155835e9.0 for ; Mon, 13 Nov 2023 08:10:11 -0800 (PST) Received: from localhost ([213.195.113.99]) by smtp.gmail.com with ESMTPSA id fm14-20020a05600c0c0e00b003fee8793911sm8414341wmb.44.2023.11.13.08.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 08:10:10 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1f65707b-823f-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1699891811; x=1700496611; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z0sqf60uuy6WP/IELnnjhXU0ebHU5JMNByUn7ifmfjM=; b=WUv60P9Mhlq8QnBW2c8krP7HicaEFRUR4RUU6dp5sC6oWlCTJbDEm8i6BvvGOL3GNU cgRvk+Dxuf+o/f09+xv9SlOrwXP9brw5lbLvpneLJG66Gok6+CFiHtxDJZEwm4saqQgw hkO6ro05yVP2y7488NVFK8IN/AKSkpZkVzXJo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699891811; x=1700496611; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z0sqf60uuy6WP/IELnnjhXU0ebHU5JMNByUn7ifmfjM=; b=JCHlA7nOx1M58MMqOZtDbAXHTKLXBHktLnVYzrwxzlXaTu28RGIMc9go0YI9jnM21t L8XC7w2FVEaD9hu8tquE3V5OzkE484rbhug8GJNbYYX+Ow7zKY5mlVJSyoOgLsgIVZ7P 3uU7ns//6xaJGIipS8tkvbo8szW2tyLOk0vPcga/KYg8MpEBb2BQmqg045KnYl8l/FRY F3Pqy+rjPCde2NVgBtGvruaSfIxN6KVCsw93SC+nDNv7NkkJhcdOwvUEyg4Y7Obw9R1G 2I3iEtjNQq6iJpBdHns9eWIXv/qbHVdCBXpZ1WADwH4WI6+dVPdnAesWuHo54MhV5e5o IBJA== X-Gm-Message-State: AOJu0YxMIBUS+T0qTp2VR7s6qOGSFgDNnIBstS1Jlzi7T1cLspryy50q CZEUi2ya6LmjaFy1t4tEy+AIdt7N5NLGerEo41s= X-Google-Smtp-Source: AGHT+IHui0DMsxmsXNBSRyttpmsh9c3gUU9wFXhTBpTmUrtGdGW8osDQWsf8XPoPBKkcKemPcMDr1A== X-Received: by 2002:a05:600c:21c2:b0:40a:463c:1d8c with SMTP id x2-20020a05600c21c200b0040a463c1d8cmr5676064wmj.21.1699891811150; Mon, 13 Nov 2023 08:10:11 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Konrad Rzeszutek Wilk , Ross Lagerwall , Roger Pau Monne Subject: [PATCH 1/2] livepatch-tools: add -largp option when required Date: Mon, 13 Nov 2023 17:09:39 +0100 Message-ID: <20231113160940.52430-2-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113160940.52430-1-roger.pau@citrix.com> References: <20231113160940.52430-1-roger.pau@citrix.com> MIME-Version: 1.0 crate-diff-object makes use of argp library, and depending on the libc used by the system (ie: musl or BSD libc) argp is a separate library and requires the addition of -largp to the build rune. Introduce some shell logic to detect whether -largp is required for linking create-diff-object. I haven't done this as a reusable macro because I'm not sure there's much point in doing so, the only library we need to test for is argp, anything else is likely to be a mandatory library flag that doesn't require such testing (like libelf for example). Signed-off-by: Roger Pau Monné --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index f96b150539d2..2f74c3433336 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,10 @@ LIBEXECDIR = $(DESTDIR)$(PREFIX)/libexec/livepatch-build-tools CFLAGS += -Iinsn -Wall -g LDFLAGS = -lelf +# Non GNU libc systems usually have argp as a standalone library. +LDFLAGS += $(shell if test -z "`$(CC) -largp 2>&1 | grep '\-largp'`"; \ + then echo "-largp"; fi;) + TARGETS = create-diff-object prelink CREATE_DIFF_OBJECT_OBJS = create-diff-object.o lookup.o insn/insn.o insn/inat.o common.o PRELINK_OBJS = prelink.o lookup.o insn/insn.o insn/inat.o common.o From patchwork Mon Nov 13 16:09:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 13454167 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B5C3C4332F for ; Mon, 13 Nov 2023 16:10:30 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.631766.985462 (Exim 4.92) (envelope-from ) id 1r2ZVy-0001JO-DI; Mon, 13 Nov 2023 16:10:18 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 631766.985462; Mon, 13 Nov 2023 16:10:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2ZVy-0001JF-AB; Mon, 13 Nov 2023 16:10:18 +0000 Received: by outflank-mailman (input) for mailman id 631766; Mon, 13 Nov 2023 16:10:15 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r2ZVv-0000kV-2j for xen-devel@lists.xenproject.org; Mon, 13 Nov 2023 16:10:15 +0000 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [2a00:1450:4864:20::134]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 2075e6e3-823f-11ee-9b0e-b553b5be7939; Mon, 13 Nov 2023 17:10:13 +0100 (CET) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50a6ff9881fso5115678e87.1 for ; Mon, 13 Nov 2023 08:10:13 -0800 (PST) Received: from localhost ([213.195.113.99]) by smtp.gmail.com with ESMTPSA id l10-20020adfa38a000000b0032dbf26e7aesm5768973wrb.65.2023.11.13.08.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 08:10:12 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2075e6e3-823f-11ee-9b0e-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1699891812; x=1700496612; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LEyJPbz5vLaL820Iu2zEMIkHFyVdUrRe5Vuo+rlUsto=; b=Mis/sw99hubGjZD36g1d1MBuwUVB+T2G95NCiAgTbwlUpj7fa2tBA+EWlbQ3a4d9J1 v9fF8wmJYfHOS1WhCx9684NuqJMJ2iJPGPfJe1s8PqfpBTsscLxaDiwlo/HSrcZpZYFD xmW5sIKpje1soy0MOsdeYcnq5m7ptg/KxcNfo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699891812; x=1700496612; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LEyJPbz5vLaL820Iu2zEMIkHFyVdUrRe5Vuo+rlUsto=; b=dDbp+JB2plHZDA6Qfs1pDNmF/is0uP3pFDQBMFehiPcP7QQptLhmWDAkjkt/z+qdCU 7C6i2pZgRK+awVsDBeReBQ/V9Hu20HzAoSoF4tyfCbTcscPtic1eu8uXdtnk95c1HBde eBOGxlFKT017LD8OMAKCiRvTzzCFs8WS3KkdI8Vgdj3hNKGhkSuva2cOvu2tXSBkHSNk auUqFWR8K3ixXzUZdUH3ooNcJPrbr4pm4YheAdL+zrd+q8wbSShSa5yNc0IjzbTLce7x TgM1uYlopaSbBBV2mBsFTb/bo/GgaPABrfxQtkSDfyu4cRBAlRBOhR4PC9dra0F0btzS qQWQ== X-Gm-Message-State: AOJu0YwjFFHEyJZxeuTOfIWH7zY3uAMhm19HTvHoFUyl8/oNnXOCx1vr nMxLwyWQkyRuU2TD0rl9b1tUmfkqQ+vJBWsTep4= X-Google-Smtp-Source: AGHT+IGywKZgKPdGiy6N9PoH+At+Tuafu6qeoZrvgjPcbES4qr0U9kIS4TqkCINRmv2eh82aCAweKA== X-Received: by 2002:ac2:43a3:0:b0:509:3bba:e8a with SMTP id t3-20020ac243a3000000b005093bba0e8amr4325582lfl.39.1699891812416; Mon, 13 Nov 2023 08:10:12 -0800 (PST) From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Konrad Rzeszutek Wilk , Ross Lagerwall , Roger Pau Monne Subject: [PATCH 2/2] livepatch-tools: fix isnumber() function clash Date: Mon, 13 Nov 2023 17:09:40 +0100 Message-ID: <20231113160940.52430-3-roger.pau@citrix.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231113160940.52430-1-roger.pau@citrix.com> References: <20231113160940.52430-1-roger.pau@citrix.com> MIME-Version: 1.0 isnumber() is already defined for some libcs [0] but the interface is not the same, the isnumber() helper just checks if a single character is a digit. Rename isnumber() to is_number() in order to avoid the clash. [0] https://man.freebsd.org/cgi/man.cgi?query=isnumber&sektion=3 Signed-off-by: Roger Pau Monné --- create-diff-object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/create-diff-object.c b/create-diff-object.c index 67784642bcd7..d0e14e3a62bb 100644 --- a/create-diff-object.c +++ b/create-diff-object.c @@ -1352,7 +1352,7 @@ static void kpatch_process_special_sections(struct kpatch_elf *kelf) } /* Returns true if s is a string of only numbers with length > 0. */ -static bool isnumber(const char *s) +static bool is_number(const char *s) { do { if (!*s || !isdigit(*s)) @@ -1380,13 +1380,13 @@ static bool is_rodata_str_section(const char *name) /* Check if name matches ".rodata.str1.[0-9]+" */ if (!strncmp(name, GCC_5_SECTION_NAME, strlen(GCC_5_SECTION_NAME))) - return isnumber(name + strlen(GCC_5_SECTION_NAME)); + return is_number(name + strlen(GCC_5_SECTION_NAME)); /* Check if name matches ".rodata..str1.[0-9]+" */ s = strstr(name, GCC_6_SECTION_NAME); if (!s) return false; - return isnumber(s + strlen(GCC_6_SECTION_NAME)); + return is_number(s + strlen(GCC_6_SECTION_NAME)); #undef GCC_5_SECTION_NAME #undef GCC_6_SECTION_NAME }