In edk2, the division and shifting of 64-bit values are forbidden with
C-language operators, because the compiler may generate intrinsic calls
for them.
For example, clang-3.8 emits a call to "__umoddi3" for
UDF_LOGICAL_SECTOR_SIZE % Media->BlockSize
in PartitionInstallUdfChildHandles(), if PartitionDxe is built for IA32,
which then fails to link.
UDF_LOGICAL_SECTOR_SIZE has type UINT64, while
EFI_BLOCK_IO_MEDIA.BlockSize has type UINT32(). Replace the % operator
with a DivU64x32Remainder() call.
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Paulo Alcantara <pcacjr@zytor.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Paulo Alcantara <pcacjr@zytor.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
)\r
{\r
+ UINT32 RemainderByMediaBlockSize;\r
EFI_STATUS Status;\r
EFI_BLOCK_IO_MEDIA *Media;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;\r
//\r
// Check if UDF logical block size is multiple of underlying device block size\r
//\r
- if ((UDF_LOGICAL_SECTOR_SIZE % Media->BlockSize) != 0 ||\r
+ DivU64x32Remainder (\r
+ UDF_LOGICAL_SECTOR_SIZE, // Dividend\r
+ Media->BlockSize, // Divisor\r
+ &RemainderByMediaBlockSize // Remainder\r
+ );\r
+ if (RemainderByMediaBlockSize != 0 ||\r
Media->BlockSize > UDF_LOGICAL_SECTOR_SIZE) {\r
return EFI_NOT_FOUND;\r
}\r