[PATCH][gdb] Make maint info sections print relocated addresses
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:
 0x00000238->0x00000254 at 0x00000238: .interp ALLOC LOAD READONLY \
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
0x0000555555554238 - 0x0000555555554254 is .interp
fix this by showing relocated addresses for maint info sections as
Build and tested on x86_64-linux.
OK for trunk?
[gdb] Make maint info sections print relocated addresses
- /* 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;
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.