From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id CCFC5393BC3B for ; Mon, 7 Jun 2021 21:37:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CCFC5393BC3B Received: by sf.home (Postfix, from userid 1000) id 7252A5A22061; Mon, 7 Jun 2021 22:37:54 +0100 (BST) From: Sergei Trofimovich To: elfutils-devel@sourceware.org, "Dmitry V. Levin" Cc: Sergei Trofimovich Subject: [PATCH v2] elflint: fix undefined 'buffer_left' reference Date: Mon, 7 Jun 2021 22:37:42 +0100 Message-Id: <20210607213742.2902147-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210606233831.GB17371@altlinux.org> References: <20210606233831.GB17371@altlinux.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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 21:38:10 -0000 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; -- 2.32.0