From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130993 invoked by alias); 23 Nov 2018 20:08:23 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 130979 invoked by uid 89); 23 Nov 2018 20:08:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy= X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Nov 2018 20:08:20 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 8712230B00D4; Fri, 23 Nov 2018 21:08:17 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 371AF403F6EC; Fri, 23 Nov 2018 21:08:17 +0100 (CET) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] libdw: Enable building with -Og. Date: Fri, 23 Nov 2018 20:08:00 -0000 Message-Id: <1543003691-6344-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q4/txt/msg00174.txt.bz2 When building with -Og gcc is unable to see that __libdw_dieabbrev () will initialize what the second argument points to when no error occurs as called by dwarf_child and dwarf_getattrs. Causing an possibly uninitialized error. Just initialize readp/die_addr to NULL, which is the value we would return if an error occurs anyway. https://sourceware.org/bugzilla/show_bug.cgi?id=23914 Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 5 +++++ libdw/dwarf_child.c | 2 +- libdw/dwarf_getattrs.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 7caa223..44405d7 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2018-10-23 Mark Wielaard + + * dwarf_child.c (__libdw_find_attr): Initialize readp to NULL. + * dwarf_getattrs.c (dwarf_getattrs): Initialize die_addr to NULL. + 2018-10-20 Mark Wielaard * libdw.map (ELFUTILS_0.175): New section. Add dwelf_elf_begin. diff --git a/libdw/dwarf_child.c b/libdw/dwarf_child.c index 9446b88..2e39d83 100644 --- a/libdw/dwarf_child.c +++ b/libdw/dwarf_child.c @@ -43,7 +43,7 @@ internal_function __libdw_find_attr (Dwarf_Die *die, unsigned int search_name, unsigned int *codep, unsigned int *formp) { - const unsigned char *readp; + const unsigned char *readp = NULL; /* Find the abbreviation entry. */ Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &readp); diff --git a/libdw/dwarf_getattrs.c b/libdw/dwarf_getattrs.c index 50faf98..4ac16b1 100644 --- a/libdw/dwarf_getattrs.c +++ b/libdw/dwarf_getattrs.c @@ -44,7 +44,7 @@ dwarf_getattrs (Dwarf_Die *die, int (*callback) (Dwarf_Attribute *, void *), if (unlikely (offset == 1)) return 1; - const unsigned char *die_addr; + const unsigned char *die_addr = NULL; /* Find the abbreviation entry. */ Dwarf_Abbrev *abbrevp = __libdw_dieabbrev (die, &die_addr); -- 1.8.3.1