diff options
| author | Richard M. Stallman | 1999-02-10 03:02:01 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1999-02-10 03:02:01 +0000 |
| commit | 72443547c2a7f9a73c4ecb1085eec52a10a495de (patch) | |
| tree | 6cbf846ea0195bbbdc79bec8cb8a3f97e42a68dd /src | |
| parent | 666f4056900138f1febfef568cc2018d42990f2b (diff) | |
| download | emacs-72443547c2a7f9a73c4ecb1085eec52a10a495de.tar.gz emacs-72443547c2a7f9a73c4ecb1085eec52a10a495de.zip | |
(HAS_SBSS_SECTION): Define this in some cases.
(unexec): Test this instead of specific systems.
Diffstat (limited to 'src')
| -rw-r--r-- | src/unexelf.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/unexelf.c b/src/unexelf.c index 0e70ac116b1..c020d524db3 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -427,8 +427,13 @@ Filesz Memsz Flags Align | |||
| 427 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 427 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) |
| 428 | #include <sys/elf_mips.h> | 428 | #include <sys/elf_mips.h> |
| 429 | #include <sym.h> | 429 | #include <sym.h> |
| 430 | #define HAS_SBSS_SECTION | ||
| 430 | #endif /* __sony_news && _SYSTYPE_SYSV */ | 431 | #endif /* __sony_news && _SYSTYPE_SYSV */ |
| 431 | 432 | ||
| 433 | #if defined (__NetBSD__) && defined (__powerpc__) | ||
| 434 | #define HAS_SBSS_SECTION | ||
| 435 | #endif | ||
| 436 | |||
| 432 | #if defined (__alpha__) && !defined (__NetBSD__) && !defined (__OpenBSD__) | 437 | #if defined (__alpha__) && !defined (__NetBSD__) && !defined (__OpenBSD__) |
| 433 | /* Declare COFF debugging symbol table. This used to be in | 438 | /* Declare COFF debugging symbol table. This used to be in |
| 434 | /usr/include/sym.h, but this file is no longer included in Red Hat | 439 | /usr/include/sym.h, but this file is no longer included in Red Hat |
| @@ -620,9 +625,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 620 | ElfW(Addr) new_data2_addr; | 625 | ElfW(Addr) new_data2_addr; |
| 621 | 626 | ||
| 622 | int n, nn, old_bss_index, old_data_index, new_data2_index; | 627 | int n, nn, old_bss_index, old_data_index, new_data2_index; |
| 623 | #if defined ( __sony_news) && defined (_SYSTYPE_SYSV) | 628 | #if defined (HAS_SBSS_SECTION) |
| 624 | int old_sbss_index, old_mdebug_index; | 629 | int old_sbss_index, old_mdebug_index; |
| 625 | #endif /* __sony_news && _SYSTYPE_SYSV */ | 630 | #endif /* HAS_SBSS_SECTION */ |
| 626 | struct stat stat_buf; | 631 | struct stat stat_buf; |
| 627 | 632 | ||
| 628 | /* Open the old file & map it into the address space. */ | 633 | /* Open the old file & map it into the address space. */ |
| @@ -672,7 +677,7 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 672 | if (old_bss_index == old_file_h->e_shnum) | 677 | if (old_bss_index == old_file_h->e_shnum) |
| 673 | fatal ("Can't find .bss in %s.\n", old_name, 0); | 678 | fatal ("Can't find .bss in %s.\n", old_name, 0); |
| 674 | 679 | ||
| 675 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 680 | #if defined (HAS_SBSS_SECTION) |
| 676 | for (old_sbss_index = 1; old_sbss_index < (int) old_file_h->e_shnum; | 681 | for (old_sbss_index = 1; old_sbss_index < (int) old_file_h->e_shnum; |
| 677 | old_sbss_index++) | 682 | old_sbss_index++) |
| 678 | { | 683 | { |
| @@ -713,10 +718,10 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 713 | } | 718 | } |
| 714 | if (old_mdebug_index == old_file_h->e_shnum) | 719 | if (old_mdebug_index == old_file_h->e_shnum) |
| 715 | old_mdebug_index = 0; | 720 | old_mdebug_index = 0; |
| 716 | #else /* not (__sony_news && _SYSTYPE_SYSV) */ | 721 | #else /* not HAS_SBSS_SECTION */ |
| 717 | old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr; | 722 | old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr; |
| 718 | old_bss_size = OLD_SECTION_H (old_bss_index).sh_size; | 723 | old_bss_size = OLD_SECTION_H (old_bss_index).sh_size; |
| 719 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | 724 | #endif /* not HAS_SBSS_SECTION */ |
| 720 | #if defined (emacs) || !defined (DEBUG) | 725 | #if defined (emacs) || !defined (DEBUG) |
| 721 | new_bss_addr = (ElfW(Addr)) sbrk (0); | 726 | new_bss_addr = (ElfW(Addr)) sbrk (0); |
| 722 | #else | 727 | #else |
| @@ -724,9 +729,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 724 | #endif | 729 | #endif |
| 725 | new_data2_addr = old_bss_addr; | 730 | new_data2_addr = old_bss_addr; |
| 726 | new_data2_size = new_bss_addr - old_bss_addr; | 731 | new_data2_size = new_bss_addr - old_bss_addr; |
| 727 | #if !defined (__sony_news) || !defined (_SYSTYPE_SYSV) | 732 | #if !defined (HAS_SBSS_SECTION) |
| 728 | new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset; | 733 | new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset; |
| 729 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | 734 | #endif /* not HAS_SBSS_SECTION */ |
| 730 | 735 | ||
| 731 | #ifdef DEBUG | 736 | #ifdef DEBUG |
| 732 | fprintf (stderr, "old_bss_index %d\n", old_bss_index); | 737 | fprintf (stderr, "old_bss_index %d\n", old_bss_index); |
| @@ -811,14 +816,14 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 811 | if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment) | 816 | if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment) |
| 812 | alignment = OLD_SECTION_H (old_bss_index).sh_addralign; | 817 | alignment = OLD_SECTION_H (old_bss_index).sh_addralign; |
| 813 | 818 | ||
| 814 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 819 | #if defined (HAS_SBSS_SECTION) |
| 815 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz | 820 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz |
| 816 | > round_up (old_bss_addr, alignment)) | 821 | > round_up (old_bss_addr, alignment)) |
| 817 | fatal ("Program segment above .bss in %s\n", old_name, 0); | 822 | fatal ("Program segment above .bss in %s\n", old_name, 0); |
| 818 | #else /* not (__sony_news && _SYSTYPE_SYSV) */ | 823 | #else /* not HAS_SBSS_SECTION */ |
| 819 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr) | 824 | if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr) |
| 820 | fatal ("Program segment above .bss in %s\n", old_name, 0); | 825 | fatal ("Program segment above .bss in %s\n", old_name, 0); |
| 821 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | 826 | #endif /* not HAS_SBSS_SECTION */ |
| 822 | 827 | ||
| 823 | if (NEW_PROGRAM_H (n).p_type == PT_LOAD | 828 | if (NEW_PROGRAM_H (n).p_type == PT_LOAD |
| 824 | && (round_up ((NEW_PROGRAM_H (n)).p_vaddr | 829 | && (round_up ((NEW_PROGRAM_H (n)).p_vaddr |
| @@ -867,15 +872,15 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 867 | { | 872 | { |
| 868 | caddr_t src; | 873 | caddr_t src; |
| 869 | int temp_index; | 874 | int temp_index; |
| 870 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 875 | #if defined (HAS_SBSS_SECTION) |
| 871 | /* If it is (s)bss section, insert the new data2 section before it. */ | 876 | /* If it is (s)bss section, insert the new data2 section before it. */ |
| 872 | /* new_data2_index is the index of either old_sbss or old_bss, that was | 877 | /* new_data2_index is the index of either old_sbss or old_bss, that was |
| 873 | chosen as a section for new_data2. */ | 878 | chosen as a section for new_data2. */ |
| 874 | temp_index = new_data2_index; | 879 | temp_index = new_data2_index; |
| 875 | #else /* not (__sony_news && _SYSTYPE_SYSV) */ | 880 | #else /* not HAS_SBSS_SECTION */ |
| 876 | /* If it is bss section, insert the new data2 section before it. */ | 881 | /* If it is bss section, insert the new data2 section before it. */ |
| 877 | temp_index = old_bss_index; | 882 | temp_index = old_bss_index; |
| 878 | #endif /* not (__sony_news && _SYSTYPE_SYSV) */ | 883 | #endif /* not HAS_SBSS_SECTION */ |
| 879 | if (n == temp_index) | 884 | if (n == temp_index) |
| 880 | { | 885 | { |
| 881 | /* Steal the data section header for this data2 section. */ | 886 | /* Steal the data section header for this data2 section. */ |
| @@ -901,11 +906,11 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 901 | old_file_h->e_shentsize); | 906 | old_file_h->e_shentsize); |
| 902 | 907 | ||
| 903 | if (n == old_bss_index | 908 | if (n == old_bss_index |
| 904 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 909 | #if defined (HAS_SBSS_SECTION) |
| 905 | /* The new bss and sbss section's size is zero, and its file offset | 910 | /* The new bss and sbss section's size is zero, and its file offset |
| 906 | and virtual address should be off by NEW_DATA2_SIZE. */ | 911 | and virtual address should be off by NEW_DATA2_SIZE. */ |
| 907 | || n == old_sbss_index | 912 | || n == old_sbss_index |
| 908 | #endif /* __sony_news and _SYSTYPE_SYSV */ | 913 | #endif /* HAS_SBSS_SECTION */ |
| 909 | ) | 914 | ) |
| 910 | { | 915 | { |
| 911 | /* NN should be `old_bss_index + 1' at this point. */ | 916 | /* NN should be `old_bss_index + 1' at this point. */ |
| @@ -970,14 +975,14 @@ unexec (new_name, old_name, data_start, bss_start, entry_address) | |||
| 970 | || !strcmp ((old_section_names + NEW_SECTION_H(n).sh_name), | 975 | || !strcmp ((old_section_names + NEW_SECTION_H(n).sh_name), |
| 971 | ".sdata") | 976 | ".sdata") |
| 972 | #endif | 977 | #endif |
| 973 | #if defined (__sony_news) && defined (_SYSTYPE_SYSV) | 978 | #if defined (HAS_SBSS_SECTION) |
| 974 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 979 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
| 975 | ".sdata") | 980 | ".sdata") |
| 976 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 981 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
| 977 | ".lit4") | 982 | ".lit4") |
| 978 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 983 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
| 979 | ".lit8") | 984 | ".lit8") |
| 980 | #endif /* __sony_news && _SYSTYPE_SYSV */ | 985 | #endif /* HAS_SBSS_SECTION */ |
| 981 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), | 986 | || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), |
| 982 | ".data1")) | 987 | ".data1")) |
| 983 | src = (caddr_t) OLD_SECTION_H (n).sh_addr; | 988 | src = (caddr_t) OLD_SECTION_H (n).sh_addr; |