aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorPetr Tesarik <ptesarik@suse.cz>2018-06-28 08:30:42 +0200
committerPetr Tesarik <ptesarik@suse.cz>2018-06-28 08:35:34 +0200
commited6dfe517ee323ed631aa8b9816289ea35219409 (patch)
tree8ebac09e44c3a548370a0c1d8a7b1f8d4e8cf299 /gdb/symfile.c
parentd4d429d589c4d6a4450146fbcac8e1aad445114d (diff)
downloadgdb-ed6dfe517ee323ed631aa8b9816289ea35219409.zip
gdb-ed6dfe517ee323ed631aa8b9816289ea35219409.tar.gz
gdb-ed6dfe517ee323ed631aa8b9816289ea35219409.tar.bz2
Make add-symbol-file's address argument optional
The (first) .text section must be always specified as the second non-option argument. The documentation states that GDB cannot figure out this address by itself. This is true if the object file was indeed relocated, but it is also confusing, because all other sections can be omitted and will use the address provided by BFD. gdb/ChangeLog: 2018-06-28 Petr Tesarik <ptesarik@suse.cz> * symfile.c (add_symbol_file_command, _initialize_symfile): Do not require the second argument. If omitted, load sections at the addresses specified in the file. gdb/doc/ChangeLog: 2018-06-28 Petr Tesarik <ptesarik@suse.cz> * gdb.texinfo (Files): The address argument for "add-symbol-file" is no longer mandatory. gdb/testsuite/ChangeLog: 2018-06-28 Petr Tesarik <ptesarik@suse.cz> * gdb.base/relocate.exp: Test add-symbol-file behavior when the address argument is omitted.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 461f60d..2a41fce 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2161,29 +2161,26 @@ add_symbol_file_command (const char *args, int from_tty)
validate_readnow_readnever (flags);
- /* This command takes at least two arguments. The first one is a
- filename, and the second is the address where this file has been
- loaded. Abort now if this address hasn't been provided by the
- user. */
- if (!seen_addr)
- error (_("The address where %s has been loaded is missing"),
- filename.get ());
-
/* Print the prompt for the query below. And save the arguments into
a sect_addr_info structure to be passed around to other
functions. We have to split this up into separate print
statements because hex_string returns a local static
string. */
- printf_unfiltered (_("add symbol table from file \"%s\" at\n"),
+ printf_unfiltered (_("add symbol table from file \"%s\""),
filename.get ());
section_addr_info section_addrs;
- for (sect_opt &sect : sect_opts)
+ std::vector<sect_opt>::const_iterator it = sect_opts.begin ();
+ if (!seen_addr)
+ ++it;
+ for (; it != sect_opts.end (); ++it)
{
CORE_ADDR addr;
- const char *val = sect.value;
- const char *sec = sect.name;
+ const char *val = it->value;
+ const char *sec = it->name;
+ if (section_addrs.empty ())
+ printf_unfiltered (_(" at\n"));
addr = parse_and_eval_address (val);
/* Here we store the section offsets in the order they were
@@ -2198,6 +2195,8 @@ add_symbol_file_command (const char *args, int from_tty)
At this point, we don't know what file type this is,
so we can't determine what section names are valid. */
}
+ if (section_addrs.empty ())
+ printf_unfiltered ("\n");
if (from_tty && (!query ("%s", "")))
error (_("Not confirmed."));
@@ -3793,8 +3792,8 @@ to execute.\n" READNOW_READNEVER_HELP), &cmdlist);
c = add_cmd ("add-symbol-file", class_files, add_symbol_file_command, _("\
Load symbols from FILE, assuming FILE has been dynamically loaded.\n\
-Usage: add-symbol-file FILE ADDR [-readnow | -readnever | \
--s SECT-NAME SECT-ADDR]...\n\
+Usage: add-symbol-file FILE [-readnow | -readnever] [ADDR] \
+[-s SECT-NAME SECT-ADDR]...\n\
ADDR is the starting address of the file's text.\n\
Each '-s' argument provides a section name and address, and\n\
should be specified if the data and bss segments are not contiguous\n\