source: mainline/uspace/lib/c/include/elf/elf_mod.h

Last change on this file was bdca26a, checked in by Jakub Jermář <jakub@…>, 6 years ago

Removing printf when failing from lib/rtld

If rtld failed a message was printed with printf.
This has been replaced with DPRINTF which
gives control to the developer over the message

  • Property mode set to 100644
File size: 3.0 KB
RevLine 
[17341d4]1/*
2 * Copyright (c) 2006 Sergey Bondari
3 * Copyright (c) 2008 Jiri Svoboda
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
[174156fd]30/** @addtogroup libc
[17341d4]31 * @{
32 */
33/** @file
34 * @brief ELF loader structures and public functions.
35 */
36
37#ifndef ELF_MOD_H_
38#define ELF_MOD_H_
39
40#include <elf/elf.h>
[8d2dd7f2]41#include <stddef.h>
42#include <stdint.h>
[17341d4]43#include <loader/pcb.h>
44
45typedef enum {
46 /** Leave all segments in RW access mode. */
47 ELDF_RW = 1
48} eld_flags_t;
49
[6adb775f]50/** TLS info for a module */
51typedef struct {
52 /** tdata section image */
53 void *tdata;
54 /** Size of tdata section image in bytes */
55 size_t tdata_size;
56 /** Size of tbss section */
57 size_t tbss_size;
[29405ac]58 /** Alignment of TLS initialization image */
59 size_t tls_align;
[6adb775f]60} elf_tls_info_t;
61
[17341d4]62/**
63 * Some data extracted from the headers are stored here
64 */
65typedef struct {
66 /** Entry point */
67 entry_point_t entry;
68
[742fc98e]69 /** The base address where the file has been loaded.
70 * Points to the ELF file header.
71 */
72 void *base;
73
[17341d4]74 /** ELF interpreter name or NULL if statically-linked */
75 const char *interp;
76
77 /** Pointer to the dynamic section */
78 void *dynamic;
[6adb775f]79
80 /** TLS info */
81 elf_tls_info_t tls;
[17341d4]82} elf_finfo_t;
83
84/**
85 * Holds information about an ELF binary being loaded.
86 */
87typedef struct {
88 /** Filedescriptor of the file from which we are loading */
89 int fd;
90
91 /** Difference between run-time addresses and link-time addresses */
92 uintptr_t bias;
93
94 /** Flags passed to the ELF loader. */
95 eld_flags_t flags;
96
97 /** Store extracted info here */
98 elf_finfo_t *info;
99} elf_ld_t;
100
[bdca26a]101extern errno_t elf_load_file(int, eld_flags_t, elf_finfo_t *);
102extern errno_t elf_load_file_name(const char *, eld_flags_t, elf_finfo_t *);
[17341d4]103
104#endif
105
106/** @}
107 */
Note: See TracBrowser for help on using the repository browser.