[82809] branches/gsoc11-post-destroot/base/src/pextlib1.0

fotanus at macports.org fotanus at macports.org
Sat Aug 20 16:43:34 PDT 2011


Revision: 82809
          http://trac.macports.org/changeset/82809
Author:   fotanus at macports.org
Date:     2011-08-20 16:43:32 -0700 (Sat, 20 Aug 2011)
Log Message:
-----------
fix bug on list_dlibs

Modified Paths:
--------------
    branches/gsoc11-post-destroot/base/src/pextlib1.0/macho.c
    branches/gsoc11-post-destroot/base/src/pextlib1.0/tests/macho.tcl

Modified: branches/gsoc11-post-destroot/base/src/pextlib1.0/macho.c
===================================================================
--- branches/gsoc11-post-destroot/base/src/pextlib1.0/macho.c	2011-08-20 23:38:27 UTC (rev 82808)
+++ branches/gsoc11-post-destroot/base/src/pextlib1.0/macho.c	2011-08-20 23:43:32 UTC (rev 82809)
@@ -85,14 +85,13 @@
  */
 
 Tcl_Obj * check_magic(const uint32_t magic, macho_input_t **input, bool * universal, uint32_t (**swap32)(uint32_t), const struct mach_header ** header, const struct fat_header ** fat_header, size_t * header_size){
+	const struct mach_header_64 *header64;
 	switch (magic) {
 		case MH_CIGAM:
-		case MH_CIGAM_64:
 			*swap32 = macho_swap32;
 			/* Fall-through */
 
 		case MH_MAGIC:
-		case MH_MAGIC_64:
 			*header_size = sizeof(**header);
 			*header = macho_read(*input, (*input)->data, *header_size);
 			if (*header == NULL) {
@@ -100,6 +99,20 @@
 			}
 			break;
 
+		case MH_CIGAM_64:
+			*swap32 = macho_swap32;
+			/* Fall-through */
+
+		case MH_MAGIC_64:
+			*header_size = sizeof(*header64);
+			header64 = macho_read(*input, (*input)->data, sizeof(*header64));
+			if (header64 == NULL)
+				return (Tcl_Obj *)TCL_ERROR;
+
+			/* The 64-bit header is a direct superset of the 32-bit header */
+			*header = (struct mach_header *) header64;
+			break;
+
 		case FAT_CIGAM:
 		case FAT_MAGIC:
 			*fat_header = macho_read(*input, (*input)->data, sizeof(**fat_header));
@@ -136,7 +149,6 @@
 	if (magic == NULL)
 		return (Tcl_Obj *)TCL_ERROR;
 
-
 	/* Check file header magic */
 	if(check_magic(*magic, &input, &universal, &swap32, &header, &fat_header, &header_size) == (Tcl_Obj *)TCL_ERROR){
 		return (Tcl_Obj *)TCL_ERROR;
@@ -152,8 +164,9 @@
 
 	/* Parse the Mach-O load commands */
 	cmd = macho_offset(input, header, header_size, sizeof(struct load_command));
-	if (cmd == NULL)
+	if (cmd == NULL){
 		return (Tcl_Obj *)TCL_ERROR;
+	}
 	ncmds = swap32(header->ncmds);
 
 	/* Iterate over the load commands */
@@ -238,7 +251,6 @@
  */
 Tcl_Obj * list_macho_archs_l(macho_input_t *input, Tcl_Interp *interp, Tcl_Obj * archs_list) {
 	const struct mach_header *header;
-	const struct mach_header_64 *header64;
 	size_t header_size;
 	const NXArchInfo *archInfo;
 	const struct fat_header *fat_header;

Modified: branches/gsoc11-post-destroot/base/src/pextlib1.0/tests/macho.tcl
===================================================================
--- branches/gsoc11-post-destroot/base/src/pextlib1.0/tests/macho.tcl	2011-08-20 23:38:27 UTC (rev 82808)
+++ branches/gsoc11-post-destroot/base/src/pextlib1.0/tests/macho.tcl	2011-08-20 23:43:32 UTC (rev 82809)
@@ -2,6 +2,7 @@
 	load $pextlibname
 
 	set test_file /bin/sh
+	#set test_file /opt/local/lib/libevent_pthreads-2.0.5.dylib
 	set archs [list_archs $test_file]
 	set libs [list_dlibs $test_file]
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20110820/1f576619/attachment.html>


More information about the macports-changes mailing list