Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp917312pxx; Tue, 27 Oct 2020 03:58:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzWJzR468AMMVfJquF6zm3ZTwmO/XB8U8HWdItBgN2lSoXrrenwkhI1BmCXtlg59DV9QXuj X-Received: by 2002:a17:906:3397:: with SMTP id v23mr1770327eja.212.1603796297080; Tue, 27 Oct 2020 03:58:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603796297; cv=none; d=google.com; s=arc-20160816; b=dIUG+I/ndI/eUfQjOFtK8m4VVmRzXgslMWVOl27hay0OhYaILX2ifg0zbtMSM+cP6x txeNqChf3MgrYIH8Sum9E73Y3ESlZIuH7REZaJeq2h6dwWqhYAIu7K81BlaUufXn34Qp +QMBnrq/aQAVw/XQoVTyLkTeOUbIZryBcJPb6+sEJhTKCFzdUj4xE3SpMg917wh9pOci azkv3ljhKGL1RU2bInsOjF2o0VGic7Y5GBQzoUDyNSPRTfbqFam//JO1759ncrjwSTpg hXeLe4D9UMvCOWPJsPR47p42EjleywlrvWChwQgPL1WX6/QmE5V5hXlIsi4d8yds4Zm4 TNKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7vgcXuZ7Fy8Flnt/gcfjiIO9Ee0bB+5629rw+3Of21o=; b=HlOtTu41ifDJ4vTXlLTRFPrwdJdwU4HTUHPkPqiYIgd5WoeErlxNESV7H2G967FIrX 1Hs7eHathEzzxrfCbAefrj0Ba95yrcRHUR36h7Wexz6hMIjug/g6DKDMNzfK80S9VnYx MI+V4+AWbIUnQ6kmgDVaRLVtLgEPtE200O18k+r6p6TTIoZcVeW50eLrGVpEpnulmuBT okIhu+JyBoNNzzqn3VDPntznqtXievEQ7d3EaQtONTMYNIKl80cJ3kaKHlXgwVO8I7ZP ZBlOq2x0oHcGB3piSLIQwO+qlHoiWlC/KvLhQv8kieE5ZFVYx4wfR3Sg/iKM0M8WUlQC bWxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f95hcGnD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d5si599434edz.431.2020.10.27.03.57.55; Tue, 27 Oct 2020 03:58:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=f95hcGnD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437606AbgJ0AEH (ORCPT + 99 others); Mon, 26 Oct 2020 20:04:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:35160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411015AbgJZXz7 (ORCPT ); Mon, 26 Oct 2020 19:55:59 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CE3F92224E; Mon, 26 Oct 2020 23:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756558; bh=FY29NxHkzmGKfl2iAk9y+aUJIBJ6wEIHkqUvYG9bZg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f95hcGnDBUdByzbJfXqUY8OzjahauPPd6kTqItTTFCn1lrOlAgOb6xZ12wmzBxNdP 3jfh7rzNJQztEQpRAzWLUsudSzag6O6HgYeHX/o78sA69Re/f2hJPYBLS18tJDCcvu UfZCxLFfBvV2D/uVNNQUO9wzyukiyXdf+HKpH0kk= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Yonghong Song , Alexei Starovoitov , Andrii Nakryiko , Sasha Levin , linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.4 34/80] selftests/bpf: Define string const as global for test_sysctl_prog.c Date: Mon, 26 Oct 2020 19:54:30 -0400 Message-Id: <20201026235516.1025100-34-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonghong Song [ Upstream commit 6e057fc15a2da4ee03eb1fa6889cf687e690106e ] When tweaking llvm optimizations, I found that selftest build failed with the following error: libbpf: elf: skipping unrecognized data section(6) .rodata.str1.1 libbpf: prog 'sysctl_tcp_mem': bad map relo against '.L__const.is_tcp_mem.tcp_mem_name' in section '.rodata.str1.1' Error: failed to open BPF object file: Relocation failed make: *** [/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h] Error 255 make: *** Deleting file `/work/net-next/tools/testing/selftests/bpf/test_sysctl_prog.skel.h' The local string constant "tcp_mem_name" is put into '.rodata.str1.1' section which libbpf cannot handle. Using untweaked upstream llvm, "tcp_mem_name" is completely inlined after loop unrolling. Commit 7fb5eefd7639 ("selftests/bpf: Fix test_sysctl_loop{1, 2} failure due to clang change") solved a similar problem by defining the string const as a global. Let us do the same here for test_sysctl_prog.c so it can weather future potential llvm changes. Signed-off-by: Yonghong Song Signed-off-by: Alexei Starovoitov Acked-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20200910202718.956042-1-yhs@fb.com Signed-off-by: Sasha Levin --- tools/testing/selftests/bpf/progs/test_sysctl_prog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c index 5cbbff416998c..4396faf33394a 100644 --- a/tools/testing/selftests/bpf/progs/test_sysctl_prog.c +++ b/tools/testing/selftests/bpf/progs/test_sysctl_prog.c @@ -19,11 +19,11 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif +const char tcp_mem_name[] = "net/ipv4/tcp_mem"; static __always_inline int is_tcp_mem(struct bpf_sysctl *ctx) { - char tcp_mem_name[] = "net/ipv4/tcp_mem"; unsigned char i; - char name[64]; + char name[sizeof(tcp_mem_name)]; int ret; memset(name, 0, sizeof(name)); -- 2.25.1