diff options
| author | Richard M. Stallman | 1997-06-27 22:08:03 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-06-27 22:08:03 +0000 |
| commit | 9240b21dcea5754dc456f1a02284a692d9549127 (patch) | |
| tree | 3ec59633e3b53883af652d16127f3440afc1e4cd /src | |
| parent | 635fc896e7c91de04802b801e9f74ab77d30b702 (diff) | |
| download | emacs-9240b21dcea5754dc456f1a02284a692d9549127.tar.gz emacs-9240b21dcea5754dc456f1a02284a692d9549127.zip | |
[__sony_news && _SYSTYPE_SYSV]: Include sym.h and sys/elf_mips.h.
(unexec): Add __sony_news && _SYSTYPE_SYSV conditionals.
Add a _nec_ews_svr4 conditional.
Diffstat (limited to 'src')
| -rw-r--r-- | src/unexelf.c | 118 |
1 files changed, 112 insertions, 6 deletions
diff --git a/src/unexelf.c b/src/unexelf.c index a832755167e..77a26b232c3 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -422,6 +422,10 @@ Filesz Memsz Flags Align | |||
| 422 | #include <fcntl.h> | 422 | #include <fcntl.h> |
| 423 | #include <elf.h> | 423 | #include <elf.h> |
| 424 | #include <sys/mman.h> | 424 | #include <sys/mman.h> |
| 425 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | ||
| 426 | #include <sys/elf_mips.h> | ||
| 427 | #include <sym.h> | ||
| 428 | #endif /* __sony_news && _SYSTYPE_SYSV */ | ||
| 425 | 429 | ||
| 426 | #ifdef __alpha__ | 430 | #ifdef __alpha__ |
| 427 | # include <sym.h> /* get COFF debugging symbol table declaration */ | 431 | # include <sym.h> /* get COFF debugging symbol table declaration */ |
| @@ -539,6 +543,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 539 | ElfW(Addr) new_data2_addr; | 543 | ElfW(Addr) new_data2_addr; |
| 540 | 544 | ||
| 541 | int n, nn, old_bss_index, old_data_index, new_data2_index; | 545 | int n, nn, old_bss_index, old_data_index, new_data2_index; |
| 546 | #if defined ( __sony_news) && defined (_SYSTYPE_SYSV) | ||
| 547 | int old_sbss_index, old_mdebug_index; | ||
| 548 | #endif /* __sony_news && _SYSTYPE_SYSV */ | ||
| 542 | struct stat stat_buf; | 549 | struct stat stat_buf; |
| 543 | 550 | ||
| 544 | /* Open the old file & map it into the address space. */ | 551 | /* Open the old file & map it into the address space. */ |
| @@ -587,8 +594,51 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 587 | if (old_bss_index == old_file_h->e_shnum) | 594 | if (old_bss_index == old_file_h->e_shnum) |
| 588 | fatal ("Can't find .bss in %s.\n", old_name, 0); | 595 | fatal ("Can't find .bss in %s.\n", old_name, 0); |
| 589 | 596 | ||
| 597 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | ||
| 598 | for (old_sbss_index = 1; old_sbss_index < (int) old_file_h->e_shnum; | ||
| 599 | old_sbss_index++) | ||
| 600 | { | ||
| 601 | #ifdef DEBUG | ||
| 602 | fprintf (stderr, "Looking for .sbss - found %s\n", | ||
| 603 | old_section_names + OLD_SECTION_H (old_sbss_index).sh_name); | ||
| 604 | #endif | ||
| 605 | if (!strcmp (old_section_names + OLD_SECTION_H (old_sbss_index).sh_name, | ||
| 606 | ".sbss")) | ||
| 607 | break; | ||
| 608 | } | ||
| 609 | if (old_sbss_index == old_file_h->e_shnum) | ||
| 610 | { | ||
| 611 | old_bss_addr = OLD_SECTION_H(old_bss_index).sh_addr; | ||
| 612 | old_bss_size = OLD_SECTION_H(old_bss_index).sh_size; | ||
| 613 | new_data2_offset = OLD_SECTION_H(old_bss_index).sh_offset; | ||
| 614 | new_data2_index = old_bss_index; | ||
| 615 | } | ||
| 616 | else | ||
| 617 | { | ||
| 618 | old_bss_addr = OLD_SECTION_H(old_sbss_index).sh_addr; | ||
| 619 | old_bss_size = OLD_SECTION_H(old_bss_index).sh_size | ||
| 620 | + OLD_SECTION_H(old_sbss_index).sh_size; | ||
| 621 | new_data2_offset = OLD_SECTION_H(old_sbss_index).sh_offset; | ||
| 622 | new_data2_index = old_sbss_index; | ||
| 623 | } | ||
| 624 | |||
| 625 | for (old_mdebug_index = 1; old_mdebug_index < (int) old_file_h->e_shnum; | ||
| 626 | old_mdebug_index++) | ||
| 627 | { | ||
| 628 | #ifdef DEBUG | ||
| 629 | fprintf (stderr, "Looking for .mdebug - found %s\n", | ||
| 630 | old_section_names + OLD_SECTION_H (old_mdebug_index).sh_name); | ||
| 631 | #endif | ||
| 632 | if (!strcmp (old_section_names + OLD_SECTION_H (old_mdebug_index).sh_name, | ||
| 633 | ".mdebug")) | ||
| 634 | break; | ||
| 635 | } | ||
| 636 | if (old_mdebug_index == old_file_h->e_shnum) | ||
| 637 | old_mdebug_index = 0; | ||
| 638 | #else /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 590 | old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr; | 639 | old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr; |
| 591 | old_bss_size = OLD_SECTION_H (old_bss_index).sh_size; | 640 | old_bss_size = OLD_SECTION_H (old_bss_index).sh_size; |
| 641 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 592 | #if defined(emacs) || !defined(DEBUG) | 642 | #if defined(emacs) || !defined(DEBUG) |
| 593 | new_bss_addr = (ElfW(Addr)) sbrk (0); | 643 | new_bss_addr = (ElfW(Addr)) sbrk (0); |
| 594 | #else | 644 | #else |
| @@ -596,7 +646,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 596 | #endif | 646 | #endif |
| 597 | new_data2_addr = old_bss_addr; | 647 | new_data2_addr = old_bss_addr; |
| 598 | new_data2_size = new_bss_addr - old_bss_addr; | 648 | new_data2_size = new_bss_addr - old_bss_addr; |
| 649 | #if !defined (__sony_news) || !defined (_SYSTYPE_SYSV) | ||
| 599 | new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset; | 650 | new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset; |
| 651 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 600 | 652 | ||
| 601 | #ifdef DEBUG | 653 | #ifdef DEBUG |
| 602 | fprintf (stderr, "old_bss_index %d\n", old_bss_index); | 654 | fprintf (stderr, "old_bss_index %d\n", old_bss_index); |
| @@ -681,8 +733,14 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 681 | if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment) | 733 | if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment) |
| 682 | alignment = OLD_SECTION_H (old_bss_index).sh_addralign; | 734 | alignment = OLD_SECTION_H (old_bss_index).sh_addralign; |
| 683 | 735 | ||
| 736 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | ||
| 737 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz | ||
| 738 | > round_up (old_bss_addr, alignment)) | ||
| 739 | fatal ("Program segment above .bss in %s\n", old_name, 0); | ||
| 740 | #else /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 684 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr) | 741 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr) |
| 685 | fatal ("Program segment above .bss in %s\n", old_name, 0); | 742 | fatal ("Program segment above .bss in %s\n", old_name, 0); |
| 743 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 686 | 744 | ||
| 687 | if (NEW_PROGRAM_H (n).p_type == PT_LOAD | 745 | if (NEW_PROGRAM_H (n).p_type == PT_LOAD |
| 688 | && (round_up ((NEW_PROGRAM_H (n)).p_vaddr | 746 | && (round_up ((NEW_PROGRAM_H (n)).p_vaddr |
| @@ -728,8 +786,17 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 728 | for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++) | 786 | for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++) |
| 729 | { | 787 | { |
| 730 | caddr_t src; | 788 | caddr_t src; |
| 731 | /* If it is bss section, insert the new data2 section before it. */ | 789 | int temp_index; |
| 732 | if (n == old_bss_index) | 790 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) |
| 791 | /* If it is (s)bss section, insert the new data2 section before it. */ | ||
| 792 | /* new_data2_index is the index of either old_sbss or old_bss, that was | ||
| 793 | chosen as a section for new_data2. */ | ||
| 794 | temp_index = new_data2_index; | ||
| 795 | #else /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 796 | /* If it is bss section, insert the new data2 section before it. */ | ||
| 797 | temp_index = old_bss_index; | ||
| 798 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | ||
| 799 | if (n == temp_index) | ||
| 733 | { | 800 | { |
| 734 | /* Steal the data section header for this data2 section. */ | 801 | /* Steal the data section header for this data2 section. */ |
| 735 | memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (old_data_index), | 802 | memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (old_data_index), |
| @@ -752,10 +819,14 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 752 | 819 | ||
| 753 | memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n), | 820 | memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n), |
| 754 | old_file_h->e_shentsize); | 821 | old_file_h->e_shentsize); |
| 755 | 822 | ||
| 756 | /* The new bss section's size is zero, and its file offset and virtual | 823 | if (n == old_bss_index |
| 757 | address should be off by NEW_DATA2_SIZE. */ | 824 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) |
| 758 | if (n == old_bss_index) | 825 | /* The new bss and sbss section's size is zero, and its file offset |
| 826 | and virtual address should be off by NEW_DATA2_SIZE. */ | ||
| 827 | || n == old_sbss_index | ||
| 828 | #endif /* __sony_news and _SYSTYPE_SYSV */ | ||
| 829 | ) | ||
| 759 | { | 830 | { |
| 760 | /* NN should be `old_bss_index + 1' at this point. */ | 831 | /* NN should be `old_bss_index + 1' at this point. */ |
| 761 | NEW_SECTION_H (nn).sh_offset += new_data2_size; | 832 | NEW_SECTION_H (nn).sh_offset += new_data2_size; |
| @@ -815,6 +886,18 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 815 | ".data" in the strings table) get copied from the current process | 886 | ".data" in the strings table) get copied from the current process |
| 816 | instead of the old file. */ | 887 | instead of the old file. */ |
| 817 | if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data") | 888 | if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data") |
| 889 | #ifdef _nec_ews_svr4 /* hir, 1994.6.13 */ | ||
| 890 | || !strcmp ((old_section_names + NEW_SECTION_H(n).sh_name), | ||
| 891 | ".sdata") | ||
| 892 | #endif | ||
| 893 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | ||
| 894 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | ||
| 895 | ".sdata") | ||
| 896 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | ||
| 897 | ".lit4") | ||
| 898 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | ||
| 899 | ".lit8") | ||
| 900 | #endif /* __sony_news && _SYSTYPE_SYSV */ | ||
| 818 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 901 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
| 819 | ".data1")) | 902 | ".data1")) |
| 820 | src = (caddr_t) OLD_SECTION_H (n).sh_addr; | 903 | src = (caddr_t) OLD_SECTION_H (n).sh_addr; |
| @@ -845,6 +928,29 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 845 | } | 928 | } |
| 846 | #endif /* __alpha__ */ | 929 | #endif /* __alpha__ */ |
| 847 | 930 | ||
| 931 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | ||
| 932 | if (NEW_SECTION_H (nn).sh_type == SHT_MIPS_DEBUG && old_mdebug_index) | ||
| 933 | { | ||
| 934 | int diff = NEW_SECTION_H(nn).sh_offset | ||
| 935 | - OLD_SECTION_H(old_mdebug_index).sh_offset; | ||
| 936 | HDRR *phdr = (HDRR *)(NEW_SECTION_H (nn).sh_offset + new_base); | ||
| 937 | |||
| 938 | if (diff) | ||
| 939 | { | ||
| 940 | phdr->cbLineOffset += diff; | ||
| 941 | phdr->cbDnOffset += diff; | ||
| 942 | phdr->cbPdOffset += diff; | ||
| 943 | phdr->cbSymOffset += diff; | ||
| 944 | phdr->cbOptOffset += diff; | ||
| 945 | phdr->cbAuxOffset += diff; | ||
| 946 | phdr->cbSsOffset += diff; | ||
| 947 | phdr->cbSsExtOffset += diff; | ||
| 948 | phdr->cbFdOffset += diff; | ||
| 949 | phdr->cbRfdOffset += diff; | ||
| 950 | phdr->cbExtOffset += diff; | ||
| 951 | } | ||
| 952 | } | ||
| 953 | #endif /* __sony_news && _SYSTYPE_SYSV */ | ||
| 848 | /* If it is the symbol table, its st_shndx field needs to be patched. */ | 954 | /* If it is the symbol table, its st_shndx field needs to be patched. */ |
| 849 | if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB | 955 | if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB |
| 850 | || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM) | 956 | || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM) |