From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 1/6] Use default section indexes in fixup_symbol_section
Date: Wed, 18 Jan 2023 08:30:20 -0700 [thread overview]
Message-ID: <20230118153025.342512-2-tromey@adacore.com> (raw)
In-Reply-To: <20230118153025.342512-1-tromey@adacore.com>
If fixup_section does not find a matching section, it arbitrarily
chooses the first one. However, it seems better to make this default
depend on the type of the symbol -- i.e., default data symbols to
.data and text symbols to .text.
I've also made fixup_section static, as it only has one caller.
---
gdb/symtab.c | 16 ++++++++++++----
gdb/symtab.h | 3 ---
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index b3445133c8c..fe247ab70eb 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1704,9 +1704,10 @@ symtab_free_objfile_observer (struct objfile *objfile)
/* Debug symbols usually don't have section information. We need to dig that
out of the minimal symbols and stash that in the debug symbol. */
-void
+static void
fixup_section (struct general_symbol_info *ginfo,
- CORE_ADDR addr, struct objfile *objfile)
+ CORE_ADDR addr, struct objfile *objfile,
+ int default_section)
{
struct minimal_symbol *msym;
@@ -1757,7 +1758,7 @@ fixup_section (struct general_symbol_info *ginfo,
a search of the section table. */
struct obj_section *s;
- int fallback = -1;
+ int fallback = default_section;
ALL_OBJFILE_OSECTIONS (objfile, s)
{
@@ -1808,9 +1809,16 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
/* We should have an objfile by now. */
gdb_assert (objfile);
+ /* Note that if this ends up as -1, fixup_section will handle that
+ reasonably well. So, it's fine to use the objfile's section
+ index without doing the check that is done by the wrapper macros
+ like SECT_OFF_TEXT. */
+ int default_section = objfile->sect_index_text;
switch (sym->aclass ())
{
case LOC_STATIC:
+ default_section = objfile->sect_index_data;
+ /* FALLTHROUGH. */
case LOC_LABEL:
addr = sym->value_address ();
break;
@@ -1824,7 +1832,7 @@ fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
return sym;
}
- fixup_section (sym, addr, objfile);
+ fixup_section (sym, addr, objfile, default_section);
return sym;
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index ae3a81991df..ac3f6391dc3 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2607,9 +2607,6 @@ extern struct block_symbol
compiler (armcc). */
bool producer_is_realview (const char *producer);
-void fixup_section (struct general_symbol_info *ginfo,
- CORE_ADDR addr, struct objfile *objfile);
-
extern unsigned int symtab_create_debug;
/* Print a "symtab-create" debug statement. */
--
2.38.1
next prev parent reply other threads:[~2023-01-18 15:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-18 15:30 [PATCH 0/6] Change how symbol section indices are set Tom Tromey
2023-01-18 15:30 ` Tom Tromey [this message]
2023-01-18 17:19 ` [PATCH 1/6] Use default section indexes in fixup_symbol_section Simon Marchi
2023-01-18 19:13 ` Tom Tromey
2023-01-18 15:30 ` [PATCH 2/6] Set section indices when symbols are made Tom Tromey
2023-01-18 21:43 ` Simon Marchi
2023-01-18 22:00 ` Tom Tromey
2023-01-18 15:30 ` [PATCH 3/6] Pass section index to start_compunit_symtab Tom Tromey
2023-01-18 21:55 ` Simon Marchi
2023-01-18 22:02 ` Tom Tromey
2023-01-18 22:06 ` Simon Marchi
2023-01-19 13:36 ` Tom Tromey
2023-02-08 16:28 ` Tom Tromey
2023-01-18 15:30 ` [PATCH 4/6] Set section index when setting a symbol's block Tom Tromey
2023-01-18 15:30 ` [PATCH 5/6] Remove most calls to fixup_symbol_section Tom Tromey
2023-01-18 15:30 ` [PATCH 6/6] Merge fixup_section and fixup_symbol_section Tom Tromey
2023-02-08 16:28 ` [PATCH 0/6] Change how symbol section indices are set Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230118153025.342512-2-tromey@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).