@@ -793,40 +793,43 @@ macho_add_fat (struct backtrace_state *state, const char *filename,
793
793
794
794
for (i = 0 ; i < nfat_arch ; ++ i )
795
795
{
796
- struct macho_fat_arch_64 fat_arch ;
797
796
uint32_t fcputype ;
797
+ uint64_t foffset ;
798
798
799
799
if (is_64 )
800
- memcpy (& fat_arch ,
801
- (const char * ) arch_view .data + i * arch_size ,
802
- arch_size );
800
+ {
801
+ struct macho_fat_arch_64 fat_arch_64 ;
802
+
803
+ memcpy (& fat_arch_64 ,
804
+ (const char * ) arch_view .data + i * arch_size ,
805
+ arch_size );
806
+ fcputype = fat_arch_64 .cputype ;
807
+ foffset = fat_arch_64 .offset ;
808
+ if (swapped )
809
+ {
810
+ fcputype = __builtin_bswap32 (fcputype );
811
+ foffset = __builtin_bswap64 (foffset );
812
+ }
813
+ }
803
814
else
804
815
{
805
816
struct macho_fat_arch fat_arch_32 ;
806
817
807
818
memcpy (& fat_arch_32 ,
808
819
(const char * ) arch_view .data + i * arch_size ,
809
820
arch_size );
810
- fat_arch .cputype = fat_arch_32 .cputype ;
811
- fat_arch .cpusubtype = fat_arch_32 .cpusubtype ;
812
- fat_arch .offset = (uint64_t ) fat_arch_32 .offset ;
813
- fat_arch .size = (uint64_t ) fat_arch_32 .size ;
814
- fat_arch .align = fat_arch_32 .align ;
815
- fat_arch .reserved = 0 ;
821
+ fcputype = fat_arch_32 .cputype ;
822
+ foffset = (uint64_t ) fat_arch_32 .offset ;
823
+ if (swapped )
824
+ {
825
+ fcputype = __builtin_bswap32 (fcputype );
826
+ foffset = (uint64_t ) __builtin_bswap32 ((uint32_t ) foffset );
827
+ }
816
828
}
817
829
818
- fcputype = fat_arch .cputype ;
819
- if (swapped )
820
- fcputype = __builtin_bswap32 (fcputype );
821
-
822
830
if (fcputype == cputype )
823
831
{
824
- uint64_t foffset ;
825
-
826
832
/* FIXME: What about cpusubtype? */
827
- foffset = fat_arch .offset ;
828
- if (swapped )
829
- foffset = __builtin_bswap64 (foffset );
830
833
backtrace_release_view (state , & arch_view , error_callback , data );
831
834
return macho_add (state , filename , descriptor , foffset , match_uuid ,
832
835
base_address , skip_symtab , error_callback , data ,
0 commit comments