Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
core.internal.elf.io
Provides (read-only) memory-mapped I/O for ELF files.
Reference http://www.dwarfstd.org/
License:
Authors:
Yazan Dabain, Martin Kinkelin
Source core/internal/elf/io.d
- template
ElfIO
(Elf_Ehdr, Elf_Shdr, ubyte ELFCLASS) - File-based memory-mapped I/O (read-only). Only supports ELF files with a byte-order matching the target platform's.Parameters:
Elf_Ehdr Expected type of the ELF header (Elf{32,64}Ehdr) Elf_Shdr Expected type of the ELF section header (Elf{32,64}Shdr) ELFCLASS Expected ELF class (ELFCLASS{32,64}) - struct
ElfFile
; - ELF file (with memory-mapped ELF header).
- static bool
open
(const(char)*path
, out ElfFilefile
); - Tries to open the specified file as ELF file matching the ElfIO template parameters.Returns:True on success.
- this(int
fd
); - Constructs an instance based on the specified file descriptor. Doesn't validate the file header. The file is closed when destructing the instance.
- TypedMMapRegion!Elf_Ehdr
ehdr
; - Memory-mapped ELF header.
- bool
isValid
() const; - Returns true if the ELF file header matches the ElfIO template parameters.
- NamedSections
namedSections
() const; - Returns a struct to iterate over the named sections.Examples:
foreach (index, name, sectionHeader; elfFile.namedSections) ...
- bool
findSectionHeaderByName
(const(char)[]sectionName
, out ElfSectionHeaderheader
) const; - Tries to find the header of the section with the specified name.Returns:True on success.
- struct
NamedSections
; - Enables iterating over an ELF file's (named) sections.
- alias
Callback
= int delegate(size_t index, const(char)[] name, ElfSectionHeader sectionHeader); - name: null-terminated
- int
opApply
(scope Callbackdg
);
- struct
ElfSectionHeader
; - Memory-mapped ELF section header.
- this(ref const ElfFile
file
, size_tindex
); - Constructs a new instance based on the specified file and section index.
- TypedMMapRegion!Elf_Shdr
shdr
; - Memory-mapped section header.
- struct
ElfSection
; - Memory-mapped ELF section data.
- this(ref const ElfFile
file
, ref const ElfSectionHeadershdr
); - Constructs a new instance based on the specified file and section header.
- const(void)[]
data
() const; - Returns the memory-mapped section data. The data is accessible as long as this ElfSection is alive.
- enum int
ELFCLASS32
; - ELF class for 32-bit ELF files.
- enum int
ELFCLASS64
; - ELF class for 64-bit ELF files.
- alias
Elf_Ehdr
= core.sys.elf.Elf64_Ehdr; - Native ELF header type.
- alias
Elf_Shdr
= core.sys.elf.Elf64_Shdr; - Native ELF section header type.
- alias
ELFCLASS
= ELFCLASS64; - Native ELF class.
- alias
NativeElfIO
= ElfIO!(Elf64_Ehdr, Elf64_Shdr, cast(ubyte)2u); - alias
ElfFile
= ElfIO!(Elf64_Ehdr, Elf64_Shdr, cast(ubyte)2u).ElfFile
; - Native ELF file.
- alias
ElfSectionHeader
= ElfIO!(Elf64_Ehdr, Elf64_Shdr, cast(ubyte)2u).ElfSectionHeader
; - Native ELF section header.
- alias
ElfSection
= ElfIO!(Elf64_Ehdr, Elf64_Shdr, cast(ubyte)2u).ElfSection
; - Native ELF section.
- nothrow @nogc char*
thisExePath
(); - Returns the path to the process' executable as newly allocated C string (free() when done), or null on error.
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Apr 28 06:59:07 2025