elf

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DF_BIND_NOW = 0x8
	DF_1_NOW    = 0x1
)
View Source
const (
	GNU_PROPERTY_X86_FEATURE_1_AND   = 0xc0000002
	GNU_PROPERTY_X86_FEATURE_1_IBT   = 0x1
	GNU_PROPERTY_X86_FEATURE_1_SHSTK = 0x2
)

GNU Property constants for x86

View Source
const (
	GNU_PROPERTY_AARCH64_FEATURE_1_AND = 0xc0000000
	GNU_PROPERTY_AARCH64_FEATURE_1_BTI = 0x1
	GNU_PROPERTY_AARCH64_FEATURE_1_PAC = 0x2
)

GNU Property constants for AArch64

View Source
const ARMBTIRuleID = "arm-bti"
View Source
const ARMBranchProtectionRuleID = "arm-branch-protection"
View Source
const ARMMTERuleID = "arm-mte"
View Source
const ARMPACRuleID = "arm-pac"
View Source
const ASANRuleID = "asan"
View Source
const ASLRRuleID = "aslr"
View Source
const CFIRuleID = "cfi"
View Source
const DF_1_PIE = 0x08000000
View Source
const FortifySourceRuleID = "fortify-source"
View Source
const FullRELRORuleID = "full-relro"
View Source
const NXBitRuleID = "nx-bit"
View Source
const NoDLOpenRuleID = "no-dlopen"
View Source
const NoDumpRuleID = "no-dump"
View Source
const NoInsecureRPATHRuleID = "no-insecure-rpath"
View Source
const NoInsecureRUNPATHRuleID = "no-insecure-runpath"
View Source
const PIERuleID = "pie"
View Source
const RELRORuleID = "relro"
View Source
const SafeStackRuleID = "safe-stack"
View Source
const SeparateCodeRuleID = "separate-code"
View Source
const StackCanaryRuleID = "stack-canary"
View Source
const StackLimitRuleID = "stack-limit"
View Source
const StrippedRuleID = "stripped"
View Source
const UBSanRuleID = "ubsan"
View Source
const WXorXRuleID = "wxorx"
View Source
const X86CETIBTRuleID = "x86-cet-ibt"
View Source
const X86CETShadowStackRuleID = "x86-cet-shstk"
View Source
const X86RetpolineRuleID = "x86-retpoline"

Variables

This section is empty.

Functions

func GetDynString

func GetDynString(f *elf.File, tag elf.DynTag) string

func HasDynFlag

func HasDynFlag(f *elf.File, tag elf.DynTag, flag uint64) bool

func HasDynTag

func HasDynTag(f *elf.File, tag elf.DynTag) bool

func RegisterRules

func RegisterRules()

Types

type ARMBTIRule

type ARMBTIRule struct{}

ARMBTIRule checks for ARM Branch Target Identification

func (ARMBTIRule) Applicability

func (r ARMBTIRule) Applicability() rule.Applicability

func (ARMBTIRule) Execute

