adfca8
From acfdfce2687342a119d4fe7cae8f5d04550a9d4a Mon Sep 17 00:00:00 2001
adfca8
From: Alan Modra <amodra@gmail.com>
adfca8
Date: Sun, 8 Nov 2015 09:28:59 -0800
adfca8
Subject: [PATCH 02/11] ELF unexec: Correct section header index
adfca8
adfca8
First a small fix.  The code incorrectly uses "NEW_SECTION_H (n)" when
adfca8
it should have been using "NEW_SECTION_H (nn)" to find the name of the
adfca8
section currently being processed.  Of course, before the bss
adfca8
sections, n and nn have the same value, so this doesn't matter except
adfca8
in the case of .sbss.  For .sbss this probably meant .bss (most likely
adfca8
the next section) was copied from memory.  A later patch removes the
adfca8
bogus .sbss handling anyway.
adfca8
adfca8
* unexelf.c (unexec): Use correct index to look up names.
adfca8
---
adfca8
 src/unexelf.c | 16 ++++++++--------
adfca8
 1 file changed, 8 insertions(+), 8 deletions(-)
adfca8
adfca8
diff --git a/src/unexelf.c b/src/unexelf.c
adfca8
index 483da6e..1699f31 100644
adfca8
--- a/src/unexelf.c
adfca8
+++ b/src/unexelf.c
adfca8
@@ -1015,12 +1015,12 @@ temacs:
adfca8
       /* Write out the sections. .data and .data1 (and data2, called
adfca8
 	 ".data" in the strings table) get copied from the current process
adfca8
 	 instead of the old file.  */
adfca8
-      if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data")
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+      if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".sdata")
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".lit4")
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".lit8")
adfca8
 	  /* The conditional bit below was in Oliva's original code
adfca8
 	     (1999-08-25) and seems to have been dropped by mistake
adfca8
@@ -1043,14 +1043,14 @@ temacs:
adfca8
 	     loader, but I never got anywhere with an SGI support call
adfca8
 	     seeking clues.  -- fx 2002-11-29.  */
adfca8
 #ifdef IRIX6_5
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".got")
adfca8
 #endif
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".sdata1")
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".data1")
adfca8
-	  || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
adfca8
+	  || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
adfca8
 		      ".sbss"))
adfca8
 	src = (caddr_t) OLD_SECTION_H (n).sh_addr;
adfca8
       else
adfca8
-- 
adfca8
2.7.4
adfca8