diff options
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2012-08-08 14:44:53 +0900 |
---|---|---|
committer | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 2012-08-08 14:44:53 +0900 |
commit | 8ccd072a2cf1216165ee9d6c641ff1982a240cfe (patch) | |
tree | 3e3365ba31ee8d66a670a634d76b234f3b0ffbc7 /src/unexmacosx.c | |
parent | bf1757d19ad6aa119568050d4ab133c008e31897 (diff) | |
download | emacs-8ccd072a2cf1216165ee9d6c641ff1982a240cfe.tar.gz |
* unexmacosx.c (copy_data_segment): Copy initialized data in statically linked libraries from input file rather than memory.
Diffstat (limited to 'src/unexmacosx.c')
-rw-r--r-- | src/unexmacosx.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/unexmacosx.c b/src/unexmacosx.c index 8661ee4be1b..b2b7c5f8e90 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -815,8 +815,24 @@ copy_data_segment (struct load_command *lc) file. */ if (strncmp (sectp->sectname, SECT_DATA, 16) == 0) { - if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size)) + extern char my_edata[]; + unsigned long my_size; + + /* The __data section is basically dumped from memory. But + initialized data in statically linked libraries are + copied from the input file. In particular, + add_image_hook.names and add_image_hook.pointers stored + by libarclite_macosx.a, are restored so that they will be + reinitialized when the dumped binary is executed. */ + my_size = (unsigned long)my_edata - sectp->addr; + if (!(sectp->addr <= (unsigned long)my_edata + && my_size <= sectp->size)) + unexec_error ("my_edata is not in section %s", SECT_DATA); + if (!unexec_write (sectp->offset, (void *) sectp->addr, my_size)) unexec_error ("cannot write section %s", SECT_DATA); + if (!unexec_copy (sectp->offset + my_size, old_file_offset + my_size, + sectp->size - my_size)) + unexec_error ("cannot copy section %s", SECT_DATA); if (!unexec_write (header_offset, sectp, sizeof (struct section))) unexec_error ("cannot write section %s's header", SECT_DATA); } |