1elf_rawfile(3ELF)            ELF Library Functions           elf_rawfile(3ELF)
2
3
4

NAME

6       elf_rawfile - retrieve uninterpreted file contents
7

SYNOPSIS

9       cc [ flag... ] file ... -lelf [ library ... ]
10       #include <libelf.h>
11
12       char *elf_rawfile(Elf *elf, size_t *ptr);
13
14

DESCRIPTION

16       The  elf_rawfile()  function returns a pointer to an uninterpreted byte
17       image of the file. This function should be used only to retrieve a file
18       being  read. For example, a program might use elf_rawfile() to retrieve
19       the bytes for an archive member.
20
21
22       A program may not  close  or  disable  (see  elf_cntl(3ELF))  the  file
23       descriptor associated with elf before the initial call to elf_rawfile()
24       , because elf_rawfile() might have to read the data from the file if it
25       does  not  already  have  the original bytes in memory. Generally, this
26       function is more efficient for  unknown  file  types  than  for  object
27       files.  The library implicitly translates object files in memory, while
28       it leaves unknown files unmodified. Thus, asking for the  uninterpreted
29       image of an object file may create a duplicate copy in memory.
30
31
32       elf_rawdata()  is  a  related  function,  providing  access to sections
33       within a file. See elf_getdata(3ELF).
34
35
36       If ptr is non-null, the library also stores the file's size, in  bytes,
37       in  the  location  to  which ptr points. If no data are present, elf is
38       null, or an error occurs, the return value is a null  pointer,  with  0
39       stored through ptr, if  ptr is non-null.
40

ATTRIBUTES

42       See attributes(5) for descriptions of the following attributes:
43
44
45
46
47       ┌─────────────────────────────┬─────────────────────────────┐
48       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
49       ├─────────────────────────────┼─────────────────────────────┤
50       │Interface Stability          │Stable                       │
51       ├─────────────────────────────┼─────────────────────────────┤
52       │MT-Level                     │MT-Safe                      │
53       └─────────────────────────────┴─────────────────────────────┘
54

SEE ALSO

56       elf(3ELF),    elf32_getehdr(3ELF),   elf_begin(3ELF),   elf_cntl(3ELF),
57       elf_getdata(3ELF),  elf_getident(3ELF),  elf_kind(3ELF),  libelf(3LIB),
58       attributes(5)
59

NOTES

61       A  program  that  uses  elf_rawfile() and that also interprets the same
62       file as an object file potentially has two copies of the bytes in  mem‐
63       ory. If such a program requests the raw image first, before it asks for
64       translated information  (through  such  functions  as  elf32_getehdr(),
65       elf_getdata(),  and so on), the library ``freezes'' its original memory
66       copy for the raw image. It then uses this frozen copy as the source for
67       creating  translated  objects,  without  reading the file again. Conse‐
68       quently, the application should view the raw  file  image  returned  by
69       elf_rawfile()  as  a read-only buffer, unless it wants to alter its own
70       view of data subsequently translated. In any case, the application  may
71       alter  the translated objects without changing bytes visible in the raw
72       image.
73
74
75       Multiple calls to elf_rawfile() with the same ELF descriptor return the
76       same value; the library does not create duplicate copies of the file.
77
78
79
80SunOS 5.11                        11 Jul 2001                elf_rawfile(3ELF)
Impressum