mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/PartitionDxe: don't divide 64-bit values with C operators
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>
This commit is contained in:
parent
eb928b17c5
commit
b19aeeb91e
|
@ -243,6 +243,7 @@ PartitionInstallUdfChildHandles (
|
||||||
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UINT32 RemainderByMediaBlockSize;
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_BLOCK_IO_MEDIA *Media;
|
EFI_BLOCK_IO_MEDIA *Media;
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
|
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
|
||||||
|
@ -255,7 +256,12 @@ PartitionInstallUdfChildHandles (
|
||||||
//
|
//
|
||||||
// Check if UDF logical block size is multiple of underlying device block size
|
// Check if UDF logical block size is multiple of underlying device block size
|
||||||
//
|
//
|
||||||
if ((UDF_LOGICAL_SECTOR_SIZE % Media->BlockSize) != 0 ||
|
DivU64x32Remainder (
|
||||||
|
UDF_LOGICAL_SECTOR_SIZE, // Dividend
|
||||||
|
Media->BlockSize, // Divisor
|
||||||
|
&RemainderByMediaBlockSize // Remainder
|
||||||
|
);
|
||||||
|
if (RemainderByMediaBlockSize != 0 ||
|
||||||
Media->BlockSize > UDF_LOGICAL_SECTOR_SIZE) {
|
Media->BlockSize > UDF_LOGICAL_SECTOR_SIZE) {
|
||||||
return EFI_NOT_FOUND;
|
return EFI_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue