From b584835b9eb0794c62290ef8f922571c39b93d9d Mon Sep 17 00:00:00 2001 From: Ryan Scott Date: Tue, 7 Jan 2025 16:46:04 -0600 Subject: [PATCH] elfIsPie: Clarify Haddocks (especially around Permissions argument) Taking action on the suggestion in https://github.com/GaloisInc/elf-edit/pull/47#issuecomment-2576279513. --- src/Data/ElfEdit/Dynamic.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Data/ElfEdit/Dynamic.hs b/src/Data/ElfEdit/Dynamic.hs index dbfe7e0..6e46dea 100644 --- a/src/Data/ElfEdit/Dynamic.hs +++ b/src/Data/ElfEdit/Dynamic.hs @@ -907,7 +907,14 @@ dynamicEntries d cl dynamic = elfClassInstances cl $ runDynamicParser d cl $ do -- | Returns 'True' if the supplied 'ElfHeaderInfo' describes a -- position-independent executable (PIE). The approach used here is adapted from -- the source code for the @file@ binutils program, which was in turn summarized --- here: https://unix.stackexchange.com/a/435038 +-- here: https://unix.stackexchange.com/a/435038. In brief: +-- +-- * A dynamically linked executable is a PIE if it contains a certain value in +-- its DT_FLAGS_1 dynamic section entry, or (if it lacks the certain value) +-- the file has executable permissions. The file permission fallback is why +-- this function requires 'Permissions' as an argument. +-- +-- * Non-dynamically-linked executables are not PIEs. elfIsPie :: forall w. Permissions -> ElfHeaderInfo w -> Bool elfIsPie perms ehi = case headerType hdr of