From patchwork Thu Oct 10 10:26:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 98652 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1DA4D3857341 for ; Thu, 10 Oct 2024 10:27:37 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-40131.protonmail.ch (mail-40131.protonmail.ch [185.70.40.131]) by sourceware.org (Postfix) with ESMTPS id B9C783857C7A for ; Thu, 10 Oct 2024 10:27:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9C783857C7A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pm.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B9C783857C7A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.40.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556024; cv=none; b=xIrsWj542vO7jp7aLXIqFb50MlT92G2f1tjD7bU4GZ17GQcuObpwoIQ4Ik3fYyg/RpD6HXibMwcYICFOt7MdKMolNvUMIa+wh/vmpYEKOHdnkAZdTpZUkRRTlieen+ozQKVMF/XcBrDBFiKdsZgJ+UxiNR5PU4mehluJ32RUJWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556024; c=relaxed/simple; bh=8CU0dczp7yNtYZ2gmicGYM29f/tY+JqhZN9/8v2GtNE=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=uyF+6wNVffv60vPdZ6HUt+PlKIosxDM6SiyKndam35KbsPkWszMC1vr3zp03uj75gBnKs/yQJYrpptudf/0R1DxQZY6/yvKua9K1ycSiAC21QRXHL8GFz17mY0q4yH1k2L5ks0mjrOWSaCNTLXrg+XO2IgYE/kVr+szLdaK7Tx8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1728556020; x=1728815220; bh=Nh0/ur/MPT+DHbcpsVX4a+J8K/JeDBLKxpKz2Amxuo8=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=SpUkA1XToR2fGJWyencRPLXPrtXLvJP2GeVAgpiaSSgApmuTPkqHXYx3hk4ONZKlo 3gZQqfB0zbIz30EwVly2jRAIShOvXwVrHPEKnnuukszE9s2UYKL1/vJtAYJjCq7ded 8vKRvBUvIqnFK55WGel7K9QCONiFO80w2WFaOvXJe6XNCc/Yeih1vDho9FHEuK25JT qgaWrJwY1GKXtCFeZIznOYvXB+ebS06x/5YYeoNt8ikFFotHjMvo8y6E1E0GTWIg9u L14z72NRyo+rIAEgIifoZfuw0Hz34EOsc13mUvsQXIx4e3Qzs/UJjS5LY9A0WUgrjV 2Foi5S7BiDoIw== Date: Thu, 10 Oct 2024 10:26:54 +0000 To: elfutils-devel@sourceware.org From: Michael Pratt Cc: Michael Pratt Subject: [PATCH 1/6] lib: Add missing config.h include to next_prime.c Message-ID: <20241010102559.9162-2-mcpratt@pm.me> In-Reply-To: <20241010102559.9162-1-mcpratt@pm.me> References: <20241010102559.9162-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: c97f19b3e7bf38a14fdb14911afc9a1c5535cfbc MIME-Version: 1.0 X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org This is the last remaining C source file as of this commit without the standard conditional inclusion of config.h as the very first header. * lib/next_prime.c: add missing config.h header. Signed-off-by: Michael Pratt --- lib/next_prime.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/next_prime.c b/lib/next_prime.c index f2c921e3..97c425e1 100644 --- a/lib/next_prime.c +++ b/lib/next_prime.c @@ -27,6 +27,10 @@ the GNU Lesser General Public License along with this program. If not, see . */ +#ifdef HAVE_CONFIG_H +# include +#endif + #include From patchwork Thu Oct 10 10:27:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 98651 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EFDF13857341 for ; Thu, 10 Oct 2024 10:27:25 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by sourceware.org (Postfix) with ESMTPS id 80CB0385703B for ; Thu, 10 Oct 2024 10:27:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 80CB0385703B Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pm.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 80CB0385703B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556032; cv=none; b=pHSS0NsQNapEgoGo/bhbenhnKxKrV3afoR7TypsHNhQ4Lml9/j9SaXJGWC9NFX7kGY+Lf4/lfK+4f7+5LVMnhfMHO3CDO7kfPF49qXWN0xsc69qIkJX9ZjRukwyjD2cfzHtxYH6iPAiJI3PjDUIj2s6BnjArVihpGPW4ju2XPhw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556032; c=relaxed/simple; bh=gFjPScs3RZ6UE2GV3VPjj+H8rWVP7C5IQ5YOCUklmkc=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=rpJNBWYOpfApjXHqjRfITiuXuatKuI2PwN3oFyMQAIF0h7e6dpWvVP4Dj+aKWxQoXhYm+HhGUjmqM1r7HzFIfv/9a1RVj7J5IWsWSWCrUBm7oXJAk86NN2BEaH12q30qWYzV1owJFEty7QBeoN5uIoobrrjZAzRlnJ8RnAHMgAk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1728556027; x=1728815227; bh=v6lEidwG8QBdOXjO0HwABK3fUPgSrxTsrbLsY5HUiPM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=HkQCq3aPKi0KfcqPwEqNPz3QSREaxlAUFDclsPBzOxf4PGW9MT61JsJLFHeG6pQ9T FkcKe7G+sBjU1WE+kdJB8+oHD3Bk/NTHvSiSCJRGqC2x2of7m/14Lo90cME9i+ouk+ XcR+VGoUxZCuTNhfQ/l7ARYKaQSMN7+wRfOEnRNa2MIeOH7c2YpfTVz10s84yVoaHp PkdJv3Ek8AS6W/EsSqu/YO3TmafAClwfM5suYNfJnYCmlHqu430VqQL6/xXIrpk638 D9/B2UzTJg36KtM+dkErhxVu9xyUCx9VWEafvH7V9iMpvrsacTkHwu56PmNOijN0/y zGfYOFK55b/pQ== Date: Thu, 10 Oct 2024 10:27:02 +0000 To: elfutils-devel@sourceware.org From: Michael Pratt Cc: Michael Pratt Subject: [PATCH 2/6] libcpu: Include config.h before standard headers in lexer source Message-ID: <20241010102559.9162-3-mcpratt@pm.me> In-Reply-To: <20241010102559.9162-1-mcpratt@pm.me> References: <20241010102559.9162-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: 93f9423e511edd845d608e785562f6c74f09c42a MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, KAM_SHORT, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org As part of the processing of flex, definitions and headers are added to output source before any literal text or generated code. This causes standard headers to come before config.h unless config.h is included in a %top block instead as specified in the flex manual, section 5.1 "Format of the Definitions". The %top block is non-POSIX, so using it reinforces the requirement of "flex" over a standardized "lex" even more. * libcpu/i386_lex.l (%top): add flex %top block and move config.h header inclusion to it. Signed-off-by: Michael Pratt --- libcpu/i386_lex.l | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libcpu/i386_lex.l b/libcpu/i386_lex.l index 9b33ed95..9c1e14db 100644 --- a/libcpu/i386_lex.l +++ b/libcpu/i386_lex.l @@ -1,3 +1,9 @@ +%top{ +#ifdef HAVE_CONFIG_H +# include +#endif +} + %{ /* Copyright (C) 2004, 2005, 2007, 2008 Red Hat, Inc. Written by Ulrich Drepper , 2004. @@ -26,10 +32,6 @@ the GNU Lesser General Public License along with this program. If not, see . */ -#ifdef HAVE_CONFIG_H -# include -#endif - #include #include From patchwork Thu Oct 10 10:27:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 98654 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B851B385AC09 for ; Thu, 10 Oct 2024 10:27:42 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by sourceware.org (Postfix) with ESMTPS id 678F73857354 for ; Thu, 10 Oct 2024 10:27:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 678F73857354 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pm.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 678F73857354 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.40.134 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556037; cv=none; b=Fc2JPPfasS2LnSWgj8D5/aULN6XgIBwdYw6MVWKCyFJOB91Kjjs6yWJNqVz00H6Rqpg/qCYktfly/PdGtWRZImHrn+7P/JrPIK360rA/1K7gv+4kU0swrchK91hY/TDpM9O301W7g3fUW+w6EYb8XckEcesQiSwR3W/YkWVTCSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556037; c=relaxed/simple; bh=UWBIvGr7vF2M9bvkmpW2mvcbLZFs48D3gS9/XVrk5N8=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=xaFvGhrdZUQSQom75OdnyygPGQeFsxyPv9+qXIVPf6cajPBuBdAFy1DLvOOXVULSEbLGvpcFUfdrDmA1TaYTJSl/eCT0GG88IcQWd51H1Fx4I4/n8BaQp9kXcs8iy0YO7PO9D8pP4T2ieL1lvW61tyGd6C5GVbmvV1ozYWN2tmg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1728556033; x=1728815233; bh=vqoYtzH73CmQnlaA+AN0WBkGKMXnLzsYI3VsWOW4MOo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=pU8WfKnrL5pU1cRMrnEV4k4AN41M94wffzTk9ez6FqVnZDN6RrFeiUM8TZYsne62x dlZgQr5RQiFs6698qDDLOyirT7W66MPFChZA9OKT+KWuS7sQSiJ1y6+b+TYXWizgSx IS95+fD2MvfbUrqcCequgQHf4Taab3VzqDiUZBpFCYw5G+2/Aj1FB9iwTByVblRvv+ Ir2/YmZC6HwSf63vX2sgzRLypSOfOO6VoKedLog0NM4rjKeY0DBJZTQFZA9LjLlxgE F5RGO12diYpJrCboWUusgqc01hCLbabX4DTejvdXI492//2uBtqyngkc3yvbkJz7ay 4WFm6tYda5rtQ== Date: Thu, 10 Oct 2024 10:27:09 +0000 To: elfutils-devel@sourceware.org From: Michael Pratt Cc: Michael Pratt Subject: [PATCH 3/6] libdw: Let clean targets be unconditional Message-ID: <20241010102559.9162-4-mcpratt@pm.me> In-Reply-To: <20241010102559.9162-1-mcpratt@pm.me> References: <20241010102559.9162-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: 8133d87bec3082e3c39b930976a20e262f5f10a0 MIME-Version: 1.0 X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org The automake rule "maintainer-clean-generic" is always available and never conditional, so let the variable that uses it be define non-conditionally. If one actually wants conditional cleaning they should write a custom rule and set it as a dependency of a "*clean-local" automake rule. There is no need to do conditional cleaning here, so move the MAINTAINERCLEANFILES variable definition to the end of the Makefile.am file as it is in the rest of the project. * libdw/Makefile.am: move MAINTAINERCLEANFILES variable to the end of the file as a non-conditional definition. Signed-off-by: Michael Pratt --- libdw/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdw/Makefile.am b/libdw/Makefile.am index 5363c02a..4b9c4413 100644 --- a/libdw/Makefile.am +++ b/libdw/Makefile.am @@ -97,7 +97,6 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \ if MAINTAINER_MODE BUILT_SOURCES = $(srcdir)/known-dwarf.h -MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h $(srcdir)/known-dwarf.h: $(top_srcdir)/config/known-dwarf.awk $(srcdir)/dwarf.h gawk -f $^ > $@.new mv -f $@.new $@ @@ -154,3 +153,4 @@ noinst_HEADERS = libdwP.h memory-access.h dwarf_abbrev_hash.h \ EXTRA_DIST = libdw.map MOSTLYCLEANFILES = $(am_libdw_pic_a_OBJECTS) libdw.so libdw.so.$(VERSION) +MAINTAINERCLEANFILES = $(srcdir)/known-dwarf.h From patchwork Thu Oct 10 10:27:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 98653 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E007A385702B for ; Thu, 10 Oct 2024 10:27:38 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by sourceware.org (Postfix) with ESMTPS id 8EC2E3857710 for ; Thu, 10 Oct 2024 10:27:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8EC2E3857710 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pm.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8EC2E3857710 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.40.133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556045; cv=none; b=D9SVWhK+L/5Cpju16zBTno0/CKCKYJ98dzl0hJzVEZUH0wHFpxtQFYLE3wl8Psy9b4mW974GCRzR/PNN1RhEOybnkkFg16NHQzO9sxOm3sZfljeuUVW/vkHsoOUeujPhCuJu025B9KIzcFKGYvbeL+kn7B1UUkzGQQPY9g63czk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556045; c=relaxed/simple; bh=rq8qq7T/1nmntbbwh6FiD7embnBtVxHx1Tr85+aAWuA=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=aGrrS3t1Q4S9cBfgaNXq1/8zJLUoMPWUnKxbQ+mnuTDb2bwBpJT3oBAWWkTGFQ+COKejP8PgL5dPPCUK8prjqDxz53YWKQgpm50Z0UBCbbbK+44s0dwT/+42slALcxyBBq/zKV6RJyuoJgMy/Utjj+/gaPj1mLD2XWRpz498hiE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1728556040; x=1728815240; bh=Mc6mtMlxoGM/P8npfvJNM0lL2P8ksxKp5FWgxBSXpBc=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=IbRDeuw4iLf5HnNvJvRh/bBsSozsN5PjTs7Oesz+w6JaRs7fIhppvPnNXbKytgzzq c95zIes6gqYFBo/LrLRuFEAwP/7DEDrAqsNrIr5PUxjm9ndIk2QvXQSyXRLu3rK7f2 00Xw3eCPNBSmeGylgOhQH4YJQozeCobYTc3ynbWmiJMmqQ3QqgtpcAL8F9L2O8ZSro uNv8Ya3Ep6KWEJYVzy14tyYP2rSR8gMD+TwghTSpMRVNrdLJ06NHdFTsoqFZbCGowi EAauAh6CtyEuxOVWyBgA9p4tmdsNP9FqOv+w+nA0PClv4ljMwe+GuhM7WZzO/Eszfr gLojlTPbF85Cw== Date: Thu, 10 Oct 2024 10:27:15 +0000 To: elfutils-devel@sourceware.org From: Michael Pratt Cc: Michael Pratt Subject: [PATCH 4/6] src: Prevent invalid include of binary into compilation Message-ID: <20241010102559.9162-5-mcpratt@pm.me> In-Reply-To: <20241010102559.9162-1-mcpratt@pm.me> References: <20241010102559.9162-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: a8edf7b32de9108f35f68fc8ad6a7917578c2831 MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org The "stack" binary built by elfutils has the same name as the standard C++ header . If that header were to be in the list of includes while building the C++ elfutils program "srcfiles", then there is a chance that the "stack" binary is included instead and treated as text, leading to a decode error if "stack" happens to be built first and "." is in the include paths. Adding the result of C++ compilation srcfiles.o to the dependencies of "stack" ensures that the C++ compilation will happen first, before the stack binary is present. While this doesn't guarantee an error will not occur in all cases, it does guarantee that it will not occur from a clean build state. * src/Makefile.am: Add compilation dependency between the stack and srcfiles binaries. Signed-off-by: Michael Pratt --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Makefile.am b/src/Makefile.am index e0267d96..c5474c68 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -94,6 +94,7 @@ strings_LDADD = $(libelf) $(libeu) $(argp_LDADD) ar_LDADD = libar.a $(libelf) $(libeu) $(argp_LDADD) $(obstack_LIBS) unstrip_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) stack_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) $(demanglelib) +EXTRA_stack_DEPENDENCIES = $(if $(findstring srcfiles,$(bin_PROGRAMS)),$(srcfiles_OBJECTS)) elfcompress_LDADD = $(libebl) $(libelf) $(libdw) $(libeu) $(argp_LDADD) elfclassify_LDADD = $(libelf) $(libdw) $(libeu) $(argp_LDADD) srcfiles_SOURCES = srcfiles.cxx From patchwork Thu Oct 10 10:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 98655 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0CB253857710 for ; Thu, 10 Oct 2024 10:27:52 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-40133.protonmail.ch (mail-40133.protonmail.ch [185.70.40.133]) by sourceware.org (Postfix) with ESMTPS id E5E8F3857C7A for ; Thu, 10 Oct 2024 10:27:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5E8F3857C7A Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pm.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E5E8F3857C7A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.40.133 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556057; cv=none; b=JyMx/KN6phvHRxE8wVZ2DXNIdea4xmNWAx/3+fl5oLV3rEI9GjsXmW7KsXwVLVu42jatI4g/q80LEHMTmL3QOdpk9ItmRvt69AqWJUuelYaDZ5LkuOWYGJ16HidwCmvKIn8OhyzKyPta216JLyeq+PPJD8jc4x5PT+ECEzeURMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556057; c=relaxed/simple; bh=mVod5Pwt36/zh94jrwrc3eNTYv1WFG+9I7KOZ5+KhVU=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=KC/F7Z0H/oivKure0ouXy384R5Rn+B79/2Tp75cLfxH7hDkb+0bLkfC9AqnS8Ymdncnn0+lecmNNWH4nVZ3L2eOzmXl76NRleV7jenluRsdyN5U+mQQ8+6wYoDUmqjGiEp5mrEidTGZDxvUbJdPCVZdl5jqqcTCa9tbfl7gZStE= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1728556049; x=1728815249; bh=rTgSsf0ZjvQs5adEeqz+uPldJIH2pzt5mORT7xKusrg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=RRjRtyZ/e3CPwygqrPrWtkHgQjbnje40I5s4n8ipTIxCR1Khz69ODR1B+ux/Vnfra IOBce28qgbmiZNUiNFij/4Iviva4uyG+9391yRpu5lbpVynDgNAmzekyiNaVUo7A3Y FChROYhhQDALrbSflP35ddAilFClnupcJ/boJgsfqvHqOpUPQwmCHLu0g8TcLf9hpz 1lDe0Hy1DMvm0kmwLSygGdfXyll2YlZYkc4Xy6z4zaO/ZH76HKLLw2iHrtXgCYxay3 qd02AYdTFljouw2PEa4kSHafQFmIRfuGFfU21iWOTxLCyZd4MxUnmDb3N40j+SaXY9 2DZ16lp80etsw== Date: Thu, 10 Oct 2024 10:27:23 +0000 To: elfutils-devel@sourceware.org From: Michael Pratt Cc: Michael Pratt Subject: [PATCH 5/6] Remove usage of "unlocked" variant of stdio print functions Message-ID: <20241010102559.9162-6-mcpratt@pm.me> In-Reply-To: <20241010102559.9162-1-mcpratt@pm.me> References: <20241010102559.9162-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: 0acabf80ff9d3535b9e18144faac2d311293bf0f MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org These Linux Standard Base functions are not available on all systems that are capable of building Linux and ELFs. The difference is negligible for simple printing to stdout. POSIX also states for the similar putc_unlocked(): These functions can safely be used in a multi-threaded program if and only if they are called while the invoking thread owns the (FILE *) object, as is the case after a successful call to the flockfile() or ftrylockfile() functions. and These unlocked versions can be safely used only within explicitly locked program regions, using exported locking primitives. and this was never done. There is inconsistent use of fputc_unlocked() mixed with putc_unlocked() and putchar_unlocked(), so consistently use the safer fputc() instead. Signed-off-by: Michael Pratt --- libasm/asm_align.c | 4 +- libcpu/i386_parse.y | 4 +- libebl/eblobjnote.c | 4 +- src/nm.c | 20 +++++----- src/objdump.c | 24 ++++++------ src/readelf.c | 90 ++++++++++++++++++++++----------------------- src/size.c | 8 ++-- src/strings.c | 20 +++++----- tests/showptable.c | 8 ++-- 9 files changed, 91 insertions(+), 91 deletions(-) diff --git a/libasm/asm_align.c b/libasm/asm_align.c index 3a976756..19ec9a13 100644 --- a/libasm/asm_align.c +++ b/libasm/asm_align.c @@ -60,13 +60,13 @@ asm_align (AsmScn_t *asmscn, GElf_Word value) fprintf (asmscn->ctx->out.file, "%02hhx\n", asmscn->pattern->bytes[0]); else { - fputc_unlocked ('"', asmscn->ctx->out.file); + fputc ('"', asmscn->ctx->out.file); for (size_t cnt = 0; cnt < asmscn->pattern->len; ++cnt) fprintf (asmscn->ctx->out.file, "\\x%02hhx", asmscn->pattern->bytes[cnt]); - fputs_unlocked ("\"\n", asmscn->ctx->out.file); + fputs ("\"\n", asmscn->ctx->out.file); } return 0; } diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y index 459684c6..5c91e520 100644 --- a/libcpu/i386_parse.y +++ b/libcpu/i386_parse.y @@ -1158,7 +1158,7 @@ instrtable_out (void) EMIT_SUFFIX (w1); EMIT_SUFFIX (W1); - fputc_unlocked ('\n', outfile); + fputc ('\n', outfile); for (int i = 0; i < 3; ++i) { @@ -1333,7 +1333,7 @@ instrtable_out (void) b = b->next; } - fputc_unlocked ('\n', outfile); + fputc ('\n', outfile); } fputs ("};\n", outfile); } diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c index ad3f49de..da69e99c 100644 --- a/libebl/eblobjnote.c +++ b/libebl/eblobjnote.c @@ -648,10 +648,10 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type, for (size_t cnt = 1; cnt < descsz / 4; ++cnt) { if (cnt > 1) - putchar_unlocked ('.'); + fputc ('.', stdout); printf ("%" PRIu32, buf[cnt]); } - putchar_unlocked ('\n'); + fputc ('\n', stdout); } if (descsz / 4 > FIXED_TAG_BYTES) free (buf); diff --git a/src/nm.c b/src/nm.c index 3675f59b..06f1a072 100644 --- a/src/nm.c +++ b/src/nm.c @@ -439,7 +439,7 @@ handle_ar (int fd, Elf *elf, const char *prefix, const char *fname, Elf_Arhdr *arhdr = NULL; size_t arhdr_off = 0; /* Note: 0 is no valid offset. */ - fputs_unlocked (_("\nArchive index:\n"), stdout); + fputs (_("\nArchive index:\n"), stdout); while (arsym->as_off != 0) { @@ -825,8 +825,8 @@ show_symbols_sysv (Ebl *ebl, GElf_Word strndx, const char *fullname, /* If we have to precede the line with the file name. */ if (print_file_name) { - fputs_unlocked (fullname, stdout); - putchar_unlocked (':'); + fputs (fullname, stdout); + fputc (':', stdout); } /* Convert the address. */ @@ -972,8 +972,8 @@ show_symbols_bsd (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, /* If we have to precede the line with the file name. */ if (print_file_name) { - fputs_unlocked (fullname, stdout); - putchar_unlocked (':'); + fputs (fullname, stdout); + fputc (':', stdout); } bool is_tls = GELF_ST_TYPE (syms[cnt].sym.st_info) == STT_TLS; @@ -1046,8 +1046,8 @@ show_symbols_bsd (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, } if (color_mode) - fputs_unlocked (color_off, stdout); - putchar_unlocked ('\n'); + fputs (color_off, stdout); + fputc ('\n', stdout); } #ifdef USE_DEMANGLE @@ -1104,9 +1104,9 @@ show_symbols_posix (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, /* If we have to precede the line with the file name. */ if (print_file_name) { - fputs_unlocked (fullname, stdout); - putchar_unlocked (':'); - putchar_unlocked (' '); + fputs (fullname, stdout); + fputc (':', stdout); + fputc (' ', stdout); } printf ("%s %c%s", symstr, diff --git a/src/objdump.c b/src/objdump.c index d43c1dd6..e081db64 100644 --- a/src/objdump.c +++ b/src/objdump.c @@ -580,12 +580,12 @@ show_full_content (Ebl *ebl, const char *fname, uint32_t shstrndx) printf ("%02hhx%02hhx%02hhx%02hhx ", cp[inner], cp[inner + 1], cp[inner + 2], cp[inner + 3]); - fputc_unlocked (' ', stdout); + fputc (' ', stdout); for (size_t inner = 0; inner < 16; ++inner) - fputc_unlocked (isascii (cp[inner]) && isprint (cp[inner]) + fputc (isascii (cp[inner]) && isprint (cp[inner]) ? cp[inner] : '.', stdout); - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); } printf (" %04zx ", cnt); @@ -601,14 +601,14 @@ show_full_content (Ebl *ebl, const char *fname, uint32_t shstrndx) for (inner = 2 * (16 - inner) + (16 - inner + 3) / 4 + 1; inner > 0; --inner) - fputc_unlocked (' ', stdout); + fputc (' ', stdout); for (inner = 0; inner < remaining; ++inner) - fputc_unlocked (isascii (cp[inner]) && isprint (cp[inner]) + fputc (isascii (cp[inner]) && isprint (cp[inner]) ? cp[inner] : '.', stdout); - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); } } @@ -640,12 +640,12 @@ disasm_output (char *buf, size_t buflen, void *arg) printf ("%8" PRIx64 ": ", (uint64_t) info->addr); if (info->bytes_color != NULL) - fputs_unlocked (info->bytes_color, stdout); + fputs (info->bytes_color, stdout); size_t cnt; for (cnt = 0; cnt < (size_t) MIN (info->cur - info->last_end, 8); ++cnt) printf (" %02" PRIx8, info->last_end[cnt]); if (info->bytes_color != NULL) - fputs_unlocked (color_off, stdout); + fputs (color_off, stdout); printf ("%*s %.*s\n", (int) (8 - cnt) * 3 + 1, "", (int) buflen, buf); @@ -663,12 +663,12 @@ disasm_output (char *buf, size_t buflen, void *arg) printf ("%8" PRIx64 ": ", (uint64_t) info->addr); if (info->bytes_color != NULL) - fputs_unlocked (info->bytes_color, stdout); + fputs (info->bytes_color, stdout); for (; cnt < (size_t) (info->cur - info->last_end); ++cnt) printf (" %02" PRIx8, info->last_end[cnt]); if (info->bytes_color != NULL) - fputs_unlocked (color_off, stdout); - putchar_unlocked ('\n'); + fputs (color_off, stdout); + fputc ('\n', stdout); info->addr += info->cur - info->last_end - 8; } diff --git a/src/readelf.c b/src/readelf.c index 21cacd7b..a524a64b 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1127,7 +1127,7 @@ print_file_type (unsigned short int e_type) static void print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) { - fputs_unlocked (_("ELF Header:\n Magic: "), stdout); + fputs (_("ELF Header:\n Magic: "), stdout); for (size_t cnt = 0; cnt < EI_NIDENT; ++cnt) printf (" %02hhx", ehdr->e_ident[cnt]); @@ -1154,7 +1154,7 @@ print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) printf (_(" ABI Version: %hhd\n"), ehdr->e_ident[EI_ABIVERSION]); - fputs_unlocked (_(" Type: "), stdout); + fputs (_(" Type: "), stdout); print_file_type (ehdr->e_type); const char *machine = dwelf_elf_e_machine_string (ehdr->e_machine); @@ -1196,9 +1196,9 @@ print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) printf (_(" (%" PRIu32 " in [0].sh_info)"), (uint32_t) shdr->sh_info); else - fputs_unlocked (_(" ([0] not available)"), stdout); + fputs (_(" ([0] not available)"), stdout); } - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); printf (_(" Size of section header entries: %" PRId16 " %s\n"), ehdr->e_shentsize, _("(bytes)")); @@ -1213,9 +1213,9 @@ print_ehdr (Ebl *ebl, GElf_Ehdr *ehdr) printf (_(" (%" PRIu32 " in [0].sh_size)"), (uint32_t) shdr->sh_size); else - fputs_unlocked (_(" ([0] not available)"), stdout); + fputs (_(" ([0] not available)"), stdout); } - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); if (unlikely (ehdr->e_shstrndx == SHN_XINDEX)) { @@ -1406,7 +1406,7 @@ There are %zd section headers, starting at offset %#" PRIx64 ":\n\ } } - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); } @@ -1552,22 +1552,22 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) && shdr->sh_addr >= relro_from && shdr->sh_addr + shdr->sh_size <= relro_to) { - fputs_unlocked (" [RELRO:", stdout); + fputs (" [RELRO:", stdout); in_relro = true; } else if (has_relro && in_relro && shdr->sh_addr >= relro_to) { - fputs_unlocked ("]", stdout); + fputs ("]", stdout); in_relro = false; } else if (has_relro && in_relro && shdr->sh_addr + shdr->sh_size > relro_to) - fputs_unlocked ("] p_type == PT_LOAD && (phdr->p_flags & PF_W) == 0) { if (!in_ro) { - fputs_unlocked (" [RO:", stdout); + fputs (" [RO:", stdout); in_ro = true; } } @@ -1592,12 +1592,12 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) { if ((phdr2->p_flags & PF_W) == 0 && !in_ro) { - fputs_unlocked (" [RO:", stdout); + fputs (" [RO:", stdout); in_ro = true; } else if ((phdr2->p_flags & PF_W) != 0 && in_ro) { - fputs_unlocked ("]", stdout); + fputs ("]", stdout); in_ro = false; } } @@ -1610,16 +1610,16 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) if (has_relro && in_relro && shdr->sh_addr + shdr->sh_size > relro_to) { - fputs_unlocked (">", stdout); + fputs (">", stdout); in_relro = false; } } } if (in_relro || in_ro) - fputs_unlocked ("]", stdout); + fputs ("]", stdout); /* Finish the line. */ - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); } } @@ -1788,8 +1788,8 @@ print_flags (int class, GElf_Xword d_val, const struct flags *flags, if (d_val & flags[cnt].mask) { if (!first) - putchar_unlocked (' '); - fputs_unlocked (flags[cnt].str, stdout); + fputc (' ', stdout); + fputs (flags[cnt].str, stdout); d_val &= ~flags[cnt].mask; first = false; } @@ -1797,11 +1797,11 @@ print_flags (int class, GElf_Xword d_val, const struct flags *flags, if (d_val != 0) { if (!first) - putchar_unlocked (' '); + fputc (' ', stdout); printf ("%#0*" PRIx64, class == ELFCLASS32 ? 10 : 18, d_val); } - putchar_unlocked ('\n'); + fputc ('\n', stdout); } @@ -1909,7 +1909,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) phdr->p_offset); } - fputs_unlocked (_(" Type Value\n"), stdout); + fputs (_(" Type Value\n"), stdout); /* if --use-dynamic option is enabled, use the string table to get the related library info. */ @@ -1953,7 +1953,7 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) case DT_BIND_NOW: case DT_TEXTREL: /* No further output. */ - fputc_unlocked ('\n', stdout); + fputc ('\n', stdout); break; case DT_NEEDED: @@ -2147,7 +2147,7 @@ handle_relocs_rel (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) elf_strptr (ebl->elf, shstrndx, shdr->sh_name), shdr->sh_offset, nentries); - fputs_unlocked (class == ELFCLASS32 + fputs (class == ELFCLASS32 ? _("\ Offset Type Value Name\n") : _("\ @@ -2336,7 +2336,7 @@ handle_relocs_rela (Ebl *ebl, GElf_Ehdr *ehdr, Elf_Scn *scn, GElf_Shdr *shdr) elf_strptr (ebl->elf, shstrndx, shdr->sh_name), shdr->sh_offset, nentries); - fputs_unlocked (class == ELFCLASS32 + fputs (class == ELFCLASS32 ? _("\ Offset Type Value Addend Name\n") : _("\ @@ -2795,7 +2795,7 @@ process_symtab (Ebl *ebl, unsigned int nsyms, Elf64_Word idx, } } - putchar_unlocked ('\n'); + fputc ('\n', stdout); } } @@ -2877,7 +2877,7 @@ handle_symtab (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) (unsigned int) shdr->sh_link, elf_strptr (ebl->elf, shstrndx, glink->sh_name)); - fputs_unlocked (class == ELFCLASS32 + fputs (class == ELFCLASS32 ? _("\ Num: Value Size Type Bind Vis Ndx Name\n") : _("\ @@ -3553,12 +3553,12 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) { ssize_t n; case 0: - fputs_unlocked (_(" 0 *local* "), + fputs (_(" 0 *local* "), stdout); break; case 1: - fputs_unlocked (_(" 1 *global* "), + fputs (_(" 1 *global* "), stdout); break; @@ -3575,7 +3575,7 @@ handle_versym (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr) break; } } - putchar_unlocked ('\n'); + fputc ('\n', stdout); } @@ -3623,7 +3623,7 @@ print_hash_info (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, size_t shstrndx, uint64_t success = 0; /* xgettext:no-c-format */ - fputs_unlocked (_("\ + fputs (_("\ Length Number % of total Coverage\n"), stdout); printf (_(" 0 %6" PRIu32 " %5.1f%%\n"), counts[0], (counts[0] * 100.0) / nbucket); @@ -4045,7 +4045,7 @@ print_attributes (Ebl *ebl, const GElf_Ehdr *ehdr) if (unlikely (*p++ != 'A')) return; - fputs_unlocked (_(" Owner Size\n"), stdout); + fputs (_(" Owner Size\n"), stdout); /* Loop over the sections. */ while (left (data, p) >= 4) @@ -7138,7 +7138,7 @@ print_encoding_base (const char *pfx, unsigned int fde_encoding) if (w & 0x70) { if (w != fde_encoding) - fputc_unlocked (' ', stdout); + fputc (' ', stdout); w = print_relinfo (w); } @@ -9678,7 +9678,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, { get_uleb128 (u128, linep, lineendp); if (n != standard_opcode_lengths[opcode]) - putc_unlocked (',', stdout); + fputc (',', stdout); printf (" %u", u128); } @@ -10431,7 +10431,7 @@ print_debug_macinfo_section (Dwfl_Module *dwflmod __attribute__ ((unused)), \nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"), elf_ndxscn (scn), section_name (ebl, shdr), (uint64_t) shdr->sh_offset); - putc_unlocked ('\n', stdout); + fputc ('\n', stdout); /* There is no function in libdw to iterate over the raw content of the section but it is easy enough to do. */ @@ -10593,7 +10593,7 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)), \nDWARF section [%2zu] '%s' at offset %#" PRIx64 ":\n"), elf_ndxscn (scn), section_name (ebl, shdr), (uint64_t) shdr->sh_offset); - putc_unlocked ('\n', stdout); + fputc ('\n', stdout); /* Get the source file information for all CUs. Uses same datastructure as macinfo. But uses offset field to directly @@ -10746,15 +10746,15 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)), goto invalid_data; args--; if (args > 0) - putchar_unlocked (','); + fputc (',', stdout); } } else printf (_(" no arguments.")); - putchar_unlocked ('\n'); + fputc ('\n', stdout); } } - putchar_unlocked ('\n'); + fputc ('\n', stdout); int level = 1; if (readp + 1 > readendp) @@ -10923,14 +10923,14 @@ print_debug_macro_section (Dwfl_Module *dwflmod __attribute__ ((unused)), if (args > 0) printf (", "); } - putchar_unlocked ('\n'); + fputc ('\n', stdout); } if (readp + 1 > readendp) goto invalid_data; opcode = *readp++; if (opcode == 0) - putchar_unlocked ('\n'); + fputc ('\n', stdout); } } } @@ -11266,7 +11266,7 @@ print_debug_frame_hdr_section (Dwfl_Module *dwflmod __attribute__ ((unused)), /* +4 because of the 4 byte header of the section. */ (uint64_t) shdr->sh_offset + 4 + eh_frame_ptr); - putchar_unlocked ('\n'); + fputc ('\n', stdout); } uint64_t fde_count = 0; @@ -11444,7 +11444,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)), else if (ar_disp != 0) puts (" -> ???"); else - putchar_unlocked ('\n'); + fputc ('\n', stdout); ++u; } while (readp < action_table_end); @@ -13098,19 +13098,19 @@ handle_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, nregloc == 0 ? nhdr->n_descsz : 0, items, nitems); if (colno != 0) - putchar_unlocked ('\n'); + fputc ('\n', stdout); colno = handle_core_registers (ebl, ebl->elf, desc + regs_offset, reglocs, nregloc); if (colno != 0) - putchar_unlocked ('\n'); + fputc ('\n', stdout); } static void handle_notes_data (Ebl *ebl, const GElf_Ehdr *ehdr, GElf_Off start, Elf_Data *data) { - fputs_unlocked (_(" Owner Data size Type\n"), stdout); + fputs (_(" Owner Data size Type\n"), stdout); if (data == NULL) goto bad_note; diff --git a/src/size.c b/src/size.c index ff8ca075..2985bc09 100644 --- a/src/size.c +++ b/src/size.c @@ -411,7 +411,7 @@ show_sysv (Elf *elf, const char *prefix, const char *fname, maxlen = MAX (maxlen, (int) strlen (name)); } - fputs_unlocked (fname, stdout); + fputs (fname, stdout); if (prefix != NULL) printf (_(" (ex %s)"), prefix); printf (":\n%-*s %*s %*s\n", @@ -483,7 +483,7 @@ show_sysv_one_line (Elf *elf) continue; if (! first) - fputs_unlocked (" + ", stdout); + fputs (" + ", stdout); first = false; printf ((radix == radix_hex ? "%" PRIx64 "(%s)" @@ -555,7 +555,7 @@ show_bsd (Elf *elf, const char *prefix, const char *fname, fname); if (prefix != NULL) printf (_(" (ex %s)"), prefix); - fputs_unlocked ("\n", stdout); + fputs ("\n", stdout); total_textsize += textsize; total_datasize += datasize; @@ -607,7 +607,7 @@ show_segments (Elf *elf, const char *fullname) continue; if (! first) - fputs_unlocked (" + ", stdout); + fputs (" + ", stdout); first = false; printf (radix == radix_hex ? "%" PRIx64 "(%c%c%c)" diff --git a/src/strings.c b/src/strings.c index 69d09ccf..fe0f3a48 100644 --- a/src/strings.c +++ b/src/strings.c @@ -345,8 +345,8 @@ process_chunk_mb (const char *fname, const unsigned char *buf, off_t to, /* We found a match. */ if (unlikely (fname != NULL)) { - fputs_unlocked (fname, stdout); - fputs_unlocked (": ", stdout); + fputs (fname, stdout); + fputs (": ", stdout); } if (unlikely (radix != radix_none)) @@ -357,7 +357,7 @@ process_chunk_mb (const char *fname, const unsigned char *buf, off_t to, if (unlikely (*unprinted != NULL)) { - fputs_unlocked (*unprinted, stdout); + fputs (*unprinted, stdout); free (*unprinted); *unprinted = NULL; } @@ -366,8 +366,8 @@ process_chunk_mb (const char *fname, const unsigned char *buf, off_t to, assume the file data is encoded in UCS-2/UTF-16 or UCS-4/UTF-32 respectively we could convert the string. But there is no such guarantee. */ - fwrite_unlocked (start, 1, buf - start, stdout); - putc_unlocked ('\n', stdout); + fwrite (start, 1, buf - start, stdout); + fputc ('\n', stdout); } start = ++buf; @@ -413,8 +413,8 @@ process_chunk (const char *fname, const unsigned char *buf, off_t to, /* We found a match. */ if (likely (fname != NULL)) { - fputs_unlocked (fname, stdout); - fputs_unlocked (": ", stdout); + fputs (fname, stdout); + fputs (": ", stdout); } if (likely (radix != radix_none)) @@ -425,12 +425,12 @@ process_chunk (const char *fname, const unsigned char *buf, off_t to, if (unlikely (*unprinted != NULL)) { - fputs_unlocked (*unprinted, stdout); + fputs (*unprinted, stdout); free (*unprinted); *unprinted = NULL; } - fwrite_unlocked (start, 1, buf - start, stdout); - putc_unlocked ('\n', stdout); + fwrite (start, 1, buf - start, stdout); + fputc ('\n', stdout); } start = ++buf; diff --git a/tests/showptable.c b/tests/showptable.c index a794b0e8..3d0552fe 100644 --- a/tests/showptable.c +++ b/tests/showptable.c @@ -111,11 +111,11 @@ main (int argc, char *argv[]) (unsigned long long int) phdr->p_memsz, (unsigned long long int) phdr->p_align); - putc_unlocked ((phdr->p_flags & PF_X) ? 'X' : ' ', stdout); - putc_unlocked ((phdr->p_flags & PF_W) ? 'W' : ' ', stdout); - putc_unlocked ((phdr->p_flags & PF_R) ? 'R' : ' ', stdout); + fputc ((phdr->p_flags & PF_X) ? 'X' : ' ', stdout); + fputc ((phdr->p_flags & PF_W) ? 'W' : ' ', stdout); + fputc ((phdr->p_flags & PF_R) ? 'R' : ' ', stdout); - putc_unlocked ('\n', stdout); + fputc ('\n', stdout); if (phdr->p_type == PT_INTERP) { From patchwork Thu Oct 10 10:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Pratt X-Patchwork-Id: 98656 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BB0AE3857835 for ; Thu, 10 Oct 2024 10:28:01 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-4322.protonmail.ch (mail-4322.protonmail.ch [185.70.43.22]) by sourceware.org (Postfix) with ESMTPS id 994D3385701E for ; Thu, 10 Oct 2024 10:27:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 994D3385701E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=pm.me ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 994D3385701E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.22 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556069; cv=none; b=APxpC77pG7wYTV9DMonbbYdkeMoatHa+higQ4mApSqkWEqr2eGxxagsg6W/RW7By96/n/IRDVTycDNZA2kZpauN6tbDdZJ78wRk9tT9Qv7B/yK3b+Tr/t2kdTHmCV0LcdfNUBQBKVpI1WFUBNiwXodEwIQUSGqnEPW4P8viN28U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728556069; c=relaxed/simple; bh=C7VYQzlvAqZlduYkbm14FoNEAloGROX0UkJxSQkBXA8=; h=DKIM-Signature:Date:To:From:Subject:Message-ID:MIME-Version; b=ry5oVHs4TlRDdN+VfpsVKHgwJLOH8rVgthAIdTrWvA7Li0IR5RPBfakCqA3dgrFDRpli25qdVrMD34D8aeRDLCpAmFmvA6SDxN71LNSZOfCE/IMkvwNElwKwveY7Y1j02X6S12zcNnGmsRpeJgCImAZiB1DQ7wV9piw7Y/QrYMk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1728556057; x=1728815257; bh=lnQXLr2kU1cBExNum3mU3g3F8tLAPF2cjTRGGVylj4w=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=mnyRaMJ09RWEU4g1NxfLKcLjLp/BsBfyZkvqB1JiBVeQ4dxurMa8K12OP9y+BMGSw Q6nFxigLEbRyeon/FEpImmQSNSQboaNFaai1AFz88OoR5mfAu6p3S8LDhkX4eheodL qlO3Q6wcp2uiKCsTuEiJsK9eLdZWQTAMzz7Y51dApmzqUnwaAjerZm1g4jztLuK2yo b7I/DYDY0m/fzBKP3sSmemniDuHUuNHPiK2xSZvnjID0MPEr43DucS/RKxKX/wJ1YW iu7YprjBPgnFHB2/4RbTPDrN73DUZhGZLvXKijxuaI1hKSEkbvbOga7hWM0/muvSjh nj3GexawsWPzw== Date: Thu, 10 Oct 2024 10:27:31 +0000 To: elfutils-devel@sourceware.org From: Michael Pratt Cc: Michael Pratt Subject: [PATCH 6/6] Use file stream or format variants of stdio print functions Message-ID: <20241010102559.9162-7-mcpratt@pm.me> In-Reply-To: <20241010102559.9162-1-mcpratt@pm.me> References: <20241010102559.9162-1-mcpratt@pm.me> Feedback-ID: 27397442:user:proton X-Pm-Message-ID: f227d81b39424f0d73ed88372dfd6b8abd95d8cb MIME-Version: 1.0 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_INFOUSMEBIZ, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org In many source files, putc() and fputc() and putchar() are used interchangeably, and puts() and fputs() and printf() are used interchangeably. Reducing the usage to 2 of the 3 both reduces binary size of the final product, improves readability and searchability of the code, especially since grepping for puts() can clash with words like "inputs" and "outputs", and that putc() can be a macro while fputc() is the safer function. While at it, adjust spacing syntax and punctuation for consistency. Signed-off-by: Michael Pratt --- libcpu/i386_disasm.c | 2 +- src/addr2line.c | 8 +-- src/ar.c | 2 +- src/elfclassify.c | 2 +- src/elflint.c | 2 +- src/nm.c | 2 +- src/objdump.c | 4 +- src/readelf.c | 108 +++++++++++++++++----------------- src/unstrip.c | 2 +- tests/addrcfi.c | 2 +- tests/addrscopes.c | 2 +- tests/all-dwarf-ranges.c | 4 +- tests/arextract.c | 4 +- tests/asm-tst1.c | 6 +- tests/asm-tst2.c | 6 +- tests/asm-tst3.c | 8 +-- tests/asm-tst4.c | 2 +- tests/asm-tst5.c | 2 +- tests/asm-tst6.c | 2 +- tests/asm-tst7.c | 6 +- tests/asm-tst8.c | 6 +- tests/asm-tst9.c | 6 +- tests/buildid.c | 4 +- tests/debugaltlink.c | 4 +- tests/dwarf-getmacros.c | 6 +- tests/dwarf-getstring.c | 2 +- tests/dwarf-ranges.c | 2 +- tests/dwarfcfi.c | 2 +- tests/dwflmodtest.c | 6 +- tests/funcretval.c | 6 +- tests/funcscopes.c | 2 +- tests/get-aranges.c | 6 +- tests/get-files-define-file.c | 2 +- tests/get-files.c | 2 +- tests/get-pubnames.c | 4 +- tests/line2addr.c | 4 +- tests/next-files.c | 2 +- tests/saridx.c | 2 +- tests/scnnames.c | 2 +- tests/sectiondump.c | 4 +- tests/show-die-info.c | 62 +++++++++---------- tests/showptable.c | 2 +- tests/test-nlist.c | 2 +- 43 files changed, 159 insertions(+), 157 deletions(-) diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index dec62bfa..7f199b49 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -565,7 +565,7 @@ i386_disasm (Ebl *ebl __attribute__((unused)), #endif default: /* Cannot happen. */ - puts ("unknown prefix"); + fputs ("unknown prefix\n", stdout); abort (); } data = begin + 1; diff --git a/src/addr2line.c b/src/addr2line.c index d87e5b45..9ced8a62 100644 --- a/src/addr2line.c +++ b/src/addr2line.c @@ -729,10 +729,10 @@ handle_address (const char *string, Dwfl *dwfl) show_int (&dwarf_lineisa, info, "isa"); show_int (&dwarf_linediscriminator, info, "discriminator"); } - putchar ('\n'); + fputc ('\n', stdout); } else - puts ("??:0"); + fputs ("??:0\n", stdout); if (show_inlines) { @@ -811,10 +811,10 @@ handle_address (const char *string, Dwfl *dwfl) if (src != NULL) { print_src (src, lineno, linecol, &cu); - putchar ('\n'); + fputc ('\n', stdout); } else - puts ("??:0"); + fputs ("??:0\n", stdout); } } } diff --git a/src/ar.c b/src/ar.c index 9ace28b9..ad48c395 100644 --- a/src/ar.c +++ b/src/ar.c @@ -579,7 +579,7 @@ do_oper_extract (int oper, const char *arfname, char **argv, int argc, if (oper == oper_list) { if (!verbose) - puts (arhdr->ar_name); + printf ("%s\n", arhdr->ar_name); goto next; } diff --git a/src/elfclassify.c b/src/elfclassify.c index 25fe9a65..8c18b5d1 100644 --- a/src/elfclassify.c +++ b/src/elfclassify.c @@ -820,7 +820,7 @@ process_current_path (int *status) { case do_print: if (checks_passed == flag_print_matching) - puts (current_path); + printf ("%s\n", current_path); break; case do_print0: if (checks_passed == flag_print_matching) diff --git a/src/elflint.c b/src/elflint.c index cdc6108d..24f3c043 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -181,7 +181,7 @@ main (int argc, char *argv[]) elf_errmsg (-1)); if (prev_error_count == error_count && !be_quiet) - puts (_("No errors")); + fputs (_("No errors\n"), stdout); } close (fd); diff --git a/src/nm.c b/src/nm.c index 06f1a072..40270c9d 100644 --- a/src/nm.c +++ b/src/nm.c @@ -1125,7 +1125,7 @@ show_symbols_posix (Elf *elf, const GElf_Ehdr *ehdr, GElf_Word strndx, : " %0*" PRIo64 " %0*" PRIo64)), digits, syms[cnt].sym.st_value, digits, syms[cnt].sym.st_size); - putchar ('\n'); + fputc ('\n', stdout); } #ifdef USE_DEMANGLE diff --git a/src/objdump.c b/src/objdump.c index e081db64..3b6b10cd 100644 --- a/src/objdump.c +++ b/src/objdump.c @@ -392,7 +392,7 @@ show_relocs_x (Ebl *ebl, GElf_Shdr *shdr, Elf_Data *symdata, } printf ("%c%#" PRIx64, sign, r_addend); } - putchar ('\n'); + fputc ('\n', stdout); } @@ -537,7 +537,7 @@ show_relocs (Ebl *ebl, const char *fname, uint32_t shstrndx) show_relocs_rela (ebl, shdr, data, symdata, xndxdata, symshdr->sh_link, shstrndx); - putchar ('\n'); + fputc ('\n', stdout); } } diff --git a/src/readelf.c b/src/readelf.c index a524a64b..c9437b79 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -1112,14 +1112,15 @@ print_file_type (unsigned short int e_type) N_("DYN (Shared object file)"), N_("CORE (Core file)") }; - puts (_(knowntypes[e_type])); + fputs (_(knowntypes[e_type]), stdout); + fputc ('\n', stdout); } else if (e_type >= ET_LOOS && e_type <= ET_HIOS) printf (_("OS Specific: (%x)\n"), e_type); else if (e_type >= ET_LOPROC /* && e_type <= ET_HIPROC always true */) printf (_("Processor Specific: (%x)\n"), e_type); else - puts ("???"); + fputs ("???\n", stdout); } @@ -1299,19 +1300,19 @@ There are %zd section headers, starting at offset %#" PRIx64 ":\n\ error_exit (0, _("cannot get section header string table index: %s"), elf_errmsg (-1)); - puts (_("Section Headers:")); + fputs (_("Section Headers:\n"), stdout); if (ehdr->e_ident[EI_CLASS] == ELFCLASS32) - puts (_("[Nr] Name Type Addr Off Size ES Flags Lk Inf Al")); + fputs (_("[Nr] Name Type Addr Off Size ES Flags Lk Inf Al\n"), stdout); else - puts (_("[Nr] Name Type Addr Off Size ES Flags Lk Inf Al")); + fputs (_("[Nr] Name Type Addr Off Size ES Flags Lk Inf Al\n"), stdout); if (print_decompress) { if (ehdr->e_ident[EI_CLASS] == ELFCLASS32) - puts (_(" [Compression Size Al]")); + fputs (_(" [Compression Size Al]\n"), stdout); else - puts (_(" [Compression Size Al]")); + fputs (_(" [Compression Size Al]\n"), stdout); } for (cnt = 0; cnt < shnum; ++cnt) @@ -1418,13 +1419,13 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) /* No program header, this is OK in relocatable objects. */ return; - puts (_("Program Headers:")); + fputs (_("Program Headers:\n"), stdout); if (ehdr->e_ident[EI_CLASS] == ELFCLASS32) - puts (_("\ - Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align")); + fputs (_("\ + Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"), stdout); else - puts (_("\ - Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align")); + fputs (_("\ + Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align\n"), stdout); /* Process all program headers. */ bool has_relro = false; @@ -1439,7 +1440,7 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) /* If for some reason the header cannot be returned show this. */ if (unlikely (phdr == NULL)) { - puts (" ???"); + fputs (" ???\n", stdout); continue; } @@ -1505,7 +1506,7 @@ print_phdr (Ebl *ebl, GElf_Ehdr *ehdr) if (unlikely (elf_getshdrstrndx (ebl->elf, &shstrndx) < 0)) error_exit (0, _("cannot get section header string table index")); - puts (_("\n Section to Segment mapping:\n Segment Sections...")); + fputs (_("\n Section to Segment mapping:\n Segment Sections...\n"), stdout); for (size_t cnt = 0; cnt < phnum; ++cnt) { @@ -2003,7 +2004,8 @@ handle_dynamic (Ebl *ebl, Elf_Scn *scn, GElf_Shdr *shdr, GElf_Phdr *phdr) case DT_PLTREL:; const char *tagname = ebl_dynamic_tag_name (ebl, dyn->d_un.d_val, NULL, 0); - puts (tagname ?: "???"); + fputs (tagname ?: "???", stdout); + fputc ('\n', stdout); break; case DT_FLAGS: @@ -3968,8 +3970,8 @@ print_liblist (Ebl *ebl) if (data == NULL) return; - puts (_("\ - Library Time Stamp Checksum Version Flags")); + fputs (_("\ + Library Time Stamp Checksum Version Flags\n"), stdout); for (int cnt = 0; cnt < nentries; ++cnt) { @@ -4769,7 +4771,7 @@ static void print_block (size_t n, const void *block) { if (n == 0) - puts (_("empty block")); + fputs (_("empty block\n"), stdout); else { printf (_("%zu byte block:"), n); @@ -4777,7 +4779,7 @@ print_block (size_t n, const void *block) do printf (" %02x", *data++); while (--n > 0); - putchar ('\n'); + fputc ('\n', stdout); } } @@ -6633,7 +6635,7 @@ print_debug_ranges_section (Dwfl_Module *dwflmod, printf (" [%6tx] ", offset); else printf (" "); - puts (_("base address")); + fputs (_("base address\n"), stdout); printf (" "); print_dwarf_addr (dwflmod, address_size, end, end); printf ("\n"); @@ -6781,7 +6783,7 @@ print_cfa_program (const unsigned char *readp, const unsigned char *const endp, { char regnamebuf[REGNAMESZ]; - puts ("\n Program:"); + fputs ("\n Program:\n", stdout); Dwarf_Word pc = vma_base; while (readp < endp) { @@ -6797,7 +6799,7 @@ print_cfa_program (const unsigned char *readp, const unsigned char *const endp, int64_t sop2; case DW_CFA_nop: - puts (" nop"); + fputs (" nop\n", stdout); break; case DW_CFA_set_loc: if ((uint64_t) (endp - readp) < 1) @@ -6871,10 +6873,10 @@ print_cfa_program (const unsigned char *readp, const unsigned char *const endp, regname (ebl, op2, regnamebuf)); break; case DW_CFA_remember_state: - puts (" remember_state"); + fputs (" remember_state\n", stdout); break; case DW_CFA_restore_state: - puts (" restore_state"); + fputs (" restore_state\n", stdout); break; case DW_CFA_def_cfa: if ((uint64_t) (endp - readp) < 1) @@ -7000,9 +7002,9 @@ print_cfa_program (const unsigned char *readp, const unsigned char *const endp, break; case DW_CFA_GNU_window_save: /* DW_CFA_AARCH64_negate_ra_state */ if (ehdr->e_machine == EM_AARCH64) - puts (" AARCH64_negate_ra_state"); + fputs (" AARCH64_negate_ra_state\n", stdout); else - puts (" GNU_window_save"); + fputs (" GNU_window_save\n", stdout); break; case DW_CFA_GNU_args_size: if ((uint64_t) (endp - readp) < 1) @@ -7128,7 +7130,7 @@ print_encoding_base (const char *pfx, unsigned int fde_encoding) printf ("(%s", pfx); if (fde_encoding == DW_EH_PE_omit) - puts ("omit)"); + fputs ("omit)\n", stdout); else { unsigned int w = fde_encoding; @@ -7146,7 +7148,7 @@ print_encoding_base (const char *pfx, unsigned int fde_encoding) if (w != 0) printf ("%s%x", w != fde_encoding ? " " : "", w); - puts (")"); + fputs (")\n", stdout); } } @@ -7380,9 +7382,9 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, while (++startp < readp) printf ("%#x ", *startp); - putchar ('('); + fputc ('(', stdout); print_encoding (encoding); - putchar (' '); + fputc (' ', stdout); switch (encoding & 0xf) { case DW_EH_PE_sleb128: @@ -7428,7 +7430,7 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, cie = cie->next; if (unlikely (cie == NULL)) { - puts ("invalid CIE reference in FDE"); + fputs ("invalid CIE reference in FDE\n", stdout); return; } @@ -7485,7 +7487,7 @@ print_debug_frame_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, & (ptr_size == 4 ? UINT64_C (0xffffffff) : UINT64_C (0xffffffffffffffff))); - putchar ('\n'); + fputc ('\n', stdout); if (cie->augmentation[0] == 'z') { @@ -8163,7 +8165,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) || (form != DW_FORM_data16 && attrp->cu->version < 4)) /* blocks were expressions. */ { - putchar ('\n'); + fputc ('\n', stdout); print_ops (cbargs->dwflmod, cbargs->dbg, 12 + level * 2, 12 + level * 2, cbargs->version, cbargs->addrsize, cbargs->offset_size, @@ -8175,7 +8177,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) case DW_AT_discr_list: if (block.length == 0) - puts (""); + fputs ("\n", stdout); else if (form != DW_FORM_data16) { const unsigned char *readp = block.data; @@ -8257,7 +8259,7 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) if (readp < readendp) printf (", "); } - putchar ('\n'); + fputc ('\n', stdout); } else print_block (block.length, block.data); @@ -9146,7 +9148,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, Dwarf_Off str_offsets_base = str_offsets_base_off (dbg, NULL); - puts (_("\nDirectory table:")); + fputs (_("\nDirectory table:\n"), stdout); if (version > 4) { struct encpair { uint16_t desc; uint16_t form; }; @@ -9223,7 +9225,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, if (unlikely (linep >= lineendp)) goto invalid_unit; - puts (_("\nFile name table:")); + fputs (_("\nFile name table:\n"), stdout); if (version > 4) { struct encpair { uint16_t desc; uint16_t form; }; @@ -9284,7 +9286,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, } else { - puts (_(" Entry Dir Time Size Name")); + fputs (_(" Entry Dir Time Size Name\n"), stdout); for (unsigned int cnt = 1; linep < lineendp && *linep != 0; ++cnt) { /* First comes the file name. */ @@ -9330,11 +9332,11 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, if (linep == lineendp) { - puts (_("\nNo line number statements.")); + fputs (_("\nNo line number statements\n"), stdout); continue; } - puts (_("\nLine number statements:")); + fputs (_("\nLine number statements:\n"), stdout); Dwarf_Word address = 0; unsigned int op_index = 0; size_t line = 1; @@ -9413,7 +9415,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, switch (opcode) { case DW_LNE_end_sequence: - puts (_(" end of sequence")); + fputs (_(" end of sequence\n"), stdout); /* Reset the registers we care about. */ address = 0; @@ -9531,7 +9533,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, default: /* Unknown, ignore it. */ - puts (_(" unknown opcode")); + fputs (_(" unknown opcode\n"), stdout); linep += len - 1; break; } @@ -9543,7 +9545,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, { case DW_LNS_copy: /* Takes no argument. */ - puts (_(" copy")); + fputs (_(" copy\n"), stdout); break; case DW_LNS_advance_pc: @@ -9604,7 +9606,7 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, case DW_LNS_set_basic_block: /* Takes no argument. */ - puts (_(" set basic block flag")); + fputs (_(" set basic block flag\n"), stdout); break; case DW_LNS_const_add_pc: @@ -9645,12 +9647,12 @@ print_debug_line_section (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr, case DW_LNS_set_prologue_end: /* Takes no argument. */ - puts (_(" set prologue end flag")); + fputs (_(" set prologue end flag\n"), stdout); break; case DW_LNS_set_epilogue_begin: /* Takes no argument. */ - puts (_(" set epilogue begin flag")); + fputs (_(" set epilogue begin flag\n"), stdout); break; case DW_LNS_set_isa: @@ -10343,7 +10345,7 @@ print_debug_loc_section (Dwfl_Module *dwflmod, printf (" [%6tx] ", offset); else printf (" "); - puts (_("base address")); + fputs (_("base address\n"), stdout); printf (" "); print_dwarf_addr (dwflmod, address_size, end, end); printf ("\n"); @@ -11282,7 +11284,7 @@ print_debug_frame_hdr_section (Dwfl_Module *dwflmod __attribute__ ((unused)), if (fde_count == 0 || table_enc == DW_EH_PE_omit) return; - puts (" Table:"); + fputs (" Table:\n", stdout); /* Optimize for the most common case. */ if (table_enc == (DW_EH_PE_datarel | DW_EH_PE_sdata4)) @@ -11383,7 +11385,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)), while (readp < action_table) { if (u == 0) - puts (_("\n Call site table:")); + fputs (_("\n Call site table:\n"), stdout); uint64_t call_site_start; readp = read_encoded (call_site_encoding, readp, dataend, @@ -11411,7 +11413,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)), unsigned int max_ar_filter = 0; if (max_action > 0) { - puts ("\n Action table:"); + fputs ("\n Action table:\n", stdout); size_t maxdata = (size_t) (dataend - action_table); if (max_action > maxdata || maxdata - max_action < 1) @@ -11442,7 +11444,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)), if (abs (ar_disp) & 1) printf (" -> [%4u]\n", u + (ar_disp + 1) / 2); else if (ar_disp != 0) - puts (" -> ???"); + fputs (" -> ???\n", stdout); else fputc ('\n', stdout); ++u; @@ -11453,7 +11455,7 @@ print_debug_exception_table (Dwfl_Module *dwflmod __attribute__ ((unused)), if (max_ar_filter > 0 && ttype_base != NULL) { unsigned char dsize; - puts ("\n TType table:"); + fputs ("\n TType table:\n", stdout); // XXX Not *4, size of encoding; switch (ttype_encoding & 7) @@ -13284,7 +13286,7 @@ hex_dump (const uint8_t *data, size_t len) printf ("%c", isprint (b) ? b : '.'); } - putchar ('\n'); + fputc ('\n', stdout); pos += chunk; } } diff --git a/src/unstrip.c b/src/unstrip.c index d70053de..3307c4c0 100644 --- a/src/unstrip.c +++ b/src/unstrip.c @@ -2489,7 +2489,7 @@ list_module (Dwfl_Module *mod) printf ("@%#" PRIx64, id_vaddr); } else - putchar ('-'); + fputc ('-', stdout); printf (" %s %s %s\n", file ?: have_elf ? "." : "-", diff --git a/tests/addrcfi.c b/tests/addrcfi.c index 2b7d7bd0..2a77db27 100644 --- a/tests/addrcfi.c +++ b/tests/addrcfi.c @@ -69,7 +69,7 @@ print_detail (int result, const Dwarf_Op *ops, size_t nops, Dwarf_Addr bias) printf ("(%" PRId64 ",%" PRId64 ")", ops[i].number, ops[i].number2); } - puts (""); + fputc ('\n', stdout); } } diff --git a/tests/addrscopes.c b/tests/addrscopes.c index b231b6a9..01eb6e4e 100644 --- a/tests/addrscopes.c +++ b/tests/addrscopes.c @@ -130,7 +130,7 @@ handle_address (GElf_Addr pc, Dwfl *dwfl) if (highpc != lowpc) paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline); } - puts (""); + fputc ('\n', stdout); print_vars (indent + INDENT, die); } diff --git a/tests/all-dwarf-ranges.c b/tests/all-dwarf-ranges.c index 4331a05b..0980d0e0 100644 --- a/tests/all-dwarf-ranges.c +++ b/tests/all-dwarf-ranges.c @@ -33,7 +33,7 @@ ranges_die (Dwarf_Die *die) Dwarf_Addr base, start, end; int ranges = dwarf_ranges (die, 0, &base, &start, &end); if (ranges < 0) - puts (dwarf_errmsg (-1)); + printf ("%s\n", dwarf_errmsg (-1)); else if (ranges > 0) { printf ("die: %s (%x)\n", dwarf_diename (die) ?: "", @@ -42,7 +42,7 @@ ranges_die (Dwarf_Die *die) (off = dwarf_ranges (die, off, &base, &start, &end)); ) if (off == -1) { - puts (dwarf_errmsg (-1)); + printf ("%s\n", dwarf_errmsg (-1)); break; } else diff --git a/tests/arextract.c b/tests/arextract.c index 936d7f55..c8cb19e2 100644 --- a/tests/arextract.c +++ b/tests/arextract.c @@ -113,7 +113,7 @@ Failed to get base address for the archive element: %s\n", if (write (outfd, buf, n) != n) { - puts ("Writing output failed"); + fputs ("Writing output failed\n", stdout); exit (1); } @@ -124,7 +124,7 @@ Failed to get base address for the archive element: %s\n", /* Check whether all the date was read and written out. */ if (todo != 0) { - puts ("Reading archive member failed."); + fputs ("Reading archive member failed\n", stdout); exit (1); } diff --git a/tests/asm-tst1.c b/tests/asm-tst1.c index d03a4361..3d845dbf 100644 --- a/tests/asm-tst1.c +++ b/tests/asm-tst1.c @@ -78,7 +78,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } @@ -132,7 +132,7 @@ main (void) } if (elf_kind (elf) != ELF_K_ELF) { - puts ("not a valid ELF file"); + fputs ("not a valid ELF file\n", stdout); result = 1; goto out_close2; } @@ -147,7 +147,7 @@ main (void) if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0) { - puts ("ELF header does not match"); + fputs ("ELF header does not match\n", stdout); result = 1; goto out_close2; } diff --git a/tests/asm-tst2.c b/tests/asm-tst2.c index e65a9d2f..de65a15a 100644 --- a/tests/asm-tst2.c +++ b/tests/asm-tst2.c @@ -77,7 +77,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } @@ -148,7 +148,7 @@ main (void) } if (elf_kind (elf) != ELF_K_ELF) { - puts ("not a valid ELF file"); + fputs ("not a valid ELF file\n", stdout); result = 1; goto out_close2; } @@ -163,7 +163,7 @@ main (void) if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0) { - puts ("ELF header does not match"); + fputs ("ELF header does not match\n", stdout); result = 1; goto out_close2; } diff --git a/tests/asm-tst3.c b/tests/asm-tst3.c index e45fa16a..2775207d 100644 --- a/tests/asm-tst3.c +++ b/tests/asm-tst3.c @@ -69,7 +69,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } @@ -155,7 +155,7 @@ main (void) } if (elf_kind (elf) != ELF_K_ELF) { - puts ("not a valid ELF file"); + fputs ("not a valid ELF file\n", stdout); result = 1; goto out_close2; } @@ -225,14 +225,14 @@ main (void) if (shdr->sh_link != 2) { - puts ("symbol table has incorrect link"); + fputs ("symbol table has incorrect link\n", stdout); result = 1; } data = elf_getdata (scn, NULL); if (data == NULL) { - puts ("cannot get data of symbol table"); + fputs ("cannot get data of symbol table\n", stdout); result = 1; } else diff --git a/tests/asm-tst4.c b/tests/asm-tst4.c index 1a05bfcc..ffec28ba 100644 --- a/tests/asm-tst4.c +++ b/tests/asm-tst4.c @@ -45,7 +45,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } diff --git a/tests/asm-tst5.c b/tests/asm-tst5.c index 256873f0..00bb9824 100644 --- a/tests/asm-tst5.c +++ b/tests/asm-tst5.c @@ -47,7 +47,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } diff --git a/tests/asm-tst6.c b/tests/asm-tst6.c index 4a665ed0..9e19ef85 100644 --- a/tests/asm-tst6.c +++ b/tests/asm-tst6.c @@ -45,7 +45,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } diff --git a/tests/asm-tst7.c b/tests/asm-tst7.c index 87c21485..ca16e97e 100644 --- a/tests/asm-tst7.c +++ b/tests/asm-tst7.c @@ -45,7 +45,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } @@ -89,7 +89,7 @@ main (void) } if (elf_kind (elf) != ELF_K_ELF) { - puts ("not a valid ELF file"); + fputs ("not a valid ELF file\n", stdout); result = 1; goto out_close2; } @@ -129,7 +129,7 @@ main (void) if (cnt > 1) { - puts ("too many symbol"); + fputs ("too many symbols\n", stdout); result = 1; break; } diff --git a/tests/asm-tst8.c b/tests/asm-tst8.c index 7dbac10f..f367135b 100644 --- a/tests/asm-tst8.c +++ b/tests/asm-tst8.c @@ -45,7 +45,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } @@ -90,7 +90,7 @@ main (void) } if (elf_kind (elf) != ELF_K_ELF) { - puts ("not a valid ELF file"); + fputs ("not a valid ELF file\n", stdout); result = 1; goto out_close2; } @@ -130,7 +130,7 @@ main (void) if (cnt > 1) { - puts ("too many symbol"); + fputs ("too many symbols\n", stdout); result = 1; break; } diff --git a/tests/asm-tst9.c b/tests/asm-tst9.c index 6bec3f6e..4bba6d11 100644 --- a/tests/asm-tst9.c +++ b/tests/asm-tst9.c @@ -97,7 +97,7 @@ main (void) Ebl *ebl = ebl_openbackend_machine (EM_386); if (ebl == NULL) { - puts ("cannot open backend library"); + fputs ("cannot open backend library\n", stdout); return 1; } @@ -182,7 +182,7 @@ main (void) } if (elf_kind (elf) != ELF_K_ELF) { - puts ("not a valid ELF file"); + fputs ("not a valid ELF file\n", stdout); result = 1; goto out_close2; } @@ -197,7 +197,7 @@ main (void) if (memcmp (ehdr, &expected_ehdr, sizeof (GElf_Ehdr)) != 0) { - puts ("ELF header does not match"); + fputs ("ELF header does not match\n", stdout); result = 1; goto out_close2; } diff --git a/tests/buildid.c b/tests/buildid.c index 2390eff7..bbc51b96 100644 --- a/tests/buildid.c +++ b/tests/buildid.c @@ -69,8 +69,8 @@ main (int argc, char *argv[]) const unsigned char *p = build_id; const unsigned char *end = p + len; while (p < end) - printf("%02x", (unsigned)*p++); - putchar('\n'); + printf ("%02x", (unsigned)*p++); + fputc ('\n', stdout); } elf_end (elf); diff --git a/tests/debugaltlink.c b/tests/debugaltlink.c index e7dc8623..763b897a 100644 --- a/tests/debugaltlink.c +++ b/tests/debugaltlink.c @@ -71,8 +71,8 @@ main (int argc, char *argv[]) const unsigned char *p = build_id; const unsigned char *end = p + ret; while (p < end) - printf("%02x", (unsigned)*p++); - putchar('\n'); + printf ("%02x", (unsigned)*p++); + fputc ('\n', stdout); } dwarf_end (dwarf); diff --git a/tests/dwarf-getmacros.c b/tests/dwarf-getmacros.c index 8381d42c..57f36041 100644 --- a/tests/dwarf-getmacros.c +++ b/tests/dwarf-getmacros.c @@ -116,7 +116,7 @@ include (Dwarf *dbg, Dwarf_Off macoff, ptrdiff_t token) while ((token = dwarf_getmacros_off (dbg, macoff, mac, dbg, token)) != 0) if (token == -1) { - puts (dwarf_errmsg (dwarf_errno ())); + printf ("%s\n", dwarf_errmsg (dwarf_errno ())); break; } } @@ -128,7 +128,7 @@ getmacros (Dwarf *dbg, Dwarf_Die *die, bool new_style) (off = dwarf_getmacros (die, mac, dbg, off)); ) if (off == -1) { - puts (dwarf_errmsg (-1)); + printf ("%s\n", dwarf_errmsg (-1)); break; } } @@ -167,7 +167,7 @@ main (int argc, char *argv[]) Dwarf_Die cudie_mem, *cudie = dwarf_offdie (dbg, cuoff, &cudie_mem); if (cudie == NULL) { - puts (dwarf_errmsg (-1)); + printf ("%s\n", dwarf_errmsg (-1)); return 1; } getmacros (dbg, cudie, new_style); diff --git a/tests/dwarf-getstring.c b/tests/dwarf-getstring.c index ffa3e375..d2689807 100644 --- a/tests/dwarf-getstring.c +++ b/tests/dwarf-getstring.c @@ -64,7 +64,7 @@ main (int argc, char *argv[]) for (int i = 0; i < 100; ++i) { str = dwarf_getstring (dbg, offset, &len); - puts (str); + printf ("%s\n", str); /* Advance. */ offset += len + 1; diff --git a/tests/dwarf-ranges.c b/tests/dwarf-ranges.c index 4bcf96ce..a2406461 100644 --- a/tests/dwarf-ranges.c +++ b/tests/dwarf-ranges.c @@ -44,7 +44,7 @@ main (int argc, char *argv[]) (off = dwarf_ranges (cudie, off, &base, &start, &end)); ) if (off == -1) { - puts (dwarf_errmsg (dwarf_errno ())); + printf ("%s\n", dwarf_errmsg (dwarf_errno ())); break; } else diff --git a/tests/dwarfcfi.c b/tests/dwarfcfi.c index 29849e71..d59e7e1f 100644 --- a/tests/dwarfcfi.c +++ b/tests/dwarfcfi.c @@ -72,7 +72,7 @@ print_detail (int result, const Dwarf_Op *ops, size_t nops) printf ("(%" PRId64 ",%" PRId64 ")", ops[i].number, ops[i].number2); } - puts (""); + fputc ('\n', stdout); } } diff --git a/tests/dwflmodtest.c b/tests/dwflmodtest.c index bec8a07c..29a6d70b 100644 --- a/tests/dwflmodtest.c +++ b/tests/dwflmodtest.c @@ -97,7 +97,7 @@ print_instance (Dwarf_Die *instance, void *arg) if (entry != (Dwarf_Addr) -1) printf (" => %#" PRIx64 "\n", entry); else - puts (""); + fputc ('\n', stdout); return DWARF_CB_OK; } @@ -123,7 +123,7 @@ print_func (Dwarf_Die *func, void *arg) if (dwarf_func_inline (func)) { - puts (" inline function"); + fputs (" inline function\n", stdout); if (show_inlines) print_inline (func, arg); } @@ -148,7 +148,7 @@ print_func (Dwarf_Die *func, void *arg) printf (" %#" PRIx64 "..%#" PRIx64 " => %#" PRIx64 "\n", lo, hi, entry); else - puts (""); + fputc ('\n', stdout); } return DWARF_CB_OK; diff --git a/tests/funcretval.c b/tests/funcretval.c index 41198ab7..8e609898 100644 --- a/tests/funcretval.c +++ b/tests/funcretval.c @@ -76,16 +76,16 @@ handle_function (Dwarf_Die *funcdie, void *arg) attr = dwarf_attr_integrate (funcdie, DW_AT_type, &attr_mem); if (dwarf_formref_die (attr, typedie) != NULL && dwarf_tag (typedie) == DW_TAG_unspecified_type) - puts ("returns unspecified type"); + fputs ("returns unspecified type\n", stdout); else - puts ("returns no value"); + fputs ("returns no value\n", stdout); } else { printf ("return value location:"); for (int i = 0; i < nlocops; ++i) printf (" {%#x, %#" PRIx64 "}", locops[i].atom, locops[i].number); - puts (""); + fputc ('\n', stdout); } return 0; diff --git a/tests/funcscopes.c b/tests/funcscopes.c index 689d376a..dd5eedb3 100644 --- a/tests/funcscopes.c +++ b/tests/funcscopes.c @@ -158,7 +158,7 @@ handle_function (Dwarf_Die *funcdie, void *arg) if (highpc != lowpc) paddr (" .. ", highpc - 1, hiline == loline ? NULL : hiline); } - puts (""); + fputc ('\n', stdout); print_vars (indent + INDENT, die); } diff --git a/tests/get-aranges.c b/tests/get-aranges.c index 7f85cdad..b8e9bdde 100644 --- a/tests/get-aranges.c +++ b/tests/get-aranges.c @@ -71,7 +71,7 @@ main (int argc, char *argv[]) if (dwarf_getarangeinfo (found, NULL, NULL, &cu_offset) != 0) { - puts ("failed to get CU die offset"); + fputs ("failed to get CU die offset\n", stdout); result = 1; } else @@ -82,7 +82,7 @@ main (int argc, char *argv[]) if (dwarf_offdie (dbg, cu_offset, &cu_die) == NULL || (cuname = dwarf_diename (&cu_die)) == NULL) { - puts ("failed to get CU die"); + fputs ("failed to get CU die\n", stdout); result = 1; } else @@ -125,7 +125,7 @@ main (int argc, char *argv[]) if (dwarf_offdie (dbg, cu_offset, &cu_die) == NULL || (cuname = dwarf_diename (&cu_die)) == NULL) { - puts ("failed to get CU die"); + fputs ("failed to get CU die\n", stdout); result = 1; } else diff --git a/tests/get-files-define-file.c b/tests/get-files-define-file.c index 583f9852..367af52c 100644 --- a/tests/get-files-define-file.c +++ b/tests/get-files-define-file.c @@ -31,7 +31,7 @@ print_dirs_and_files (Dwarf_Files *files, const char *const *dirs, size_t nfiles, size_t ndirs) { if (dirs[0] == NULL) - puts (" dirs[0] = (null)"); + fputs (" dirs[0] = (null)\n", stdout); else printf (" dirs[0] = \"%s\"\n", dirs[0]); for (size_t i = 1; i < ndirs; ++i) diff --git a/tests/get-files.c b/tests/get-files.c index fa65aa93..80fa4b6f 100644 --- a/tests/get-files.c +++ b/tests/get-files.c @@ -94,7 +94,7 @@ main (int argc, char *argv[]) } if (dirs[0] == NULL) - puts (" dirs[0] = (null)"); + fputs (" dirs[0] = (null)\n", stdout); else printf (" dirs[0] = \"%s\"\n", dirs[0]); for (size_t i = 1; i < ndirs; ++i) diff --git a/tests/get-pubnames.c b/tests/get-pubnames.c index 4777f49d..cc5433e4 100644 --- a/tests/get-pubnames.c +++ b/tests/get-pubnames.c @@ -42,7 +42,7 @@ callback (Dwarf *dbg, Dwarf_Global *gl, void *arg __attribute__ ((unused))) if (dwarf_offdie (dbg, gl->cu_offset, &cu_die) == NULL || (cuname = dwarf_diename (&cu_die)) == NULL) { - puts ("failed to get CU die"); + fputs ("failed to get CU die\n", stdout); result = DWARF_CB_ABORT; } else @@ -53,7 +53,7 @@ callback (Dwarf *dbg, Dwarf_Global *gl, void *arg __attribute__ ((unused))) if (dwarf_offdie (dbg, gl->die_offset, &die) == NULL || (diename = dwarf_diename (&die)) == NULL) { - puts ("failed to get object die"); + fputs ("failed to get object die\n", stdout); result = DWARF_CB_ABORT; } else diff --git a/tests/line2addr.c b/tests/line2addr.c index 663746fd..c7a11759 100644 --- a/tests/line2addr.c +++ b/tests/line2addr.c @@ -97,9 +97,9 @@ handle_module (Dwfl_Module *mod __attribute__ ((unused)), printf (":%d", col); if (modname[0] != '\0' || strcmp (file, a->file) || line != a->line || col != 0) - puts (")"); + fputs (")\n", stdout); else - puts (""); + fputc ('\n', stdout); } } free (lines); diff --git a/tests/next-files.c b/tests/next-files.c index 9de5c8b0..490d100a 100644 --- a/tests/next-files.c +++ b/tests/next-files.c @@ -68,7 +68,7 @@ main (int argc, char *argv[]) } if (dirs[0] == NULL) - puts (" dirs[0] = (null)"); + fputs (" dirs[0] = (null)\n", stdout); else printf (" dirs[0] = \"%s\"\n", dirs[0]); for (size_t i = 1; i < ndirs; ++i) diff --git a/tests/saridx.c b/tests/saridx.c index e7f0c566..dc28e3ec 100644 --- a/tests/saridx.c +++ b/tests/saridx.c @@ -116,7 +116,7 @@ main (int argc, char *argv[]) /* Set the ELF version we are using here. */ if (elf_version (EV_CURRENT) == EV_NONE) { - puts ("ELF library too old"); + fputs ("ELF library too old\n", stdout); exit (1); } diff --git a/tests/scnnames.c b/tests/scnnames.c index 7f268258..ee34b786 100644 --- a/tests/scnnames.c +++ b/tests/scnnames.c @@ -35,7 +35,7 @@ main (int argc, char *argv[]) if (argc < 2) { - puts ("missing parameter"); + fputs ("missing parameter\n", stdout); exit (1); } diff --git a/tests/sectiondump.c b/tests/sectiondump.c index 661e6440..d89aadc6 100644 --- a/tests/sectiondump.c +++ b/tests/sectiondump.c @@ -130,7 +130,7 @@ handle_section (Elf *elf, Elf_Scn *scn) } /* Separate form the next section. */ - puts (""); + fputc ('\n', stdout); /* All done correctly. */ return 0; @@ -154,7 +154,7 @@ print_bytes (Elf_Data *data) for (inner = 0; inner < 16 && cnt + inner < size; ++inner) printf (" %02hhx", buf[cnt + inner]); - puts (""); + fputc ('\n', stdout); } } diff --git a/tests/show-die-info.c b/tests/show-die-info.c index bda459a5..7f8fa85e 100644 --- a/tests/show-die-info.c +++ b/tests/show-die-info.c @@ -99,7 +99,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) for (cnt = 0; cnt < 0xffff; ++cnt) if (dwarf_hasattr (die, cnt)) printf (" %s", dwarf_attr_string (cnt) ?: ""); - puts (""); + fputc ('\n', stdout); if (dwarf_hasattr (die, DW_AT_low_pc) && dwarf_lowpc (die, &addr) == 0) { @@ -111,13 +111,13 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_low_pc, &attr) == NULL || dwarf_formaddr (&attr, &addr2) != 0 || addr != addr2) - puts ("************* DW_AT_low_pc verify failed ************"); + fputs ("************* DW_AT_low_pc verify failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_addr)) - puts ("************* DW_AT_low_pc form failed ************"); + fputs ("************* DW_AT_low_pc form failed ************\n", stdout); else if (dwarf_whatform (&attr) != DW_FORM_addr) - puts ("************* DW_AT_low_pc form (2) failed ************"); + fputs ("************* DW_AT_low_pc form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_low_pc) - puts ("************* DW_AT_low_pc attr failed ************"); + fputs ("************* DW_AT_low_pc attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_high_pc) && dwarf_highpc (die, &addr) == 0) { @@ -128,13 +128,13 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_high_pc, &attr) == NULL || dwarf_formaddr (&attr, &addr2) != 0 || addr != addr2) - puts ("************* DW_AT_high_pc verify failed ************"); + fputs ("************* DW_AT_high_pc verify failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_addr)) - puts ("************* DW_AT_high_pc form failed ************"); + fputs ("************* DW_AT_high_pc form failed ************\n", stdout); else if (dwarf_whatform (&attr) != DW_FORM_addr) - puts ("************* DW_AT_high_pc form (2) failed ************"); + fputs ("************* DW_AT_high_pc form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_high_pc) - puts ("************* DW_AT_high_pc attr failed ************"); + fputs ("************* DW_AT_high_pc attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_byte_size) && (i = dwarf_bytesize (die)) != -1) @@ -146,14 +146,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_byte_size, &attr) == NULL || dwarf_formudata (&attr, &u2) != 0 || i != (int) u2) - puts ("************* DW_AT_byte_size verify failed ************"); + fputs ("************* DW_AT_byte_size verify failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_data1) && ! dwarf_hasform (&attr, DW_FORM_data2) && ! dwarf_hasform (&attr, DW_FORM_data4) && ! dwarf_hasform (&attr, DW_FORM_data8) && ! dwarf_hasform (&attr, DW_FORM_sdata) && ! dwarf_hasform (&attr, DW_FORM_udata)) - puts ("************* DW_AT_byte_size form failed ************"); + fputs ("************* DW_AT_byte_size form failed ************\n", stdout); else if ((u = dwarf_whatform (&attr)) == 0 || (u != DW_FORM_data1 && u != DW_FORM_data2 @@ -161,9 +161,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) && u != DW_FORM_data8 && u != DW_FORM_sdata && u != DW_FORM_udata)) - puts ("************* DW_AT_byte_size form (2) failed ************"); + fputs ("************* DW_AT_byte_size form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_byte_size) - puts ("************* DW_AT_byte_size attr failed ************"); + fputs ("************* DW_AT_byte_size attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_bit_size) && (i = dwarf_bitsize (die)) != -1) { @@ -174,14 +174,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_bit_size, &attr) == NULL || dwarf_formudata (&attr, &u2) != 0 || i != (int) u2) - puts ("************* DW_AT_bit_size test failed ************"); + fputs ("************* DW_AT_bit_size test failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_data1) && ! dwarf_hasform (&attr, DW_FORM_data2) && ! dwarf_hasform (&attr, DW_FORM_data4) && ! dwarf_hasform (&attr, DW_FORM_data8) && ! dwarf_hasform (&attr, DW_FORM_sdata) && ! dwarf_hasform (&attr, DW_FORM_udata)) - puts ("************* DW_AT_bit_size form failed ************"); + fputs ("************* DW_AT_bit_size form failed ************\n", stdout); else if ((u = dwarf_whatform (&attr)) == 0 || (u != DW_FORM_data1 && u != DW_FORM_data2 @@ -189,9 +189,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) && u != DW_FORM_data8 && u != DW_FORM_sdata && u != DW_FORM_udata)) - puts ("************* DW_AT_bit_size form (2) failed ************"); + fputs ("************* DW_AT_bit_size form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_bit_size) - puts ("************* DW_AT_bit_size attr failed ************"); + fputs ("************* DW_AT_bit_size attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_bit_offset) && (i = dwarf_bitoffset (die)) != -1) @@ -203,14 +203,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_bit_offset, &attr) == NULL || dwarf_formudata (&attr, &u2) != 0 || i != (int) u2) - puts ("************* DW_AT_bit_offset test failed ************"); + fputs ("************* DW_AT_bit_offset test failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_data1) && ! dwarf_hasform (&attr, DW_FORM_data2) && ! dwarf_hasform (&attr, DW_FORM_data4) && ! dwarf_hasform (&attr, DW_FORM_data8) && ! dwarf_hasform (&attr, DW_FORM_sdata) && ! dwarf_hasform (&attr, DW_FORM_udata)) - puts ("************* DW_AT_bit_offset form failed ************"); + fputs ("************* DW_AT_bit_offset form failed ************\n", stdout); else if ((u = dwarf_whatform (&attr)) == 0 || (u != DW_FORM_data1 && u != DW_FORM_data2 @@ -218,9 +218,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) && u != DW_FORM_data8 && u != DW_FORM_sdata && u != DW_FORM_udata)) - puts ("************* DW_AT_bit_offset form (2) failed ************"); + fputs ("************* DW_AT_bit_offset form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_bit_offset) - puts ("************* DW_AT_bit_offset attr failed ************"); + fputs ("************* DW_AT_bit_offset attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_language) && (i = dwarf_srclang (die)) != -1) @@ -232,14 +232,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_language, &attr) == NULL || dwarf_formudata (&attr, &u2) != 0 || i != (int) u2) - puts ("************* DW_AT_language test failed ************"); + fputs ("************* DW_AT_language test failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_data1) && ! dwarf_hasform (&attr, DW_FORM_data2) && ! dwarf_hasform (&attr, DW_FORM_data4) && ! dwarf_hasform (&attr, DW_FORM_data8) && ! dwarf_hasform (&attr, DW_FORM_sdata) && ! dwarf_hasform (&attr, DW_FORM_udata)) - puts ("************* DW_AT_language form failed ************"); + fputs ("************* DW_AT_language form failed ************\n", stdout); else if ((u = dwarf_whatform (&attr)) == 0 || (u != DW_FORM_data1 && u != DW_FORM_data2 @@ -247,9 +247,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) && u != DW_FORM_data8 && u != DW_FORM_sdata && u != DW_FORM_udata)) - puts ("************* DW_AT_language form (2) failed ************"); + fputs ("************* DW_AT_language form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_language) - puts ("************* DW_AT_language attr failed ************"); + fputs ("************* DW_AT_language attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_ordering) @@ -262,14 +262,14 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) if (dwarf_attr (die, DW_AT_ordering, &attr) == NULL || dwarf_formudata (&attr, &u2) != 0 || i != (int) u2) - puts ("************* DW_AT_ordering test failed ************"); + fputs ("************* DW_AT_ordering test failed ************\n", stdout); else if (! dwarf_hasform (&attr, DW_FORM_data1) && ! dwarf_hasform (&attr, DW_FORM_data2) && ! dwarf_hasform (&attr, DW_FORM_data4) && ! dwarf_hasform (&attr, DW_FORM_data8) && ! dwarf_hasform (&attr, DW_FORM_sdata) && ! dwarf_hasform (&attr, DW_FORM_udata)) - puts ("************* DW_AT_ordering failed ************"); + fputs ("************* DW_AT_ordering failed ************\n", stdout); else if ((u = dwarf_whatform (&attr)) == 0 || (u != DW_FORM_data1 && u != DW_FORM_data2 @@ -277,9 +277,9 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) && u != DW_FORM_data8 && u != DW_FORM_sdata && u != DW_FORM_udata)) - puts ("************* DW_AT_ordering form (2) failed ************"); + fputs ("************* DW_AT_ordering form (2) failed ************\n", stdout); else if (dwarf_whatattr (&attr) != DW_AT_ordering) - puts ("************* DW_AT_ordering attr failed ************"); + fputs ("************* DW_AT_ordering attr failed ************\n", stdout); } if (dwarf_hasattr (die, DW_AT_comp_dir)) @@ -287,7 +287,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) Dwarf_Attribute attr; if (dwarf_attr (die, DW_AT_comp_dir, &attr) == NULL || (name = dwarf_formstring (&attr)) == NULL) - puts ("************* DW_AT_comp_dir attr failed ************"); + fputs ("************* DW_AT_comp_dir attr failed ************\n", stdout); else printf ("%*s directory : %s\n", n * 5, "", name); } @@ -297,7 +297,7 @@ handle (Dwarf *dbg, Dwarf_Die *die, int n) Dwarf_Attribute attr; if (dwarf_attr (die, DW_AT_producer, &attr) == NULL || (name = dwarf_formstring (&attr)) == NULL) - puts ("************* DW_AT_comp_dir attr failed ************"); + fputs ("************* DW_AT_comp_dir attr failed ************\n", stdout); else printf ("%*s producer : %s\n", n * 5, "", name); } diff --git a/tests/showptable.c b/tests/showptable.c index 3d0552fe..83208041 100644 --- a/tests/showptable.c +++ b/tests/showptable.c @@ -34,7 +34,7 @@ main (int argc, char *argv[]) if (argc < 2) { - puts ("missing parameter"); + fputs ("missing parameter\n", stdout); exit (1); } diff --git a/tests/test-nlist.c b/tests/test-nlist.c index 679c911b..8cb65791 100644 --- a/tests/test-nlist.c +++ b/tests/test-nlist.c @@ -49,7 +49,7 @@ main (int argc, char *argv[] __attribute__ ((unused))) if (nlist (".libs/test-nlist", nl) != 0 && nlist ("./test-nlist", nl) != 0) { - puts ("nlist failed"); + fputs ("nlist failed\n", stdout); exit (1); }