diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2022-08-30 23:07:28 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2022-08-30 23:07:28 +0200 |
| commit | d3eaabd2855f21d0c7cf4a4e1fe52dfc50a2b07f (patch) | |
| tree | 5a98d161ad4ff1f00c9302514d773576185156b7 /lib/std | |
| parent | f559ea95b1c37fd6ede8fff6ffb2d74d5c2abc4e (diff) | |
| download | zig-d3eaabd2855f21d0c7cf4a4e1fe52dfc50a2b07f.tar.gz zig-d3eaabd2855f21d0c7cf4a4e1fe52dfc50a2b07f.zip | |
coff: add base relocation related types
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/coff.zig | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/std/coff.zig b/lib/std/coff.zig index e822416f70..1caec57c4a 100644 --- a/lib/std/coff.zig +++ b/lib/std/coff.zig @@ -310,6 +310,84 @@ pub const ImageDataDirectory = extern struct { size: u32, }; +pub const BaseRelocationDirectoryEntry = extern struct { + /// The image base plus the page RVA is added to each offset to create the VA where the base relocation must be applied. + page_rva: u32, + + /// The total number of bytes in the base relocation block, including the Page RVA and Block Size fields and the Type/Offset fields that follow. + block_size: u32, +}; + +pub const BaseRelocation = packed struct { + /// Stored in the remaining 12 bits of the WORD, an offset from the starting address that was specified in the Page RVA field for the block. + /// This offset specifies where the base relocation is to be applied. + offset: u12, + + /// Stored in the high 4 bits of the WORD, a value that indicates the type of base relocation to be applied. + @"type": BaseRelocationType, +}; + +pub const BaseRelocationType = enum(u4) { + /// The base relocation is skipped. This type can be used to pad a block. + ABSOLUTE = 0, + + /// The base relocation adds the high 16 bits of the difference to the 16-bit field at offset. The 16-bit field represents the high value of a 32-bit word. + HIGH = 1, + + /// The base relocation adds the low 16 bits of the difference to the 16-bit field at offset. The 16-bit field represents the low half of a 32-bit word. + LOW = 2, + + /// The base relocation applies all 32 bits of the difference to the 32-bit field at offset. + HIGHLOW = 3, + + /// The base relocation adds the high 16 bits of the difference to the 16-bit field at offset. + /// The 16-bit field represents the high value of a 32-bit word. + /// The low 16 bits of the 32-bit value are stored in the 16-bit word that follows this base relocation. + /// This means that this base relocation occupies two slots. + HIGHADJ = 4, + + /// When the machine type is MIPS, the base relocation applies to a MIPS jump instruction. + MIPS_JMPADDR = 5, + + /// This relocation is meaningful only when the machine type is ARM or Thumb. + /// The base relocation applies the 32-bit address of a symbol across a consecutive MOVW/MOVT instruction pair. + // ARM_MOV32 = 5, + + /// This relocation is only meaningful when the machine type is RISC-V. + /// The base relocation applies to the high 20 bits of a 32-bit absolute address. + // RISCV_HIGH20 = 5, + + /// Reserved, must be zero. + RESERVED = 6, + + /// This relocation is meaningful only when the machine type is Thumb. + /// The base relocation applies the 32-bit address of a symbol to a consecutive MOVW/MOVT instruction pair. + THUMB_MOV32 = 7, + + /// This relocation is only meaningful when the machine type is RISC-V. + /// The base relocation applies to the low 12 bits of a 32-bit absolute address formed in RISC-V I-type instruction format. + // RISCV_LOW12I = 7, + + /// This relocation is only meaningful when the machine type is RISC-V. + /// The base relocation applies to the low 12 bits of a 32-bit absolute address formed in RISC-V S-type instruction format. + RISCV_LOW12S = 8, + + /// This relocation is only meaningful when the machine type is LoongArch 32-bit. + /// The base relocation applies to a 32-bit absolute address formed in two consecutive instructions. + // LOONGARCH32_MARK_LA = 8, + + /// This relocation is only meaningful when the machine type is LoongArch 64-bit. + /// The base relocation applies to a 64-bit absolute address formed in four consecutive instructions. + // LOONGARCH64_MARK_LA = 8, + + /// The relocation is only meaningful when the machine type is MIPS. + /// The base relocation applies to a MIPS16 jump instruction. + MIPS_JMPADDR16 = 9, + + /// The base relocation applies the difference to the 64-bit field at offset. + DIR64 = 10, +}; + pub const DebugDirectoryEntry = extern struct { characteristics: u32, time_date_stamp: u32, |
