aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Love2000-03-12 17:04:43 +0000
committerDave Love2000-03-12 17:04:43 +0000
commit1b963cdda9ba97fb76cc2ac764fccea385f886c6 (patch)
tree32d89dc6e738493a8f8a78c8a450883cd1a66527 /src
parent9b2f3c38300a597cf7607a49b459c9a4d461d306 (diff)
downloademacs-1b963cdda9ba97fb76cc2ac764fccea385f886c6.tar.gz
emacs-1b963cdda9ba97fb76cc2ac764fccea385f886c6.zip
Restore changes of 1999-10-19.
(unexec): Don't adjust bss for sbss type SHT_PROGBITS; otherwise fix its type and alignment; copy it from current process.
Diffstat (limited to 'src')
-rw-r--r--src/unexelf.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/src/unexelf.c b/src/unexelf.c
index a90885ba64f..93c0a25cd12 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992 1/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992, 1999, 2000
2 Free Software Foundation, Inc. 2 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
@@ -52,11 +52,6 @@ what you give them. Help stamp out software-hoarding! */
52 * The value you specify may be rounded down to a suitable boundary 52 * The value you specify may be rounded down to a suitable boundary
53 * as required by the machine you are using. 53 * as required by the machine you are using.
54 * 54 *
55 * Specifying zero for data_start means the boundary between text and data
56 * should not be the same as when the program was loaded.
57 * If NO_REMAP is defined, the argument data_start is ignored and the
58 * segment boundaries are never changed.
59 *
60 * Bss_start indicates how much of the data segment is to be saved in the 55 * Bss_start indicates how much of the data segment is to be saved in the
61 * a.out file and restored when the program is executed. It gives the lowest 56 * a.out file and restored when the program is executed. It gives the lowest
62 * unsaved address, and is rounded up to a page boundary. The default when 0 57 * unsaved address, and is rounded up to a page boundary. The default when 0
@@ -66,9 +61,6 @@ what you give them. Help stamp out software-hoarding! */
66 * 61 *
67 * The new file is set up to start at entry_address. 62 * The new file is set up to start at entry_address.
68 * 63 *
69 * If you make improvements I'd like to get them too.
70 * harpo!utah-cs!thomas, thomas@Utah-20
71 *
72 */ 64 */
73 65
74/* Even more heavily modified by james@bigtex.cactus.org of Dell Computer Co. 66/* Even more heavily modified by james@bigtex.cactus.org of Dell Computer Co.
@@ -412,6 +404,13 @@ Filesz Memsz Flags Align
412 404
413 */ 405 */
414 406
407#ifndef emacs
408#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1)
409#else
410#include <config.h>
411extern void fatal (char *, ...);
412#endif
413
415#include <sys/types.h> 414#include <sys/types.h>
416#include <stdio.h> 415#include <stdio.h>
417#include <sys/stat.h> 416#include <sys/stat.h>
@@ -509,17 +508,18 @@ typedef struct {
509 508
510#ifndef ElfW 509#ifndef ElfW
511# ifdef __STDC__ 510# ifdef __STDC__
512# define ElfW(type) Elf32_##type 511# define ElfBitsW(bits, type) Elf##bits##_##type
513# else 512# else
514# define ElfW(type) Elf32_/**/type 513# define ElfBitsW(bits, type) Elf/**/bits/**/_/**/type
515# endif 514# endif
516#endif 515# ifdef _LP64
517 516# define ELFSIZE 64
518#ifndef emacs 517# else
519#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1) 518# define ELFSIZE 32
520#else 519# endif
521#include <config.h> 520 /* This macro expands `bits' before invoking ElfBitsW. */
522extern void fatal (char *, ...); 521# define ElfExpandBitsW(bits, type) ElfBitsW (bits, type)
522# define ElfW(type) ElfExpandBitsW (ELFSIZE, type)
523#endif 523#endif
524 524
525#ifndef ELF_BSS_SECTION_NAME 525#ifndef ELF_BSS_SECTION_NAME
@@ -702,6 +702,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
702 702
703 old_sbss_index = find_section (".sbss", old_section_names, 703 old_sbss_index = find_section (".sbss", old_section_names,
704 old_name, old_file_h, old_section_h, 1); 704 old_name, old_file_h, old_section_h, 1);
705 if (old_sbss_index != -1)
706 if (OLD_SECTION_H (old_sbss_index).sh_type == SHT_PROGBITS)
707 old_sbss_index = -1;
705 708
706 if (old_sbss_index == -1) 709 if (old_sbss_index == -1)
707 { 710 {
@@ -958,6 +961,15 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
958 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB 961 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB
959 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM) 962 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM)
960 PATCH_INDEX (NEW_SECTION_H (nn).sh_info); 963 PATCH_INDEX (NEW_SECTION_H (nn).sh_info);
964
965 if (old_sbss_index != -1)
966 if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".sbss"))
967 {
968 NEW_SECTION_H (nn).sh_offset =
969 round_up (NEW_SECTION_H (nn).sh_offset,
970 NEW_SECTION_H (nn).sh_addralign);
971 NEW_SECTION_H (nn).sh_type = SHT_PROGBITS;
972 }
961 973
962 /* Now, start to copy the content of sections. */ 974 /* Now, start to copy the content of sections. */
963 if (NEW_SECTION_H (nn).sh_type == SHT_NULL 975 if (NEW_SECTION_H (nn).sh_type == SHT_NULL
@@ -977,7 +989,9 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
977 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), 989 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
978 ".sdata1") 990 ".sdata1")
979 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name), 991 || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
980 ".data1")) 992 ".data1")
993 || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name,
994 ".sbss"))
981 src = (caddr_t) OLD_SECTION_H (n).sh_addr; 995 src = (caddr_t) OLD_SECTION_H (n).sh_addr;
982 else 996 else
983 src = old_base + OLD_SECTION_H (n).sh_offset; 997 src = old_base + OLD_SECTION_H (n).sh_offset;