| | 1 | --- src/unexmacosx.c 2009/01/08 03:16:02 1.29 |
| | 2 | +++ src/unexmacosx.c 2009/08/28 22:49:46 1.30 |
| | 3 | @@ -582,6 +582,14 @@ |
| | 4 | printf ("LC_UUID "); |
| | 5 | break; |
| | 6 | #endif |
| | 7 | +#ifdef LC_DYLD_INFO |
| | 8 | + case LC_DYLD_INFO: |
| | 9 | + printf ("LC_DYLD_INFO "); |
| | 10 | + break; |
| | 11 | + case LC_DYLD_INFO_ONLY: |
| | 12 | + printf ("LC_DYLD_INFO_ONLY"); |
| | 13 | + break; |
| | 14 | +#endif |
| | 15 | default: |
| | 16 | printf ("unknown "); |
| | 17 | } |
| | 18 | @@ -819,6 +827,7 @@ |
| | 19 | || strncmp (sectp->sectname, "__const", 16) == 0 |
| | 20 | || strncmp (sectp->sectname, "__cfstring", 16) == 0 |
| | 21 | || strncmp (sectp->sectname, "__gcc_except_tab", 16) == 0 |
| | 22 | + || strncmp (sectp->sectname, "__program_vars", 16) == 0 |
| | 23 | || strncmp (sectp->sectname, "__objc_", 7) == 0) |
| | 24 | { |
| | 25 | if (!unexec_copy (sectp->offset, old_file_offset, sectp->size)) |
| | 26 | @@ -1086,6 +1095,36 @@ |
| | 27 | curr_header_offset += lc->cmdsize; |
| | 28 | } |
| | 29 | |
| | 30 | +#ifdef LC_DYLD_INFO |
| | 31 | +/* Copy a LC_DYLD_INFO(_ONLY) load command from the input file to the output |
| | 32 | + file, adjusting the file offset fields. */ |
| | 33 | +static void |
| | 34 | +copy_dyld_info (struct load_command *lc, long delta) |
| | 35 | +{ |
| | 36 | + struct dyld_info_command *dip = (struct dyld_info_command *) lc; |
| | 37 | + |
| | 38 | + if (dip->rebase_off > 0) |
| | 39 | + dip->rebase_off += delta; |
| | 40 | + if (dip->bind_off > 0) |
| | 41 | + dip->bind_off += delta; |
| | 42 | + if (dip->weak_bind_off > 0) |
| | 43 | + dip->weak_bind_off += delta; |
| | 44 | + if (dip->lazy_bind_off > 0) |
| | 45 | + dip->lazy_bind_off += delta; |
| | 46 | + if (dip->export_off > 0) |
| | 47 | + dip->export_off += delta; |
| | 48 | + |
| | 49 | + printf ("Writing "); |
| | 50 | + print_load_command_name (lc->cmd); |
| | 51 | + printf (" command\n"); |
| | 52 | + |
| | 53 | + if (!unexec_write (curr_header_offset, lc, lc->cmdsize)) |
| | 54 | + unexec_error ("cannot write dyld info command to header"); |
| | 55 | + |
| | 56 | + curr_header_offset += lc->cmdsize; |
| | 57 | +} |
| | 58 | +#endif |
| | 59 | + |
| | 60 | /* Copy other kinds of load commands from the input file to the output |
| | 61 | file, ones that do not require adjustments of file offsets. */ |
| | 62 | static void |
| | 63 | @@ -1152,6 +1191,12 @@ |
| | 64 | case LC_TWOLEVEL_HINTS: |
| | 65 | copy_twolevelhints (lca[i], linkedit_delta); |
| | 66 | break; |
| | 67 | +#ifdef LC_DYLD_INFO |
| | 68 | + case LC_DYLD_INFO: |
| | 69 | + case LC_DYLD_INFO_ONLY: |
| | 70 | + copy_dyld_info (lca[i], linkedit_delta); |
| | 71 | + break; |
| | 72 | +#endif |
| | 73 | default: |
| | 74 | copy_other (lca[i]); |
| | 75 | break; |
| | 76 | |