Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754157AbdLHOx5 (ORCPT ); Fri, 8 Dec 2017 09:53:57 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:48698 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754130AbdLHOxs (ORCPT ); Fri, 8 Dec 2017 09:53:48 -0500 From: Roman Gushchin To: CC: , , , , , , , Quentin Monnet , David Ahern Subject: [PATCH v3 net-next 2/4] libbpf: prefer global symbols as bpf program name source Date: Fri, 8 Dec 2017 14:52:34 +0000 Message-ID: <20171208145236.12635-3-guro@fb.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171208145236.12635-1-guro@fb.com> References: <20171208145236.12635-1-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:180::1:b43a] X-ClientProxiedBy: VI1PR0102CA0086.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::27) To CO1PR15MB1078.namprd15.prod.outlook.com (2a01:111:e400:7b66::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96d503cf-5c14-4356-066a-08d53e4b692f X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307);SRVR:CO1PR15MB1078; X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;3:sWaMgUk8NOICNPEgdR2/nAUjw695pQB5Uyo6HsS8UlDjuw5/DlS76Ug4MQu6dV7FdsQW0FGWoBVJAJ1V+wghUmKudeJLnxjCoT+kX0MW2uUm3oG0wD736+JY3HcC9+2uAr2HlAgMf+nid0IjpaAEx3grddRrhrJyuj41XkY9udTxcirfSE0K0ZG/jJ+DUcVJFEupx+eAygKFCp/lkXfqTtcGbNjCi5RW7AeHNEb08MAKRpALSsFBC9cNaqj2wwZ6;25:sWA7St01ZGrbYcOQVOcbcC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1r9xSIAUzbGZ1qL+rzI8zqMdcJ7NH70+ZI1equRWUO7fypBpueBEI3DERCNoM8c+Ow6yNDz6v;4:LKoHFjgD16nI5DhZFi/4PIJIQxAYgjCr0R9u7ZfkvyDuDiXIXyk5ZKpwy5AfVpr2YYenPfQWNEDVk8GI2lNAAIZTXunfXsWmmFqUYLaLml8u++tqhzp7ugs0j1hfF6f6+entz7T6zVkhQYItxTnsuwWyDOQ22v9ti2QoDPXkpTuAOJ4NSyXqHmUwWdVOLcqwOVxSEbTqNTD8DTslxgqQBLkd1IQWTcw/O6eOteMPvaQIzeIgmGOt5Sq/q5mcXYuP1auwQZxWRcObVkfYA/TMzkoC6R8BpSzbqL9Zf9fNgSM8du8+ZwHJQeoqvBE0bVEk X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(11241501159)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231022)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123558100)(20161123560025)(20161123555025)(6072148)(201708071742011);SRVR:CO1PR15MB1078;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CO1PR15MB1078; X-Forefront-PRVS: 0515208626 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(366004)(376002)(346002)(189003)(199004)(7736002)(68736007)(6116002)(86362001)(575784001)(1076002)(105586002)(48376002)(106356001)(33646002)(2351001)(50226002)(2361001)(305945005)(2906002)(53416004)(2950100002)(6666003)(8936002)(81166006)(50466002)(8676002)(6916009)(81156014)(5660300001)(52116002)(51416003)(69596002)(6506006)(478600001)(53936002)(52396003)(16586007)(316002)(6486002)(39060400002)(4326008)(36756003)(6512007)(76176011)(25786009)(47776003)(97736004)(54906003)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:CO1PR15MB1078;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO1PR15MB1078;23:XoWIgE23r5x1H8u3gXsrLoDTcAF7/KJtW5iVgPt5y?= =?us-ascii?Q?/aH39YfIi5ByTBVJsQ3urGzTI6JwRAxCGja45+UZk0ZsVn9TD5pGeNXMGDVm?= =?us-ascii?Q?6oyuWt82wp9g4v8DPUx9rsqvGB4H+aulAD8a7z+uYv1PwyxteVI6GLvB8fxj?= =?us-ascii?Q?rjd27e4YcXYHzfi2uAMY0MSl82mWXPgExPV7D4twNshNokysRoPkanGCpNC2?= =?us-ascii?Q?+tpgguxQmL/TKp4mqoNC2CkSkg53HLbRV6kx8xTsgCSxTA3k5WiIGXQh0UP+?= =?us-ascii?Q?6Wpe+QhLgyws+yrjZh4VpiT7NVnW4NAktDRf6IZcV5dcV3+4Ni5v4+7qeNWs?= =?us-ascii?Q?8GjZfe9TT3Q37voI8wFk/+HLxc9HGJWCamrhmgMkp/1y0fQdCD8bDhpwU3H6?= =?us-ascii?Q?YwAKcjxB11xdvW8eI14Jm/tvTB20yRxjeUUuiel17DE3l0Eplw0Jsm1XYr7k?= =?us-ascii?Q?Wy3uNRKymLmOeCwh0h4EYtOqW1XEp1FuM6F73zOgBekDxnc9LPhlWpfaB8uy?= =?us-ascii?Q?BA245wk+Hh4g095CYMByqE9bg48Vw7x4Y6BeuO+44bIan6ug7GOU1coKm/uQ?= =?us-ascii?Q?bVvTP6CQmISi1/q/6+CLGSh75lXTD5gEF1z9shoR2XOEf5RS79TEpbonX8Uh?= =?us-ascii?Q?//G7carX+mYxDZdEbmL4azmn8A0VfPS8dj7DX5l9mhwB9hc5XDCtomRMWVsp?= =?us-ascii?Q?onvI0Bj0Vg0apFun3oiGG4Q2VGFsiydfmNw0nAWUAzKThqoyivy7x59QOpsv?= =?us-ascii?Q?Swub10Ev1PEQRXjOpVL1I9EEaWB0/TjgOpDaXn6R4SU1MrjNcXmcD0lxKKW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xuf94O6NsAc+bZfbjTgV8hLH7yV3DF1MWwqnsHFEYsAoj3GEUNPoVJh0OYUY=;7:12jheQp3V2JRc+Xq4aImW8IlnqKdqggzVl+9nbHusLQHMtOhsQ8RC/W37hiBS3aXTroK8jx1KzuB5z9rnK2AMlX79ZPsI7Tk04ewDM7acIoQLn2trmCci+IO32ngmW21AKoJYenJwBF5JcIHBR2izWVgykDbrPzha1+G+kWzT9edOfvYBAfynel8KqHBxKnLHMOl3VuNN25o+Nv/weODfdLqLsj4ihIiavQM78FgcBNxkD/kyxMvbbC8yJtKa6Jw SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;CO1PR15MB1078;20:wTUMyp/JcchgsZlJpOiNuf8O3waohmqzKv+Db2dgppgc1XLBIndG7uU7j4v1bhF5SkTh2/tm1XSJgjxz8Fu/63E13mWtD0qZMmxJBEub0D9jZf46yWWm7TYc3ofg1CZOKHwpgOQzvPSTQBaiOW2h/E+bAfhYL7n4U0Q3FllyrC0= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2017 14:53:11.7201 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 96d503cf-5c14-4356-066a-08d53e4b692f X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR15MB1078 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-08_08:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1361 Lines: 44 Libbpf picks the name of the first symbol in the corresponding elf section to use as a program name. But without taking symbol's scope into account it may end's up with some local label as a program name. E.g.: $ bpftool prog 1: type 15 name LBB0_10 tag 0390a5136ba23f5c loaded_at Dec 07/17:22 uid 0 xlated 456B not jited memlock 4096B Fix this by preferring global symbols as program name. For instance: $ bpftool prog 1: type 15 name bpf_prog1 tag 0390a5136ba23f5c loaded_at Dec 07/17:26 uid 0 xlated 456B not jited memlock 4096B Signed-off-by: Roman Gushchin Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Jakub Kicinski Cc: Martin KaFai Lau Cc: Quentin Monnet Cc: David Ahern --- tools/lib/bpf/libbpf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 205b7822fa0a..65d0d0aff4fa 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -387,6 +387,8 @@ bpf_object__init_prog_names(struct bpf_object *obj) continue; if (sym.st_shndx != prog->idx) continue; + if (GELF_ST_BIND(sym.st_info) != STB_GLOBAL) + continue; name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, -- 2.14.3