diff options
author | kaiw <kaiw@FreeBSD.org> | 2014-01-19 13:42:49 +0000 |
---|---|---|
committer | kaiw <kaiw@FreeBSD.org> | 2014-01-19 13:42:49 +0000 |
commit | f87e56cfe029ecf7ccb27686adc00c8182494e76 (patch) | |
tree | 68eb5dd826cb2e2d42ff6b232b048021fbaa1a53 /contrib/elftoolchain | |
parent | da160d852b438adb9cbef1fbf431fa44eaecfbcd (diff) | |
download | FreeBSD-src-f87e56cfe029ecf7ccb27686adc00c8182494e76.zip FreeBSD-src-f87e56cfe029ecf7ccb27686adc00c8182494e76.tar.gz |
* 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.
Diffstat (limited to 'contrib/elftoolchain')
-rw-r--r-- | contrib/elftoolchain/libdwarf/dwarf_loclist.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/contrib/elftoolchain/libdwarf/dwarf_loclist.c b/contrib/elftoolchain/libdwarf/dwarf_loclist.c index cf6fa9d..4696bc5 100644 --- a/contrib/elftoolchain/libdwarf/dwarf_loclist.c +++ b/contrib/elftoolchain/libdwarf/dwarf_loclist.c @@ -56,8 +56,20 @@ dwarf_loclist_n(Dwarf_Attribute at, Dwarf_Locdesc ***llbuf, 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_Locdesc **llbuf, 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) { |