aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2009-05-06 02:27:51 +0000
committerYAMAMOTO Mitsuharu2009-05-06 02:27:51 +0000
commitbcda200f6a983541782e326144778db4096ba805 (patch)
tree07af4d5e11f67ac7fbc46265da35c3b218af16f5 /src
parentd01179d9077f640e41958cfec8b1691a28db3f50 (diff)
downloademacs-bcda200f6a983541782e326144778db4096ba805.tar.gz
emacs-bcda200f6a983541782e326144778db4096ba805.zip
(unexec): Consider a section to precede the .bss section
if its addresses overlap that of .bss. (unexec) [NS_IMPL_GNUSTEP]: Copy ObjC-related data from old file instead of dumping process.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog11
-rw-r--r--src/unexelf.c64
2 files changed, 68 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index b8e23d74d41..f68a937aa5e 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,14 @@
12009-05-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
2
3 * keyboard.h (add_user_signal): Fix typo in extern.
4
5 * lisp.h (add_user_signal): Remove extern.
6
7 * unexelf.c (unexec): Consider a section to precede the .bss section
8 if its addresses overlap that of .bss.
9 (unexec) [NS_IMPL_GNUSTEP]: Copy ObjC-related data from old file
10 instead of dumping process.
11
12009-05-06 Stefan Monnier <monnier@iro.umontreal.ca> 122009-05-06 Stefan Monnier <monnier@iro.umontreal.ca>
2 13
3 * keyboard.c (syms_of_keyboard): Staticpro pending_funcalls. 14 * keyboard.c (syms_of_keyboard): Staticpro pending_funcalls.
diff --git a/src/unexelf.c b/src/unexelf.c
index 83e57003759..45de52dffda 100644
--- a/src/unexelf.c
+++ b/src/unexelf.c
@@ -985,9 +985,29 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
985 placed after the .bss section. Overlap can occur if the 985 placed after the .bss section. Overlap can occur if the
986 section just before .bss has less-strict alignment; this 986 section just before .bss has less-strict alignment; this
987 was observed between .symtab and .bss on Solaris 2.5.1 987 was observed between .symtab and .bss on Solaris 2.5.1
988 (sparc) with GCC snapshot 960602. */ 988 (sparc) with GCC snapshot 960602.
989 989
990 if (NEW_SECTION_H (nn).sh_offset >= old_bss_offset) 990> dump -h temacs
991
992temacs:
993
994 **** SECTION HEADER TABLE ****
995[No] Type Flags Addr Offset Size Name
996 Link Info Adralgn Entsize
997
998[22] 1 3 0x335150 0x315150 0x4 .data.rel.local
999 0 0 0x4 0
1000
1001[23] 8 3 0x335158 0x315158 0x42720 .bss
1002 0 0 0x8 0
1003
1004[24] 2 0 0 0x315154 0x1c9d0 .symtab
1005 25 1709 0x4 0x10
1006 */
1007
1008 if (NEW_SECTION_H (nn).sh_offset >= old_bss_offset
1009 || (NEW_SECTION_H (nn).sh_offset + NEW_SECTION_H (nn).sh_size
1010 > new_data2_offset))
991 NEW_SECTION_H (nn).sh_offset += new_data2_incr; 1011 NEW_SECTION_H (nn).sh_offset += new_data2_incr;
992 1012
993 /* Any section that was originally placed after the section 1013 /* Any section that was originally placed after the section
@@ -1206,11 +1226,41 @@ unexec (new_name, old_name, data_start, bss_start, entry_address)
1206 symendp = (ElfW(Sym) *) ((byte *)symp + NEW_SECTION_H (n).sh_size); 1226 symendp = (ElfW(Sym) *) ((byte *)symp + NEW_SECTION_H (n).sh_size);
1207 1227
1208 for (; symp < symendp; symp ++) 1228 for (; symp < symendp; symp ++)
1209 if (strcmp ((char *) (symnames + symp->st_name), "_end") == 0 1229 {
1210 || strcmp ((char *) (symnames + symp->st_name), "end") == 0 1230 if (strcmp ((char *) (symnames + symp->st_name), "_end") == 0
1211 || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0 1231 || strcmp ((char *) (symnames + symp->st_name), "end") == 0
1212 || strcmp ((char *) (symnames + symp->st_name), "edata") == 0) 1232 || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0
1213 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr)); 1233 || strcmp ((char *) (symnames + symp->st_name), "edata") == 0)
1234 memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr));
1235
1236 /* Strictly speaking, #ifdef below is not necessary. But we
1237 keep it to indicate that this kind of change may also be
1238 necessary for other unexecs to support GNUstep. */
1239#ifdef NS_IMPL_GNUSTEP
1240 /* ObjC runtime modifies the values of some data structures
1241 such as classes and selectors in the .data section after
1242 loading. As the dump process copies the .data section
1243 from the current process, that causes problems when the
1244 modified classes are reinitialized in the dumped
1245 executable. We copy such data from the old file, not
1246 from the current process. */
1247 if (strncmp ((char *) (symnames + symp->st_name),
1248 "_OBJC_", sizeof ("_OBJC_") - 1) == 0)
1249 {
1250 caddr_t old, new;
1251
1252 new = ((symp->st_value - NEW_SECTION_H (symp->st_shndx).sh_addr)
1253 + NEW_SECTION_H (symp->st_shndx).sh_offset + new_base);
1254 /* "Unpatch" index. */
1255 nn = symp->st_shndx;
1256 if (nn > old_bss_index)
1257 nn--;
1258 old = ((symp->st_value - NEW_SECTION_H (symp->st_shndx).sh_addr)
1259 + OLD_SECTION_H (nn).sh_offset + old_base);
1260 memcpy (new, old, symp->st_size);
1261 }
1262#endif
1263 }
1214 } 1264 }
1215 1265
1216 /* This loop seeks out relocation sections for the data section, so 1266 /* This loop seeks out relocation sections for the data section, so