| Copyright | (c) Galois Inc 2026 |
|---|---|
| Maintainer | Langston Barrett <langston@galois.com> |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Macaw.Memory.LLVMJumpTableSizes
Description
Read the .llvm_jump_table_sizes section emitted by Clang/LLVM (>= 20)
when compiled with -mllvm -emit-jump-table-sizes-section.
The section consists of a sequence of fixed-size entries; each entry is two target-pointer-sized words written in target endianness:
- the address of the jump table, and
- the number of basic-block targets in that jump table.
See SHT_LLVM_JT_SIZES in the LLVM ELF.h header and
https://llvm.org/docs/Extensions.html.
Synopsis
- sectionName :: ByteString
- newtype JumpTableSize (w :: Nat) = JumpTableSize {
- getJumpTableSize :: MemWord w
- data SectionSizeError = SectionSizeError Int Int
- newtype UnresolvableAddress (w :: Nat) = UnresolvableAddress (MemWord w)
- parseLLVMJumpTableSizes :: forall (w :: Natural). AddrWidthRepr w -> Endianness -> ByteString -> Either SectionSizeError [(MemWord w, JumpTableSize w)]
- llvmJumpTableSizesFromElf :: forall (w :: Nat). ElfHeaderInfo w -> Memory w -> Either SectionSizeError ([UnresolvableAddress w], Map (MemSegmentOff w) (JumpTableSize w))
Documentation
sectionName :: ByteString Source #
The ELF section name emitted by LLVM.
newtype JumpTableSize (w :: Nat) Source #
The number of basic-block targets (entries) in a jump table, as recorded
in a Clang/LLVM .llvm_jump_table_sizes section.
The type parameter w is the target address width.
Constructors
| JumpTableSize | |
Fields
| |
Instances
| Show (JumpTableSize w) Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes Methods showsPrec :: Int -> JumpTableSize w -> ShowS # show :: JumpTableSize w -> String # showList :: [JumpTableSize w] -> ShowS # | |
| Eq (JumpTableSize w) Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes Methods (==) :: JumpTableSize w -> JumpTableSize w -> Bool # (/=) :: JumpTableSize w -> JumpTableSize w -> Bool # | |
data SectionSizeError Source #
The section byte count was not a multiple of the entry size.
Constructors
| SectionSizeError | |
Instances
| Show SectionSizeError Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes Methods showsPrec :: Int -> SectionSizeError -> ShowS # show :: SectionSizeError -> String # showList :: [SectionSizeError] -> ShowS # | |
| Eq SectionSizeError Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes Methods (==) :: SectionSizeError -> SectionSizeError -> Bool # (/=) :: SectionSizeError -> SectionSizeError -> Bool # | |
| Pretty SectionSizeError Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes | |
newtype UnresolvableAddress (w :: Nat) Source #
An entry's jump-table address could not be resolved in the Memory.
Constructors
| UnresolvableAddress (MemWord w) |
Instances
| MemWidth w => Show (UnresolvableAddress w) Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes Methods showsPrec :: Int -> UnresolvableAddress w -> ShowS # show :: UnresolvableAddress w -> String # showList :: [UnresolvableAddress w] -> ShowS # | |
| Eq (UnresolvableAddress w) Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes Methods (==) :: UnresolvableAddress w -> UnresolvableAddress w -> Bool # (/=) :: UnresolvableAddress w -> UnresolvableAddress w -> Bool # | |
| MemWidth w => Pretty (UnresolvableAddress w) Source # | |
Defined in Data.Macaw.Memory.LLVMJumpTableSizes | |
parseLLVMJumpTableSizes :: forall (w :: Natural). AddrWidthRepr w -> Endianness -> ByteString -> Either SectionSizeError [(MemWord w, JumpTableSize w)] Source #
Parse the raw bytes of a .llvm_jump_table_sizes section.
Each entry is two pointer-sized words: (address, entry_count). The
bytestring length must be an exact multiple of 2 * pointer_size; otherwise
a Left is returned.
llvmJumpTableSizesFromElf :: forall (w :: Nat). ElfHeaderInfo w -> Memory w -> Either SectionSizeError ([UnresolvableAddress w], Map (MemSegmentOff w) (JumpTableSize w)) Source #
Read the .llvm_jump_table_sizes section out of an ELF binary, parse
it, and resolve each address against the provided Memory.
Returns a SectionSizeError if the section is malformed, otherwise a list
of per-entry warnings (one per unresolvable address) along with a map from
resolved jump-table base addresses to entry counts.
If the section is absent the result is Right ([], Map.empty).