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 CD9BB3847825 for ; Sun, 6 Jun 2021 23:38:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CD9BB3847825 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 CBB5872C8C5; Mon, 7 Jun 2021 02:38:31 +0300 (MSK) Received: by mua.local.altlinux.org (Postfix, from userid 508) id A11CB7CC8BB; Mon, 7 Jun 2021 02:38:31 +0300 (MSK) Date: Mon, 7 Jun 2021 02:38:31 +0300 From: "Dmitry V. Levin" To: Sergei Trofimovich Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH] elflint: fix undefined 'buffer_left' reference Message-ID: <20210606233831.GB17371@altlinux.org> References: <20210606225709.2480357-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: <20210606225709.2480357-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: Sun, 06 Jun 2021 23:38:35 -0000 Hi, On Sun, Jun 06, 2021 at 11:57:09PM +0100, Sergei Trofimovich via Elfutils-devel 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") > --- > src/ChangeLog | 5 +++++ > src/elflint.c | 2 +- > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/src/ChangeLog b/src/ChangeLog > index 2c7be185..e030de0d 100644 > --- a/src/ChangeLog > +++ b/src/ChangeLog > @@ -1,3 +1,8 @@ > +2021-06-06 Sergei Trofimovich > + > + * elflint.c (buffer_left): Mark as 'inline' to avoid external linkage > + failure. Did you mean 'static'? > + > 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; I suppose we could simply replace these 'inline' with 'static' and let the compiler decide whether to inline or not. -- ldv