Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp207032pxb; Fri, 15 Jan 2021 00:46:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2bqlfUoLRR2tsWVs2rAcb7C8nrKTvzGKsLe4F/ZNPirf64MoqxxHmk+2bkLWziuH3OTzL X-Received: by 2002:aa7:dd17:: with SMTP id i23mr8646128edv.14.1610700406886; Fri, 15 Jan 2021 00:46:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610700406; cv=none; d=google.com; s=arc-20160816; b=Kss9gqczedATb1IshOvl3/GtxwFOYedgt2eYibvQ8py8m4IKbxz/MsFX1O8uajdvXe TVmAVJgtb/qooCxcmtOT0Ha52FWA/wre15UfHTI0oVTKCmn/CK1XDN4AvfRwf+AoSTEJ chEoO6UV4ttJXOcGMPOFzrSFTf3hmjCysquTsYGH1UlrPM1zUa36Uz56Q/A+4YV7h/fG KWn48rc+GgX+p8kkC2unwS+mTfkboeTOLrjr4T83eC5jkOWXmVucPqBOLQ6ajNA9z7zb DN62NAjTpLvsAgWLXAWUB2yucS5lnr9OWIa9OI+JO654CSHhrgTXi0ia7JbacYOTJi+/ aTBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=AGB2FYlHkYy8Oqylnwu4GaXuq7mjj+kJASMcPXLkX3Y=; b=YU4TUL6P7WwGnAxK/Ji6nouJIBHAxtupqSh+6IQFj4lxR03QvXJ06ifZclBPDpiWDH bmcu4kpkNEGJRY/v6qJCwBGbcTwaaJVVIKN3hw1EAnyXjnKVfWi6p0V1P44qVK5G+S/u CS8/kFqFsv9IsfC0OU20RmGg/a0D7rtfa0oLcNSh78N7c/6Rf9sEAeFbR6KlLBmPLQac 3uqlLiTQDFhlfZAC0XeBTy8m7qAjec8j/OY7t9nRWJhqIBL93aAaL8K85s2Rm2h+8anA Gz1PEZpNqaQrtYO3QeWf0cVftBPiV1nMjTbiQZDAP8m/+1d9onGNRcIjD9IzLnXdoxAz aKYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j3lziUWJ; 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 g3si3494036ejf.612.2021.01.15.00.46.22; Fri, 15 Jan 2021 00:46:46 -0800 (PST) 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=k20201202 header.b=j3lziUWJ; 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 S1727812AbhAOIPa (ORCPT + 99 others); Fri, 15 Jan 2021 03:15:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:55292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727679AbhAOIP2 (ORCPT ); Fri, 15 Jan 2021 03:15:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 513C52072D; Fri, 15 Jan 2021 08:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610698487; bh=VDBSNkhjih0ytWUhVsQuY2EtZRagprXKw9fTDS9CCDs=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j3lziUWJc66mIc65O04sk7hiw5QKBQL2GnpTYf7OeJhH83aiZdrSjYpLSQChdhI/D N/2QP9z8AnLTX2s+diTRuSWpiSahvJJes6J7PDPmp+SuctM1tpkr+IZkjvdPkGDDKF tGF60IlD3kaGZMWWzIqB3xN0ZRj8SduaI5Wywp4qdbLtYirNlth9b12GmSR/Gxm2kA z4Uzsfm6h94mYE9ioqzRbbtvkIsT0lVfKJGdSICvuRKCt0c2WpA9HVwHZWWWM/elI9 upDpmBtLAyLmLDRuoP7QKdVGe+Muej35iQ2jTrApVOxtxUhieE5YjKH/vc1hR9PZll kPhuUrP33HRTw== Date: Fri, 15 Jan 2021 09:14:42 +0100 From: Jessica Yu To: Marco Elver Cc: Fangrui Song , LKML , clang-built-linux , Sam Ravnborg Subject: Re: [PATCH v2] module: Ignore _GLOBAL_OFFSET_TABLE_ when warning for undefined symbols Message-ID: <20210115081442.GB9637@linux-8ccs> References: <20210114211840.GA5617@linux-8ccs> <20210114215416.993167-1-maskray@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-OS: Linux linux-8ccs 5.8.0-rc6-lp150.12.61-default+ x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Marco Elver [15/01/21 08:03 +0100]: >On Thu, 14 Jan 2021 at 22:54, Fangrui Song wrote: >> clang-12 -fno-pic (since >> https://github.com/llvm/llvm-project/commit/a084c0388e2a59b9556f2de0083333232da3f1d6) >> can emit `call __stack_chk_fail@PLT` instead of `call __stack_chk_fail` >> on x86. The two forms should have identical behaviors on x86-64 but the >> former causes GNU as<2.37 to produce an unreferenced undefined symbol >> _GLOBAL_OFFSET_TABLE_. >> >> (On x86-32, there is an R_386_PC32 vs R_386_PLT32 difference but the >> linker behavior is identical as far as Linux kernel is concerned.) >> >> Simply ignore _GLOBAL_OFFSET_TABLE_ for now, like what >> scripts/mod/modpost.c:ignore_undef_symbol does. This also fixes the >> problem for gcc/clang -fpie and -fpic, which may emit `call foo@PLT` for >> external function calls on x86. >> >> Note: ld -z defs and dynamic loaders do not error for unreferenced >> undefined symbols so the module loader is reading too much. If we ever >> need to ignore more symbols, the code should be refactored to ignore >> unreferenced symbols. >> >> Reported-by: Marco Elver >> Link: https://github.com/ClangBuiltLinux/linux/issues/1250 >> Signed-off-by: Fangrui Song > >Tested-by: Marco Elver > >Thank you for the patch! > >> --- >> kernel/module.c | 20 ++++++++++++++++++-- >> 1 file changed, 18 insertions(+), 2 deletions(-) >> --- >> Changes in v2: >> * Fix Marco's email address >> * Add a function ignore_undef_symbol similar to scripts/mod/modpost.c:ignore_undef_symbol >> >> diff --git a/kernel/module.c b/kernel/module.c >> index 4bf30e4b3eaa..278f5129bde2 100644 >> --- a/kernel/module.c >> +++ b/kernel/module.c >> @@ -2348,6 +2348,20 @@ static int verify_exported_symbols(struct module *mod) >> return 0; >> } >> >> +static int ignore_undef_symbol(Elf_Half emachine, const char *name) > >Why not 'bool' return-type? > >> +{ >> + /* On x86, PIC code and Clang non-PIC code may have call foo@PLT. GNU as > >Not sure if checkpatch.pl warns about this, but this multi-line >comment does not follow the normal kernel-style (see elsewhere in >file): > >/* > * ... > */ +1 to Marco's comments. Otherwise, patch looks good to me. Thanks Fangrui! Jessica