aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1994-08-20 00:48:16 +0000
committerRichard M. Stallman1994-08-20 00:48:16 +0000
commit8bf761ce6fc7cc756833a3e07a43a9d68c87a59f (patch)
treed88578137dd0713999599ae4a66d16117302b563 /src
parent422450b944a8c0be2e778607601ef2f7b25256b0 (diff)
downloademacs-8bf761ce6fc7cc756833a3e07a43a9d68c87a59f.tar.gz
emacs-8bf761ce6fc7cc756833a3e07a43a9d68c87a59f.zip
Eliminate local var bss_end.
Update the symbol values of _edata and _end.
Diffstat (limited to 'src')
-rw-r--r--src/unexelf.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/unexelf.c b/src/unexelf.c
index 32f39c7d2b6..a7f607e3de8 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -475,7 +475,6 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
475 char *new_name, *old_name; 475 char *new_name, *old_name;
476 unsigned data_start, bss_start, entry_address; 476 unsigned data_start, bss_start, entry_address;
477{ 477{
478 extern unsigned int bss_end;
479 int new_file, old_file, new_file_size; 478 int new_file, old_file, new_file_size;
480 479
481 /* Pointers to the base of the image of the two files. */ 480 /* Pointers to the base of the image of the two files. */
@@ -548,8 +547,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
548 old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr; 547 old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr;
549 old_bss_size = OLD_SECTION_H (old_bss_index).sh_size; 548 old_bss_size = OLD_SECTION_H (old_bss_index).sh_size;
550#if defined(emacs) || !defined(DEBUG) 549#if defined(emacs) || !defined(DEBUG)
551 bss_end = (unsigned int) sbrk (0); 550 new_bss_addr = (Elf32_Addr) sbrk (0);
552 new_bss_addr = (Elf32_Addr) bss_end;
553#else 551#else
554 new_bss_addr = old_bss_addr + old_bss_size + 0x1234; 552 new_bss_addr = old_bss_addr + old_bss_size + 0x1234;
555#endif 553#endif
@@ -771,6 +769,26 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
771 } 769 }
772 } 770 }
773 771
772 /* Update the symbol values of _edata and _end. */
773 for (n = new_file_h->e_shnum - 1; n; n--)
774 {
775 byte *symnames;
776 Elf32_Sym *symp, *symendp;
777
778 if (NEW_SECTION_H (n).sh_type != SHT_DYNSYM
779 && NEW_SECTION_H (n).sh_type != SHT_SYMTAB)
780 continue;
781
782 symnames = NEW_SECTION_H (NEW_SECTION_H (n).sh_link).sh_offset + new_base;
783 symp = (Elf32_Sym *) (NEW_SECTION_H (n).sh_offset + new_base);
784 symendp = (Elf32_Sym *) ((byte *)symp + NEW_SECTION_H (n).sh_size);
785
786 for (; symp < symendp; symp ++)
787 if (strcmp ((char *) (symnames + symp->st_name), "_end") == 0
788 || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0)
789 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr));
790 }
791
774 /* Close the files and make the new file executable */ 792 /* Close the files and make the new file executable */
775 793
776 if (close (old_file)) 794 if (close (old_file))