@@ -92,7 +92,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9292#include "dwarf_object_detector.h"
9393#include "dwarf_macho_loader.h"
9494
95- #if 1
95+ #if 0
9696static void
9797dump_bytes (const char * msg ,Dwarf_Small * start , long len )
9898{
@@ -142,6 +142,7 @@ static int _dwarf_macho_object_access_init(
142142 unsigned ftype ,
143143 unsigned endian ,
144144 unsigned offsetsize ,
145+ unsigned * universalbinary_count ,
145146 Dwarf_Unsigned filesize ,
146147 Dwarf_Obj_Access_Interface_a * * binary_interface ,
147148 int * localerrnum );
@@ -327,12 +328,10 @@ load_macho_header32(dwarf_macho_object_access_internals_t *mfp,
327328 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .flags ,mh32 .flags );
328329 mfp -> mo_header .reserved = 0 ;
329330 mfp -> mo_command_count = (unsigned int )mfp -> mo_header .ncmds ;
330- printf ("dadebug command count 0x%lx line %d\n" ,(unsigned long )mfp -> mo_header .ncmds ,__LINE__ );
331331 if (mfp -> mo_command_count >= mfp -> mo_filesize ||
332332 mfp -> mo_header .sizeofcmds >= mfp -> mo_filesize ||
333333 mfp -> mo_command_count >= mfp -> mo_header .sizeofcmds ) {
334334 * errcode = DW_DLE_MACHO_CORRUPT_HEADER ;
335- printf ("dadebug DW_DLE_MACHO_CORRUPT_HEADER line %d\n" ,__LINE__ );
336335 return DW_DLV_ERROR ;
337336 }
338337
@@ -358,35 +357,21 @@ load_macho_header64(dwarf_macho_object_access_internals_t *mfp,
358357 if (res != DW_DLV_OK ) {
359358 return res ;
360359 }
361- printf ("dadebug header64 RRMOA 0x%lx\n" ,(unsigned long )inner );
362360 /* Do not adjust endianness of magic, leave as-is. */
363- dump_bytes ("dadebug mh64 " ,(unsigned char * )& mh64 ,sizeof (mh64 ));
364361 ASNAR (memcpy ,mfp -> mo_header .magic ,mh64 .magic );
365362 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .cputype ,mh64 .cputype );
366363 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .cpusubtype ,
367364 mh64 .cpusubtype );
368365 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .filetype ,mh64 .filetype );
369366 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .ncmds ,mh64 .ncmds );
370- printf ("dadeug wordcpy addr 0x%lx\n" ,(unsigned long )mfp -> mo_copy_word );
371- printf ("dadeug std wordcpy addr 0x%lx\n" ,(unsigned long )_dwarf_memcpy_swap_bytes );
372- printf ("dadebug command count 0x%lx line %d\n" ,(unsigned long )mfp -> mo_header .ncmds ,__LINE__ );
373367 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .sizeofcmds ,
374368 mh64 .sizeofcmds );
375- printf ("dadebug command count 0x%lx line %d\n" ,(unsigned long )mfp -> mo_header .sizeofcmds ,__LINE__ );
376369 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .flags ,mh64 .flags );
377370 ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .reserved ,mh64 .reserved );
378371 mfp -> mo_command_count = (unsigned int )mfp -> mo_header .ncmds ;
379372 if (mfp -> mo_command_count >= mfp -> mo_filesize ||
380373 mfp -> mo_header .sizeofcmds >= mfp -> mo_filesize ||
381374 mfp -> mo_command_count >= mfp -> mo_header .sizeofcmds ) {
382- printf ("dadebug "
383- " comm count 0x%lx "
384- " filesize 0x%lx "
385- " sizeofcmds 0x%lx \n" ,
386- (unsigned long )mfp -> mo_command_count ,
387- (unsigned long )mfp -> mo_filesize ,
388- (unsigned long )mfp -> mo_header .sizeofcmds );
389- printf ("dadebug DW_DLE_MACHO_CORRUPT_HEADER line %d\n" ,__LINE__ );
390375 * errcode = DW_DLE_MACHO_CORRUPT_HEADER ;
391376 return DW_DLV_ERROR ;
392377 }
@@ -890,11 +875,14 @@ _dwarf_macho_setup(int fd,
890875 dwarf_macho_object_access_internals_t * intfc = 0 ;
891876 int res = DW_DLV_OK ;
892877 int localerrnum = 0 ;
878+ unsigned universalbinary_count = 0 ;
893879
894880 res = _dwarf_macho_object_access_init (
895881 fd ,
896882 universalnumber ,
897- ftype ,endian ,offsetsize ,filesize ,
883+ ftype ,endian ,offsetsize ,
884+ & universalbinary_count ,
885+ filesize ,
898886 & binary_interface ,
899887 & localerrnum );
900888 if (res != DW_DLV_OK ) {
@@ -914,6 +902,8 @@ _dwarf_macho_setup(int fd,
914902 }
915903 intfc = binary_interface -> ai_object ;
916904 intfc -> mo_path = strdup (true_path );
905+ (* dbg )-> de_universalbinary_index = universalnumber ;
906+ (* dbg )-> de_universalbinary_count = universalbinary_count ;
917907 return res ;
918908}
919909
@@ -955,7 +945,6 @@ _dwarf_macho_inner_object_fd(int fd,
955945 Dwarf_Unsigned innerbase = 0 ;
956946 Dwarf_Unsigned innersize = 0 ;
957947
958- printf ("dadebug fd %d line %d\n" ,fd ,__LINE__ );
959948 res = _dwarf_object_detector_universal_head_fd (
960949 fd , outer_filesize , unibinarycount ,
961950 & head , errcode );
@@ -1009,6 +998,7 @@ _dwarf_macho_object_access_internals_init(
1009998 unsigned ftype ,
1010999 unsigned endian ,
10111000 unsigned offsetsize ,
1001+ unsigned * unibinarycount ,
10121002 Dwarf_Unsigned filesize ,
10131003 int * errcode )
10141004{
@@ -1045,6 +1035,7 @@ _dwarf_macho_object_access_internals_init(
10451035 }
10461036 return res ;
10471037 }
1038+ * unibinarycount = unibinarycounti ;
10481039 endian = endiani ;
10491040 }
10501041
@@ -1055,7 +1046,6 @@ _dwarf_macho_object_access_internals_init(
10551046 intfc -> mo_fd = fd ;
10561047 intfc -> mo_offsetsize = offsetsizei ;
10571048 intfc -> mo_pointersize = offsetsizei ;
1058- printf ("dadebug inner offset now 0x%lx\n" ,(unsigned long )fileoffseti );
10591049 intfc -> mo_inner_offset = fileoffseti ;
10601050 intfc -> mo_filesize = filesizei ;
10611051 intfc -> mo_ftype = ftypei ;
@@ -1074,11 +1064,9 @@ printf("dadebug inner offset now 0x%lx\n",(unsigned long)fileoffseti);
10741064 if (endian == DW_END_little ) {
10751065 intfc -> mo_copy_word = _dwarf_memcpy_noswap_bytes ;
10761066 intfc -> mo_endian = DW_END_little ;
1077- printf ("dadebug endian %lu line %d\n" ,(unsigned long )endian ,__LINE__ );
10781067 } else {
10791068 intfc -> mo_copy_word = _dwarf_memcpy_swap_bytes ;
10801069 intfc -> mo_endian = DW_END_big ;
1081- printf ("dadebug endian %lu line %d\n" ,(unsigned long )endian ,__LINE__ );
10821070 }
10831071#endif /* LITTLE- BIG-ENDIAN */
10841072 res = _dwarf_load_macho_header (intfc ,errcode );
@@ -1103,7 +1091,6 @@ printf("dadebug endian %lu line %d\n",(unsigned long)endian,__LINE__);
11031091 count better be zero. */
11041092 if (intfc -> mo_dwarf_sectioncount ) {
11051093 _dwarf_destruct_macho_access (localdoas );
1106- printf ("dadebug DW_DLE_MACHO_CORRUPT_HEADER line %d\n" ,__LINE__ );
11071094 * errcode = DW_DLE_MACHO_CORRUPT_HEADER ;
11081095 return DW_DLV_ERROR ;
11091096 }
@@ -1130,6 +1117,7 @@ _dwarf_macho_object_access_init(
11301117 unsigned ftype ,
11311118 unsigned endian ,
11321119 unsigned offsetsize ,
1120+ unsigned * universalbinary_count ,
11331121 Dwarf_Unsigned filesize ,
11341122 Dwarf_Obj_Access_Interface_a * * binary_interface ,
11351123 int * localerrnum )
@@ -1150,7 +1138,9 @@ _dwarf_macho_object_access_init(
11501138 res = _dwarf_macho_object_access_internals_init (internals ,
11511139 fd ,
11521140 uninumber ,
1153- ftype , endian , offsetsize , filesize ,
1141+ ftype , endian , offsetsize ,
1142+ universalbinary_count ,
1143+ filesize ,
11541144 localerrnum );
11551145 if (res != DW_DLV_OK ){
11561146 /* *err is already set and the call freed internals. */
@@ -1290,16 +1280,12 @@ printf("Reading magic number universal compare failed " "Inconsistent\n");
12901280 ASNAR (word_swap ,duhd .au_count ,fh .nfat_arch );
12911281 /* The limit is a first-cut safe heuristic. */
12921282 if (duhd .au_count >= (dw_filesize /2 ) ) {
1293- printf ("dadebug Universal Binary header count impossible: 0x%lx \n" ,
1294- (unsigned long ) duhd .au_count );
12951283 * errcode = DW_DLE_UNIVERSAL_BINARY_ERROR ;
12961284 return DW_DLV_ERROR ;
12971285 }
12981286 duhd .au_arches = (struct Dwarf_Universal_Arch_s * )
12991287 calloc (duhd .au_count , sizeof (struct Dwarf_Universal_Arch_s ));
13001288 if (!duhd .au_arches ) {
1301- printf ("dadebug Universal Binary au_arches alloc fail line %d\n" ,
1302- __LINE__ );
13031289 * errcode = DW_DLE_ALLOC_FAIL ;
13041290 return DW_DLV_ERROR ;
13051291 }
@@ -1308,8 +1294,6 @@ printf("dadebug Universal Binary au_arches alloc fail line %d\n",
13081294 fa = (struct fat_arch * )calloc (duhd .au_count ,
13091295 sizeof (struct fat_arch ));
13101296 if (!fa ) {
1311- printf ("dadebug Universal Binary au_arches alloc fail line %d\n" ,
1312- __LINE__ );
13131297 * errcode = DW_DLE_ALLOC_FAIL ;
13141298 free (duhd .au_arches );
13151299 duhd .au_arches = 0 ;
@@ -1320,8 +1304,6 @@ printf("dadebug Universal Binary au_arches alloc fail line %d\n",
13201304 duhd .au_count * sizeof (* fa ),
13211305 dw_filesize ,errcode );
13221306 if (res != DW_DLV_OK ) {
1323- printf ("dadebug Universal Binary value read fail line %d\n" ,
1324- __LINE__ );
13251307 free (duhd .au_arches );
13261308 duhd .au_arches = 0 ;
13271309 free (fa );
@@ -1330,8 +1312,6 @@ __LINE__);
13301312 res = fill_in_uni_arch_32 (fa ,& duhd ,word_swap );
13311313 if (res != DW_DLV_OK ) {
13321314 free (duhd .au_arches );
1333- printf ("dadebug Universal Binary value read fail line %d\n" ,
1334- __LINE__ );
13351315 duhd .au_arches = 0 ;
13361316 free (fa );
13371317 return res ;
@@ -1343,8 +1323,6 @@ __LINE__);
13431323 fa = (struct fat_arch_64 * )calloc (duhd .au_count ,
13441324 sizeof (struct fat_arch ));
13451325 if (!fa ) {
1346- printf ("dadebug Universal Binary au_arches alloc fail line %d\n" ,
1347- __LINE__ );
13481326 * errcode = DW_DLE_ALLOC_FAIL ;
13491327 free (duhd .au_arches );
13501328 duhd .au_arches = 0 ;
@@ -1354,7 +1332,6 @@ __LINE__);
13541332 duhd .au_count * sizeof (fa ),
13551333 dw_filesize ,errcode );
13561334 if (res == DW_DLV_ERROR ) {
1357- printf ("dadebug Universal Binary value read fail line %d\n" , __LINE__ );
13581335 free (duhd .au_arches );
13591336 duhd .au_arches = 0 ;
13601337 free (fa );
0 commit comments