From d81a3eaff36b41ed67758a119a6864b50f60a60d Mon Sep 17 00:00:00 2001
From: Petr Tesarik <ptesarik@suse.cz>
Date: Thu, 28 Jun 2018 08:32:27 +0200
Subject: Make sure that sorting does not change section order

Symbol files may contain multiple sections with the same name.
Section addresses specified by 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-28  Petr Tesarik  <ptesarik@suse.cz>

	* symfile.c (add_symbol_file_command): Make sure that sections
---
 gdb/symfile.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'gdb/symfile.h')

diff --git a/gdb/symfile.h b/gdb/symfile.h
index d9185092eec..1b476690488 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -61,7 +61,9 @@ struct other_sections
   CORE_ADDR addr;
   std::string name;
 
-  /* SECTINDEX must be valid for associated BFD or set to -1.  */
+  /* SECTINDEX must be valid for associated BFD or set to -1.
+     See syms_from_objfile_1 for an exception to this rule.
+   */
   int sectindex;
 };
 
-- 
cgit v1.2.1