From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from progateway7-pub.mail.pro1.eigbox.com (gproxy5-pub.mail.unifiedlayer.com [67.222.38.55]) by sourceware.org (Postfix) with ESMTPS id 2622F3858CDB for ; Sun, 16 Apr 2023 16:28:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2622F3858CDB Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw11.mail.unifiedlayer.com (unknown [10.0.90.126]) by progateway7.mail.pro1.eigbox.com (Postfix) with ESMTP id B570910047C0D for ; Sun, 16 Apr 2023 16:28:29 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id o5ErpEjOnb9i8o5ErpLlVI; Sun, 16 Apr 2023 16:28:29 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Wd7J12tX c=1 sm=1 tr=0 ts=643c222d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10:nop_charset_1 a=dKHAf1wccvYA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=KwVJX9qDfJcGm-fn9P4A:9 a=QEXdDO2ut3YA:10:nop_charset_2 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HXI2FWA7rhg2w7OLztUG/3XlNmFpOreTyw0DTi3ER4I=; b=G3Xx60C4b6cV6rMV9h4U0i239b EHiNfbGJ2b+nSQtPKjokZ07PnUdoIBBmdQboKCRGTIduJOAOA62EA60hnxh5KDPtrWMUyVviArTqd oYOf+WLXttiIpVXOJL5wqncaN; Received: from 71-211-191-82.hlrn.qwest.net ([71.211.191.82]:48248 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1po5Er-002aa3-Et for gdb-patches@sourceware.org; Sun, 16 Apr 2023 10:28:29 -0600 From: Tom Tromey Date: Sun, 16 Apr 2023 10:28:27 -0600 Subject: [PATCH 1/4] Rename objfile::sections MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230416-remove-all-macros-v1-1-f118956faafe@tromey.com> References: <20230416-remove-all-macros-v1-0-f118956faafe@tromey.com> In-Reply-To: <20230416-remove-all-macros-v1-0-f118956faafe@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.191.82 X-Source-L: No X-Exim-ID: 1po5Er-002aa3-Et X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-191-82.hlrn.qwest.net ([192.168.0.21]) [71.211.191.82]:48248 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3026.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_NONE,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 List-Id: I think objfile::sections makes sense as the name of the method to iterate over an objfile's sections, so this patch renames the existing field to objfile::sections_start in preparation for that. --- gdb/machoread.c | 2 +- gdb/maint.c | 6 +++--- gdb/objfiles.c | 12 ++++++------ gdb/objfiles.h | 4 ++-- gdb/solib-aix.c | 4 ++-- gdb/solib-dsbt.c | 2 +- gdb/solib-frv.c | 2 +- gdb/symfile.c | 2 +- gdb/symmisc.c | 2 +- gdb/symtab.c | 4 ++-- gdb/xcoffread.c | 3 ++- 11 files changed, 22 insertions(+), 21 deletions(-) diff --git a/gdb/machoread.c b/gdb/machoread.c index 9735de80d57..dc841c30af2 100644 --- a/gdb/machoread.c +++ b/gdb/machoread.c @@ -926,7 +926,7 @@ macho_symfile_offsets (struct objfile *objfile, ALL_OBJFILE_OSECTIONS (objfile, osect) { const char *bfd_sect_name = osect->the_bfd_section->name; - int sect_index = osect - objfile->sections;; + int sect_index = osect - objfile->sections_start; if (startswith (bfd_sect_name, "LC_SEGMENT.")) bfd_sect_name += 11; diff --git a/gdb/maint.c b/gdb/maint.c index a8afef0e16b..3cd2c5e899a 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -331,11 +331,11 @@ maint_obj_section_from_bfd_section (bfd *abfd, asection *asection, objfile *ofile) { - if (ofile->sections == nullptr) + if (ofile->sections_start == nullptr) return nullptr; obj_section *osect - = &ofile->sections[gdb_bfd_section_index (abfd, asection)]; + = &ofile->sections_start[gdb_bfd_section_index (abfd, asection)]; if (osect >= ofile->sections_end) return nullptr; @@ -375,7 +375,7 @@ maint_print_all_sections (const char *header, bfd *abfd, objfile *objfile, if (objfile != nullptr) { - gdb_assert (objfile->sections != nullptr); + gdb_assert (objfile->sections_start != nullptr); osect = maint_obj_section_from_bfd_section (abfd, sect, objfile); if (osect->the_bfd_section == nullptr) diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 9caebfefd59..e3fa691dd53 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -264,7 +264,7 @@ add_to_objfile_sections (struct bfd *abfd, struct bfd_section *asect, return; } - section = &objfile->sections[gdb_bfd_section_index (abfd, asect)]; + section = &objfile->sections_start[gdb_bfd_section_index (abfd, asect)]; section->objfile = objfile; section->the_bfd_section = asect; section->ovly_mapped = 0; @@ -280,10 +280,10 @@ build_objfile_section_table (struct objfile *objfile) { int count = gdb_bfd_count_sections (objfile->obfd.get ()); - objfile->sections = OBSTACK_CALLOC (&objfile->objfile_obstack, - count, - struct obj_section); - objfile->sections_end = (objfile->sections + count); + objfile->sections_start = OBSTACK_CALLOC (&objfile->objfile_obstack, + count, + struct obj_section); + objfile->sections_end = (objfile->sections_start + count); for (asection *sect : gdb_bfd_sections (objfile->obfd)) add_to_objfile_sections (objfile->obfd.get (), sect, objfile, 0); @@ -660,7 +660,7 @@ objfile_relocate1 (struct objfile *objfile, struct obj_section *s; ALL_OBJFILE_OSECTIONS (objfile, s) { - int idx = s - objfile->sections; + int idx = s - objfile->sections_start; exec_set_section_address (bfd_get_filename (objfile->obfd.get ()), idx, s->addr ()); diff --git a/gdb/objfiles.h b/gdb/objfiles.h index 342aa09ac6a..0e326287907 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -128,7 +128,7 @@ struct entry_info }; #define ALL_OBJFILE_OSECTIONS(objfile, osect) \ - for (osect = objfile->sections; osect < objfile->sections_end; osect++) \ + for (osect = objfile->sections_start; osect < objfile->sections_end; osect++) \ if (osect->the_bfd_section == NULL) \ { \ /* Nothing. */ \ @@ -722,7 +722,7 @@ struct objfile structure data is only valid for certain sections (e.g. non-empty, SEC_ALLOC). */ - struct obj_section *sections = nullptr; + struct obj_section *sections_start = nullptr; struct obj_section *sections_end = nullptr; /* GDB allows to have debug symbols in separate object files. This is diff --git a/gdb/solib-aix.c b/gdb/solib-aix.c index d7062b4ee17..d3119db25bb 100644 --- a/gdb/solib-aix.c +++ b/gdb/solib-aix.c @@ -400,7 +400,7 @@ solib_aix_get_section_offsets (struct objfile *objfile, if (objfile->sect_index_text != -1) { struct bfd_section *sect - = objfile->sections[objfile->sect_index_text].the_bfd_section; + = objfile->sections_start[objfile->sect_index_text].the_bfd_section; offsets[objfile->sect_index_text] = info->text_addr + sect->filepos - bfd_section_vma (sect); @@ -411,7 +411,7 @@ solib_aix_get_section_offsets (struct objfile *objfile, if (objfile->sect_index_data != -1) { struct bfd_section *sect - = objfile->sections[objfile->sect_index_data].the_bfd_section; + = objfile->sections_start[objfile->sect_index_data].the_bfd_section; offsets[objfile->sect_index_data] = info->data_addr - bfd_section_vma (sect); diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c index 866087ef3a5..8106c342b15 100644 --- a/gdb/solib-dsbt.c +++ b/gdb/solib-dsbt.c @@ -822,7 +822,7 @@ dsbt_relocate_main_executable (void) int osect_idx; int seg; - osect_idx = osect - objf->sections; + osect_idx = osect - objf->sections_start; /* Current address of section. */ addr = osect->addr (); diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c index 240b4da5d9d..7cce11d52da 100644 --- a/gdb/solib-frv.c +++ b/gdb/solib-frv.c @@ -757,7 +757,7 @@ frv_relocate_main_executable (void) int osect_idx; int seg; - osect_idx = osect - objf->sections; + osect_idx = osect - objf->sections_start; /* Current address of section. */ addr = osect->addr (); diff --git a/gdb/symfile.c b/gdb/symfile.c index 8ae2177b159..3e84cd0e058 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2571,7 +2571,7 @@ reread_symbols (int from_tty) /* NB: after this call to obstack_free, objfiles_changed will need to be called (see discussion below). */ obstack_free (&objfile->objfile_obstack, 0); - objfile->sections = NULL; + objfile->sections_start = NULL; objfile->section_offsets.clear (); objfile->sect_index_bss = -1; objfile->sect_index_data = -1; diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 3d7fd560956..fb8a3ebf602 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -212,7 +212,7 @@ dump_msymbols (struct objfile *objfile, struct ui_file *outfile) bfd_section_name (section->the_bfd_section)); else gdb_printf (outfile, " spurious section %ld", - (long) (section - objfile->sections)); + (long) (section - objfile->sections_start)); } if (msymbol->demangled_name () != NULL) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 9e9798676cb..6c70d6e5ef1 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1089,7 +1089,7 @@ struct obj_section * general_symbol_info::obj_section (const struct objfile *objfile) const { if (section_index () >= 0) - return &objfile->sections[section_index ()]; + return &objfile->sections_start[section_index ()]; return nullptr; } @@ -1767,7 +1767,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile) if ((bfd_section_flags (s->the_bfd_section) & SEC_ALLOC) == 0) continue; - int idx = s - objfile->sections; + int idx = s - objfile->sections_start; CORE_ADDR offset = objfile->section_offsets[idx]; if (fallback == -1) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index d71127b40f6..d6c91cf7709 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -2888,7 +2888,8 @@ xcoff_symfile_offsets (struct objfile *objfile, if (objfile->section_offsets.empty ()) return; /* Is that even possible? Better safe than sorry. */ - first_section_name = bfd_section_name (objfile->sections[0].the_bfd_section); + first_section_name + = bfd_section_name (objfile->sections_start[0].the_bfd_section); if (objfile->sect_index_text == 0 && strcmp (first_section_name, ".text") != 0) -- 2.39.2