public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Petr Tesarik <ptesarik@suse.cz>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	John Baldwin <jhb@freebsd.org>,	Petr Tesarik <petr@tesarici.cz>,
	Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH 3/4] Make sure that sorting does not change section order
Date: Fri, 08 Jun 2018 12:40:00 -0000	[thread overview]
Message-ID: <20180608124000.10668-4-ptesarik@suse.cz> (raw)
In-Reply-To: <20180608124000.10668-1-ptesarik@suse.cz>

From: Petr Tesarik <petr@tesarici.cz>

Symbol files may contain multiple sections with the same name.
Section addresses specified add-symbol-file are assigned to the
corresponding BFD sections in addr_info_make_relative using sorted
indexes of both vectors.  Since the sort algorithm is not inherently
stable, the comparison function uses sectindex to maintain the
original order.  However, add_symbol_file_command uses zero for all
sections, so if the user specifies multiple sections with the same
name, they will be assigned randomly to symbol file sections with
the same name.

gdb/ChangeLog:
2018-06-08  Petr Tesarik  <ptesarik@suse.com>

	* symfile.c (add_symbol_file_command): Make sure that sections
	with the same name are sorted in the same order.
---
 gdb/ChangeLog | 2 ++
 gdb/symfile.c | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e6e763b506..91a5d7b4b9 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -5,6 +5,8 @@
 	offset to each section of the symbol file.
 	(add_symbol_file_command): Do not require the second argument.  If
 	omitted, load sections at the addresses specified in the file.
+	(add_symbol_file_command): Make sure that sections with the same
+	name are sorted in the same order.
 
 2018-06-07  Pedro Alves  <palves@redhat.com>
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d319bb0564..890e2478bf 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2185,7 +2185,7 @@ add_symbol_file_command (const char *args, int from_tty)
 
       /* Here we store the section offsets in the order they were
          entered on the command line.  */
-      section_addrs.emplace_back (addr, sec, 0);
+      section_addrs.emplace_back (addr, sec, section_addrs.size ());
       printf_unfiltered ("\t%s_addr = %s\n", sec,
 			 paddress (gdbarch, addr));
 
-- 
2.13.6

  parent reply	other threads:[~2018-06-08 12:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 12:40 [PATCH 0/4] Allow loading symbol files with an offset Petr Tesarik
2018-06-08 12:40 ` [PATCH 4/4] Add an optional offset option to the "add-symbol-file" command Petr Tesarik
2018-06-08 12:40 ` [PATCH 1/4] Add an optional offset option to the "symbol-file" command Petr Tesarik
2018-06-08 12:59   ` Tom Tromey
2018-06-08 13:09   ` Eli Zaretskii
2018-06-08 12:40 ` Petr Tesarik [this message]
2018-06-08 12:53 ` [PATCH 2/4] Make add-symbol-file's address argument optional Petr Tesarik
2018-06-08 13:11   ` Eli Zaretskii
2018-06-08 13:34 ` [PATCH 0/4] Allow loading symbol files with an offset Pedro Alves
2018-06-11  9:41   ` Petr Tesarik
2018-06-11 18:41     ` Petr Tesarik
2018-06-11 19:10       ` Eli Zaretskii

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=20180608124000.10668-4-ptesarik@suse.cz \
    --to=ptesarik@suse.cz \
    --cc=gdb-patches@sourceware.org \
    --cc=jeffm@suse.com \
    --cc=jhb@freebsd.org \
    --cc=petr@tesarici.cz \
    --cc=simon.marchi@polymtl.ca \
    /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).