From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from vmicros1.altlinux.org (vmicros1.altlinux.org [194.107.17.57]) by sourceware.org (Postfix) with ESMTP id 496D2386FC2E for ; Mon, 7 Jun 2021 22:10:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 496D2386FC2E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=altlinux.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=altlinux.org Received: from mua.local.altlinux.org (mua.local.altlinux.org [192.168.1.14]) by vmicros1.altlinux.org (Postfix) with ESMTP id C349172C8B0; Tue, 8 Jun 2021 01:10:29 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id B625D7CF722; Tue, 8 Jun 2021 01:10:29 +0300 (MSK) Date: Tue, 8 Jun 2021 01:10:29 +0300 From: "Dmitry V. Levin" To: Sergei Trofimovich Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH v2] elflint: fix undefined 'buffer_left' reference Message-ID: <20210607221029.GA474@altlinux.org> References: <20210606233831.GB17371@altlinux.org> <20210607213742.2902147-1-slyfox@gentoo.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210607213742.2902147-1-slyfox@gentoo.org> X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2021 22:10:40 -0000 On Mon, Jun 07, 2021 at 10:37:42PM +0100, Sergei Trofimovich wrote: > Link failure is reproducible on gcc-11.1.0 target: > > ``` > $ autoreconf -i -f > $ ./configure --enable-maintainer-mode --disable-debuginfod \ > --host=x86_64-pc-linux-gnu \ > CFLAGS=-march=znver3 \ > CXXFLAGS=-march=znver3 \ > LDFLAGS=" " > $ make > > CCLD elflint > ld: elflint.o: in function `check_attributes': > elflint.c:(.text+0xdcff): undefined reference to `buffer_left' > ld: elflint.c:(.text+0xe557): undefined reference to `buffer_left' > ``` > > It happens due to possible external linkage of `buffer_left()`. > > The change forces local linkkage to always use local definition > (either inline or out-of-line). > > Reported-by: Toralf Förster > Bug: https://bugs.gentoo.org/794601 > Signed-off-by: Sergei Trofimovich > Fixes: e95d1fbb ("elflint: Pull left() in file scope") > --- > Change since v1 suggested by Dmitry: > - fixed changelog to spell 'static' correctly :) > - added 'Fixes' annotation > > Did not drop 'inline' to be consistent with other tiny helpers > in the same file. > > src/ChangeLog | 5 +++++ > src/elflint.c | 2 +- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/ChangeLog b/src/ChangeLog > index 2c7be185..698b3c77 100644 > --- a/src/ChangeLog > +++ b/src/ChangeLog > @@ -1,3 +1,8 @@ > +2021-06-06 Sergei Trofimovich > + > + * elflint.c (buffer_left): Mark as 'static' to avoid external linkage > + failure. > + > 2021-05-12 Dmitry V. Levin > > * elfcompress.c (process_file): Return 1 instead of -1 in case of an > diff --git a/src/elflint.c b/src/elflint.c > index 85cc7833..35b40500 100644 > --- a/src/elflint.c > +++ b/src/elflint.c > @@ -3434,7 +3434,7 @@ buffer_pos (Elf_Data *data, const unsigned char *p) > return p - (const unsigned char *) data->d_buf; > } > > -inline size_t > +static inline size_t > buffer_left (Elf_Data *data, const unsigned char *p) > { > return (const unsigned char *) data->d_buf + data->d_size - p; Applied, thanks. -- ldv