diff options
author | Laszlo Ersek <lersek@redhat.com> | 2017-09-10 00:23:42 +0200 |
---|---|---|
committer | Laszlo Ersek <lersek@redhat.com> | 2017-09-12 12:12:29 +0200 |
commit | b19aeeb91e3c548a7f42828f4d474e23ae6b59b8 (patch) | |
tree | d8bebb28c04d0121402f4f22bf62c9e8b8770af7 | |
parent | eb928b17c5c4a3918ba1d16aed5fbd797e69e75e (diff) | |
download | edk2-b19aeeb91e3c548a7f42828f4d474e23ae6b59b8.tar.gz edk2-b19aeeb91e3c548a7f42828f4d474e23ae6b59b8.tar.bz2 edk2-b19aeeb91e3c548a7f42828f4d474e23ae6b59b8.zip |
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>
-rw-r--r-- | MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c index 3174ab2b4b..e46cf1d4f4 100644 --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Udf.c @@ -243,6 +243,7 @@ PartitionInstallUdfChildHandles ( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
)
{
+ UINT32 RemainderByMediaBlockSize;
EFI_STATUS Status;
EFI_BLOCK_IO_MEDIA *Media;
EFI_DEVICE_PATH_PROTOCOL *DevicePathNode;
@@ -255,7 +256,12 @@ PartitionInstallUdfChildHandles ( //
// 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) {
return EFI_NOT_FOUND;
}
|