199767f8919635c4928607450d9e0abb932109ceToomas Soome/*-
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (c) 1993 Paul Kranenburg
199767f8919635c4928607450d9e0abb932109ceToomas Soome * All rights reserved.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Redistribution and use in source and binary forms, with or without
199767f8919635c4928607450d9e0abb932109ceToomas Soome * modification, are permitted provided that the following conditions
199767f8919635c4928607450d9e0abb932109ceToomas Soome * are met:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 1. Redistributions of source code must retain the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 2. Redistributions in binary form must reproduce the above copyright
199767f8919635c4928607450d9e0abb932109ceToomas Soome * notice, this list of conditions and the following disclaimer in the
199767f8919635c4928607450d9e0abb932109ceToomas Soome * documentation and/or other materials provided with the distribution.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 3. All advertising materials mentioning features or use of this software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * must display the following acknowledgement:
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This product includes software developed by Paul Kranenburg.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * 4. The name of the author may not be used to endorse or promote products
199767f8919635c4928607450d9e0abb932109ceToomas Soome * derived from this software without specific prior written permission
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
199767f8919635c4928607450d9e0abb932109ceToomas Soome * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
199767f8919635c4928607450d9e0abb932109ceToomas Soome * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
199767f8919635c4928607450d9e0abb932109ceToomas Soome * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
199767f8919635c4928607450d9e0abb932109ceToomas Soome * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * $FreeBSD$
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * RRS section definitions.
199767f8919635c4928607450d9e0abb932109ceToomas Soome *
199767f8919635c4928607450d9e0abb932109ceToomas Soome * The layout of some data structures defined in this header file is
199767f8919635c4928607450d9e0abb932109ceToomas Soome * such that we can provide compatibility with the SunOS 4.x shared
199767f8919635c4928607450d9e0abb932109ceToomas Soome * library scheme.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifndef _SYS_LINK_ELF_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define _SYS_LINK_ELF_H_
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#include <sys/elf.h>
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome/*
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Flags that describe the origin of the entries in Dl_serinfo.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * SunOS has these in <sys/link.h>, we follow the suit.
199767f8919635c4928607450d9e0abb932109ceToomas Soome */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LA_SER_ORIG 0x01 /* original (needed) name */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LA_SER_LIBPATH 0x02 /* LD_LIBRARY_PATH entry prepended */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LA_SER_RUNPATH 0x04 /* runpath entry prepended */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LA_SER_CONFIG 0x08 /* configuration entry prepended */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LA_SER_DEFAULT 0x40 /* default path prepended */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#define LA_SER_SECURE 0x80 /* default (secure) path prepended */
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef struct link_map {
199767f8919635c4928607450d9e0abb932109ceToomas Soome caddr_t l_addr; /* Base Address of library */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __mips__
199767f8919635c4928607450d9e0abb932109ceToomas Soome caddr_t l_offs; /* Load Offset of library */
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome const char *l_name; /* Absolute Path to Library */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const void *l_ld; /* Pointer to .dynamic in memory */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct link_map *l_next, *l_prev; /* linked list of of mapped libs */
199767f8919635c4928607450d9e0abb932109ceToomas Soome} Link_map;
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct r_debug {
199767f8919635c4928607450d9e0abb932109ceToomas Soome int r_version; /* not used */
199767f8919635c4928607450d9e0abb932109ceToomas Soome struct link_map *r_map; /* list of loaded images */
199767f8919635c4928607450d9e0abb932109ceToomas Soome void (*r_brk)(struct r_debug *, struct link_map *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome /* pointer to break point */
199767f8919635c4928607450d9e0abb932109ceToomas Soome enum {
199767f8919635c4928607450d9e0abb932109ceToomas Soome RT_CONSISTENT, /* things are stable */
199767f8919635c4928607450d9e0abb932109ceToomas Soome RT_ADD, /* adding a shared library */
199767f8919635c4928607450d9e0abb932109ceToomas Soome RT_DELETE /* removing a shared library */
199767f8919635c4928607450d9e0abb932109ceToomas Soome } r_state;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soomestruct dl_phdr_info
199767f8919635c4928607450d9e0abb932109ceToomas Soome{
199767f8919635c4928607450d9e0abb932109ceToomas Soome Elf_Addr dlpi_addr; /* module relocation base */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const char *dlpi_name; /* module name */
199767f8919635c4928607450d9e0abb932109ceToomas Soome const Elf_Phdr *dlpi_phdr; /* pointer to module's phdr */
199767f8919635c4928607450d9e0abb932109ceToomas Soome Elf_Half dlpi_phnum; /* number of entries in phdr */
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned long long int dlpi_adds; /* total # of loads */
199767f8919635c4928607450d9e0abb932109ceToomas Soome unsigned long long int dlpi_subs; /* total # of unloads */
199767f8919635c4928607450d9e0abb932109ceToomas Soome size_t dlpi_tls_modid;
199767f8919635c4928607450d9e0abb932109ceToomas Soome void *dlpi_tls_data;
199767f8919635c4928607450d9e0abb932109ceToomas Soome};
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome__BEGIN_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soometypedef int (*__dl_iterate_hdr_callback)(struct dl_phdr_info *, size_t, void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeextern int dl_iterate_phdr(__dl_iterate_hdr_callback, void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint _rtld_addr_phdr(const void *, struct dl_phdr_info *);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint _rtld_get_stack_prot(void);
199767f8919635c4928607450d9e0abb932109ceToomas Soomeint _rtld_is_dlopened(void *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#ifdef __ARM_EABI__
199767f8919635c4928607450d9e0abb932109ceToomas Soomevoid * dl_unwind_find_exidx(const void *, int *);
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome__END_DECLS
199767f8919635c4928607450d9e0abb932109ceToomas Soome
199767f8919635c4928607450d9e0abb932109ceToomas Soome#endif /* _SYS_LINK_ELF_H_ */