MdePkg/UeImage: Fix chained UE reloc member order

This commit is contained in:
Marvin Häuser 2023-07-06 21:42:49 +02:00 committed by MikhailKrichanov
parent 9a98ee1c1b
commit 98d76ebdf6
2 changed files with 15 additions and 16 deletions

View File

@ -429,8 +429,8 @@ ToolImageEmitUeRelocTable (
ChainInProgress = ChainSupported && RelocOffset <= UE_CHAINED_RELOC_FIXUP_MAX_OFFSET; ChainInProgress = ChainSupported && RelocOffset <= UE_CHAINED_RELOC_FIXUP_MAX_OFFSET;
if (ChainInProgress) { if (ChainInProgress) {
PrevChainRelocInfo = RelocOffset; PrevChainRelocInfo = RelocType;
PrevChainRelocInfo |= RelocType << 12U; PrevChainRelocInfo |= RelocOffset << 4U;
PrevChainRelocInfo |= PrevRelocValue << 16U; PrevChainRelocInfo |= PrevRelocValue << 16U;
assert (UE_CHAINED_RELOC_FIXUP_NEXT_OFFSET (PrevChainRelocInfo) == RelocOffset); assert (UE_CHAINED_RELOC_FIXUP_NEXT_OFFSET (PrevChainRelocInfo) == RelocOffset);
assert (UE_CHAINED_RELOC_FIXUP_NEXT_TYPE (PrevChainRelocInfo) == RelocType); assert (UE_CHAINED_RELOC_FIXUP_NEXT_TYPE (PrevChainRelocInfo) == RelocType);
@ -448,7 +448,7 @@ ToolImageEmitUeRelocTable (
} }
if (ChainSupported) { if (ChainSupported) {
ChainRelocInfo = UE_CHAINED_RELOC_FIXUP_OFFSET_END; ChainRelocInfo = UE_CHAINED_RELOC_FIXUP_OFFSET_END << 4U;
ChainRelocInfo |= RelocValue << 16U; ChainRelocInfo |= RelocValue << 16U;
if ((ChainRelocInfo >> 16U) != RelocValue) { if ((ChainRelocInfo >> 16U) != RelocValue) {
DEBUG_RAISE (); DEBUG_RAISE ();

View File

@ -205,8 +205,8 @@ STATIC_ASSERT (
/// ///
typedef struct { typedef struct {
/// ///
/// The offset of the first head fixup, in bytes, from the previous UE /// The offset of the first head fixup, in bytes, from the end of the previous
/// relocation fixup (chained or not). The first UE fixup root is /// UE relocation fixup (chained or not). The first UE fixup root is
/// relative to 0. /// relative to 0.
/// ///
UINT32 FirstOffset; UINT32 FirstOffset;
@ -214,8 +214,8 @@ typedef struct {
/// The head fixups of the UE fixup root. /// The head fixups of the UE fixup root.
/// ///
/// [Bits 3:0] The type of the UE relocation fixup. /// [Bits 3:0] The type of the UE relocation fixup.
/// [Bits 15:4] The offset of the next UE head fixup from the last UE /// [Bits 15:4] The offset of the next UE head fixup from the end of the last
/// relocation fixup in the chain (if chained). If 0x0FFF, the /// UE relocation fixup in the chain (if chained). If 0x0FFF, the
/// current fixup root is terminated. /// current fixup root is terminated.
/// ///
UINT16 Heads[]; UINT16 Heads[];
@ -267,8 +267,8 @@ STATIC_ASSERT (
@param[in] FixupInfo The UE relocation fixup information. @param[in] FixupInfo The UE relocation fixup information.
**/ **/
#define UE_CHAINED_RELOC_FIXUP_NEXT_OFFSET(FixupInfo) \ #define UE_CHAINED_RELOC_FIXUP_NEXT_OFFSET(FixupInfo) \
((UINT16)(FixupInfo) & 0x0FFFU) ((UINT16)((UINT16)(FixupInfo) >> 4U) & 0x0FFFU)
/// ///
/// The maximum offset, in bytes, of the next UE chained relocation fixup. /// The maximum offset, in bytes, of the next UE chained relocation fixup.
@ -286,7 +286,7 @@ STATIC_ASSERT (
@param[in] FixupInfo The UE relocation fixup information. @param[in] FixupInfo The UE relocation fixup information.
**/ **/
#define UE_CHAINED_RELOC_FIXUP_NEXT_TYPE(FixupInfo) \ #define UE_CHAINED_RELOC_FIXUP_NEXT_TYPE(FixupInfo) \
((UINT8)(((UINT16)(FixupInfo) >> 12U) & 0x0FU)) ((UINT8)((UINT16)(FixupInfo) & 0x0FU))
/// ///
/// The shift exponent for UE chained relocation fixup values. /// The shift exponent for UE chained relocation fixup values.
@ -304,12 +304,11 @@ STATIC_ASSERT (
/// ///
/// Definition of the common header of UE chained relocation fixups. /// Definition of the common header of UE chained relocation fixups.
/// ///
/// [Bits 11:0] The offset to the next chained relocation fixup, from the end /// [Bits 3:0] The relocation type of the next chained relocation fixup. Only
/// of the current chained relocation fixup. If 0x0FFF, the current /// valid when [Bits 15:4] are not 0x0FFF.
/// chain is terminated. Consult the fixup root for further /// [Bits 15:4] The offset to the next chained relocation fixup from the end
/// relocation fixups. /// of the current one. If 0x0FFF, the current chain is terminated.
/// [Bits 15:12] The relocation type of the next chained relocation fixup. Only /// Consult the fixup root for further relocation fixups.
/// valid when [Bits 11:0] are non-0.
/// ///
typedef UINT16 UE_RELOC_FIXUP_HDR; typedef UINT16 UE_RELOC_FIXUP_HDR;