annotate etc/AIX.DUMP @ 27337:d895d4e8a6f0

(_widget_value): Add help string.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 17 Jan 2000 09:10:40 +0000
parents e96ffe544684
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25853
Dave Love <fx@gnu.org>
parents:
diff changeset
1 The following text was written by someone at IBM to describe an older
Dave Love <fx@gnu.org>
parents:
diff changeset
2 version of the code for dumping on AIX. It does NOT apply to
Dave Love <fx@gnu.org>
parents:
diff changeset
3 the current version of Emacs. It is included in case someone
Dave Love <fx@gnu.org>
parents:
diff changeset
4 is curious.
Dave Love <fx@gnu.org>
parents:
diff changeset
5
Dave Love <fx@gnu.org>
parents:
diff changeset
6
Dave Love <fx@gnu.org>
parents:
diff changeset
7 I (rms) couldn't understand the code, and I can't fully understand
Dave Love <fx@gnu.org>
parents:
diff changeset
8 this text either. I rewrote the code to use the same basic
Dave Love <fx@gnu.org>
parents:
diff changeset
9 principles, as far as I understood them, but more cleanly. This
Dave Love <fx@gnu.org>
parents:
diff changeset
10 rewritten code does not always work. In fact, the basic method
Dave Love <fx@gnu.org>
parents:
diff changeset
11 seems to be intrinsically flawed.
Dave Love <fx@gnu.org>
parents:
diff changeset
12
Dave Love <fx@gnu.org>
parents:
diff changeset
13 Since then, someone else implemented a different way of dumping on
Dave Love <fx@gnu.org>
parents:
diff changeset
14 the RS/6000, which does seem to work. None of the following
Dave Love <fx@gnu.org>
parents:
diff changeset
15 applies to the way Emacs now dumps on the 6000. However, the
Dave Love <fx@gnu.org>
parents:
diff changeset
16 current method fails to use shared libraries. Anyone who might be
Dave Love <fx@gnu.org>
parents:
diff changeset
17 interested in trying to resurrect the previous method might still
Dave Love <fx@gnu.org>
parents:
diff changeset
18 find the following information useful.
Dave Love <fx@gnu.org>
parents:
diff changeset
19
Dave Love <fx@gnu.org>
parents:
diff changeset
20
Dave Love <fx@gnu.org>
parents:
diff changeset
21 It seems that the IBM dumping code was simply set up to detect when
Dave Love <fx@gnu.org>
parents:
diff changeset
22 the dumped data cannot be used, and in that case to act approximately
Dave Love <fx@gnu.org>
parents:
diff changeset
23 as if CANNOT_DUMP had been defined all along. (This is buried in
Dave Love <fx@gnu.org>
parents:
diff changeset
24 paragraph 1.) It seems simpler just to define CANNOT_DUMP, since
Dave Love <fx@gnu.org>
parents:
diff changeset
25 Emacs is not set up to decide at run time whether there is dumping or
Dave Love <fx@gnu.org>
parents:
diff changeset
26 not, and doing so correctly would be a lot of work.
Dave Love <fx@gnu.org>
parents:
diff changeset
27
Dave Love <fx@gnu.org>
parents:
diff changeset
28 Note that much of the other information, such as the name and format
Dave Love <fx@gnu.org>
parents:
diff changeset
29 of the dumped data file, has been changed.
Dave Love <fx@gnu.org>
parents:
diff changeset
30
Dave Love <fx@gnu.org>
parents:
diff changeset
31
Dave Love <fx@gnu.org>
parents:
diff changeset
32 --rms
Dave Love <fx@gnu.org>
parents:
diff changeset
33
Dave Love <fx@gnu.org>
parents:
diff changeset
34
Dave Love <fx@gnu.org>
parents:
diff changeset
35
Dave Love <fx@gnu.org>
parents:
diff changeset
36 A different approach has been taken to implement the
Dave Love <fx@gnu.org>
parents:
diff changeset
37 "dump/load" feature of GNU Emacs for AIX 3.1. Traditionally the
Dave Love <fx@gnu.org>
parents:
diff changeset
38 unexec function creates a new a.out executable file which contains
Dave Love <fx@gnu.org>
parents:
diff changeset
39 preloaded Lisp code. Executing the new a.out file (normally called
Dave Love <fx@gnu.org>
parents:
diff changeset
40 xemacs) provides rapid startup since the standard suite of Lisp code
Dave Love <fx@gnu.org>
parents:
diff changeset
41 is preloaded as part of the executable file.
Dave Love <fx@gnu.org>
parents:
diff changeset
42
Dave Love <fx@gnu.org>
parents:
diff changeset
43 AIX 3.1 architecture precludes the use of this technique
Dave Love <fx@gnu.org>
parents:
diff changeset
44 because the dynamic loader cannot guarantee a fixed starting location
Dave Love <fx@gnu.org>
parents:
diff changeset
45 for the process data section. The loader loads all shared library
Dave Love <fx@gnu.org>
parents:
diff changeset
46 data BEFORE process data. When a shared library changes its data
Dave Love <fx@gnu.org>
parents:
diff changeset
47 space, the process initial data section address (_data) will change
Dave Love <fx@gnu.org>
parents:
diff changeset
48 and all global process variables are automatically relocated to new
Dave Love <fx@gnu.org>
parents:
diff changeset
49 addresses. This invalidates the "dumped" Emacs executable which has
Dave Love <fx@gnu.org>
parents:
diff changeset
50 data addresses which are not relocatable and now corrupt. Emacs would
Dave Love <fx@gnu.org>
parents:
diff changeset
51 fail to execute until rebuilt with the new libraries.
Dave Love <fx@gnu.org>
parents:
diff changeset
52
Dave Love <fx@gnu.org>
parents:
diff changeset
53 To circumvent the dynamic loader feature of AIX 3.1, the dump process
Dave Love <fx@gnu.org>
parents:
diff changeset
54 has been modified as follows:
Dave Love <fx@gnu.org>
parents:
diff changeset
55
Dave Love <fx@gnu.org>
parents:
diff changeset
56 1) A new executable file is NOT created. Instead, both pure and
Dave Love <fx@gnu.org>
parents:
diff changeset
57 impure data are saved by the dump function and automatically
Dave Love <fx@gnu.org>
parents:
diff changeset
58 reloaded during process initialization. If any of the saved data
Dave Love <fx@gnu.org>
parents:
diff changeset
59 is unavailable or invalid, loadup.el will be automatically loaded.
Dave Love <fx@gnu.org>
parents:
diff changeset
60
Dave Love <fx@gnu.org>
parents:
diff changeset
61 2) Pure data is defined as a shared memory segment and attached
Dave Love <fx@gnu.org>
parents:
diff changeset
62 automatically as read-only data during initialization. This
Dave Love <fx@gnu.org>
parents:
diff changeset
63 allows the pure data to be a shared resource among all Emacs
Dave Love <fx@gnu.org>
parents:
diff changeset
64 processes. The shared memory segment size is PURESIZE bytes.
Dave Love <fx@gnu.org>
parents:
diff changeset
65 If the shared memory segment is unavailable or invalid, a new
Dave Love <fx@gnu.org>
parents:
diff changeset
66 shared memory segment is created and the impure data save file
Dave Love <fx@gnu.org>
parents:
diff changeset
67 is destroyed, forcing loadup.el to be reloaded.
Dave Love <fx@gnu.org>
parents:
diff changeset
68
Dave Love <fx@gnu.org>
parents:
diff changeset
69 3) The ipc key used to create and access Emacs shared memory is
Dave Love <fx@gnu.org>
parents:
diff changeset
70 SHMKEY and can be overridden by the environment symbol EMACSSHMKEY.
Dave Love <fx@gnu.org>
parents:
diff changeset
71 Only one ipc key is allowed per system. The environment symbol
Dave Love <fx@gnu.org>
parents:
diff changeset
72 is provided in case the default ipc key has already been used.
Dave Love <fx@gnu.org>
parents:
diff changeset
73
Dave Love <fx@gnu.org>
parents:
diff changeset
74 4) Impure data is written to the ../bin/.emacs.data file by the
Dave Love <fx@gnu.org>
parents:
diff changeset
75 dump function. This file contains the process' impure data
Dave Love <fx@gnu.org>
parents:
diff changeset
76 at the moment of load completion. During Emacs initialization,
Dave Love <fx@gnu.org>
parents:
diff changeset
77 the process' data section is expanded and overwritten
Dave Love <fx@gnu.org>
parents:
diff changeset
78 with the .emacs.data file contents.
Dave Love <fx@gnu.org>
parents:
diff changeset
79
Dave Love <fx@gnu.org>
parents:
diff changeset
80 The following are software notes concerning the GNU Emacs dump function under AIX 3.1:
Dave Love <fx@gnu.org>
parents:
diff changeset
81
Dave Love <fx@gnu.org>
parents:
diff changeset
82 1) All of the new dump/load code is activated by the #ifdef SHMKEY
Dave Love <fx@gnu.org>
parents:
diff changeset
83 conditional.
Dave Love <fx@gnu.org>
parents:
diff changeset
84
Dave Love <fx@gnu.org>
parents:
diff changeset
85 2) The automatic loading of loadup.el does NOT cause the dump function
Dave Love <fx@gnu.org>
parents:
diff changeset
86 to be performed. Therefore once the pure/impure data is discarded,
Dave Love <fx@gnu.org>
parents:
diff changeset
87 someone must remake Emacs to create the saved data files. This
Dave Love <fx@gnu.org>
parents:
diff changeset
88 should only be necessary when Emacs is first installed or whenever
Dave Love <fx@gnu.org>
parents:
diff changeset
89 AIX is upgraded.
Dave Love <fx@gnu.org>
parents:
diff changeset
90
Dave Love <fx@gnu.org>
parents:
diff changeset
91 3) Emacs will exit with an error if executed in a non-X environment
Dave Love <fx@gnu.org>
parents:
diff changeset
92 and the dump function was performed within a X window. Therefore
Dave Love <fx@gnu.org>
parents:
diff changeset
93 the dump function should always be performed in a non-X
Dave Love <fx@gnu.org>
parents:
diff changeset
94 environment unless the X environment will ALWAYS be available.
Dave Love <fx@gnu.org>
parents:
diff changeset
95
Dave Love <fx@gnu.org>
parents:
diff changeset
96 4) Emacs only maintains the lower 24 bits of any data address. The
Dave Love <fx@gnu.org>
parents:
diff changeset
97 remaining upper 8 bits are reset by the XPNTR macro whenever any
Dave Love <fx@gnu.org>
parents:
diff changeset
98 Lisp object is referenced. This poses a serious problem because
Dave Love <fx@gnu.org>
parents:
diff changeset
99 pure data is stored in segment 3 (shared memory) and impure data
Dave Love <fx@gnu.org>
parents:
diff changeset
100 is stored in segment 2 (data). To reset the upper 8 address bits
Dave Love <fx@gnu.org>
parents:
diff changeset
101 correctly, XPNTR must guess as to which type of data is represented
Dave Love <fx@gnu.org>
parents:
diff changeset
102 by the lower 24 address bits. The technique chosen is based upon
Dave Love <fx@gnu.org>
parents:
diff changeset
103 the fact that pure data offsets in segment 3 range from
Dave Love <fx@gnu.org>
parents:
diff changeset
104 0 -> PURESIZE-1, which are relatively small offsets. Impure data
Dave Love <fx@gnu.org>
parents:
diff changeset
105 offsets in segment 2 are relatively large (> 0x40000) because they
Dave Love <fx@gnu.org>
parents:
diff changeset
106 must follow all shared library data. Therefore XPNTR adds segment
Dave Love <fx@gnu.org>
parents:
diff changeset
107 3 to each data offset which is small (below PURESIZE) and adds
Dave Love <fx@gnu.org>
parents:
diff changeset
108 segment 2 to all other offsets. This algorithm will remain valid
Dave Love <fx@gnu.org>
parents:
diff changeset
109 as long as a) pure data size remains relatively small and b) process
Dave Love <fx@gnu.org>
parents:
diff changeset
110 data is loaded after shared library data.
Dave Love <fx@gnu.org>
parents:
diff changeset
111
Dave Love <fx@gnu.org>
parents:
diff changeset
112 To eliminate this guessing game, Emacs must preserve the 32-bit
Dave Love <fx@gnu.org>
parents:
diff changeset
113 address and add additional data object overhead for the object type
Dave Love <fx@gnu.org>
parents:
diff changeset
114 and garbage collection mark bit.
Dave Love <fx@gnu.org>
parents:
diff changeset
115
Dave Love <fx@gnu.org>
parents:
diff changeset
116 5) The data section written to .emacs.data is divided into three
Dave Love <fx@gnu.org>
parents:
diff changeset
117 areas as shown below. The file header contains four character
Dave Love <fx@gnu.org>
parents:
diff changeset
118 pointers which are used during automatic data loading. The file's
Dave Love <fx@gnu.org>
parents:
diff changeset
119 contents will only be used if the first three addresses match
Dave Love <fx@gnu.org>
parents:
diff changeset
120 their counterparts in the current process. The fourth address is
Dave Love <fx@gnu.org>
parents:
diff changeset
121 the new data segment address required to hold all of the preloaded
Dave Love <fx@gnu.org>
parents:
diff changeset
122 data.
Dave Love <fx@gnu.org>
parents:
diff changeset
123
Dave Love <fx@gnu.org>
parents:
diff changeset
124
Dave Love <fx@gnu.org>
parents:
diff changeset
125 .emacs.data file format
Dave Love <fx@gnu.org>
parents:
diff changeset
126
Dave Love <fx@gnu.org>
parents:
diff changeset
127 +---------------------------------------+ \
Dave Love <fx@gnu.org>
parents:
diff changeset
128 | address of _data | \
Dave Love <fx@gnu.org>
parents:
diff changeset
129 +---------------------------------------+ \
Dave Love <fx@gnu.org>
parents:
diff changeset
130 | address of _end | \
Dave Love <fx@gnu.org>
parents:
diff changeset
131 +---------------------------------------+ file header
Dave Love <fx@gnu.org>
parents:
diff changeset
132 | address of initial sbrk(0) | /
Dave Love <fx@gnu.org>
parents:
diff changeset
133 +---------------------------------------+ /
Dave Love <fx@gnu.org>
parents:
diff changeset
134 | address of final sbrk(0) | /
Dave Love <fx@gnu.org>
parents:
diff changeset
135 +---------------------------------------+ /
Dave Love <fx@gnu.org>
parents:
diff changeset
136 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
137 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
138 all data to be loaded from
Dave Love <fx@gnu.org>
parents:
diff changeset
139 _data to _end
Dave Love <fx@gnu.org>
parents:
diff changeset
140 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
141 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
142 +---------------------------------------+
Dave Love <fx@gnu.org>
parents:
diff changeset
143 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
144 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
145 all data to be loaded from
Dave Love <fx@gnu.org>
parents:
diff changeset
146 initial to final sbrk(0)
Dave Love <fx@gnu.org>
parents:
diff changeset
147 \ \
Dave Love <fx@gnu.org>
parents:
diff changeset
148 +---------------------------------------+
Dave Love <fx@gnu.org>
parents:
diff changeset
149
Dave Love <fx@gnu.org>
parents:
diff changeset
150
Dave Love <fx@gnu.org>
parents:
diff changeset
151 Sections two and three contain the preloaded data which is
Dave Love <fx@gnu.org>
parents:
diff changeset
152 restored at locations _data and initial sbrk(0) respectively.
Dave Love <fx@gnu.org>
parents:
diff changeset
153
Dave Love <fx@gnu.org>
parents:
diff changeset
154 The reason two separate sections are needed is that process
Dave Love <fx@gnu.org>
parents:
diff changeset
155 initialization allocates data (via malloc) prior to main()
Dave Love <fx@gnu.org>
parents:
diff changeset
156 being called. Therefore _end is several kbytes lower than
Dave Love <fx@gnu.org>
parents:
diff changeset
157 the address returned by an initial sbrk(0). This creates a
Dave Love <fx@gnu.org>
parents:
diff changeset
158 hole in the process data space and malloc will abort if this
Dave Love <fx@gnu.org>
parents:
diff changeset
159 region is overwritten during the load function.
Dave Love <fx@gnu.org>
parents:
diff changeset
160
Dave Love <fx@gnu.org>
parents:
diff changeset
161 One further complication with the malloc'd space is that it
Dave Love <fx@gnu.org>
parents:
diff changeset
162 is partially empty and must be "consumed" so that data space
Dave Love <fx@gnu.org>
parents:
diff changeset
163 malloc'd in the future is not assigned to this region. The malloc
Dave Love <fx@gnu.org>
parents:
diff changeset
164 function distributed with Emacs anticipates this problem but the
Dave Love <fx@gnu.org>
parents:
diff changeset
165 AIX 3.1 version does not. Therefore, repeated malloc calls are
Dave Love <fx@gnu.org>
parents:
diff changeset
166 needed to exhaust this initial malloc space. How do you know
Dave Love <fx@gnu.org>
parents:
diff changeset
167 when malloc has exhausted its free memory? You don't! So the
Dave Love <fx@gnu.org>
parents:
diff changeset
168 code must repeatedly call malloc for each buffer size and
Dave Love <fx@gnu.org>
parents:
diff changeset
169 detect when a new memory page has been allocated. Once the new
Dave Love <fx@gnu.org>
parents:
diff changeset
170 memory page is allocated, you can calculate the number of free
Dave Love <fx@gnu.org>
parents:
diff changeset
171 buffers in that page and request exactly that many more. Future
Dave Love <fx@gnu.org>
parents:
diff changeset
172 malloc requests will now be added at the top of a new memory page.
Dave Love <fx@gnu.org>
parents:
diff changeset
173
Dave Love <fx@gnu.org>
parents:
diff changeset
174 One final point - the initial sbrk(0) is the value of sbrk(0)
Dave Love <fx@gnu.org>
parents:
diff changeset
175 after all of the above malloc hacking has been performed.
Dave Love <fx@gnu.org>
parents:
diff changeset
176
Dave Love <fx@gnu.org>
parents:
diff changeset
177
Dave Love <fx@gnu.org>
parents:
diff changeset
178 The following Emacs dump/load issues need to be addressed:
Dave Love <fx@gnu.org>
parents:
diff changeset
179
Dave Love <fx@gnu.org>
parents:
diff changeset
180 1) Loadup.el exits with an error message because the xemacs and
Dave Love <fx@gnu.org>
parents:
diff changeset
181 emacs-xxx files are not created during the dump function.
Dave Love <fx@gnu.org>
parents:
diff changeset
182
Dave Love <fx@gnu.org>
parents:
diff changeset
183 Loadup.el should be changed to check for the new .emacs.data
Dave Love <fx@gnu.org>
parents:
diff changeset
184 file.
Dave Love <fx@gnu.org>
parents:
diff changeset
185
Dave Love <fx@gnu.org>
parents:
diff changeset
186 2) Dump will only support one .emacs.data file for the entire
Dave Love <fx@gnu.org>
parents:
diff changeset
187 system. This precludes the ability to allow each user to
Dave Love <fx@gnu.org>
parents:
diff changeset
188 define his/her own "dumped" Emacs.
Dave Love <fx@gnu.org>
parents:
diff changeset
189
Dave Love <fx@gnu.org>
parents:
diff changeset
190 Add an environment symbol to override the default .emacs.data
Dave Love <fx@gnu.org>
parents:
diff changeset
191 path.
Dave Love <fx@gnu.org>
parents:
diff changeset
192
Dave Love <fx@gnu.org>
parents:
diff changeset
193 3) An error message "error in init file" is displayed out of
Dave Love <fx@gnu.org>
parents:
diff changeset
194 startup.el when the dumped Emacs is invoked by a non-root user.
Dave Love <fx@gnu.org>
parents:
diff changeset
195 Although all of the preloaded Lisp code is present, the important
Dave Love <fx@gnu.org>
parents:
diff changeset
196 purify-flag has not been set back to Qnil - precluding the
Dave Love <fx@gnu.org>
parents:
diff changeset
197 loading of any further Lisp code until the flag is manually
Dave Love <fx@gnu.org>
parents:
diff changeset
198 reset.
Dave Love <fx@gnu.org>
parents:
diff changeset
199
Dave Love <fx@gnu.org>
parents:
diff changeset
200 The problem appears to be an access violation which will go
Dave Love <fx@gnu.org>
parents:
diff changeset
201 away if the read-write access modes to all of the files are
Dave Love <fx@gnu.org>
parents:
diff changeset
202 changed to rw-.
Dave Love <fx@gnu.org>
parents:
diff changeset
203
Dave Love <fx@gnu.org>
parents:
diff changeset
204 4) In general, all file access modes should be changed from
Dave Love <fx@gnu.org>
parents:
diff changeset
205 rw-r--r-- to rw-rw-rw-. They are currently setup to match
Dave Love <fx@gnu.org>
parents:
diff changeset
206 standard AIX access modes.
Dave Love <fx@gnu.org>
parents:
diff changeset
207
Dave Love <fx@gnu.org>
parents:
diff changeset
208 5) The dump function is not invoked when the automatic load of
Dave Love <fx@gnu.org>
parents:
diff changeset
209 loadup.el is performed.
Dave Love <fx@gnu.org>
parents:
diff changeset
210
Dave Love <fx@gnu.org>
parents:
diff changeset
211 Perhaps the command arguments array should be expanded with
Dave Love <fx@gnu.org>
parents:
diff changeset
212 "dump" added to force an automatic dump.
Dave Love <fx@gnu.org>
parents:
diff changeset
213
Dave Love <fx@gnu.org>
parents:
diff changeset
214 6) The automatic initialization function alloc_shm will delete
Dave Love <fx@gnu.org>
parents:
diff changeset
215 the shared memory segment and .emacs.data file if the "dump"
Dave Love <fx@gnu.org>
parents:
diff changeset
216 command argument is found in ANY argument position. The
Dave Love <fx@gnu.org>
parents:
diff changeset
217 dump function will only take place in loadup.el if "dump"
Dave Love <fx@gnu.org>
parents:
diff changeset
218 is the third or fourth command argument.
Dave Love <fx@gnu.org>
parents:
diff changeset
219
Dave Love <fx@gnu.org>
parents:
diff changeset
220 Change alloc_shm to live by loadup.el rules.
Dave Love <fx@gnu.org>
parents:
diff changeset
221