Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1og4m0-000274-0b for mharc-grub-devel@gnu.org; Wed, 05 Oct 2022 09:49:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51042) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1og4lk-0001zr-LR for grub-devel@gnu.org; Wed, 05 Oct 2022 09:49:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:56781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1og4lh-0000Ed-3e for grub-devel@gnu.org; Wed, 05 Oct 2022 09:49:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664977740; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r/r9iCc8qfnKO2fIjoDnCGRogDaymRB8jMAiReP4Cgo=; b=VvhSSVFGxBc/3bd57pprnqP02SvcB0tqHVzavRyYaPSwmiG0NOowsM7WFD3gvtCcsoVOkG GriaB5zlD32wICzkWvn8MHIpQkz2bBZU+q4f2U7j3GGyoiKKAJmmGm/wqzjm9YwoTzA64j Pv56JNIbgjZGlL2D/uq2dU5O79t5Ryw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-a5Cu-TNOPRSkAAKr3WCaQg-1; Wed, 05 Oct 2022 09:48:57 -0400 X-MC-Unique: a5Cu-TNOPRSkAAKr3WCaQg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D84D918871; Wed, 5 Oct 2022 13:48:51 +0000 (UTC) Received: from eesha.redhat.com (unknown [10.22.34.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4036B1121325; Wed, 5 Oct 2022 13:48:45 +0000 (UTC) From: Robbie Harwood To: grub-devel@gnu.org Cc: Peter Jones , dkiper@net-space.pl, Robbie Harwood Subject: [PATCH v5 1/1] grub-module-verifierxx.c: enable running standalone checkers Date: Wed, 5 Oct 2022 09:48:37 -0400 Message-Id: <20221005134837.3840-2-rharwood@redhat.com> In-Reply-To: <20221005134837.3840-1-rharwood@redhat.com> References: <20221005134837.3840-1-rharwood@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Received-SPF: pass client-ip=170.10.129.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2022 13:49:17 -0000 From: Peter Jones Allow treating grub-module-verifierxx.c as a file you can build directly so syntax checkers like vim's "syntastic" plugin, which uses "gcc -x c -fsyntax-only" to build it, will work. One still has to do whatever setup is required to make it pick the right include dirs, which -I options we use, etc., but this makes it so you can do the checking on the file you're editing, rather than on a different file. Signed-off-by: Peter Jones Signed-off-by: Robbie Harwood --- include/grub/elf.h | 4 ++-- util/grub-module-verifier32.c | 2 ++ util/grub-module-verifier64.c | 2 ++ util/grub-module-verifierXX.c | 9 +++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/grub/elf.h b/include/grub/elf.h index 0e70651d4b..e6f073bc90 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -2593,8 +2593,8 @@ typedef Elf64_Word Elf_Word; typedef Elf64_Xword Elf_Xword; typedef Elf64_Shnum Elf_Shnum; -#define ELF_ST_BIND(val) ELF64_ST_BIND (val) -#define ELF_ST_TYPE(val) ELF64_ST_TYPE (val) +#define ELF_ST_BIND(val) ELF64_ST_BIND(val) +#define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) #define ELF_ST_INFO(a,b) ELF64_ST_INFO(a,b) #define ELF_R_SYM(val) ELF64_R_SYM(val) #define ELF_R_TYPE(val) ELF64_R_TYPE(val) diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c index 257229f8f0..ba7d41aafe 100644 --- a/util/grub-module-verifier32.c +++ b/util/grub-module-verifier32.c @@ -1,2 +1,4 @@ #define MODULEVERIFIER_ELF32 1 +#ifndef GRUB_MODULE_VERIFIERXX #include "grub-module-verifierXX.c" +#endif diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c index 4db6b4bedd..fc23ef800b 100644 --- a/util/grub-module-verifier64.c +++ b/util/grub-module-verifier64.c @@ -1,2 +1,4 @@ #define MODULEVERIFIER_ELF64 1 +#ifndef GRUB_MODULE_VERIFIERXX #include "grub-module-verifierXX.c" +#endif diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 8e0cd91d90..d5907f268e 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -1,3 +1,12 @@ +#define GRUB_MODULE_VERIFIERXX +#if !defined(MODULEVERIFIER_ELF32) && !defined(MODULEVERIFIER_ELF64) +#if __SIZEOF_POINTER__ == 8 +#include "grub-module-verifier64.c" +#else +#include "grub-module-verifier32.c" +#endif +#endif + #include #include -- 2.35.1