No empty .Rs/.Re
[netbsd-mini2440.git] / libexec / ld.aout_so / ld.h
bloba4b9031c8f448cb537f2ea28a1b22217e080d18e
1 /* $NetBSD: ld.h,v 1.2 1998/12/17 23:36:38 pk Exp $ */
3 /*-
4 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Paul Kranenburg.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Definitions and functions prototypes shared between the
34 * link-editor, ld(1), and the run-time linker, ld.so(1).
37 #define SUN_COMPAT
39 #include "md.h"
40 #include "link.h"
42 /* If compiled with GNU C, use the built-in alloca */
43 #if defined(__GNUC__) || defined(sparc)
44 #define alloca __builtin_alloca
45 #endif
47 /* Align to power-of-two boundary */
48 #define PALIGN(x,p) (((x) + (u_long)(p) - 1) & (-(u_long)(p)))
50 /* Align to machine dependent boundary */
51 #define MALIGN(x) PALIGN(x,MAX_ALIGNMENT)
53 #ifndef nounderscore
54 #define ETEXT_SYM "_etext"
55 #define EDATA_SYM "_edata"
56 #define END_SYM "_end"
57 #define DYN_SYM "__DYNAMIC"
58 #define GOT_SYM "__GLOBAL_OFFSET_TABLE_"
59 #define PLT_SYM "__PROCEDURE_LINKAGE_TABLE_"
60 #define LPREFIX 'L'
61 #else
62 #define ETEXT_SYM "etext"
63 #define EDATA_SYM "edata"
64 #define END_SYM "end"
65 #define DYN_SYM "_DYNAMIC"
66 #define GOT_SYM "_GLOBAL_OFFSET_TABLE_"
67 #define PLT_SYM "_PROCEDURE_LINKAGE_TABLE_"
68 #define LPREFIX '.'
69 #endif
72 * Default macros; these may be overridden in <arch/---/md.h>.
73 * Note: we only test the existence of RELOC_ADDRESS, so
74 * you should override all or nothing at all.
76 * See ld.c for an addtional information on their use.
78 #ifndef RELOC_ADDRESS
80 #define RELOC_ADDRESS(r) ((r)->r_address)
81 #define RELOC_EXTERN_P(r) ((r)->r_extern)
82 #define RELOC_TYPE(r) ((r)->r_symbolnum)
83 #define RELOC_SYMBOL(r) ((r)->r_symbolnum)
84 #define RELOC_MEMORY_SUB_P(r) 0
85 #define RELOC_MEMORY_ADD_P(r) 1
86 #undef RELOC_ADD_EXTRA
87 #define RELOC_PCREL_P(r) ((r)->r_pcrel)
88 #define RELOC_VALUE_RIGHTSHIFT(r) 0
89 #if defined(RTLD) && defined(SUN_COMPAT)
90 #define RELOC_TARGET_SIZE(r) (2) /* !!!!! Sun BUG compatible */
91 #else
92 #define RELOC_TARGET_SIZE(r) ((r)->r_length)
93 #endif
94 #define RELOC_TARGET_BITPOS(r) 0
95 #define RELOC_TARGET_BITSIZE(r) 32
97 #define RELOC_JMPTAB_P(r) ((r)->r_jmptable)
98 #define RELOC_BASEREL_P(r) ((r)->r_baserel)
99 #define RELOC_RELATIVE_P(r) ((r)->r_relative)
100 #define RELOC_COPY_P(r) ((r)->r_copy)
101 #define RELOC_LAZY_P(r) ((r)->r_jmptable)
103 #define CHECK_GOT_RELOC(r) ((r)->r_pcrel)
104 #define RELOC_PIC_TYPE(r) ((r)->r_baserel? \
105 PIC_TYPE_LARGE:PIC_TYPE_NONE)
107 #endif /* RELOC_ADDRESS */
109 /* A separately overridable macros */
110 #ifndef RELOC_INIT_SEGMENT_RELOC
111 #define RELOC_INIT_SEGMENT_RELOC(r)
112 #endif
114 #ifndef MAX_GOTOFF
115 #define MAX_GOTOFF(x) (LONG_MAX)
116 #endif
118 #ifndef MIN_GOTOFF
119 #define MIN_GOTOFF(x) (LONG_MIN)
120 #endif
122 #ifndef TEXT_START
123 #define TEXT_START(x) N_TXTADDR(x)
124 #endif
126 #ifndef DATA_START
127 #define DATA_START(x) N_DATADDR(x)
128 #endif
130 /* Macros dealing with the set element symbols defined in a.out.h */
131 #define SET_ELEMENT_P(x) ((x) >= N_SETA && (x) <= (N_SETB|N_EXT))
132 #define TYPE_OF_SET_ELEMENT(x) ((x) - N_SETA + N_ABS)
134 #define N_ISWEAK(p) (N_BIND(p) & BIND_WEAK)
136 /* Functions that must be provided by arch/md.c: */
137 void md_init_header __P((struct exec *, int, int));
138 long md_get_addend __P((struct relocation_info *, unsigned char *));
139 void md_relocate __P((struct relocation_info *, long,
140 unsigned char *, int));
141 int md_make_reloc __P((struct relocation_info *,
142 struct relocation_info *, int));
143 void md_set_breakpoint __P((long, long *));
144 void md_make_jmpslot __P((jmpslot_t *, long, long));
145 void md_fix_jmpslot __P((jmpslot_t *, long, u_long, int));
146 void md_make_jmpreloc __P((struct relocation_info *,
147 struct relocation_info *, int));
148 void md_make_gotreloc __P((struct relocation_info *,
149 struct relocation_info *, int));
150 void md_make_cpyreloc __P((struct relocation_info *,
151 struct relocation_info *));
152 int md_midcompat __P((struct exec *));