blob: 4321944db4553c05cc7ebd7cb1665d5278838941 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
.TH ELF64_OFFSCN 3 "June 2024" "Elfutils" "Library Functions Manual"
.SH NAME
elf64_offscn \- retrieve a section descriptor by file offset for an ELF64 file
.SH SYNOPSIS
.B #include <libelf.h>
.BI "Elf_Scn *elf64_offscn(Elf *" elf ", off_t " offset ");"
.SH DESCRIPTION
The .B elf64_offscn function retrieves the section descriptor for the section at the specified file offset in the ELF64 object referred to by .I elf.
Sections in an ELF file are located at specific offsets within the file. This function allows access to a section based on its file offset, which is particularly useful when parsing or manipulating ELF files at a low level.
.SH PARAMETERS
.TP
.I elf
An .I Elf pointer to the ELF object from which the section descriptor is to be retrieved.
.TP
.I offset
An .I off_t value representing the file offset of the section whose descriptor is to be retrieved. The offset is typically obtained from other ELF structures, such as program headers or section headers.
.SH RETURN VALUE
The .B elf64_offscn function returns a pointer to the .I Elf_Scn structure for the section at the specified offset. If an error occurs, it returns NULL and sets an appropriate error code.
.SH ERRORS
If .B elf64_offscn fails, it sets the following error codes:
.TP
.B ELFMEM
Memory allocation failed.
.TP
.B ELFARG
The .I elf parameter is NULL, or .I offset is invalid.
.TP
.B ELFERR
An unspecified internal error occurred.
.SH EXAMPLES
.B "Example 1: Retrieve the section descriptor for a section at a specific offset"
.nf
.in +4
#include <libelf.h>
Elf *elf = ...; // Assume elf is a valid Elf pointer
off_t offset = ...; // Specify a valid file offset
Elf_Scn *scn = elf64_offscn(elf, offset);
if (scn == NULL) {
// Handle error
}
.in -4
.fi
.SH SEE ALSO
.BR elf64_getshdr (3),
.BR elf64_getphdr (3),
.BR elf_getscn (3),
.BR elf (3),
.BR libelf (3)
.SH AUTHORS
Elfutils was written by the Elfutils development team.
.SH COPYRIGHT
Copyright © 2024 Elfutils Development Team.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|