Bug 577001 - DW_AT_high_pc with DW_FORM_udata form not handled
Summary: DW_AT_high_pc with DW_FORM_udata form not handled
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: 1.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Eugene Tarassov CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-02 04:15 EDT by Andreas Ragnerstam CLA
Modified: 2021-11-05 03:43 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Ragnerstam CLA 2021-11-02 04:15:57 EDT
With GCC 11.2 a user gets a binary with DWARF info like this (from objdump):

    DW_AT_stmt_list    DW_FORM_sec_offset
    DW_AT_low_pc       DW_FORM_addr
    DW_AT_high_pc      DW_FORM_udata
    DW_AT_name         DW_FORM_strp
    DW_AT_comp_dir     DW_FORM_strp
    DW_AT_producer     DW_FORM_strp
    DW_AT_language     DW_FORM_data2
    DW_AT value: 0     DW_FORM value: 0

But this does not work in TCF, an error, "FORM_DATA or FORM_SEC_OFFSET was expected", is reported.

I found that in dio_ReadAttribute for AT_high_pc, DW_FORM_udata is not handled:

    if (sSection->relocate &&
            (Attr == AT_stmt_list || Attr == AT_ranges ||
                (Attr == AT_high_pc && Form != FORM_ADDR
                 && Form != FORM_UDATA))) {
        U4_T Size = 0;
        switch (Form) {
        case FORM_DATA2     : Size = 2; break;
        case FORM_DATA4     : Size = 4; break;
        case FORM_DATA8     : Size = 8; break;
        case FORM_SEC_OFFSET: Size = sSectionRefSize; break;
        default: str_exception(ERR_INV_DWARF, "FORM_DATA or FORM_SEC_OFFSET was expected");

I assume this is a too strict limitation in the TCF agent, and that it should be supported.

Unfortunately I cannot attach the failing binary, but if necessary I could try to create a new one.
Comment 1 Eugene Tarassov CLA 2021-11-04 13:48:37 EDT
Yes, the code is unnecessary restrictive.
I reworked the code to make is more generic.
Fixed.
Thanks!
Comment 2 Andreas Ragnerstam CLA 2021-11-05 03:43:26 EDT
Thanks for the quick fix!