From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) by sourceware.org (Postfix) with ESMTPS id 955983858D3C for ; Tue, 17 May 2022 11:38:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 955983858D3C Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05lp2104.outbound.protection.outlook.com [104.47.17.104]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-35-5XIS2VaQMVmPXPrmhP6m5w-1; Tue, 17 May 2022 13:38:40 +0200 X-MC-Unique: 5XIS2VaQMVmPXPrmhP6m5w-1 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bWBN8MMcL1lnKNZCbSXpuXJc6aheu8nZDBQtP33ZknfxmbLUGAROTa/7quqxTohIkXLjaQuTpJxOe5/1ELch+ed4cjf7o67mvcBSxBkYQGQEI+2/51OzQyAX9j701jINfWTajl3nHpnKkgpqYiaDw8wdCWC6HO1wJd+zZLg1pjhs/iEks4T1HLw/hMdX49GKFptVeT/LpmYEeVqzgvRCwFjLhALSTUBEaX+nZJtrXLQM0RLLLAmjcRuCbkcDEukYQ9vXyV5iPfvBfe70e3b5E/OXwvNqAhMf4wk0QYGPf+4tD8UU87BnlRIX7esKLklgI8p9d8jTdPWOFKP6vsv9LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o15KQALeLINJYekks2hZ6qbo8kPnIwlaFtOs9kF+SqI=; b=XEiuMnCMBS8WDd9QbMrO5v3AF+1h/YfRuPH2n2nen1qoyQeYNG+KSnNn2n0j+n2t16f7mO8ExzqrBRiWU89xCh6JyYJVp2Kn0kuNms+Is2vFcJ2J9IqD6RtZf7YCSMxxKDk1SJWM7OqQwKwr8dpAqw0qV6lz3bWQ1NGY8oy5E9QEQDsrBtSCOagwXGCShOC62KfoIU5m498nVvj39Apd8W8PTQ1YmzULf0okp9xOeDravBTIC4S07IFK2SjkXG3tgIg1v35mvlp3iM7IkZvRN6+nsDupBuGe5NtPyonbwtoTxxU6gF3YlSiCUQ9GD0TSs8xF3RA/SeD7eNctgX3bZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by VI1PR0401MB2494.eurprd04.prod.outlook.com (2603:10a6:800:57::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5250.18; Tue, 17 May 2022 11:38:38 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::91b8:8f7f:61ac:cc9b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::91b8:8f7f:61ac:cc9b%7]) with mapi id 15.20.5250.018; Tue, 17 May 2022 11:38:38 +0000 Message-ID: Date: Tue, 17 May 2022 13:38:45 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH] bfd: Add Support for DW_FORM_strx* and DW_FORM_addrx*. Content-Language: en-US To: "Potharla, Rupesh" Cc: "George, Jini Susan" , "Parasuraman, Hariharan" , "Natarajan, Kavitha" , "binutils@sourceware.org" References: <868fc919-c81c-3724-cec0-9d85983439f8@suse.com> From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AS9PR06CA0012.eurprd06.prod.outlook.com (2603:10a6:20b:462::34) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 301eb613-f4bd-4b49-2978-08da37f9c8e7 X-MS-TrafficTypeDiagnostic: VI1PR0401MB2494:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qYwVySv9HUaqVg2dg17FYwl/5cRjjyx12zPQyfq3Q0YvNLwW9OFe1CQTzQWyG9hZgIvCKAARXPGCDD57FtYRWWgY8LZyL4DFqUzNvNzmQ6JYldqzC7YAIr9SQXhdPb13Ya2tqyqtZYsI4nAf2SilC+WicREogpR4f9mdxR0EOPQ/Rc4naUDpG0GockB3MaJ0W+uue+KaD154w8MiITvznPa5J7s0mKZ4K27rOHV/1IuKI2fnTJIHkI+7wF4+InlOtE1gE48qtJVKRPnB1HqwVRWyi6tZsMiu94NhJ/TWH77BshAY1W9kEN4tirPETTI3DOiYpVYPJwvcFuAWdAgiAI9Xi6Iifryjkr159oAbOcVbiQ33fvkTGVrRl2wc1CdnI7ShwtiSIb1miGikRvNSlBsMe5nbCk/Y2DSDSrm/6pjCY3SlKMzngqXLWuXPnpQR+ziiPqUsQarjCI4ypwDhh1lO86e2qVZQedO4XNkdY+Fc4Hq6VjoqXsj+sEaidn2Vxrx/aSKV9TYTtJtuhKgMgy5lP9w/iKsCMlOyxnx5NWyXx9Futz6jXJYykFklJAy2+OlWzGq8LtkDC/Y7wN3PLQ6ztFLI/J/HGmU13e97Z0B7mddcxl6/7+9xgOVBXLzOH2g8vbjCNfviRaCDQGSROwEFEmE+LbGNjFootnt0MEgFXTf+uytnqmi0yQyWF4+LxicWADIxBynmG2EGo0JTXCBPnxok5kVGvo9GKPjPRUg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(186003)(83380400001)(38100700002)(2616005)(4326008)(5660300002)(31686004)(30864003)(8936002)(2906002)(6512007)(53546011)(66476007)(26005)(66946007)(86362001)(31696002)(6916009)(54906003)(66556008)(6666004)(8676002)(6506007)(36756003)(6486002)(498600001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Ly9IRzBZejZwcDFuMVJaY0lBMmlzRjVLTjN2djh4TENWbENCbHh0M1pURmQ2?= =?utf-8?B?U3RkaWhQQVVMdjNBVmZkcEVNdmxKZkUreFdVckRRZUlpQmkwWWN0WUJjUVlt?= =?utf-8?B?YTVVSW9ycy9QK1lqaTRoRDY3VmlRY0JCMFoybGJYcnp1dkJGOEV0L1VJbWJU?= =?utf-8?B?dVVkVm9tYXdaTks5ZWNrdEpTZEpCTW1yT2dCVHRweGNyZ0lLdzAxdk1uZ0RU?= =?utf-8?B?KzgxUlBJSmE1QmQxUFBRU3VxL2N1ZURqbGZXRVFpbjgweDhZOGlGeFN2VWlx?= =?utf-8?B?Y2dhZzZGZUVaWStkYVBnU1k0RUJzVzhMMWp1d3JkRElkdkVDWllDRVp1Q01p?= =?utf-8?B?aVBTd1I1M2p4c1ZrenBVcUpmaHpEeXE4MWNJVlFuNlhKOXE4bEhvRGE0Z25J?= =?utf-8?B?YXZ6amYzWENrV1dJMWdmcU5YSktaN01XVFRBUUlnQ25CZWdDend4UldLTGxq?= =?utf-8?B?MmxtTXhWWVhMTm4xcktaQ0NpMUlTN01QamxoNlAwVTVyMWtkZDhQSCttcUtz?= =?utf-8?B?Y2xYMS9jWEpTQ2laTzVxRndFL0FLeG1sNWhUZnhzWE9qK0I2akRLOHBodFNq?= =?utf-8?B?YlpFcHZlTUp2N2tvaTR5Qm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49-2978-08da37f9c8e7 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2022 11:38:38.5042 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mtMUVMWrr6jIC6d/c0zRerCBrgfVUESEAxm0qAJ6uySNhQ60bIaRo2gnuCHHlNGBvRzLnlns3w8VyVjNOYHsYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0401MB2494 X-Spam-Status: No, score=-3039.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2022 11:38:45 -0000 On 08.05.2022 18:28, Potharla, Rupesh wrote: > [Public] > > Jan, > > Apologies for the delayed reply did not get a chance to work on this due to personal reasons. Made the code changes suggested and removed code changes related to file index will send the patch separately for review. Can you review my code changes and send in your comments/suggestions? > > Regards, > Rupesh P Can you please submit a proper v2 patch? Thanks, Jan > From 812ce279d73cfba5dea464d91536edc512d193b3 Mon Sep 17 00:00:00 2001 > From: rupothar > Date: Wed, 30 Mar 2022 15:38:19 +0530 > Subject: [PATCH] bfd/dwarf2: Add Support for DW_FORM_strx* and DW_FORM_addrx*. > > Made code changes implementing strx* and addrx* forms to the BFD library. > --- > bfd/dwarf2.c | 275 ++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 264 insertions(+), 11 deletions(-) > > diff --git a/bfd/dwarf2.c b/bfd/dwarf2.c > index 404f35df62b..fe6c0b907c4 100644 > --- a/bfd/dwarf2.c > +++ b/bfd/dwarf2.c > @@ -118,6 +118,18 @@ struct dwarf2_debug_file > /* Length of the loaded .debug_str section. */ > bfd_size_type dwarf_str_size; > > + /* Pointer to the .debug_str_offsets section loaded into memory. */ > + bfd_byte *dwarf_str_offsets_buffer; > + > + /* Length of the loaded .debug_str_offsets section. */ > + bfd_size_type dwarf_str_offsets_size; > + > + /* Pointer to the .debug_addr section loaded into memory. */ > + bfd_byte *dwarf_addr_buffer; > + > + /* Length of the loaded .debug_addr section. */ > + bfd_size_type dwarf_addr_size; > + > /* Pointer to the .debug_line_str section loaded into memory. */ > bfd_byte *dwarf_line_str_buffer; > > @@ -296,6 +308,12 @@ struct comp_unit > > /* TRUE if symbols are cached in hash table for faster lookup by name. */ > bool cached; > + > + /* Base address of debug_addr section. */ > + unsigned long dwarf_addr_offset; > + > + /* Base address of string offset table. */ > + unsigned long dwarf_str_offset; > }; > > /* This data structure holds the information of an abbrev. */ > @@ -338,6 +356,8 @@ const struct dwarf_debug_section dwarf_debug_sections[] = > { ".debug_static_vars", ".zdebug_static_vars" }, > { ".debug_str", ".zdebug_str", }, > { ".debug_str", ".zdebug_str", }, > + { ".debug_str_offsets", ".zdebug_str_offsets", }, > + { ".debug_addr", ".zdebug_addr", }, > { ".debug_line_str", ".zdebug_line_str", }, > { ".debug_types", ".zdebug_types" }, > /* GNU DWARF 1 extensions */ > @@ -372,6 +392,8 @@ enum dwarf_debug_section_enum > debug_static_vars, > debug_str, > debug_str_alt, > + debug_str_offsets, > + debug_addr, > debug_line_str, > debug_types, > debug_sfnames, > @@ -1221,12 +1243,93 @@ is_int_form (const struct attribute *attr) > } > } > > +/* Returns true if the form is strx[1-4]. */ > + > +static inline bool > +is_strx_form(enum dwarf_form form) > +{ > + return (form == DW_FORM_strx > + || form == DW_FORM_strx1 > + || form == DW_FORM_strx2 > + || form == DW_FORM_strx3 > + || form == DW_FORM_strx4); > +} > + > +/* Return true if the form is addrx[1-4]. */ > + > +static inline bool > +is_addrx_form(enum dwarf_form form) > +{ > + return (form == DW_FORM_addrx > + || form == DW_FORM_addrx1 > + || form == DW_FORM_addrx2 > + || form == DW_FORM_addrx3 > + || form == DW_FORM_addrx4); > +} > + > +/* Returns the address in .debug_addr section using DW_AT_addr_base. > + Used to implement DW_FORM_addrx*. */ > +static bfd_vma > +read_indexed_address (bfd_uint64_t idx, > + struct comp_unit *unit) > +{ > + struct dwarf2_debug *stash = unit->stash; > + struct dwarf2_debug_file *file = unit->file; > + unsigned long addr_base = unit->dwarf_addr_offset; > + bfd_byte *info_ptr; > + > + if (stash == NULL) > + return 0; > + > + if (!read_section (unit->abfd, &stash->debug_sections[debug_addr], > + file->syms, 0, > + &file->dwarf_addr_buffer, &file->dwarf_addr_size)) > + return 0; > + > + info_ptr = (bfd_byte *)(file->dwarf_addr_buffer + addr_base > + + idx * unit->offset_size); > + > + if (unit->offset_size == 4) > + return bfd_get_32 (unit->abfd, info_ptr); > + else > + return bfd_get_64 (unit->abfd, info_ptr); > +} > + > +/* Returns the string using DW_AT_str_offsets_base. > + Used to implement DW_FORM_strx*. */ > static const char * > -read_indexed_string (bfd_uint64_t idx ATTRIBUTE_UNUSED, > - struct comp_unit * unit ATTRIBUTE_UNUSED) > +read_indexed_string (bfd_uint64_t idx, > + struct comp_unit * unit) > { > - /* FIXME: Add support for indexed strings. */ > - return ""; > + struct dwarf2_debug *stash = unit->stash; > + struct dwarf2_debug_file *file = unit->file; > + bfd_byte *info_ptr; > + unsigned long str_offset; > + > + if (stash == NULL) > + return NULL; > + > + if (!read_section (unit->abfd, &stash->debug_sections[debug_str], > + file->syms, 0, > + &file->dwarf_str_buffer, &file->dwarf_str_size)) > + return NULL; > + > + if (!read_section (unit->abfd, &stash->debug_sections[debug_str_offsets], > + file->syms, 0, > + &file->dwarf_str_offsets_buffer, > + &file->dwarf_str_offsets_size)) > + return NULL; > + > + info_ptr = (bfd_byte *)(file->dwarf_str_offsets_buffer > + + unit->dwarf_str_offset > + + idx * unit->offset_size); > + > + if (unit->offset_size == 4) > + str_offset = bfd_get_32 (unit->abfd, info_ptr); > + else > + str_offset = bfd_get_64 (unit->abfd, info_ptr); > + > + return (const char*) (file->dwarf_str_buffer + str_offset); > } > > /* Read and fill in the value of attribute ATTR as described by FORM. > @@ -1295,21 +1398,37 @@ read_attribute_value (struct attribute * attr, > case DW_FORM_ref1: > case DW_FORM_flag: > case DW_FORM_data1: > + attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); > + break; > case DW_FORM_addrx1: > attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); > + /* dwarf_addr_offset value 0 indicates the attribute DW_AT_addr_base > + is not yet read. */ > + if (unit->dwarf_addr_offset != 0) > + attr->u.val = read_indexed_address(attr->u.val, unit); > break; > case DW_FORM_data2: > - case DW_FORM_addrx2: > case DW_FORM_ref2: > attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); > break; > + case DW_FORM_addrx2: > + attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); > + if (unit->dwarf_addr_offset != 0) > + attr->u.val = read_indexed_address(attr->u.val, unit); > + break; > case DW_FORM_addrx3: > attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); > + if (unit->dwarf_addr_offset != 0) > + attr->u.val = read_indexed_address(attr->u.val, unit); > break; > case DW_FORM_ref4: > case DW_FORM_data4: > + attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); > + break; > case DW_FORM_addrx4: > attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); > + if (unit->dwarf_addr_offset != 0) > + attr->u.val = read_indexed_address(attr->u.val, unit); > break; > case DW_FORM_data8: > case DW_FORM_ref8: > @@ -1330,24 +1449,31 @@ read_attribute_value (struct attribute * attr, > break; > case DW_FORM_strx1: > attr->u.val = read_1_byte (abfd, &info_ptr, info_ptr_end); > - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > + /* dwarf_str_offset value 0 indicates the attribute DW_AT_str_offsets_base > + is not yet read. */ > + if (unit->dwarf_str_offset != 0) > + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > break; > case DW_FORM_strx2: > attr->u.val = read_2_bytes (abfd, &info_ptr, info_ptr_end); > - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > + if (unit->dwarf_str_offset != 0) > + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > break; > case DW_FORM_strx3: > attr->u.val = read_3_bytes (abfd, &info_ptr, info_ptr_end); > - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > + if (unit->dwarf_str_offset != 0) > + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > break; > case DW_FORM_strx4: > attr->u.val = read_4_bytes (abfd, &info_ptr, info_ptr_end); > - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > + if (unit->dwarf_str_offset != 0) > + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > break; > case DW_FORM_strx: > attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, > false, info_ptr_end); > - attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > + if (unit->dwarf_str_offset != 0) > + attr->u.str = (char *) read_indexed_string (attr->u.val, unit); > break; > case DW_FORM_exprloc: > case DW_FORM_block: > @@ -1369,9 +1495,14 @@ read_attribute_value (struct attribute * attr, > break; > case DW_FORM_ref_udata: > case DW_FORM_udata: > + attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, > + false, info_ptr_end); > + break; > case DW_FORM_addrx: > attr->u.val = _bfd_safe_read_leb128 (abfd, &info_ptr, > false, info_ptr_end); > + if (unit->dwarf_addr_offset != 0) > + attr->u.val = read_indexed_address(attr->u.val, unit); > break; > case DW_FORM_indirect: > form = _bfd_safe_read_leb128 (abfd, &info_ptr, > @@ -2117,6 +2248,11 @@ read_formatted_entries (struct comp_unit *unit, bfd_byte **bufp, > { > case DW_FORM_string: > case DW_FORM_line_strp: > + case DW_FORM_strx: > + case DW_FORM_strx1: > + case DW_FORM_strx2: > + case DW_FORM_strx3: > + case DW_FORM_strx4: > *stringp = attr.u.str; > break; > > @@ -3749,6 +3885,77 @@ scan_unit_for_symbols (struct comp_unit *unit) > return false; > } > > +/* read the attributes of the form strx and addrx. */ > +static void reread_attribute (struct comp_unit * unit, > + struct attribute attr, > + bfd_vma *low_pc, > + bfd_vma *high_pc, > + bool *high_pc_relative, > + bool compunit) > +{ > + > + if (is_strx_form(attr.form)) > + attr.u.str = (char*) read_indexed_string (attr.u.val, unit); > + if (is_addrx_form(attr.form)) > + attr.u.val = read_indexed_address (attr.u.val, unit); > + > + switch (attr.name) > + { > + case DW_AT_stmt_list: > + unit->stmtlist = 1; > + unit->line_offset = attr.u.val; > + break; > + > + case DW_AT_name: > + if (is_str_form (&attr)) > + unit->name = attr.u.str; > + break; > + > + case DW_AT_low_pc: > + *low_pc = attr.u.val; > + if (compunit) > + unit->base_address = *low_pc; > + break; > + > + case DW_AT_high_pc: > + *high_pc = attr.u.val; > + *high_pc_relative = attr.form != DW_FORM_addr; > + break; > + > + case DW_AT_ranges: > + if (!read_rangelist (unit, &unit->arange, attr.u.val)) > + return; > + break; > + > + case DW_AT_comp_dir: > + { > + char *comp_dir = attr.u.str; > + > + if (! is_str_form (&attr)) > + { > + _bfd_error_handler > + (_("DWARF error: DW_AT_comp_dir attribute encountered with a non-string form")); > + comp_dir = NULL; > + } > + > + if (comp_dir) > + { > + char *cp = strchr (comp_dir, ':'); > + > + if (cp && cp != comp_dir && cp[-1] == '.' && cp[1] == '/') > + comp_dir = cp + 1; > + } > + unit->comp_dir = comp_dir; > + break; > + } > + > + case DW_AT_language: > + unit->lang = attr.u.val; > + default: > + break; > + } > +} > + > /* Parse a DWARF2 compilation unit starting at INFO_PTR. UNIT_LENGTH > includes the compilation unit header that proceeds the DIE's, but > does not include the length field that precedes each compilation > @@ -3782,6 +3989,9 @@ parse_comp_unit (struct dwarf2_debug *stash, > bfd *abfd = file->bfd_ptr; > bool high_pc_relative = false; > enum dwarf_unit_type unit_type; > + struct attribute *str_addrp = NULL; > + unsigned int count = 0; > + bool compunit_flag = false; > > version = read_2_bytes (abfd, &info_ptr, end_ptr); > if (version < 2 || version > 5) > @@ -3886,12 +4096,34 @@ parse_comp_unit (struct dwarf2_debug *stash, > unit->file = file; > unit->info_ptr_unit = info_ptr_unit; > > + if (abbrev->tag == DW_TAG_compile_unit) > + compunit_flag = true; > + > for (i = 0; i < abbrev->num_attrs; ++i) > { > info_ptr = read_attribute (&attr, &abbrev->attrs[i], unit, info_ptr, end_ptr); > if (info_ptr == NULL) > return NULL; > > + /* Identify attributes of the form strx* and addrx* which come before > + DW_AT_str_offsets_base and DW_AT_addr_base respectively in the CU. > + Store the attributes in an array and process them later. */ > + if ((is_strx_form(attr.form) && > + unit->dwarf_str_offset == 0) || > + (is_addrx_form(attr.form) && > + unit->dwarf_addr_offset == 0)) > + { > + str_addrp = (struct attribute *) > + bfd_realloc(str_addrp, (count + 1) * sizeof(struct attribute)); > + if (str_addrp == NULL) > + return NULL; > + str_addrp[count].name = attr.name; > + str_addrp[count].form = (enum dwarf_form) attr.form; > + str_addrp[count].u.val = attr.u.val; > + count++; > + continue; > + } > + > /* Store the data if it is of an attribute we want to keep in a > partial symbol table. */ > switch (attr.name) > @@ -3916,7 +4148,7 @@ parse_comp_unit (struct dwarf2_debug *stash, > /* If the compilation unit DIE has a DW_AT_low_pc attribute, > this is the base address to use when reading location > lists or range lists. */ > - if (abbrev->tag == DW_TAG_compile_unit) > + if (compunit_flag) > unit->base_address = low_pc; > } > break; > @@ -3965,10 +4197,27 @@ parse_comp_unit (struct dwarf2_debug *stash, > unit->lang = attr.u.val; > break; > > + case DW_AT_addr_base: > + unit->dwarf_addr_offset = attr.u.val; > + break; > + > + case DW_AT_str_offsets_base: > + unit->dwarf_str_offset = attr.u.val; > + break; > + > default: > break; > } > } > + > + for (i = 0; i < count; ++i) > + { > + struct attribute attr1 = str_addrp[i]; > + reread_attribute(unit, attr1, &low_pc, &high_pc, > + &high_pc_relative, compunit_flag); > + > + } > + > if (high_pc_relative) > high_pc += low_pc; > if (high_pc != 0) > @@ -3978,6 +4227,10 @@ parse_comp_unit (struct dwarf2_debug *stash, > } > > unit->first_child_die_ptr = info_ptr; > + > + if (str_addrp != NULL) > + free(str_addrp); > + > return unit; > } >