Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2898030rdb; Wed, 4 Oct 2023 15:22:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrqZgbIvyJgXvgEulhirdfFr/QDSl8UfkmrNOpQTTi5LeQEuF+p1X4ucyl6+9uYhBHeH0h X-Received: by 2002:a05:6a20:7f96:b0:131:b3fa:eaaa with SMTP id d22-20020a056a207f9600b00131b3faeaaamr4263884pzj.61.1696458147686; Wed, 04 Oct 2023 15:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696458147; cv=none; d=google.com; s=arc-20160816; b=CJDtKKvJiltjQKmNAQqFvRxUgACuo84pIHhWNs5AqSgejLKYVSm/R/f/VHyu5xFrkZ Trp4KmjrMcIVSdEAkkrpMb2EIqC+fG7sokrlanWK0/4VkDoTzqpi3zg/Zj0S5FWkvml6 E1vZnLZ+pRYPa7dgtY9aSPTG22uNdxa0myJLKc7f6TcxaseIqpgogMIsJONjDZEruSzC 5bRZD39zaMD+r5tfvi/FLYeCEor+ciGDTbttPgZ5ZWXHwaPoYNe0BX565jdBv7KjSl9I 9Qmdd1rLZ6P+mjHeSIiT6jTz819py0vgVFL/gKyrBpZXDfvCT+iAWuIuPI8e8elIzCFE 6/wA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=LRYb+Nos6yDxCQJYwqOzPdAjSY5dhjaa83JaZUviEiE=; fh=ucMdsYwPLQiIPXwccFwCFrGcM+nDdmgXKb8Y9F0BDF0=; b=bdEIKuughcGhKZNpPBGBUBPSmCsXrzc0i/77Bt2S98GrcYHI8ewQPAlAMUKXRBPHAm MWaHpz9QdbTvVfW4CliJqPyS/3pnRNvaPyPMJcKD9L+8awgTEfZC9M79VPLAu1rp6ogU 7QFM3GLc4ACWYk8yERNF5ZxTnzCjqaMbPTd51zvUbofrDPCT3DVrq627Yx0rgrg/5voK g3rRi1Z49/UyiiPFumGnL3UCaV6jVKf/4HOaN06W4Ew1G3EzWi/XE5RsLaApgvrkegUT a8AtV01rDrGPXHF2KDWaR1JwX6or3/LEoifLdVz753Il0Xdzs3ws0/JTtjFcrn3VY15g G7iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PlM56leG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u15-20020a056a00124f00b0069023c19351si51825pfi.154.2023.10.04.15.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 15:22:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=PlM56leG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 15FCF81EE385; Wed, 4 Oct 2023 15:22:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232276AbjJDWWA (ORCPT + 99 others); Wed, 4 Oct 2023 18:22:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbjJDWV6 (ORCPT ); Wed, 4 Oct 2023 18:21:58 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07530C6 for ; Wed, 4 Oct 2023 15:21:55 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-50348c54439so738e87.1 for ; Wed, 04 Oct 2023 15:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696458113; x=1697062913; darn=vger.kernel.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=LRYb+Nos6yDxCQJYwqOzPdAjSY5dhjaa83JaZUviEiE=; b=PlM56leGd34N3gHvuP5shCEJnnF2EDHvUZtXzDMepNIWs7JhlMLE7Cl71fjWwCunV+ zbb/bYnpxj2lANxVZZByKJTa6HaAByGyu6/u9fGN3BkyUvy5VH+T5N93V/EV2NgtmVP+ fNwPBtzWYTiZeKH3gZaYwXzo0OXhuVAEXWERLvCMT5lcd2jt1/50Ap641SAr/yxT1yYE Qq1aQeEn4uqdwtFJKLLteEfOTxXlZxLPs0P4AtgfAxhOv9OOrWtZ9O087CDx9LaRz1DQ ojd6H2hC1ZOEAdDEFcLfJ2+8CxO3ago0cIxkEArz989VZ9FswugO6S1jtebTBS1yfAHg islw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696458113; x=1697062913; 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=LRYb+Nos6yDxCQJYwqOzPdAjSY5dhjaa83JaZUviEiE=; b=ksx2+XV+ZneuzoQ0tFuydtauPdj6oMns1KrEChQpoj3igq2BCAQNhi+fEct/em+Pj5 imx1HCCO4lMW5MPbZI49dubM26RW56WMiwl9Lx+TCG0XbcuSrIi8rEMBaY88RiBgNHJ9 Tma/HN25mX2OLhWgUYgL0Ct8uKvKP2N8ks2I9xSi2Dt9ZMr57BuFeFf5oeWK62hoF1aD XsTr+yfDibhgKK3eLLUYfLXgDtqAhuvdabU7YZcyAhO8LB/NvKDbE7auW0OQbnAOzYxb DllMEt5tVl7cDONcSwbJxL/WzTIoHM42dMaz0cuUHkSJwyNA96mscD8O5CY0LMJpiZAH grPg== X-Gm-Message-State: AOJu0YzmqzRGQjKOwuNYCLHOCA+wcc1XyQk8sZBoIsh7x6c1VyiAeRbW PAfwQSB+HC42SWaYdueCJwRJWclqNwNGysA1dygJPg== X-Received: by 2002:a19:f50d:0:b0:505:6e12:9e70 with SMTP id j13-20020a19f50d000000b005056e129e70mr32520lfb.6.1696458112755; Wed, 04 Oct 2023 15:21:52 -0700 (PDT) MIME-Version: 1.0 References: <20231004204334.3465116-1-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 4 Oct 2023 15:21:38 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] bpftool: Align output skeleton ELF code To: Andrii Nakryiko Cc: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Alan Maguire Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Wed, 04 Oct 2023 15:22:10 -0700 (PDT) On Wed, Oct 4, 2023 at 2:56=E2=80=AFPM Andrii Nakryiko wrote: > > On Wed, Oct 4, 2023 at 1:43=E2=80=AFPM Ian Rogers wr= ote: > > > > libbpf accesses the ELF data requiring at least 8 byte alignment, > > however, the data is generated into a C string that doesn't guarantee > > alignment. Fix this by assigning to an aligned char array. Use sizeof > > on the array, less one for the \0 terminator, rather than generating a > > constant. > > > > Fixes: a6cc6b34b93e ("bpftool: Provide a helper method for accessing sk= eleton's embedded ELF data") > > Signed-off-by: Ian Rogers > > Reviewed-by: Alan Maguire > > --- > > tools/bpf/bpftool/gen.c | 15 +++++++++------ > > 1 file changed, 9 insertions(+), 6 deletions(-) > > > > CI is not happy still, see [0] > > [0] https://github.com/kernel-patches/bpf/actions/runs/6411371996/job/1= 7406696212 Thanks, typo crept into patch 2/2. Will send v4. Ian > > diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c > > index 2883660d6b67..b8ebcee9bc56 100644 > > --- a/tools/bpf/bpftool/gen.c > > +++ b/tools/bpf/bpftool/gen.c > > @@ -1209,7 +1209,7 @@ static int do_skeleton(int argc, char **argv) > > codegen("\ > > \n\ > > = \n\ > > - s->data =3D (void *)%2$s__elf_bytes(&s->data_sz= ); \n\ > > + s->data =3D (void *)%1$s__elf_bytes(&s->data_sz= ); \n\ > > = \n\ > > obj->skeleton =3D s; = \n\ > > return 0; = \n\ > > @@ -1218,12 +1218,12 @@ static int do_skeleton(int argc, char **argv) > > return err; = \n\ > > } = \n\ > > = \n\ > > - static inline const void *%2$s__elf_bytes(size_t *sz) = \n\ > > + static inline const void *%1$s__elf_bytes(size_t *sz) = \n\ > > { = \n\ > > - *sz =3D %1$d; = \n\ > > - return (const void *)\"\\ = \n\ > > - " > > - , file_sz, obj_name); > > + static const char data[] __attribute__((__align= ed__(8))) =3D \"\\\n\ > > + ", > > + obj_name > > + ); > > > > /* embed contents of BPF object file */ > > print_hex(obj_data, file_sz); > > @@ -1231,6 +1231,9 @@ static int do_skeleton(int argc, char **argv) > > codegen("\ > > \n\ > > \"; = \n\ > > + = \n\ > > + *sz =3D sizeof(data) - 1; = \n\ > > + return (const void *)data; = \n\ > > } = \n\ > > = \n\ > > #ifdef __cplusplus = \n\ > > -- > > 2.42.0.609.gbb76f46606-goog > >