This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Use memcpy in minimal_symbol_reader::install


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0de2420c4b023e644f91a409803fedfb235bfc0b

commit 0de2420c4b023e644f91a409803fedfb235bfc0b
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Mar 2 12:31:04 2019 -0700

    Use memcpy in minimal_symbol_reader::install
    
    minimal_symbol_reader::install copies minsyms from the msym_bunch
    objects into the allocated memory.  It seemed better to me to do this
    via memcpy, as that is frequently optimized in libc.
    
    gdb/ChangeLog
    2019-03-15  Tom Tromey  <tom@tromey.com>
    
    	* minsyms.c (minimal_symbol_reader::install): Use memcpy.

Diff:
---
 gdb/ChangeLog | 4 ++++
 gdb/minsyms.c | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 581a4c6..8ac4515 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2019-03-15  Tom Tromey  <tom@tromey.com>
 
+	* minsyms.c (minimal_symbol_reader::install): Use memcpy.
+
+2019-03-15  Tom Tromey  <tom@tromey.com>
+
 	* objfiles.h (struct objfile_per_bfd_storage) <msymbols>: Now a
 	unique_xmalloc_ptr.
 	(objfile::msymbols_range::begin, objfile::msymbols_range::end):
diff --git a/gdb/minsyms.c b/gdb/minsyms.c
index 88ff259..93097b1 100644
--- a/gdb/minsyms.c
+++ b/gdb/minsyms.c
@@ -1337,7 +1337,6 @@ build_minimal_symbol_hash_tables (struct objfile *objfile)
 void
 minimal_symbol_reader::install ()
 {
-  int bindex;
   int mcount;
   struct msym_bunch *bunch;
   struct minimal_symbol *msymbols;
@@ -1384,8 +1383,9 @@ minimal_symbol_reader::install ()
 
       for (bunch = m_msym_bunch; bunch != NULL; bunch = bunch->next)
 	{
-	  for (bindex = 0; bindex < m_msym_bunch_index; bindex++, mcount++)
-	    msymbols[mcount] = bunch->contents[bindex];
+	  memcpy (&msymbols[mcount], &bunch->contents[0],
+		  m_msym_bunch_index * sizeof (struct minimal_symbol));
+	  mcount += m_msym_bunch_index;
 	  m_msym_bunch_index = BUNCH_SIZE;
 	}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]