From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Borkmann Subject: Re: [PATCH iproute2] bpf: check map symbol type properly with newer llvm compiler Date: Tue, 30 Oct 2018 01:08:18 +0100 Message-ID: References: <20181029223203.3135200-1-yhs@fb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: kernel-team@fb.com To: Yonghong Song , ast@fb.com, netdev@vger.kernel.org Return-path: Received: from www62.your-server.de ([213.133.104.62]:53070 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbeJ3I70 (ORCPT ); Tue, 30 Oct 2018 04:59:26 -0400 In-Reply-To: <20181029223203.3135200-1-yhs@fb.com> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/29/2018 11:32 PM, Yonghong Song wrote: > With llvm 7.0 or earlier, the map symbol type is STT_NOTYPE. > -bash-4.4$ cat t.c > __attribute__((section("maps"))) int g; > -bash-4.4$ clang -target bpf -O2 -c t.c > -bash-4.4$ readelf -s t.o > > Symbol table '.symtab' contains 2 entries: > Num: Value Size Type Bind Vis Ndx Name > 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND > 1: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 3 g > -bash-4.4$ > > The following llvm commit enables BPF target to generate > proper symbol type and size. > commit bf6ec206615b9718869d48b4e5400d0c6e3638dd > Author: Yonghong Song > Date: Wed Sep 19 16:04:13 2018 +0000 > > [bpf] Symbol sizes and types in object file > > Clang-compiled object files currently don't include the symbol sizes and > types. Some tools however need that information. For example, ctfconvert > uses that information to generate FreeBSD's CTF representation from ELF > files. > With this patch, symbol sizes and types are included in object files. > > Signed-off-by: Paul Chaignon > Reported-by: Yutaro Hayakawa > > Hence, for llvm 8.0.0 (currently trunk), symbol type will be not NOTYPE, but OBJECT. > -bash-4.4$ clang -target bpf -O2 -c t.c > -bash-4.4$ readelf -s t.o > > Symbol table '.symtab' contains 3 entries: > Num: Value Size Type Bind Vis Ndx Name > 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND > 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS t.c > 2: 0000000000000000 4 OBJECT GLOBAL DEFAULT 3 g > -bash-4.4$ > > This patch makes sure bpf library accepts both NOTYPE and OBJECT types > of global map symbols. > > Signed-off-by: Yonghong Song Thanks! Acked-by: Daniel Borkmann