@@ -680,23 +680,30 @@ getArchitecture(uint16_t *pCPU, uint16_t *pBits, UBool *pIsBigEndian, const char
680
680
*pBits=32 ;
681
681
*pIsBigEndian=(UBool)(U_IS_BIG_ENDIAN ? ELFDATA2MSB : ELFDATA2LSB);
682
682
#elif U_PLATFORM_HAS_WIN32_API
683
- /* _M_IA64 should be defined in windows.h */
684
- # if defined(_M_IA64)
685
- *pCPU=IMAGE_FILE_MACHINE_IA64;
686
- *pBits = 64 ;
687
- # elif defined(_M_AMD64)
688
- // link.exe does not really care about the .obj machine type and this will
689
- // allow us to build a dll for both ARM & x64 with an amd64 built tool
690
- // ARM is same as x64 except for first 2 bytes of object file
691
- *pCPU = IMAGE_FILE_MACHINE_UNKNOWN;
692
- // *pCPU = IMAGE_FILE_MACHINE_ARMNT; // If we wanted to be explicit
693
- // *pCPU = IMAGE_FILE_MACHINE_AMD64; // We would use one of these names
694
- *pBits = 64 ; // Doesn't seem to be used for anything interesting?
683
+ // Windows always runs in little-endian mode.
684
+ *pIsBigEndian = FALSE ;
685
+
686
+ // Note: The various _M_<arch> macros are predefined by the MSVC compiler based
687
+ // on the target compilation architecture.
688
+ // https://docs.microsoft.com/cpp/preprocessor/predefined-macros
689
+
690
+ // link.exe will link an IMAGE_FILE_MACHINE_UNKNOWN data-only .obj file
691
+ // no matter what architecture it is targeting (though other values are
692
+ // required to match). Unfortunately, the variable name decoration/mangling
693
+ // is slightly different on x86, which means we can't use the UNKNOWN type
694
+ // for all architectures though.
695
+ # if defined(_M_IX86)
696
+ *pCPU = IMAGE_FILE_MACHINE_I386;
695
697
# else
696
- *pCPU=IMAGE_FILE_MACHINE_I386; // We would use one of these names
698
+ *pCPU = IMAGE_FILE_MACHINE_UNKNOWN;
699
+ # endif
700
+ # if defined(_M_IA64) || defined(_M_AMD64) || defined (_M_ARM64)
701
+ *pBits = 64 ; // Doesn't seem to be used for anything interesting though?
702
+ # elif defined(_M_IX86) || defined(_M_ARM)
697
703
*pBits = 32 ;
704
+ # else
705
+ # error "Unknown platform for CAN_GENERATE_OBJECTS."
698
706
# endif
699
- *pIsBigEndian=FALSE ;
700
707
#else
701
708
# error "Unknown platform for CAN_GENERATE_OBJECTS."
702
709
#endif
0 commit comments