@@ -92,7 +92,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
92
92
#include "dwarf_object_detector.h"
93
93
#include "dwarf_macho_loader.h"
94
94
95
- #if 1
95
+ #if 0
96
96
static void
97
97
dump_bytes (const char * msg ,Dwarf_Small * start , long len )
98
98
{
@@ -142,6 +142,7 @@ static int _dwarf_macho_object_access_init(
142
142
unsigned ftype ,
143
143
unsigned endian ,
144
144
unsigned offsetsize ,
145
+ unsigned * universalbinary_count ,
145
146
Dwarf_Unsigned filesize ,
146
147
Dwarf_Obj_Access_Interface_a * * binary_interface ,
147
148
int * localerrnum );
@@ -327,12 +328,10 @@ load_macho_header32(dwarf_macho_object_access_internals_t *mfp,
327
328
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .flags ,mh32 .flags );
328
329
mfp -> mo_header .reserved = 0 ;
329
330
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__ );
331
331
if (mfp -> mo_command_count >= mfp -> mo_filesize ||
332
332
mfp -> mo_header .sizeofcmds >= mfp -> mo_filesize ||
333
333
mfp -> mo_command_count >= mfp -> mo_header .sizeofcmds ) {
334
334
* errcode = DW_DLE_MACHO_CORRUPT_HEADER ;
335
- printf ("dadebug DW_DLE_MACHO_CORRUPT_HEADER line %d\n" ,__LINE__ );
336
335
return DW_DLV_ERROR ;
337
336
}
338
337
@@ -358,35 +357,21 @@ load_macho_header64(dwarf_macho_object_access_internals_t *mfp,
358
357
if (res != DW_DLV_OK ) {
359
358
return res ;
360
359
}
361
- printf ("dadebug header64 RRMOA 0x%lx\n" ,(unsigned long )inner );
362
360
/* Do not adjust endianness of magic, leave as-is. */
363
- dump_bytes ("dadebug mh64 " ,(unsigned char * )& mh64 ,sizeof (mh64 ));
364
361
ASNAR (memcpy ,mfp -> mo_header .magic ,mh64 .magic );
365
362
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .cputype ,mh64 .cputype );
366
363
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .cpusubtype ,
367
364
mh64 .cpusubtype );
368
365
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .filetype ,mh64 .filetype );
369
366
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__ );
373
367
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .sizeofcmds ,
374
368
mh64 .sizeofcmds );
375
- printf ("dadebug command count 0x%lx line %d\n" ,(unsigned long )mfp -> mo_header .sizeofcmds ,__LINE__ );
376
369
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .flags ,mh64 .flags );
377
370
ASNAR (mfp -> mo_copy_word ,mfp -> mo_header .reserved ,mh64 .reserved );
378
371
mfp -> mo_command_count = (unsigned int )mfp -> mo_header .ncmds ;
379
372
if (mfp -> mo_command_count >= mfp -> mo_filesize ||
380
373
mfp -> mo_header .sizeofcmds >= mfp -> mo_filesize ||
381
374
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__ );
390
375
* errcode = DW_DLE_MACHO_CORRUPT_HEADER ;
391
376
return DW_DLV_ERROR ;
392
377
}
@@ -890,11 +875,14 @@ _dwarf_macho_setup(int fd,
890
875
dwarf_macho_object_access_internals_t * intfc = 0 ;
891
876
int res = DW_DLV_OK ;
892
877
int localerrnum = 0 ;
878
+ unsigned universalbinary_count = 0 ;
893
879
894
880
res = _dwarf_macho_object_access_init (
895
881
fd ,
896
882
universalnumber ,
897
- ftype ,endian ,offsetsize ,filesize ,
883
+ ftype ,endian ,offsetsize ,
884
+ & universalbinary_count ,
885
+ filesize ,
898
886
& binary_interface ,
899
887
& localerrnum );
900
888
if (res != DW_DLV_OK ) {
@@ -914,6 +902,8 @@ _dwarf_macho_setup(int fd,
914
902
}
915
903
intfc = binary_interface -> ai_object ;
916
904
intfc -> mo_path = strdup (true_path );
905
+ (* dbg )-> de_universalbinary_index = universalnumber ;
906
+ (* dbg )-> de_universalbinary_count = universalbinary_count ;
917
907
return res ;
918
908
}
919
909
@@ -955,7 +945,6 @@ _dwarf_macho_inner_object_fd(int fd,
955
945
Dwarf_Unsigned innerbase = 0 ;
956
946
Dwarf_Unsigned innersize = 0 ;
957
947
958
- printf ("dadebug fd %d line %d\n" ,fd ,__LINE__ );
959
948
res = _dwarf_object_detector_universal_head_fd (
960
949
fd , outer_filesize , unibinarycount ,
961
950
& head , errcode );
@@ -1009,6 +998,7 @@ _dwarf_macho_object_access_internals_init(
1009
998
unsigned ftype ,
1010
999
unsigned endian ,
1011
1000
unsigned offsetsize ,
1001
+ unsigned * unibinarycount ,
1012
1002
Dwarf_Unsigned filesize ,
1013
1003
int * errcode )
1014
1004
{
@@ -1045,6 +1035,7 @@ _dwarf_macho_object_access_internals_init(
1045
1035
}
1046
1036
return res ;
1047
1037
}
1038
+ * unibinarycount = unibinarycounti ;
1048
1039
endian = endiani ;
1049
1040
}
1050
1041
@@ -1055,7 +1046,6 @@ _dwarf_macho_object_access_internals_init(
1055
1046
intfc -> mo_fd = fd ;
1056
1047
intfc -> mo_offsetsize = offsetsizei ;
1057
1048
intfc -> mo_pointersize = offsetsizei ;
1058
- printf ("dadebug inner offset now 0x%lx\n" ,(unsigned long )fileoffseti );
1059
1049
intfc -> mo_inner_offset = fileoffseti ;
1060
1050
intfc -> mo_filesize = filesizei ;
1061
1051
intfc -> mo_ftype = ftypei ;
@@ -1074,11 +1064,9 @@ printf("dadebug inner offset now 0x%lx\n",(unsigned long)fileoffseti);
1074
1064
if (endian == DW_END_little ) {
1075
1065
intfc -> mo_copy_word = _dwarf_memcpy_noswap_bytes ;
1076
1066
intfc -> mo_endian = DW_END_little ;
1077
- printf ("dadebug endian %lu line %d\n" ,(unsigned long )endian ,__LINE__ );
1078
1067
} else {
1079
1068
intfc -> mo_copy_word = _dwarf_memcpy_swap_bytes ;
1080
1069
intfc -> mo_endian = DW_END_big ;
1081
- printf ("dadebug endian %lu line %d\n" ,(unsigned long )endian ,__LINE__ );
1082
1070
}
1083
1071
#endif /* LITTLE- BIG-ENDIAN */
1084
1072
res = _dwarf_load_macho_header (intfc ,errcode );
@@ -1103,7 +1091,6 @@ printf("dadebug endian %lu line %d\n",(unsigned long)endian,__LINE__);
1103
1091
count better be zero. */
1104
1092
if (intfc -> mo_dwarf_sectioncount ) {
1105
1093
_dwarf_destruct_macho_access (localdoas );
1106
- printf ("dadebug DW_DLE_MACHO_CORRUPT_HEADER line %d\n" ,__LINE__ );
1107
1094
* errcode = DW_DLE_MACHO_CORRUPT_HEADER ;
1108
1095
return DW_DLV_ERROR ;
1109
1096
}
@@ -1130,6 +1117,7 @@ _dwarf_macho_object_access_init(
1130
1117
unsigned ftype ,
1131
1118
unsigned endian ,
1132
1119
unsigned offsetsize ,
1120
+ unsigned * universalbinary_count ,
1133
1121
Dwarf_Unsigned filesize ,
1134
1122
Dwarf_Obj_Access_Interface_a * * binary_interface ,
1135
1123
int * localerrnum )
@@ -1150,7 +1138,9 @@ _dwarf_macho_object_access_init(
1150
1138
res = _dwarf_macho_object_access_internals_init (internals ,
1151
1139
fd ,
1152
1140
uninumber ,
1153
- ftype , endian , offsetsize , filesize ,
1141
+ ftype , endian , offsetsize ,
1142
+ universalbinary_count ,
1143
+ filesize ,
1154
1144
localerrnum );
1155
1145
if (res != DW_DLV_OK ){
1156
1146
/* *err is already set and the call freed internals. */
@@ -1290,16 +1280,12 @@ printf("Reading magic number universal compare failed " "Inconsistent\n");
1290
1280
ASNAR (word_swap ,duhd .au_count ,fh .nfat_arch );
1291
1281
/* The limit is a first-cut safe heuristic. */
1292
1282
if (duhd .au_count >= (dw_filesize /2 ) ) {
1293
- printf ("dadebug Universal Binary header count impossible: 0x%lx \n" ,
1294
- (unsigned long ) duhd .au_count );
1295
1283
* errcode = DW_DLE_UNIVERSAL_BINARY_ERROR ;
1296
1284
return DW_DLV_ERROR ;
1297
1285
}
1298
1286
duhd .au_arches = (struct Dwarf_Universal_Arch_s * )
1299
1287
calloc (duhd .au_count , sizeof (struct Dwarf_Universal_Arch_s ));
1300
1288
if (!duhd .au_arches ) {
1301
- printf ("dadebug Universal Binary au_arches alloc fail line %d\n" ,
1302
- __LINE__ );
1303
1289
* errcode = DW_DLE_ALLOC_FAIL ;
1304
1290
return DW_DLV_ERROR ;
1305
1291
}
@@ -1308,8 +1294,6 @@ printf("dadebug Universal Binary au_arches alloc fail line %d\n",
1308
1294
fa = (struct fat_arch * )calloc (duhd .au_count ,
1309
1295
sizeof (struct fat_arch ));
1310
1296
if (!fa ) {
1311
- printf ("dadebug Universal Binary au_arches alloc fail line %d\n" ,
1312
- __LINE__ );
1313
1297
* errcode = DW_DLE_ALLOC_FAIL ;
1314
1298
free (duhd .au_arches );
1315
1299
duhd .au_arches = 0 ;
@@ -1320,8 +1304,6 @@ printf("dadebug Universal Binary au_arches alloc fail line %d\n",
1320
1304
duhd .au_count * sizeof (* fa ),
1321
1305
dw_filesize ,errcode );
1322
1306
if (res != DW_DLV_OK ) {
1323
- printf ("dadebug Universal Binary value read fail line %d\n" ,
1324
- __LINE__ );
1325
1307
free (duhd .au_arches );
1326
1308
duhd .au_arches = 0 ;
1327
1309
free (fa );
@@ -1330,8 +1312,6 @@ __LINE__);
1330
1312
res = fill_in_uni_arch_32 (fa ,& duhd ,word_swap );
1331
1313
if (res != DW_DLV_OK ) {
1332
1314
free (duhd .au_arches );
1333
- printf ("dadebug Universal Binary value read fail line %d\n" ,
1334
- __LINE__ );
1335
1315
duhd .au_arches = 0 ;
1336
1316
free (fa );
1337
1317
return res ;
@@ -1343,8 +1323,6 @@ __LINE__);
1343
1323
fa = (struct fat_arch_64 * )calloc (duhd .au_count ,
1344
1324
sizeof (struct fat_arch ));
1345
1325
if (!fa ) {
1346
- printf ("dadebug Universal Binary au_arches alloc fail line %d\n" ,
1347
- __LINE__ );
1348
1326
* errcode = DW_DLE_ALLOC_FAIL ;
1349
1327
free (duhd .au_arches );
1350
1328
duhd .au_arches = 0 ;
@@ -1354,7 +1332,6 @@ __LINE__);
1354
1332
duhd .au_count * sizeof (fa ),
1355
1333
dw_filesize ,errcode );
1356
1334
if (res == DW_DLV_ERROR ) {
1357
- printf ("dadebug Universal Binary value read fail line %d\n" , __LINE__ );
1358
1335
free (duhd .au_arches );
1359
1336
duhd .au_arches = 0 ;
1360
1337
free (fa );
0 commit comments