aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-08-23 21:35:23 +0000
committerRichard M. Stallman1994-08-23 21:35:23 +0000
commit8917361f1ffd35abaa79e557bb20ca1b28ab6043 (patch)
tree58ee77e76ce391ea8473efb03ca37132ad88ef1e /src
parentb16234d8488edb56683281319169c861ebd5667c (diff)
downloademacs-8917361f1ffd35abaa79e557bb20ca1b28ab6043.tar.gz
emacs-8917361f1ffd35abaa79e557bb20ca1b28ab6043.zip
(unexec): Don't alter the info field of SHT_SYMTAB and SHT_DYNSYM sections.
Diffstat (limited to 'src')
-rw-r--r--src/unexelf.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/unexelf.c b/src/unexelf.c
index a7f607e3de8..d1badcbda66 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -725,20 +725,23 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
725 725
726 /* If any section hdr refers to the section after the new .data 726 /* If any section hdr refers to the section after the new .data
727 section, make it refer to next one because we have inserted 727 section, make it refer to next one because we have inserted
728 a new section in between. */ 728 a new section in between. */
729 729
730 PATCH_INDEX (NEW_SECTION_H (nn).sh_link); 730 PATCH_INDEX (NEW_SECTION_H (nn).sh_link);
731 PATCH_INDEX (NEW_SECTION_H (nn).sh_info); 731 /* For symbol tables, info is a symbol table index,
732 732 so don't change it. */
733 /* Now, start to copy the content of sections. */ 733 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB
734 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM)
735 PATCH_INDEX (NEW_SECTION_H (nn).sh_info);
736
737 /* Now, start to copy the content of sections. */
734 if (NEW_SECTION_H (nn).sh_type == SHT_NULL 738 if (NEW_SECTION_H (nn).sh_type == SHT_NULL
735 || NEW_SECTION_H (nn).sh_type == SHT_NOBITS) 739 || NEW_SECTION_H (nn).sh_type == SHT_NOBITS)
736 continue; 740 continue;
737 741
738 /* Write out the sections. .data and .data1 (and data2, called 742 /* Write out the sections. .data and .data1 (and data2, called
739 * ".data" in the strings table) get copied from the current process 743 ".data" in the strings table) get copied from the current process
740 * instead of the old file. 744 instead of the old file. */
741 */
742 if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data") 745 if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data")
743 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), 746 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
744 ".data1")) 747 ".data1"))
@@ -749,7 +752,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
749 memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src, 752 memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src,
750 NEW_SECTION_H (nn).sh_size); 753 NEW_SECTION_H (nn).sh_size);
751 754
752 /* If it is the symbol table, its st_shndx field needs to be patched. */ 755 /* If it is the symbol table, its st_shndx field needs to be patched. */
753 if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB 756 if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB
754 || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM) 757 || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM)
755 { 758 {
@@ -769,7 +772,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
769 } 772 }
770 } 773 }
771 774
772 /* Update the symbol values of _edata and _end. */ 775 /* Update the symbol values of _edata and _end. */
773 for (n = new_file_h->e_shnum - 1; n; n--) 776 for (n = new_file_h->e_shnum - 1; n; n--)
774 { 777 {
775 byte *symnames; 778 byte *symnames;
@@ -789,7 +792,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
789 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr)); 792 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr));
790 } 793 }
791 794
792 /* Close the files and make the new file executable */ 795 /* Close the files and make the new file executable. */
793 796
794 if (close (old_file)) 797 if (close (old_file))
795 fatal ("Can't close (%s): errno %d\n", old_name, errno); 798 fatal ("Can't close (%s): errno %d\n", old_name, errno);