/[emacs]/emacs/src/unexmacosx.c
ViewVC logotype

Diff of /emacs/src/unexmacosx.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by akochoi, Fri Apr 26 23:39:05 2002 UTC revision 1.1.2.1 by miles, Fri Apr 4 06:21:03 2003 UTC
# Line 276  print_regions () Line 276  print_regions ()
276    
277        if (object_name != MACH_PORT_NULL)        if (object_name != MACH_PORT_NULL)
278          mach_port_deallocate (target_task, object_name);          mach_port_deallocate (target_task, object_name);
279          
280        address += size;        address += size;
281      }      }
282  }  }
# Line 329  build_region_list () Line 329  build_region_list ()
329        else        else
330          {          {
331            r = (struct region_t *) malloc (sizeof (struct region_t));            r = (struct region_t *) malloc (sizeof (struct region_t));
332              
333            if (!r)            if (!r)
334              unexec_error ("cannot allocate region structure");              unexec_error ("cannot allocate region structure");
335              
336            r->address = address;            r->address = address;
337            r->size = size;            r->size = size;
338            r->protection = info.protection;            r->protection = info.protection;
339            r->max_protection = info.max_protection;            r->max_protection = info.max_protection;
340              
341            r->next = 0;            r->next = 0;
342            if (region_list_head == 0)            if (region_list_head == 0)
343              {              {
# Line 349  build_region_list () Line 349  build_region_list ()
349                region_list_tail->next = r;                region_list_tail->next = r;
350                region_list_tail = r;                region_list_tail = r;
351              }              }
352              
353            /* Deallocate (unused) object name returned by            /* Deallocate (unused) object name returned by
354               vm_region.  */               vm_region.  */
355            if (object_name != MACH_PORT_NULL)            if (object_name != MACH_PORT_NULL)
356              mach_port_deallocate (target_task, object_name);              mach_port_deallocate (target_task, object_name);
357          }          }
358          
359        address += size;        address += size;
360      }      }
361    
# Line 498  read_load_commands () Line 498  read_load_commands ()
498    
499    nlc = mh.ncmds;    nlc = mh.ncmds;
500    lca = (struct load_command **) malloc (nlc * sizeof (struct load_command *));    lca = (struct load_command **) malloc (nlc * sizeof (struct load_command *));
501      
502    for (i = 0; i < nlc; i++)    for (i = 0; i < nlc; i++)
503      {      {
504        struct load_command lc;        struct load_command lc;
# Line 513  read_load_commands () Line 513  read_load_commands ()
513        if (lc.cmd == LC_SEGMENT)        if (lc.cmd == LC_SEGMENT)
514          {          {
515            struct segment_command *scp = (struct segment_command *) lca[i];            struct segment_command *scp = (struct segment_command *) lca[i];
516              
517            if (scp->vmaddr + scp->vmsize > infile_lc_highest_addr)            if (scp->vmaddr + scp->vmsize > infile_lc_highest_addr)
518              infile_lc_highest_addr = scp->vmaddr + scp->vmsize;              infile_lc_highest_addr = scp->vmaddr + scp->vmsize;
519    
# Line 638  copy_data_segment (struct load_command * Line 638  copy_data_segment (struct load_command *
638        else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0        else if (strncmp (sectp->sectname, "__la_symbol_ptr", 16) == 0
639                 || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0                 || strncmp (sectp->sectname, "__nl_symbol_ptr", 16) == 0
640                 || strncmp (sectp->sectname, "__dyld", 16) == 0                 || strncmp (sectp->sectname, "__dyld", 16) == 0
641                 || strncmp (sectp->sectname, "__const", 16) == 0)                 || strncmp (sectp->sectname, "__const", 16) == 0
642                   || strncmp (sectp->sectname, "__cfstring", 16) == 0)
643          {          {
644            if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))            if (!unexec_copy (sectp->offset, old_file_offset, sectp->size))
645              unexec_error ("cannot copy section %s", sectp->sectname);              unexec_error ("cannot copy section %s", sectp->sectname);
# Line 647  copy_data_segment (struct load_command * Line 648  copy_data_segment (struct load_command *
648          }          }
649        else        else
650          unexec_error ("unrecognized section name in __DATA segment");          unexec_error ("unrecognized section name in __DATA segment");
651          
652        printf ("        section %-16.16s at %#8x - %#8x (sz: %#8x)\n",        printf ("        section %-16.16s at %#8x - %#8x (sz: %#8x)\n",
653                sectp->sectname, sectp->offset, sectp->offset + sectp->size,                sectp->sectname, sectp->offset, sectp->offset + sectp->size,
654                sectp->size);                sectp->size);
# Line 675  copy_data_segment (struct load_command * Line 676  copy_data_segment (struct load_command *
676    for (j = 0; j < num_unexec_regions; j++)    for (j = 0; j < num_unexec_regions; j++)
677      {      {
678        struct segment_command sc;        struct segment_command sc;
679          
680        sc.cmd = LC_SEGMENT;        sc.cmd = LC_SEGMENT;
681        sc.cmdsize = sizeof (struct segment_command);        sc.cmdsize = sizeof (struct segment_command);
682        strncpy (sc.segname, SEG_DATA, 16);        strncpy (sc.segname, SEG_DATA, 16);
# Line 687  copy_data_segment (struct load_command * Line 688  copy_data_segment (struct load_command *
688        sc.initprot = VM_PROT_READ | VM_PROT_WRITE;        sc.initprot = VM_PROT_READ | VM_PROT_WRITE;
689        sc.nsects = 0;        sc.nsects = 0;
690        sc.flags = 0;        sc.flags = 0;
691          
692        printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n",        printf ("Writing segment %-16.16s at %#8x - %#8x (sz: %#8x)\n",
693                sc.segname, sc.fileoff, sc.fileoff + sc.filesize,                sc.segname, sc.fileoff, sc.fileoff + sc.filesize,
694                sc.filesize);                sc.filesize);
# Line 696  copy_data_segment (struct load_command * Line 697  copy_data_segment (struct load_command *
697          unexec_error ("cannot write new __DATA segment");          unexec_error ("cannot write new __DATA segment");
698        delta += sc.filesize;        delta += sc.filesize;
699        file_offset += sc.filesize;        file_offset += sc.filesize;
700          
701        if (!unexec_write (curr_header_offset, &sc, sc.cmdsize))        if (!unexec_write (curr_header_offset, &sc, sc.cmdsize))
702          unexec_error ("cannot write new __DATA segment's header");          unexec_error ("cannot write new __DATA segment's header");
703        curr_header_offset += sc.cmdsize;        curr_header_offset += sc.cmdsize;
# Line 753  copy_dysymtab (struct load_command *lc) Line 754  copy_dysymtab (struct load_command *lc)
754    curr_header_offset += lc->cmdsize;    curr_header_offset += lc->cmdsize;
755  }  }
756    
757    /* Copy a LC_TWOLEVEL_HINTS load command from the input file to the output
758       file, adjusting the file offset fields.  */
759    static void
760    copy_twolevelhints (struct load_command *lc)
761    {
762      struct twolevel_hints_command *tlhp = (struct twolevel_hints_command *) lc;
763    
764      if (tlhp->nhints > 0) {
765        tlhp->offset += delta;
766      }
767    
768      printf ("Writing LC_TWOLEVEL_HINTS command\n");
769    
770      if (!unexec_write (curr_header_offset, lc, lc->cmdsize))
771        unexec_error ("cannot write two level hint command to header");
772    
773      curr_header_offset += lc->cmdsize;
774    }
775    
776  /* Copy other kinds of load commands from the input file to the output  /* Copy other kinds of load commands from the input file to the output
777     file, ones that do not require adjustments of file offsets.  */     file, ones that do not require adjustments of file offsets.  */
778  static void  static void
# Line 799  dump_it () Line 819  dump_it ()
819        case LC_DYSYMTAB:        case LC_DYSYMTAB:
820          copy_dysymtab (lca[i]);          copy_dysymtab (lca[i]);
821          break;          break;
822          case LC_TWOLEVEL_HINTS:
823            copy_twolevelhints (lca[i]);
824            break;
825        default:        default:
826          copy_other (lca[i]);          copy_other (lca[i]);
827          break;          break;
# Line 828  unexec (char *outfile, char *infile, voi Line 851  unexec (char *outfile, char *infile, voi
851      {      {
852        unexec_error ("cannot open input file `%s'", infile);        unexec_error ("cannot open input file `%s'", infile);
853      }      }
854            
855    outfd = open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);    outfd = open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0755);
856    if (outfd < 0)    if (outfd < 0)
857      {      {
# Line 888  unexec_realloc (void *old_ptr, size_t ne Line 911  unexec_realloc (void *old_ptr, size_t ne
911          /* 2002-04-15 T. Ikegami <ikegami@adam.uprr.pr>.  The original          /* 2002-04-15 T. Ikegami <ikegami@adam.uprr.pr>.  The original
912             code to get size failed to reallocate read_buffer             code to get size failed to reallocate read_buffer
913             (lread.c).  */             (lread.c).  */
914          int old_size = emacs_zone->size (emacs_zone, old_ptr);          int old_size = malloc_default_zone()->size (emacs_zone, old_ptr);
915          int size = new_size > old_size ? old_size : new_size;          int size = new_size > old_size ? old_size : new_size;
916    
917          if (size)          if (size)

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26