aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1996-01-08 22:29:48 +0000
committerKarl Heuer1996-01-08 22:29:48 +0000
commit48240339243662c5f0f0191c82c0f8de4361f1e1 (patch)
tree9d3a6061ec4b7d1a9eaf16f918156ce733533225 /src
parent449decf581c0092e3048c9529dbe747b8b1619d3 (diff)
downloademacs-48240339243662c5f0f0191c82c0f8de4361f1e1.tar.gz
emacs-48240339243662c5f0f0191c82c0f8de4361f1e1.zip
(unexec) [SOLARIS2]: Undo relocations performed by the
runtime linker.
Diffstat (limited to 'src')
-rw-r--r--src/unexelf.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/unexelf.c b/src/unexelf.c
index c61f4c368f1..c86663f7ace 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -807,6 +807,40 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
807 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr)); 807 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr));
808 } 808 }
809 809
810#ifdef SOLARIS2
811 /* This loop seeks out relocation sections for the data section, so
812 that it can undo relocations performed by the runtime linker. */
813 for (n = new_file_h->e_shnum - 1; n; n--)
814 {
815 Elf32_Shdr section = NEW_SECTION_H (n);
816 switch (section.sh_type) {
817 default:
818 break;
819 case SHT_REL:
820 case SHT_RELA:
821 /* This code handles two different size structs, but there
822 should be no harm in that provided that r_offset is always
823 the first member. */
824 nn = section.sh_info;
825 if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
826 || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
827 ".data1"))
828 {
829 Elf32_Addr offset = NEW_SECTION_H (nn).sh_addr -
830 NEW_SECTION_H (nn).sh_offset;
831 caddr_t reloc = old_base + section.sh_offset, end;
832 for (end = reloc + section.sh_size; reloc < end;
833 reloc += section.sh_entsize)
834 {
835 Elf32_Addr addr = ((Elf32_Rel *) reloc)->r_offset - offset;
836 memcpy (new_base + addr, old_base + addr, 4);
837 }
838 }
839 break;
840 }
841 }
842#endif
843
810#ifdef UNEXEC_USE_MAP_PRIVATE 844#ifdef UNEXEC_USE_MAP_PRIVATE
811 if (lseek (new_file, 0, SEEK_SET) == -1) 845 if (lseek (new_file, 0, SEEK_SET) == -1)
812 fatal ("Can't rewind (%s): errno %d\n", new_name, errno); 846 fatal ("Can't rewind (%s): errno %d\n", new_name, errno);