From owner-svn-src-projects@FreeBSD.ORG Sun Jan 19 13:42:49 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BA9E53B9; Sun, 19 Jan 2014 13:42:49 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 8D86B1E14; Sun, 19 Jan 2014 13:42:49 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s0JDgnaZ026743; Sun, 19 Jan 2014 13:42:49 GMT (envelope-from kaiw@svn.freebsd.org) Received: (from kaiw@localhost) by svn.freebsd.org (8.14.7/8.14.7/Submit) id s0JDgnDn026742; Sun, 19 Jan 2014 13:42:49 GMT (envelope-from kaiw@svn.freebsd.org) Message-Id: <201401191342.s0JDgnDn026742@svn.freebsd.org> From: Kai Wang Date: Sun, 19 Jan 2014 13:42:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r260879 - projects/elftoolchain/contrib/elftoolchain/libdwarf X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Jan 2014 13:42:49 -0000 Author: kaiw Date: Sun Jan 19 13:42:49 2014 New Revision: 260879 URL: http://svnweb.freebsd.org/changeset/base/260879 Log: * Allow API dwarf_loclist_n() and dwarf_loclist() to be called with attributes that have form DW_FORM_sec_offset. * If the .debug_info section conforms to DWARF4, do not allow the value of attributes with form DW_FORM_data[48] to be used as section offset. Modified: projects/elftoolchain/contrib/elftoolchain/libdwarf/dwarf_loclist.c Modified: projects/elftoolchain/contrib/elftoolchain/libdwarf/dwarf_loclist.c ============================================================================== --- projects/elftoolchain/contrib/elftoolchain/libdwarf/dwarf_loclist.c Sun Jan 19 13:38:40 2014 (r260878) +++ projects/elftoolchain/contrib/elftoolchain/libdwarf/dwarf_loclist.c Sun Jan 19 13:42:49 2014 (r260879) @@ -56,8 +56,20 @@ dwarf_loclist_n(Dwarf_Attribute at, Dwar switch (at->at_form) { case DW_FORM_data4: case DW_FORM_data8: - ret = _dwarf_loclist_find(at->at_die->die_dbg, - at->at_die->die_cu, at->u[0].u64, &ll, error); + /* + * DW_FORM_data[48] can not be used as section offset + * since DWARF4. For DWARF[23], the application needs + * to determine if DW_FORM_data[48] is representing + * a constant or a section offset. + */ + if (at->at_die->die_cu->cu_version >= 4) { + DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY); + return (DW_DLV_NO_ENTRY); + } + /* FALLTHROUGH */ + case DW_FORM_sec_offset: + ret = _dwarf_loclist_find(dbg, at->at_die->die_cu, + at->u[0].u64, &ll, error); if (ret == DW_DLE_NO_ENTRY) { DWARF_SET_ERROR(dbg, error, ret); return (DW_DLV_NO_ENTRY); @@ -119,6 +131,19 @@ dwarf_loclist(Dwarf_Attribute at, Dwarf_ switch (at->at_form) { case DW_FORM_data4: case DW_FORM_data8: + /* + * DW_FORM_data[48] can not be used as section offset + * since DWARF4. For DWARF[23], the application needs + * to determine if DW_FORM_data[48] is representing + * a constant or a section offset. + */ + if (at->at_die->die_cu->cu_version >= 4) { + printf("called cu_version >= 4\n"); + DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY); + return (DW_DLV_NO_ENTRY); + } + /* FALLTHROUGH */ + case DW_FORM_sec_offset: ret = _dwarf_loclist_find(at->at_die->die_dbg, at->at_die->die_cu, at->u[0].u64, &ll, error); if (ret == DW_DLE_NO_ENTRY) {