func (r ARMBTIRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (ARMBTIRule) ID

func (r ARMBTIRule) ID() string

func (ARMBTIRule) Name

func (r ARMBTIRule) Name() string

type ARMBranchProtectionRule

type ARMBranchProtectionRule struct{}

ARMBranchProtectionRule checks for ARM branch protection (PAC+BTI) ARM: https://developer.arm.com/documentation/ddi0487/latest GCC: https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mbranch-protection Clang: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbranch-protection

func (ARMBranchProtectionRule) Applicability

func (r ARMBranchProtectionRule) Applicability() rule.Applicability

func (ARMBranchProtectionRule) Execute

func (ARMBranchProtectionRule) ID

func (ARMBranchProtectionRule) Name

type ARMMTERule

type ARMMTERule struct{}

ARMMTERule checks for ARM Memory Tagging Extension ARM: https://developer.arm.com/documentation/ddi0487/latest LLVM: https://llvm.org/docs/MemTagSanitizer.html

func (ARMMTERule) Applicability

func (r ARMMTERule) Applicability() rule.Applicability

func (ARMMTERule) Execute

func (r ARMMTERule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (ARMMTERule) ID

func (r ARMMTERule) ID() string

func (ARMMTERule) Name

func (r ARMMTERule) Name() string

type ARMPACRule

type ARMPACRule struct{}

ARMPACRule checks for ARM Pointer Authentication Code ARM: https://developer.arm.com/documentation/ddi0487/latest GCC: https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html#index-mbranch-protection Clang: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mbranch-protection

func (ARMPACRule) Applicability

func (r ARMPACRule) Applicability() rule.Applicability

func (ARMPACRule) Execute

func (r ARMPACRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (ARMPACRule) ID

func (r ARMPACRule) ID() string

func (ARMPACRule) Name

func (r ARMPACRule) Name() string

type ASANRule

type ASANRule struct{}

ASANRule checks for AddressSanitizer instrumentation Clang: https://clang.llvm.org/docs/AddressSanitizer.html GCC: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fsanitize=address

func (ASANRule) Applicability

func (r ASANRule) Applicability() rule.Applicability

func (ASANRule) Execute

func (r ASANRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (ASANRule) ID

func (r ASANRule) ID() string

func (ASANRule) Name

func (r ASANRule) Name() string

type ASLRRule

type ASLRRule struct{}

ASLRRule checks if binary is ASLR compatible Linux Kernel: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/sysctl/kernel.rst

func (ASLRRule) Applicability

func (r ASLRRule) Applicability() rule.Applicability

func (ASLRRule) Execute

func (r ASLRRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (ASLRRule) ID

func (r ASLRRule) ID() string

func (ASLRRule) Name

func (r ASLRRule) Name() string

type CFIRule

type CFIRule struct{}

CFIRule checks for Clang Control Flow Integrity https://clang.llvm.org/docs/ControlFlowIntegrity.html

func (CFIRule) Applicability

func (r CFIRule) Applicability() rule.Applicability

func (CFIRule) Execute

func (r CFIRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (CFIRule) ID

func (r CFIRule) ID() string

func (CFIRule) Name

func (r CFIRule) Name() string

type DynEntry

type DynEntry struct {
	Tag uint64
	Val uint64
}

func ParseDynamic

func ParseDynamic(f *elf.File) []DynEntry

type FortifySourceRule

type FortifySourceRule struct{}

FortifySourceRule checks for FORTIFY_SOURCE protection glibc: https://sourceware.org/glibc/wiki/FortifySourceLevel3 GCC: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-D_FORTIFY_SOURCE

func (FortifySourceRule) Applicability

func (r FortifySourceRule) Applicability() rule.Applicability

func (FortifySourceRule) Execute

func (FortifySourceRule) ID

func (r FortifySourceRule) ID() string

func (FortifySourceRule) Name

func (r FortifySourceRule) Name() string

type FullRELRORule

type FullRELRORule struct{}

FullRELRORule checks for full RELRO protection ld: https://sourceware.org/binutils/docs/ld/Options.html

func (FullRELRORule) Applicability

func (r FullRELRORule) Applicability() rule.Applicability

func (FullRELRORule) Execute

func (FullRELRORule) ID

func (r FullRELRORule) ID() string

func (FullRELRORule) Name

func (r FullRELRORule) Name() string

type NXBitRule

type NXBitRule struct{}

NXBitRule checks for non-executable stack GCC: https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#index-z

func (NXBitRule) Applicability

func (r NXBitRule) Applicability() rule.Applicability

func (NXBitRule) Execute

func (r NXBitRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (NXBitRule) ID

func (r NXBitRule) ID() string

func (NXBitRule) Name

func (r NXBitRule) Name() string

type NoDLOpenRule

type NoDLOpenRule struct{}

NoDLOpenRule checks if dlopen is disabled ld: https://sourceware.org/binutils/docs/ld/Options.html#index-z-keyword

func (NoDLOpenRule) Applicability

func (r NoDLOpenRule) Applicability() rule.Applicability

func (NoDLOpenRule) Execute

func (NoDLOpenRule) ID

func (r NoDLOpenRule) ID() string

func (NoDLOpenRule) Name

func (r NoDLOpenRule) Name() string

type NoDumpRule

type NoDumpRule struct{}

NoDumpRule checks if core dumps are disabled ld: https://sourceware.org/binutils/docs/ld/Options.html#index-z-keyword

func (NoDumpRule) Applicability

func (r NoDumpRule) Applicability() rule.Applicability

func (NoDumpRule) Execute

func (r NoDumpRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (NoDumpRule) ID

func (r NoDumpRule) ID() string

func (NoDumpRule) Name

func (r NoDumpRule) Name() string

type NoInsecureRPATHRule

type NoInsecureRPATHRule struct{}

NoInsecureRPATHRule checks for insecure RPATH values ld: https://sourceware.org/binutils/docs/ld/Options.html

func (NoInsecureRPATHRule) Applicability

func (r NoInsecureRPATHRule) Applicability() rule.Applicability

func (NoInsecureRPATHRule) Execute

func (NoInsecureRPATHRule) ID

func (r NoInsecureRPATHRule) ID() string

func (NoInsecureRPATHRule) Name

func (r NoInsecureRPATHRule) Name() string

type NoInsecureRUNPATHRule

type NoInsecureRUNPATHRule struct{}

NoInsecureRUNPATHRule checks for insecure RUNPATH values ld: https://sourceware.org/binutils/docs/ld/Options.html

func (NoInsecureRUNPATHRule) Applicability

func (r NoInsecureRUNPATHRule) Applicability() rule.Applicability

func (NoInsecureRUNPATHRule) Execute

func (NoInsecureRUNPATHRule) ID

func (NoInsecureRUNPATHRule) Name

func (r NoInsecureRUNPATHRule) Name() string

type PIERule

type PIERule struct{}

PIERule checks if binary is compiled as Position Independent Executable GCC: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fPIE Clang: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fpie

func (PIERule) Applicability

func (r PIERule) Applicability() rule.Applicability

func (PIERule) Execute

func (r PIERule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (PIERule) ID

func (r PIERule) ID() string

func (PIERule) Name

func (r PIERule) Name() string

type RELRORule

type RELRORule struct{}

RELRORule checks for partial RELRO ld: https://sourceware.org/binutils/docs/ld/Options.html

func (RELRORule) Applicability

func (r RELRORule) Applicability() rule.Applicability

func (RELRORule) Execute

func (r RELRORule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (RELRORule) ID

func (r RELRORule) ID() string

func (RELRORule) Name

func (r RELRORule) Name() string

type SafeStackRule

type SafeStackRule struct{}

SafeStackRule checks for SafeStack protection Clang: https://clang.llvm.org/docs/SafeStack.html LLVM: https://llvm.org/docs/SafeStack.html

func (SafeStackRule) Applicability

func (r SafeStackRule) Applicability() rule.Applicability

func (SafeStackRule) Execute

func (SafeStackRule) ID

func (r SafeStackRule) ID() string

func (SafeStackRule) Name

func (r SafeStackRule) Name() string

type SeparateCodeRule

type SeparateCodeRule struct{}

SeparateCodeRule checks if code and data are in separate pages ld: https://sourceware.org/binutils/docs/ld/Options.html#index-z-keyword

func (SeparateCodeRule) Applicability

func (r SeparateCodeRule) Applicability() rule.Applicability

func (SeparateCodeRule) Execute

func (SeparateCodeRule) ID

func (r SeparateCodeRule) ID() string

func (SeparateCodeRule) Name

func (r SeparateCodeRule) Name() string

type StackCanaryRule

type StackCanaryRule struct{}

StackCanaryRule checks for stack canary protection GCC: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fstack-protector Clang: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fstack-protector-strong

func (StackCanaryRule) Applicability

func (r StackCanaryRule) Applicability() rule.Applicability

func (StackCanaryRule) Execute

func (StackCanaryRule) ID

func (r StackCanaryRule) ID() string

func (StackCanaryRule) Name

func (r StackCanaryRule) Name() string

type StackLimitRule

type StackLimitRule struct{}

StackLimitRule checks for explicit stack size limit ld: https://sourceware.org/binutils/docs/ld/Options.html#index-z-keyword

func (StackLimitRule) Applicability

func (r StackLimitRule) Applicability() rule.Applicability

func (StackLimitRule) Execute

func (StackLimitRule) ID

func (r StackLimitRule) ID() string

func (StackLimitRule) Name

func (r StackLimitRule) Name() string

type StrippedRule

type StrippedRule struct{}

StrippedRule checks if binary is fully stripped ld: https://sourceware.org/binutils/docs/ld/Options.html#index-_002d_002dstrip_002dall

func (StrippedRule) Applicability

func (r StrippedRule) Applicability() rule.Applicability

func (StrippedRule) Execute

func (StrippedRule) ID

func (r StrippedRule) ID() string

func (StrippedRule) Name

func (r StrippedRule) Name() string

type UBSanRule

type UBSanRule struct{}

UBSanRule checks for Undefined Behavior Sanitizer Clang: https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html GCC: https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html#index-fsanitize=undefined

func (UBSanRule) Applicability

func (r UBSanRule) Applicability() rule.Applicability

func (UBSanRule) Execute

func (r UBSanRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (UBSanRule) ID

func (r UBSanRule) ID() string

func (UBSanRule) Name

func (r UBSanRule) Name() string

type WXorXRule

type WXorXRule struct{}

WXorXRule checks for W^X (Write XOR Execute) policy GNU ld: https://sourceware.org/binutils/docs/ld/Options.html (-z noexecstack)

func (WXorXRule) Applicability

func (r WXorXRule) Applicability() rule.Applicability

func (WXorXRule) Execute

func (r WXorXRule) Execute(bin *binary.ELFBinary) rule.ExecuteResult

func (WXorXRule) ID

func (r WXorXRule) ID() string

func (WXorXRule) Name

func (r WXorXRule) Name() string

type X86CETIBTRule

type X86CETIBTRule struct{}

X86CETIBTRule checks for CET Indirect Branch Tracking (Intel/AMD) GCC: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-fcf-protection

func (X86CETIBTRule) Applicability

func (r X86CETIBTRule) Applicability() rule.Applicability

func (X86CETIBTRule) Execute

func (X86CETIBTRule) ID

func (r X86CETIBTRule) ID() string

func (X86CETIBTRule) Name

func (r X86CETIBTRule) Name() string

type X86CETShadowStackRule

type X86CETShadowStackRule struct{}

X86CETShadowStackRule checks for CET Shadow Stack (Intel/AMD) GCC: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-fcf-protection

func (X86CETShadowStackRule) Applicability

func (r X86CETShadowStackRule) Applicability() rule.Applicability

func (X86CETShadowStackRule) Execute

func (X86CETShadowStackRule) ID

func (X86CETShadowStackRule) Name

func (r X86CETShadowStackRule) Name() string

type X86RetpolineRule

type X86RetpolineRule struct{}

X86RetpolineRule checks for Spectre v2 mitigation (retpoline) GCC: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mindirect-branch Clang: https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mretpoline

func (X86RetpolineRule) Applicability

func (r X86RetpolineRule) Applicability() rule.Applicability

func (X86RetpolineRule) Execute

func (X86RetpolineRule) ID

func (r X86RetpolineRule) ID() string

func (X86RetpolineRule) Name

func (r X86RetpolineRule) Name() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL