macaw-base
Copyright(c) Galois Inc 2026
MaintainerLangston Barrett <langston@galois.com>
Safe HaskellNone
LanguageHaskell2010

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

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 

Instances

Instances details
Show (JumpTableSize w) Source # 
Instance details

Defined in Data.Macaw.Memory.LLVMJumpTableSizes

Eq (JumpTableSize w) Source # 
Instance details

Defined in Data.Macaw.Memory.LLVMJumpTableSizes

data SectionSizeError Source #

The section byte count was not a multiple of the entry size.

Constructors

SectionSizeError 

Fields

  • Int

    actual section size in bytes

  • Int

    required entry size in bytes

newtype UnresolvableAddress (w :: Nat) Source #

An entry's jump-table address could not be resolved in the Memory.

Constructors

UnresolvableAddress (MemWord w) 

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).