diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/unexmacosx.c | 18 |
2 files changed, 22 insertions, 1 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index eac08d19da4..963179cb08f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-08-08 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | ||
| 2 | |||
| 3 | * unexmacosx.c (copy_data_segment): Copy initialized data in | ||
| 4 | statically linked libraries from input file rather than memory. | ||
| 5 | |||
| 1 | 2012-08-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 6 | 2012-08-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | 7 | ||
| 3 | * unexmacosx.c (print_load_command_name): Add cases LC_MAIN, | 8 | * unexmacosx.c (print_load_command_name): Add cases LC_MAIN, |
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) | |||
| 815 | file. */ | 815 | file. */ |
| 816 | if (strncmp (sectp->sectname, SECT_DATA, 16) == 0) | 816 | if (strncmp (sectp->sectname, SECT_DATA, 16) == 0) |
| 817 | { | 817 | { |
| 818 | if (!unexec_write (sectp->offset, (void *) sectp->addr, sectp->size)) | 818 | extern char my_edata[]; |
| 819 | unsigned long my_size; | ||
| 820 | |||
| 821 | /* The __data section is basically dumped from memory. But | ||
| 822 | initialized data in statically linked libraries are | ||
| 823 | copied from the input file. In particular, | ||
| 824 | add_image_hook.names and add_image_hook.pointers stored | ||
| 825 | by libarclite_macosx.a, are restored so that they will be | ||
| 826 | reinitialized when the dumped binary is executed. */ | ||
| 827 | my_size = (unsigned long)my_edata - sectp->addr; | ||
| 828 | if (!(sectp->addr <= (unsigned long)my_edata | ||
| 829 | && my_size <= sectp->size)) | ||
| 830 | unexec_error ("my_edata is not in section %s", SECT_DATA); | ||
| 831 | if (!unexec_write (sectp->offset, (void *) sectp->addr, my_size)) | ||
| 819 | unexec_error ("cannot write section %s", SECT_DATA); | 832 | unexec_error ("cannot write section %s", SECT_DATA); |
| 833 | if (!unexec_copy (sectp->offset + my_size, old_file_offset + my_size, | ||
| 834 | sectp->size - my_size)) | ||
| 835 | unexec_error ("cannot copy section %s", SECT_DATA); | ||
| 820 | if (!unexec_write (header_offset, sectp, sizeof (struct section))) | 836 | if (!unexec_write (header_offset, sectp, sizeof (struct section))) |
| 821 | unexec_error ("cannot write section %s's header", SECT_DATA); | 837 | unexec_error ("cannot write section %s's header", SECT_DATA); |
| 822 | } | 838 | } |