Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1031229pxx; Tue, 27 Oct 2020 06:45:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeo5RBzw/pb+sDula1jL476n4G++X5fDoIlZgUPv7KvC25oKJGmIMhq1ck9TfHywAhc7fA X-Received: by 2002:a17:906:857:: with SMTP id f23mr2419243ejd.3.1603806329754; Tue, 27 Oct 2020 06:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603806329; cv=none; d=google.com; s=arc-20160816; b=BaOOoOLHqcSiaqVzkSuoqGS5ntd40Rmyv1evfs6Kbr/n4gJb6tQFL9yNSFxVepIDjL bSPQc6NZ079GZr/1Svwpuk7h8pc5mxNQWwzW2fhkZQriVDaowirR0al6W9CFWfaSAp+4 vfNCAezZS3DL3Kxrt9QLaW6h9CAqg8iKFt04GriE1VZiIHJSQ+tzZw9OWKqmyZSULLh7 9as3+H4Lt+RTEtE+YCELrFcox+kMpqctxGGGEO/5dL5CcznSvmn3Hal1kIqpD0UgtIO5 dIJNCV+JKqUN1dxAJd4HnYTzRHQawIAr9NSXEvNSo9dTJFSOzer8lVzisP1dk3XVdBfM m70w== 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=vl0DoymQvVQPWVFe0h8eqh/96NNnfFTZA0WaRWbWhXI=; b=xH/mBws+2don0qjdMzFxqRqwkzpQwmmbDE+MooU+lMw/BVbBSUM5teDStxi/Y5mt2+ 3RFRo9NShkTCJgpM7HEA3KTvayu8jlD+7DSKgx+CnfQQlDE3Z2CjgSI8IQnDdF1A0kfk prBlCXeG1O0BpQNqsAJe0+Skfacz477btw4VeZWE2BfYZUqiOcr5vyESAdWqlQUDpPbd HnwbYDu3f7X1nE0z2Dz6+9k3dWxxir9wn6uymc9pVwd6Q8Azarprt6vymHkAMlP0Bmsk u/m6O99lXfAnC38Gc1SGCfh/BAsphCdR17LmNBQFDRHJC2lVBJPum1GrPCpMD1q5MCU4 dt6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cKj0n9NH; 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 dn22si916982edb.603.2020.10.27.06.45.07; Tue, 27 Oct 2020 06:45:29 -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=cKj0n9NH; 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 S2444609AbgJ0Ai7 (ORCPT + 99 others); Mon, 26 Oct 2020 20:38:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:49976 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409120AbgJZXua (ORCPT ); Mon, 26 Oct 2020 19:50:30 -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 DDFF720872; Mon, 26 Oct 2020 23:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756228; bh=Yqk5FXGBcKBnhqS8F2wYGNYMmv3N3uxVYR4uH+Wcgts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cKj0n9NHB8195pYwpYBsrh9IKAIaJ31WM9o1ARyQTpuSU64OcNwKPU0oFu2mquo2K SXIIVSR2cvjoHg29Uvyh7spoXfAcxH+4A2p3qnlocc6GSCjpBoGOAr5Mutg1rDmeTZ y2ZTCiKZ4Vx2tglcAErP4Y+B6mT/DrAx0ZBz2gT4= 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.9 067/147] selftests/bpf: Define string const as global for test_sysctl_prog.c Date: Mon, 26 Oct 2020 19:47:45 -0400 Message-Id: <20201026234905.1022767-67-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-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 50525235380e8..5489823c83fc2 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