* [PATCH][gdb] Make maint info sections print relocated addresses
@ 2019-08-14 15:15 Tom de Vries
2019-08-15 20:08 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2019-08-14 15:15 UTC (permalink / raw)
To: gdb-patches
Hi,
When running gdb.base/compare-sections.exp with -fPIE/-pie, we get:
...
print /u *(unsigned char *) 0x00000238^M
Cannot access memory at address 0x238^M
(gdb) FAIL: gdb.base/compare-sections.exp: read-only: get value of read-only section
...
The problem is that that "maint info sections" prints an unrelocated address:
...
[0] 0x00000238->0x00000254 at 0x00000238: .interp ALLOC LOAD READONLY \
DATA HAS_CONTENTS
...
while the test expects a relocated address.
Given that the documentation states that the command displays "the section
information displayed by info files", and that info files shows relocated
addresses:
...
0x0000555555554238 - 0x0000555555554254 is .interp
...
fix this by showing relocated addresses for maint info sections as
well.
Build and tested on x86_64-linux.
OK for trunk?
Thanks,
- Tom
[gdb] Make maint info sections print relocated addresses
gdb/ChangeLog:
2019-08-14 Tom de Vries <tdevries@suse.de>
* maint.c (maintenance_info_sections): Also handle !ALLOBJ case using
print_objfile_section_info.
---
gdb/maint.c | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
diff --git a/gdb/maint.c b/gdb/maint.c
index f7485dc3ab..12262b14e5 100644
--- a/gdb/maint.c
+++ b/gdb/maint.c
@@ -329,33 +329,36 @@ maintenance_info_sections (const char *arg, int from_tty)
{
if (exec_bfd)
{
+ struct obj_section *osect;
+ bool allobj = false;
+
printf_filtered (_("Exec file:\n"));
printf_filtered (" `%s', ", bfd_get_filename (exec_bfd));
wrap_here (" ");
printf_filtered (_("file type %s.\n"), bfd_get_target (exec_bfd));
- if (arg && *arg && match_substring (arg, "ALLOBJ"))
- {
- struct obj_section *osect;
- /* Only this function cares about the 'ALLOBJ' argument;
- if 'ALLOBJ' is the only argument, discard it rather than
- passing it down to print_objfile_section_info (which
- wouldn't know how to handle it). */
- if (strcmp (arg, "ALLOBJ") == 0)
- arg = NULL;
+ /* Only this function cares about the 'ALLOBJ' argument;
+ if 'ALLOBJ' is the only argument, discard it rather than
+ passing it down to print_objfile_section_info (which
+ wouldn't know how to handle it). */
+ if (arg && strcmp (arg, "ALLOBJ") == 0)
+ {
+ arg = NULL;
+ allobj = true;
+ }
- for (objfile *ofile : current_program_space->objfiles ())
+ for (objfile *ofile : current_program_space->objfiles ())
+ {
+ if (allobj)
+ printf_filtered (_(" Object file: %s\n"),
+ bfd_get_filename (ofile->obfd));
+ ALL_OBJFILE_OSECTIONS (ofile, osect)
{
- printf_filtered (_(" Object file: %s\n"),
- bfd_get_filename (ofile->obfd));
- ALL_OBJFILE_OSECTIONS (ofile, osect)
- {
- print_objfile_section_info (ofile->obfd, osect, arg);
- }
+ if (!allobj && ofile->obfd != exec_bfd)
+ continue;
+ print_objfile_section_info (ofile->obfd, osect, arg);
}
}
- else
- bfd_map_over_sections (exec_bfd, print_bfd_section_info, (void *) arg);
}
if (core_bfd)
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH][gdb] Make maint info sections print relocated addresses
2019-08-14 15:15 [PATCH][gdb] Make maint info sections print relocated addresses Tom de Vries
@ 2019-08-15 20:08 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2019-08-15 20:08 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> gdb/ChangeLog:
Tom> 2019-08-14 Tom de Vries <tdevries@suse.de>
Tom> * maint.c (maintenance_info_sections): Also handle !ALLOBJ case using
Tom> print_objfile_section_info.
Thanks.
Tom> + if (arg && strcmp (arg, "ALLOBJ") == 0)
Tom> + {
Tom> + arg = NULL;
Tom> + allobj = true;
Tom> + }
It took me a minute to understand that this was equivalent to the old
code. It looked like the intent was to use match_substring, but then
other code defeated that. If this was more user-facing I'd say "ALLOBJ"
should be replaced with a real option; but since this is a maint command
I would not bother.
This patch is ok. Thanks.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-15 20:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14 15:15 [PATCH][gdb] Make maint info sections print relocated addresses Tom de Vries
2019-08-15 20:08 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox