/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1988 AT&T
* All Rights Reserved
*
*/
/*
* Local include file for ld library.
*/
#ifndef _LIBLD_DOT_H
#define _LIBLD_DOT_H
#include <libld.h>
#include <_libelf.h>
#include <debug.h>
#include <conv.h>
#include <msg.h>
#include <reloc_defs.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* In order to allow for cross linking, we need to be able to build
* libld with support for multiple targets within a single object.
* This is done using a global variable (ld_targ) of type Target to
* access target-specific code for the current target via indirection.
*/
/*
* Machine information for target
*/
typedef struct {
/* Used for EM_SPARC32PLUS */
/* a machplus object */
/* Relocation type codes */
/* Relocation related constants */
/* GOT related constants */
/* PLT related constants */
/* Section type of .eh_frame/.eh_frame_hdr sections */
} Target_mach;
/*
* Section identifiers, used to order sections in output object
*/
typedef struct {
/*
* Target_nullfunc supplies machine code for generating a
*
* void (*)(void)
*
* unnamed function. Such a function can be called, and returns
* immediately without doing any work. This is used to back FUNC
* symbol definitions added with a mapfile.
*
* The machine instructions are specified as an array of bytes rather
* than a larger integer type in order to avoid byte order issues that
* can otherwise occur in cross linking.
*/
typedef struct {
/*
* Target_fill supplies machine code for fill bytes in executable output
* sections. Normally, libelf fills the gaps caused by alignment and size
* requirements of the constituent input sections with 0. Depending on the
* target architecture, it may be desirable to instead fill with executable
* NOP instructions. There are two reasons to do this:
*
* - So that .init/.fini sections will not contain unexecutable gaps
* that cause the executing program to trap and die.
*
* - To eliminate confusing garbage instructions between sections containing
* executable code when viewed with a disassembler.
*
* The ff_execfill function is allowed to be NULL if the underlying target
* does not require a special fill for executable sections.
*/
typedef struct {
/*
* Target_machrel holds pointers to the reloc_table and machrel functions
* for a given target machine.
*
* The following function pointers are allowed to be NULL, if the
* underlying target does not require the specified operation. All
* other functions must be supplied:
*
* mr_assign_got
* mr_reloc_register
* mr_reloc_GOTOP
* mr_allocate_got
*/
typedef struct {
Boolean *);
Ofl_desc *);
Rel_desc *);
/*
* Target_machsym holds pointers to the machsym functions
* for a given target machine.
*
* These fields are allowed to be NULL for targets that do not require
* special handling of register symbols. Register symbols are used by
* sparc targets. If any of these fields are non-NULL, all of them are
* required to be present (use empty stub routines if necessary).
*/
typedef struct {
typedef struct {
} Target;
/*
* Structure to manage the update of weak symbols from their associated alias.
*/
typedef struct wk_desc {
} Wk_desc;
/*
* Structure to manage the support library interfaces.
*/
typedef struct func_list {
/* function is from */
} Func_list;
typedef struct support_list {
} Support_list;
/*
* Structure to manage a sorted output relocation list.
*
* rl_key1 -> pointer to needed ndx
* rl_key2 -> pointer to symbol relocation is against
* rl_key3 -> virtual offset of relocation
*/
typedef struct reloc_list {
} Reloc_list;
typedef struct sym_s_list {
} Sym_s_list;
/*
* ld heap management structure
*/
struct _ld_heap {
void *lh_free;
void *lh_end;
};
/*
* Dynamic per-symbol filtee string table descriptor. This associates filtee
* strings that will be created in the .dynstr, with .dynamic entries.
*/
typedef struct {
} Dfltr_desc;
/*
* Per-symbol filtee descriptor. This associates symbol definitions with
* their filtees.
*/
typedef struct {
} Sfltr_desc;
/*
* Capabilities descriptor, and capabilities group descriptor, used to track
* the symbol capabilities of any input files and the output file.
*
* A relocatable object input file may contain one or more symbol capabilities
* groups. The Cap_desc structures keep track of all unique groups that are
* collected for the output file. Relocatable objects that contain an object
* capabilities group, and the -z symbolcap option is in effect, have their
* object group translated to a symbol capabilities group.
*
* Individual capabilities groups are maintained with the Cap_group descriptor.
* A group can consist of one or more capabilities definitions. One or more
* symbols can be associated with each group.
*
* For the output file, capabilities families are used to track the symbols of
* a given family, each symbol being associated with a different group. This
* collection of data is used to create the final Capinfo structure, and for
* dynamic objects, the Capchain structure.
*
* For example, an object may contain two capabilities groups:
*
* CA_SUNW_MACH - sun4u CA_SUNW_MACH - sun4v
*
* Two symbols can be associated with each group:
*
* foo%sun4u foo%sun4v
* bar%sun4u bar%sun4v
*
* Two families are maintained, and include the generic, or lead, instance of
* the capabilities members:
*
* foo, foo%sun4u, foo%sun4v
* bar, bar%sun4u, bar%sun4v
*/
struct cap_desc {
/* translated from object to */
}; /* symbol capabilities */
typedef struct {
/* use this descriptor */
/* the group */
} Cap_group;
/*
* A Capabilities family node, extends a symbol node, and provides for tracking
* capabilities families. A family is defined by its lead symbol (for example,
* a generic, non-capabilities aware foo()), and one or more capabilities
* members (for example, capabilities instances foo%sun4u(), foo%sun4v(), etc.).
*
* Each member associates a symbol with its group using a Cap_sym structure.
*/
typedef struct {
} Cap_avlnode;
typedef struct {
} Cap_sym;
/*
* Define Alist initialization sizes.
*/
/* names */
/*
* Return codes for {tls|got}_fixups() routines
*/
typedef enum {
} Fixupret;
#ifndef FILENAME_MAX
#endif
/*
* We pad the end of the .dynstr section with a block of DYNSTR_EXTRA_PAD
* bytes, and we insert DYNAMIC_EXTRA_ELTS unused items into the
* .dynamic section (with value DT_NULL). This provides the resources needed
*/
/*
* Default relocation cache allocation unit. This number should be small
* enough to not hurt memory use significantly, but large enough to avoid
* the need for too many subsequent allocations.
*/
/*
* Given a symbol of a type that is allowed within a .SUNW_dynsymsort or
* .SUNW_dyntlssort section, examine the symbol attributes to determine
* if this particular symbol should be included or not.
*
* entry:
* The symbol must have an allowed type: Either a type verified by
* dynsymsort_symtype[] or STT_TLS.
*
* _sdp - Pointer to symbol descriptor
* _sym - Pointer to symbol referenced by _sdp.
*
* _sym is derivable from _sdp: _sdp->sd_sym
* However, most callers assign it to a local variable for efficiency,
* and this macro allows such a variable to be used within. If you
* don't have such a variable, supply _sdp->sd_sym.
*
* The tests used require some explanation:
*
* (_sdp->sd_flags & FLG_SY_DYNSORT)
* Some special symbols are kept even if they don't meet the
* usual requirements. These symbols have the FLG_SY_DYNSORT
* bit set. If this bit isn't set then we look at the other
* attributes.
*
* (((_sdp->sd_ref != REF_DYN_NEED) &&
* (_sdp->sd_sym->st_shndx != SHN_UNDEF))
* || (_sdp->sd_flags & FLG_SY_MVTOCOMM))
* We do not want to include symbols that are not defined within
* the object we are creating. REF_DYN_NEED corresponds to those
* UNDEF items. However, if the symbol is the target of a copy
* relocation, then it effectively becomes defined within the
* object after all. FLG_SY_MVTOCOMM indicates a copy relocation,
* and prevents us from culling those exceptions.
*
* (_sym->st_size != 0)
* Symbols with 0 length are labels injected by the compilers
* or the linker for purposes of code generation, and do
* not directly correspond to actual code. In fact, most of the
* symbols we mark with FLG_SY_DYNSORT need that flag set because
* they have size 0. This size test filters out the others.
*
* !(_sdp->sd_flags & FLG_SY_NODYNSORT)
* Some symbols are not kept, even though they do meet the usual
* requirements. These symbols have FLG_SY_NODYNSORT set.
* For example, if there are weak and non-weak versions of a given
* symbol, we only want to keep one of them. So, we set
* FLG_SY_NODYNSORT on the one we don't want.
*/
/*
* We use output section descriptor counters to add up the number of
* symbol indexes to put in the .SUNW_dynsort and .SUNW_dyntlssort sections.
* Non-TLS symbols are counted by ofl->ofl_dynsymsortcnt, while TLS symbols are
* counted by ofl->ofl_dyntlssortcnt. This computation is done inline in
* several places. The DYNSORT_COUNT macro allows us to generate this from
* a single description.
*
* entry:
* _sdp, _sym - As per DYNSORT_TEST_ATTR
* _type - Type of symbol (STT_*)
* _inc_or_dec_op - Either ++, or --. This specifies the operation
* to be applied to the counter, and determines whether we
* are adding, or removing, a symbol from .SUNW_dynsymsort.
*
* Note that _type is derivable from _sym: ELF_ST_TYPE(_sdp->sd_sym->st_info).
* Most callers already have it in a variable, so this allows us to use that
* variable. If you don't have such a variable, use ELF_ST_TYPE() as shown.
*/
{ \
\
} else { /* Don't count this symbol */ \
} \
}
/*
* The OFL_SWAP_RELOC macros are used to determine whether
* relocation processing needs to swap the data being relocated.
* It is an optimization to ld_swap_reloc_data(), as it avoids
* the function call in the case where the linker host and the
* target have the same byte order.
*/
/*
* Define an AVL node for maintaining input section descriptors. AVL trees of
* these descriptors are used to process group and COMDAT section.
*
* Pure COMDAT uses the input section name as the search key, while
* SHT_GROUP sections use the name of a special signature symbol. We
* support both by using the isd_name field to carry the name. An alternative
* design would be to use a separate type for each use, saving the cost
* of the unneeded pointer for pure COMDAT. We favor a single implementation
* because we believe that SHT_GROUP comdat will be more common going forward,
* particularly in the largest objects produced by C++ where SHT_GROUP is
* needed to manage the complex section relationships. In contrast, we think
* that pure COMDAT is both more rare, and used in smaller objects where the
* cost of an extra pointer per node is relatively unimportant.
*/
typedef struct {
} Isd_node;
/*
* Type used to break down an input file path into its component parts,
* as used by ld_place_section() to compare an input file path to
* entrance criteria ec_files file strings.
*
* We define a path in the usual Unix '/' separated manner, augmented
* with an optional archive member suffix enclosed in parenthesis:
*
*
* The basename is the final path component, and includes the archive
* member, if present. The meaning of "object name" depends on whether or
* not the file comes from an archive or not. If not an archive, it is the
* same as the basename. If an archive, it is the name of the archive member
* from within the file.
*
* Variables of this type are initialized with ld_place_path_info_init().
*/
typedef struct {
/*
* Local data items.
*/
extern char *Plibpath;
extern char *Llibdir;
extern char *Ulibdir;
extern APlist *lib_support;
extern int demangle_flag;
extern int Verbose;
extern const int ldynsym_symtype[];
extern const int dynsymsort_symtype[];
/*
* Local functions.
*/
extern char *add_string(char *, char *);
extern const char *demangle(const char *);
extern void lds_atexit(Ofl_desc *, int);
extern void libld_free(void *);
extern void *libld_malloc(size_t);
extern void *libld_realloc(void *, size_t);
extern int isdavl_compare(const void *, const void *);
#if defined(_ELF64)
#else
#endif
extern void dbg_cleanup(void);
Ar_mem *);
extern void ld_cap_move_symtoobj(Ofl_desc *);
extern void ld_ent_check(Ofl_desc *);
avl_index_t *where);
extern const char *ld_stt_section_sym_name(Is_desc *);
extern void ld_init_sighandler(Ofl_desc *);
extern void ld_map_out(Ofl_desc *);
Place_path_info *);
Place_path_info *path_info, int, const char *);
Ofl_desc *);
extern uintptr_t ld_process_open(const char *, const char *, int *,
Word);
Os_desc *);
Sym_desc *);
extern const char *ld_reloc_sym_name(Rel_desc *);
avl_index_t *where);
extern void ld_sec_validate(Ofl_desc *);
extern Half ld_sunw_ldmach();
extern void ld_sup_atexit(Ofl_desc *, int);
extern void ld_sup_open(Ofl_desc *, const char **, const char **,
const Elf_Kind);
extern void ld_sup_input_done(Ofl_desc *);
extern int ld_sym_avl_comp(const void *, const void *);
Ofl_desc *);
extern const Target *ld_targ_init_sparc(void);
extern const Target *ld_targ_init_x86(void);
Ofl_desc *);
extern int ld_vers_verify(Ofl_desc *);
/*
* Most platforms have both a 32 and 64-bit variant (e.g. EM_SPARC and
* EM_SPARCV9). To support this, there many files in libld that are built
* twice, once for ELFCLASS64 (_ELF64), and once for ELFCLASS32. In these
* files, we sometimes want to supply one value for the ELFCLASS32 case
* and another for ELFCLASS64. The LD_TARG_BYCLASS macro is used to do
* this. It is called with both both alternatives, and yields the one
* that applies to the current compilation environment.
*/
#ifdef _ELF64
#else
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LIBLD_DOT_H */