xref: /haiku/headers/compatibility/bsd/sys/link_elf.h (revision 3ddf0bbc29dc201ef90f376708fbaf2dc31f2100)
1c6fd6cbbSZoltán Mizsei /*-
2c6fd6cbbSZoltán Mizsei  * SPDX-License-Identifier: BSD-4-Clause
3c6fd6cbbSZoltán Mizsei  *
4c6fd6cbbSZoltán Mizsei  * Copyright (c) 1993 Paul Kranenburg
5c6fd6cbbSZoltán Mizsei  * All rights reserved.
6c6fd6cbbSZoltán Mizsei  *
7c6fd6cbbSZoltán Mizsei  * Redistribution and use in source and binary forms, with or without
8c6fd6cbbSZoltán Mizsei  * modification, are permitted provided that the following conditions
9c6fd6cbbSZoltán Mizsei  * are met:
10c6fd6cbbSZoltán Mizsei  * 1. Redistributions of source code must retain the above copyright
11c6fd6cbbSZoltán Mizsei  *    notice, this list of conditions and the following disclaimer.
12c6fd6cbbSZoltán Mizsei  * 2. Redistributions in binary form must reproduce the above copyright
13c6fd6cbbSZoltán Mizsei  *    notice, this list of conditions and the following disclaimer in the
14c6fd6cbbSZoltán Mizsei  *    documentation and/or other materials provided with the distribution.
15c6fd6cbbSZoltán Mizsei  * 3. All advertising materials mentioning features or use of this software
16c6fd6cbbSZoltán Mizsei  *    must display the following acknowledgement:
17c6fd6cbbSZoltán Mizsei  *      This product includes software developed by Paul Kranenburg.
18c6fd6cbbSZoltán Mizsei  * 4. The name of the author may not be used to endorse or promote products
19c6fd6cbbSZoltán Mizsei  *    derived from this software without specific prior written permission
20c6fd6cbbSZoltán Mizsei  *
21c6fd6cbbSZoltán Mizsei  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22c6fd6cbbSZoltán Mizsei  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23c6fd6cbbSZoltán Mizsei  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24c6fd6cbbSZoltán Mizsei  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25c6fd6cbbSZoltán Mizsei  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26c6fd6cbbSZoltán Mizsei  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27c6fd6cbbSZoltán Mizsei  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28c6fd6cbbSZoltán Mizsei  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29c6fd6cbbSZoltán Mizsei  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30c6fd6cbbSZoltán Mizsei  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31c6fd6cbbSZoltán Mizsei  *
32c6fd6cbbSZoltán Mizsei  * $FreeBSD$
33c6fd6cbbSZoltán Mizsei  */
34c6fd6cbbSZoltán Mizsei 
35c6fd6cbbSZoltán Mizsei /*
36c6fd6cbbSZoltán Mizsei  * RRS section definitions.
37c6fd6cbbSZoltán Mizsei  *
38c6fd6cbbSZoltán Mizsei  * The layout of some data structures defined in this header file is
39c6fd6cbbSZoltán Mizsei  * such that we can provide compatibility with the SunOS 4.x shared
40c6fd6cbbSZoltán Mizsei  * library scheme.
41c6fd6cbbSZoltán Mizsei  */
42c6fd6cbbSZoltán Mizsei 
43c6fd6cbbSZoltán Mizsei #ifndef _SYS_LINK_ELF_H_
44c6fd6cbbSZoltán Mizsei #define	_SYS_LINK_ELF_H_
45c6fd6cbbSZoltán Mizsei 
46c6fd6cbbSZoltán Mizsei 
47c6fd6cbbSZoltán Mizsei #ifdef _BSD_SOURCE
48c6fd6cbbSZoltán Mizsei 
49c6fd6cbbSZoltán Mizsei 
50*3ddf0bbcSZoltán Mizsei #include <os/kernel/elf.h>
51c6fd6cbbSZoltán Mizsei 
52c6fd6cbbSZoltán Mizsei /*
53c6fd6cbbSZoltán Mizsei  * Flags that describe the origin of the entries in Dl_serinfo.
54c6fd6cbbSZoltán Mizsei  * SunOS has these in <sys/link.h>, we follow the suit.
55c6fd6cbbSZoltán Mizsei  */
56c6fd6cbbSZoltán Mizsei #define	LA_SER_ORIG	0x01	/* original (needed) name */
57c6fd6cbbSZoltán Mizsei #define	LA_SER_LIBPATH	0x02	/* LD_LIBRARY_PATH entry prepended */
58c6fd6cbbSZoltán Mizsei #define	LA_SER_RUNPATH	0x04	/* runpath entry prepended */
59c6fd6cbbSZoltán Mizsei #define	LA_SER_CONFIG	0x08	/* configuration entry prepended */
60c6fd6cbbSZoltán Mizsei #define	LA_SER_DEFAULT	0x40	/* default path prepended */
61c6fd6cbbSZoltán Mizsei #define	LA_SER_SECURE	0x80	/* default (secure) path prepended */
62c6fd6cbbSZoltán Mizsei 
63c6fd6cbbSZoltán Mizsei typedef struct link_map {
64c6fd6cbbSZoltán Mizsei 	caddr_t		l_addr;			/* Base Address of library */
65c6fd6cbbSZoltán Mizsei #ifdef __mips__
66c6fd6cbbSZoltán Mizsei 	caddr_t		l_offs;			/* Load Offset of library */
67c6fd6cbbSZoltán Mizsei #endif
68c6fd6cbbSZoltán Mizsei 	const char	*l_name;		/* Absolute Path to Library */
69c6fd6cbbSZoltán Mizsei 	const void	*l_ld;			/* Pointer to .dynamic in memory */
70c6fd6cbbSZoltán Mizsei 	struct link_map	*l_next, *l_prev;	/* linked list of of mapped libs */
71c6fd6cbbSZoltán Mizsei } Link_map;
72c6fd6cbbSZoltán Mizsei 
73c6fd6cbbSZoltán Mizsei struct r_debug {
74c6fd6cbbSZoltán Mizsei 	int		r_version;		/* not used */
75c6fd6cbbSZoltán Mizsei 	struct link_map *r_map;			/* list of loaded images */
76c6fd6cbbSZoltán Mizsei 	void		(*r_brk)(struct r_debug *, struct link_map *);
77c6fd6cbbSZoltán Mizsei 						/* pointer to break point */
78c6fd6cbbSZoltán Mizsei 	enum {
79c6fd6cbbSZoltán Mizsei 		RT_CONSISTENT,			/* things are stable */
80c6fd6cbbSZoltán Mizsei 		RT_ADD,				/* adding a shared library */
81c6fd6cbbSZoltán Mizsei 		RT_DELETE			/* removing a shared library */
82c6fd6cbbSZoltán Mizsei 	}		r_state;
83c6fd6cbbSZoltán Mizsei };
84c6fd6cbbSZoltán Mizsei 
85c6fd6cbbSZoltán Mizsei struct dl_phdr_info
86c6fd6cbbSZoltán Mizsei {
87c6fd6cbbSZoltán Mizsei 	Elf_Addr dlpi_addr;			/* module relocation base */
88c6fd6cbbSZoltán Mizsei 	const char *dlpi_name;			/* module name */
89c6fd6cbbSZoltán Mizsei 	const Elf_Phdr *dlpi_phdr;		/* pointer to module's phdr */
90c6fd6cbbSZoltán Mizsei 	Elf_Half dlpi_phnum;			/* number of entries in phdr */
91c6fd6cbbSZoltán Mizsei 	unsigned long long int dlpi_adds;	/* total # of loads */
92c6fd6cbbSZoltán Mizsei 	unsigned long long int dlpi_subs;	/* total # of unloads */
93c6fd6cbbSZoltán Mizsei 	size_t dlpi_tls_modid;
94c6fd6cbbSZoltán Mizsei 	void *dlpi_tls_data;
95c6fd6cbbSZoltán Mizsei };
96c6fd6cbbSZoltán Mizsei 
97c6fd6cbbSZoltán Mizsei __BEGIN_DECLS
98c6fd6cbbSZoltán Mizsei 
99c6fd6cbbSZoltán Mizsei typedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *);
100c6fd6cbbSZoltán Mizsei extern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
101c6fd6cbbSZoltán Mizsei int _rtld_addr_phdr(const void *, struct dl_phdr_info *);
102c6fd6cbbSZoltán Mizsei int _rtld_get_stack_prot(void);
103c6fd6cbbSZoltán Mizsei int _rtld_is_dlopened(void *);
104c6fd6cbbSZoltán Mizsei 
105c6fd6cbbSZoltán Mizsei #ifdef __ARM_EABI__
106c6fd6cbbSZoltán Mizsei void * dl_unwind_find_exidx(const void *, int *);
107c6fd6cbbSZoltán Mizsei #endif
108c6fd6cbbSZoltán Mizsei 
109c6fd6cbbSZoltán Mizsei __END_DECLS
110c6fd6cbbSZoltán Mizsei 
111c6fd6cbbSZoltán Mizsei 
112c6fd6cbbSZoltán Mizsei #endif
113c6fd6cbbSZoltán Mizsei 
114c6fd6cbbSZoltán Mizsei 
115c6fd6cbbSZoltán Mizsei #endif /* _SYS_LINK_ELF_H_ */
116