Safe Haskell | None |
---|---|
Language | Haskell2010 |
Data.Macaw.Memory.ElfLoader.DynamicDependencies
Description
Functionality for computing the names and addresses of PLT stub functions in a dynamically linked ELF binary.
Note that the API in this library is somewhat experimental, and as we further
develop the underlying approach (see Note [Dynamic lookup scope]
), we may
need to change the API accordingly.
Synopsis
- loadDynamicDependencies :: forall (w :: Nat). ElfMachine -> ElfClass w -> FilePath -> ElfHeaderInfo w -> FilePath -> IO [(ElfHeaderInfo w, FilePath)]
- parseDynNeeded :: forall (w :: Nat). ElfHeaderInfo w -> FilePath -> Maybe (Either DynamicLoadingError [ByteString])
- data DynamicLoadingError where
- NonElfBinaryFormat :: FilePath -> DynamicLoadingError
- ElfDynamicParseError :: FilePath -> DynamicError -> DynamicLoadingError
- ElfDynamicNeededError :: FilePath -> String -> DynamicLoadingError
- ElfVirtualAddressMapError :: FilePath -> DynamicLoadingError
- ElfMultipleDynamicHeaders :: FilePath -> DynamicLoadingError
- ElfNonDynamicSharedLib :: FilePath -> DynamicLoadingError
- SoMismatchedElfMachine :: ElfMachine -> ElfMachine -> DynamicLoadingError
- SoMismatchedElfClass :: forall (w :: Nat) (w' :: Nat). ElfClass w -> ElfClass w' -> DynamicLoadingError
Documentation
loadDynamicDependencies Source #
Arguments
:: forall (w :: Nat). ElfMachine | The architecture of the main binary (x86-64, AArch32, etc.) |
-> ElfClass w | Whether the main binary is 32-bit or 64-bit |
-> FilePath | The directory in which the shared libraries live |
-> ElfHeaderInfo w | The main binary's ELF header info |
-> FilePath | The main binary's path |
-> IO [(ElfHeaderInfo w, FilePath)] | The shared libraries in order of global lookup scope, paired with their file paths |
Given a binary, load all of the shared libraries that it transitively
depends on, returning the order in which they were encountered in a
breadth-first search. Returning them in this order is important since we
rely on the assumption that the binaries are in the same order as the global
lookup scope. See Note [Dynamic lookup scope]
.
This function makes a couple of simplifying assumptions about how shared libraries work that are not true in general:
- All of the shared libraries that the main binary depends on are located in a single directory.
- None of the binaries use
dlopen
, which can load additional shared libraries at runtime.
Arguments
:: forall (w :: Nat). ElfHeaderInfo w | |
-> FilePath | The path to the ELF file |
-> Maybe (Either DynamicLoadingError [ByteString]) |
Get values of DT_NEEDED
entries in an ELF file. If this is not a dynamic
executable, then Nothing
is returned.
data DynamicLoadingError where Source #
Constructors
NonElfBinaryFormat :: FilePath -> DynamicLoadingError | Encountered a non-ELF binary format, which is not supported. |
ElfDynamicParseError :: FilePath -> DynamicError -> DynamicLoadingError | Encountered an error when parsing a dynamic section in an ELF binary. |
ElfDynamicNeededError :: FilePath -> String -> DynamicLoadingError | Encountered an error when parsing the |
ElfVirtualAddressMapError :: FilePath -> DynamicLoadingError | Could not constuct a virtual address map for an ELF binary. |
ElfMultipleDynamicHeaders :: FilePath -> DynamicLoadingError | Encountered multiple |
ElfNonDynamicSharedLib :: FilePath -> DynamicLoadingError | Encountered a shared library that is not dynamically linked. |
SoMismatchedElfMachine :: ElfMachine -> ElfMachine -> DynamicLoadingError | A provided shared object had a different ELF machine value than the main
binary. The first argument is the |
SoMismatchedElfClass :: forall (w :: Nat) (w' :: Nat). ElfClass w -> ElfClass w' -> DynamicLoadingError | A provided shared object had a different ELF class value than the main
binary. The first argument is the |
Instances
Exception DynamicLoadingError Source # | |
Defined in Data.Macaw.Memory.ElfLoader.DynamicDependencies Methods toException :: DynamicLoadingError -> SomeException # fromException :: SomeException -> Maybe DynamicLoadingError # | |
Show DynamicLoadingError Source # | |
Defined in Data.Macaw.Memory.ElfLoader.DynamicDependencies Methods showsPrec :: Int -> DynamicLoadingError -> ShowS # show :: DynamicLoadingError -> String # showList :: [DynamicLoadingError] -> ShowS # | |
Pretty DynamicLoadingError Source # | |