Imported NetBSD's ld for shared libs.
[unix-history] / gnu / usr.bin / ld / ld.h
CommitLineData
1136f72d
PR
1/* $Id: ld.h,v 1.4 1993/11/01 16:26:16 pk Exp $ */
2/*-
3 * This code is derived from software copyrighted by the Free Software
4 * Foundation.
5 *
6 * Modified 1991 by Donn Seeley at UUNET Technologies, Inc.
7 */
8
9#define SUN_COMPAT
10
11#ifndef N_SIZE
12#define N_SIZE 0xc
13#endif
14
15#ifndef min
16#define min(a,b) ((a) < (b) ? (a) : (b))
17#endif
18
19#ifndef __P
20#ifndef __STDC__
21#define __P(a) ()
22#else
23#define __P(a) a
24#endif
25#endif
26
27/* If compiled with GNU C, use the built-in alloca */
28#if defined(__GNUC__) || defined(sparc)
29#define alloca __builtin_alloca
30#endif
31
32#include "md.h"
33#include "link.h"
34
35/* Macro to control the number of undefined references printed */
36#define MAX_UREFS_PRINTED 10
37
38/* Align to power-of-two boundary */
39#define PALIGN(x,p) (((x) + (u_long)(p) - 1) & (-(u_long)(p)))
40
41/* Align to machine dependent boundary */
42#define MALIGN(x) PALIGN(x,MAX_ALIGNMENT)
43
44/* Size of a page; obtained from the operating system. */
45
46int page_size;
47
48/* Name this program was invoked by. */
49
50char *progname;
51\f
52/* System dependencies */
53
54/* Define this to specify the default executable format. */
55
56#ifndef DEFAULT_MAGIC
57#define DEFAULT_MAGIC ZMAGIC
58#endif
59
60#ifdef QMAGIC
61int oldmagic;
62#endif
63
64
65/*
66 * Ok. Following are the relocation information macros. If your
67 * system should not be able to use the default set (below), you must
68 * define the following:
69
70 * relocation_info: This must be typedef'd (or #define'd) to the type
71 * of structure that is stored in the relocation info section of your
72 * a.out files. Often this is defined in the a.out.h for your system.
73 *
74 * RELOC_ADDRESS (rval): Offset into the current section of the
75 * <whatever> to be relocated. *Must be an lvalue*.
76 *
77 * RELOC_EXTERN_P (rval): Is this relocation entry based on an
78 * external symbol (1), or was it fully resolved upon entering the
79 * loader (0) in which case some combination of the value in memory
80 * (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains
81 * what the value of the relocation actually was. *Must be an lvalue*.
82 *
83 * RELOC_TYPE (rval): If this entry was fully resolved upon
84 * entering the loader, what type should it be relocated as?
85 *
86 * RELOC_SYMBOL (rval): If this entry was not fully resolved upon
87 * entering the loader, what is the index of it's symbol in the symbol
88 * table? *Must be a lvalue*.
89 *
90 * RELOC_MEMORY_ADD_P (rval): This should return true if the final
91 * relocation value output here should be added to memory, or if the
92 * section of memory described should simply be set to the relocation
93 * value.
94 *
95 * RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives
96 * an extra value to be added to the relocation value based on the
97 * individual relocation entry. *Must be an lvalue if defined*.
98 *
99 * RELOC_PCREL_P (rval): True if the relocation value described is
100 * pc relative.
101 *
102 * RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the
103 * final relocation value before putting it where it belongs.
104 *
105 * RELOC_TARGET_SIZE (rval): log to the base 2 of the number of
106 * bytes of size this relocation entry describes; 1 byte == 0; 2 bytes
107 * == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could
108 * do everything in terms of the bit operators below), but having this
109 * macro could end up producing better code on machines without fancy
110 * bit twiddling. Also, it's easier to understand/code big/little
111 * endian distinctions with this macro.
112 *
113 * RELOC_TARGET_BITPOS (rval): The starting bit position within the
114 * object described in RELOC_TARGET_SIZE in which the relocation value
115 * will go.
116 *
117 * RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced
118 * with the bits of the relocation value. It may be assumed by the
119 * code that the relocation value will fit into this many bits. This
120 * may be larger than RELOC_TARGET_SIZE if such be useful.
121 *
122 *
123 * Things I haven't implemented
124 * ----------------------------
125 *
126 * Values for RELOC_TARGET_SIZE other than 0, 1, or 2.
127 *
128 * Pc relative relocation for External references.
129 *
130 *
131 */
132
133
134/* Default macros */
135#ifndef RELOC_ADDRESS
136
137#define RELOC_ADDRESS(r) ((r)->r_address)
138#define RELOC_EXTERN_P(r) ((r)->r_extern)
139#define RELOC_TYPE(r) ((r)->r_symbolnum)
140#define RELOC_SYMBOL(r) ((r)->r_symbolnum)
141#define RELOC_MEMORY_SUB_P(r) 0
142#define RELOC_MEMORY_ADD_P(r) 1
143#undef RELOC_ADD_EXTRA
144#define RELOC_PCREL_P(r) ((r)->r_pcrel)
145#define RELOC_VALUE_RIGHTSHIFT(r) 0
146#if defined(RTLD) && defined(SUN_COMPAT)
147#define RELOC_TARGET_SIZE(r) (2) /* !!!!! Sun BUG compatible */
148#else
149#define RELOC_TARGET_SIZE(r) ((r)->r_length)
150#endif
151#define RELOC_TARGET_BITPOS(r) 0
152#define RELOC_TARGET_BITSIZE(r) 32
153
154#define RELOC_JMPTAB_P(r) ((r)->r_jmptable)
155#define RELOC_BASEREL_P(r) ((r)->r_baserel)
156#define RELOC_RELATIVE_P(r) ((r)->r_relative)
157#define RELOC_COPY_P(r) ((r)->r_copy)
158#define RELOC_LAZY_P(r) ((r)->r_jmptable)
159
160#define CHECK_GOT_RELOC(r) ((r)->r_pcrel)
161
162#endif
163
164/*
165 * Internal representation of relocation types
166 */
167#define RELTYPE_EXTERN 1
168#define RELTYPE_JMPSLOT 2
169#define RELTYPE_BASEREL 4
170#define RELTYPE_RELATIVE 8
171#define RELTYPE_COPY 16
172
173#ifdef nounderscore
174#define LPREFIX '.'
175#else
176#define LPREFIX 'L'
177#endif
178
179#ifndef TEXT_START
180#define TEXT_START(x) N_TXTADDR(x)
181#endif
182
183#ifndef DATA_START
184#define DATA_START(x) N_DATADDR(x)
185#endif
186\f
187/* If a this type of symbol is encountered, its name is a warning
188 message to print each time the symbol referenced by the next symbol
189 table entry is referenced.
190
191 This feature may be used to allow backwards compatibility with
192 certain functions (eg. gets) but to discourage programmers from
193 their use.
194
195 So if, for example, you wanted to have ld print a warning whenever
196 the function "gets" was used in their C program, you would add the
197 following to the assembler file in which gets is defined:
198
199 .stabs "Obsolete function \"gets\" referenced",30,0,0,0
200 .stabs "_gets",1,0,0,0
201
202 These .stabs do not necessarily have to be in the same file as the
203 gets function, they simply must exist somewhere in the compilation. */
204
205#ifndef N_WARNING
206#define N_WARNING 0x1E /* Warning message to print if symbol
207 included */
208#endif /* This is input to ld */
209
210/* Special global symbol types understood by GNU LD. */
211
212/* The following type indicates the definition of a symbol as being
213 an indirect reference to another symbol. The other symbol
214 appears as an undefined reference, immediately following this symbol.
215
216 Indirection is asymmetrical. The other symbol's value will be used
217 to satisfy requests for the indirect symbol, but not vice versa.
218 If the other symbol does not have a definition, libraries will
219 be searched to find a definition.
220
221 So, for example, the following two lines placed in an assembler
222 input file would result in an object file which would direct gnu ld
223 to resolve all references to symbol "foo" as references to symbol
224 "bar".
225
226 .stabs "_foo",11,0,0,0
227 .stabs "_bar",1,0,0,0
228
229 Note that (11 == (N_INDR | N_EXT)) and (1 == (N_UNDF | N_EXT)). */
230
231#ifndef N_INDR
232#define N_INDR 0xa
233#endif
234
235/* The following symbols refer to set elements. These are expected
236 only in input to the loader; they should not appear in loader
237 output (unless relocatable output is requested). To be recognized
238 by the loader, the input symbols must have their N_EXT bit set.
239 All the N_SET[ATDB] symbols with the same name form one set. The
240 loader collects all of these elements at load time and outputs a
241 vector for each name.
242 Space (an array of 32 bit words) is allocated for the set in the
243 data section, and the n_value field of each set element value is
244 stored into one word of the array.
245 The first word of the array is the length of the set (number of
246 elements). The last word of the vector is set to zero for possible
247 use by incremental loaders. The array is ordered by the linkage
248 order; the first symbols which the linker encounters will be first
249 in the array.
250
251 In C syntax this looks like:
252
253 struct set_vector {
254 unsigned int length;
255 unsigned int vector[length];
256 unsigned int always_zero;
257 };
258
259 Before being placed into the array, each element is relocated
260 according to its type. This allows the loader to create an array
261 of pointers to objects automatically. N_SETA type symbols will not
262 be relocated.
263
264 The address of the set is made into an N_SETV symbol
265 whose name is the same as the name of the set.
266 This symbol acts like a N_DATA global symbol
267 in that it can satisfy undefined external references.
268
269 For the purposes of determining whether or not to load in a library
270 file, set element definitions are not considered "real
271 definitions"; they will not cause the loading of a library
272 member.
273
274 If relocatable output is requested, none of this processing is
275 done. The symbols are simply relocated and passed through to the
276 output file.
277
278 So, for example, the following three lines of assembler code
279 (whether in one file or scattered between several different ones)
280 will produce a three element vector (total length is five words;
281 see above), referenced by the symbol "_xyzzy", which will have the
282 addresses of the routines _init1, _init2, and _init3.
283
284 *NOTE*: If symbolic addresses are used in the n_value field of the
285 defining .stabs, those symbols must be defined in the same file as
286 that containing the .stabs.
287
288 .stabs "_xyzzy",23,0,0,_init1
289 .stabs "_xyzzy",23,0,0,_init2
290 .stabs "_xyzzy",23,0,0,_init3
291
292 Note that (23 == (N_SETT | N_EXT)). */
293
294#ifndef N_SETA
295#define N_SETA 0x14 /* Absolute set element symbol */
296#endif /* This is input to LD, in a .o file. */
297
298#ifndef N_SETT
299#define N_SETT 0x16 /* Text set element symbol */
300#endif /* This is input to LD, in a .o file. */
301
302#ifndef N_SETD
303#define N_SETD 0x18 /* Data set element symbol */
304#endif /* This is input to LD, in a .o file. */
305
306#ifndef N_SETB
307#define N_SETB 0x1A /* Bss set element symbol */
308#endif /* This is input to LD, in a .o file. */
309
310/* Macros dealing with the set element symbols defined in a.out.h */
311#define SET_ELEMENT_P(x) ((x) >= N_SETA && (x) <= (N_SETB|N_EXT))
312#define TYPE_OF_SET_ELEMENT(x) ((x) - N_SETA + N_ABS)
313
314#ifndef N_SETV
315#define N_SETV 0x1C /* Pointer to set vector in data area. */
316#endif /* This is output from LD. */
317
318
319#ifndef __GNU_STAB__
320
321/* Line number for the data section. This is to be used to describe
322 the source location of a variable declaration. */
323#ifndef N_DSLINE
324#define N_DSLINE (N_SLINE+N_DATA-N_TEXT)
325#endif
326
327/* Line number for the bss section. This is to be used to describe
328 the source location of a variable declaration. */
329#ifndef N_BSLINE
330#define N_BSLINE (N_SLINE+N_BSS-N_TEXT)
331#endif
332
333#endif /* not __GNU_STAB__ */
334\f
335/* Symbol table */
336
337/*
338 * Global symbol data is recorded in these structures, one for each global
339 * symbol. They are found via hashing in 'symtab', which points to a vector
340 * of buckets. Each bucket is a chain of these structures through the link
341 * field.
342 */
343
344typedef struct glosym {
345 /* Pointer to next symbol in this symbol's hash bucket. */
346 struct glosym *link;
347 /* Name of this symbol. */
348 char *name;
349 /* Value of this symbol as a global symbol. */
350 long value;
351 /*
352 * Chain of external 'nlist's in files for this symbol, both defs and
353 * refs.
354 */
355 struct localsymbol *refs;
356 /*
357 * Any warning message that might be associated with this symbol from
358 * an N_WARNING symbol encountered.
359 */
360 char *warning;
361 /*
362 * Nonzero means definitions of this symbol as common have been seen,
363 * and the value here is the largest size specified by any of them.
364 */
365 int max_common_size;
366 /*
367 * For relocatable_output, records the index of this global sym in
368 * the symbol table to be written, with the first global sym given
369 * index 0.
370 */
371 int symbolnum;
372 /*
373 * For dynamically linked output, records the index in the RRS
374 * symbol table.
375 */
376 int rrs_symbolnum;
377 /*
378 * Nonzero means a definition of this global symbol is known to
379 * exist. Library members should not be loaded on its account.
380 */
381 char defined;
382 /*
383 * Nonzero means a reference to this global symbol has been seen in a
384 * file that is surely being loaded. A value higher than 1 is the
385 * n_type code for the symbol's definition.
386 */
387 char referenced;
388 /*
389 * A count of the number of undefined references printed for a
390 * specific symbol. If a symbol is unresolved at the end of
391 * digest_symbols (and the loading run is supposed to produce
392 * relocatable output) do_file_warnings keeps track of how many
393 * unresolved reference error messages have been printed for each
394 * symbol here. When the number hits MAX_UREFS_PRINTED, messages
395 * stop.
396 */
397 unsigned char undef_refs;
398 /*
399 * 1 means that this symbol has multiple definitions. 2 means that
400 * it has multiple definitions, and some of them are set elements,
401 * one of which has been printed out already.
402 */
403 unsigned char multiply_defined;
404 /* Nonzero means print a message at all refs or defs of this symbol */
405 char trace;
406
407 /*
408 * For symbols of type N_INDR, this points at the real symbol.
409 */
410 struct glosym *alias;
411
412 /*
413 * Count number of elements in set vector if symbol is of type N_SETV
414 */
415 int setv_count;
416
417 /* Dynamic lib support */
418
419 /*
420 * Nonzero means a definition of this global symbol has been found
421 * in a shared object. These symbols do not go into the symbol
422 * section of the resulting a.out file. They *do* go into the
423 * dynamic link information segment.
424 */
425 char so_defined;
426
427 /* Size of symbol as determined by N_SIZE 'nlist's in object files */
428 int size;
429
430 /*
431 * Chain of external 'nlist's in shared objects for this symbol, both
432 * defs and refs.
433 */
434 struct localsymbol *sorefs;
435
436 /* The offset into one of the RRS tables, -1 if not used */
437 long jmpslot_offset;
438 char jmpslot_claimed;
439
440 long gotslot_offset;
441 char gotslot_claimed;
442
443 char cpyreloc_reserved;
444 char cpyreloc_claimed;
445
446 /* The local symbol that gave this global symbol its definition */
447 struct nlist *def_nlist;
448} symbol;
449
450/* Number of buckets in symbol hash table */
451#define TABSIZE 1009
452
453/* The symbol hash table: a vector of TABSIZE pointers to struct glosym. */
454symbol *symtab[TABSIZE];
455#define FOR_EACH_SYMBOL(i,sp) { \
456 int i; \
457 for (i = 0; i < TABSIZE; i++) { \
458 register symbol *sp; \
459 for (sp = symtab[i]; sp; sp = sp->link)
460
461#define END_EACH_SYMBOL }}
462
463/* Number of symbols in symbol hash table. */
464int num_hash_tab_syms;
465
466/* Count the number of nlist entries that are for local symbols.
467 This count and the three following counts
468 are incremented as as symbols are entered in the symbol table. */
469int local_sym_count;
470
471/* Count number of nlist entries that are for local symbols
472 whose names don't start with L. */
473int non_L_local_sym_count;
474
475/* Count the number of nlist entries for debugger info. */
476int debugger_sym_count;
477
478/* Count the number of global symbols referenced and not defined. */
479int undefined_global_sym_count;
480
481/* Count the number of symbols referenced from shared objects and not defined */
482int undefined_shobj_sym_count;
483
484/* Count the number of global symbols multiply defined. */
485int multiple_def_count;
486
487/* Count the number of defined global symbols.
488 Each symbol is counted only once
489 regardless of how many different nlist entries refer to it,
490 since the output file will need only one nlist entry for it.
491 This count is computed by `digest_symbols';
492 it is undefined while symbols are being loaded. */
493int defined_global_sym_count;
494
495/* Count the number of symbols defined through common declarations.
496 This count is kept in symdef_library, linear_library, and
497 enter_global_ref. It is incremented when the defined flag is set
498 in a symbol because of a common definition, and decremented when
499 the symbol is defined "for real" (ie. by something besides a common
500 definition). */
501int common_defined_global_count;
502
503/* Count the number of linker defined symbols.
504 XXX - Currently, only __DYNAMIC and _G_O_T_ go here if required,
505 perhaps _etext, _edata and _end should go here too */
506int special_sym_count;
507
508/* Count number of aliased symbols */
509int global_alias_count;
510
511/* Count number of set element type symbols and the number of separate
512 vectors which these symbols will fit into */
513int set_symbol_count;
514int set_vector_count;
515
516/* Define a linked list of strings which define symbols which should
517 be treated as set elements even though they aren't. Any symbol
518 with a prefix matching one of these should be treated as a set
519 element.
520
521 This is to make up for deficiencies in many assemblers which aren't
522 willing to pass any stabs through to the loader which they don't
523 understand. */
524struct string_list_element {
525 char *str;
526 struct string_list_element *next;
527};
528
529struct string_list_element *set_element_prefixes;
530
531/* Count the number of warning symbols encountered. */
532int warning_count;
533
534/* 1 => write load map. */
535int write_map;
536
537/* 1 => write relocation into output file so can re-input it later. */
538int relocatable_output;
539
540/* Nonzero means ptr to symbol entry for symbol to use as start addr.
541 -e sets this. */
542symbol *entry_symbol;
543
544symbol *edata_symbol; /* the symbol _edata */
545symbol *etext_symbol; /* the symbol _etext */
546symbol *end_symbol; /* the symbol _end */
547symbol *got_symbol; /* the symbol __GLOBAL_OFFSET_TABLE_ */
548symbol *dynamic_symbol; /* the symbol __DYNAMIC */
549
550\f
551/*
552 * Each input file, and each library member ("subfile") being loaded, has a
553 * `file_entry' structure for it.
554 *
555 * For files specified by command args, these are contained in the vector which
556 * `file_table' points to.
557 *
558 * For library members, they are dynamically allocated, and chained through the
559 * `chain' field. The chain is found in the `subfiles' field of the
560 * `file_entry'. The `file_entry' objects for the members have `superfile'
561 * fields pointing to the one for the library.
562 */
563
564struct file_entry {
565 /* Name of this file. */
566 char *filename;
567
568 /*
569 * Name to use for the symbol giving address of text start Usually
570 * the same as filename, but for a file spec'd with -l this is the -l
571 * switch itself rather than the filename.
572 */
573 char *local_sym_name;
574
575 /* Describe the layout of the contents of the file */
576
577 /* The file's a.out header. */
578 struct exec header;
579 /* Offset in file of GDB symbol segment, or 0 if there is none. */
580 int symseg_offset;
581
582 /* Describe data from the file loaded into core */
583
584 /*
585 * Symbol table of the file.
586 * We need access to the global symbol early, ie. before
587 * symbols are asssigned there final values. gotslot_offset is
588 * here because GOT entries may be generated for local symbols.
589 */
590 struct localsymbol {
591 struct nzlist nzlist;
592 struct glosym *symbol;
593 struct localsymbol *next;
594 long gotslot_offset;
595 char gotslot_claimed;
596 } *symbols;
597
598 /* Number of symbols in above array. */
599 int nsymbols;
600
601 /* Size in bytes of string table. */
602 int string_size;
603
604 /*
605 * Pointer to the string table. The string table is not kept in core
606 * all the time, but when it is in core, its address is here.
607 */
608 char *strings;
609
610 /* Offset of string table (normally N_STROFF() + 4) */
611 int strings_offset;
612
613 /* Next two used only if `relocatable_output' or if needed for */
614 /* output of undefined reference line numbers. */
615
616 /* Text reloc info saved by `write_text' for `coptxtrel'. */
617 struct relocation_info *textrel;
618 int ntextrel;
619
620 /* Data reloc info saved by `write_data' for `copdatrel'. */
621 struct relocation_info *datarel;
622 int ndatarel;
623
624 /* Relation of this file's segments to the output file */
625
626 /* Start of this file's text seg in the output file core image. */
627 int text_start_address;
628
629 /* Start of this file's data seg in the output file core image. */
630 int data_start_address;
631
632 /* Start of this file's bss seg in the output file core image. */
633 int bss_start_address;
634 /*
635 * Offset in bytes in the output file symbol table of the first local
636 * symbol for this file. Set by `write_file_symbols'.
637 */
638 int local_syms_offset;
639
640 /* For library members only */
641
642 /* For a library, points to chain of entries for the library members. */
643 struct file_entry *subfiles;
644
645 /*
646 * For a library member, offset of the member within the archive.
647 * Zero for files that are not library members.
648 */
649 int starting_offset;
650
651 /* Size of contents of this file, if library member. */
652 int total_size;
653
654 /* For library member, points to the library's own entry. */
655 struct file_entry *superfile;
656
657 /* For library member, points to next entry for next member. */
658 struct file_entry *chain;
659
660 /* 1 if file is a library. */
661 char library_flag;
662
663 /* 1 if file's header has been read into this structure. */
664 char header_read_flag;
665
666 /* 1 means search a set of directories for this file. */
667 char search_dirs_flag;
668
669 /*
670 * 1 means this is base file of incremental load. Do not load this
671 * file's text or data. Also default text_start to after this file's
672 * bss.
673 */
674 char just_syms_flag;
675
676 /* 1 means search for dynamic libraries (dependent on -B switch) */
677 char search_dynamic_flag;
678
679 /* version numbers of selected shared library */
680 int lib_major, lib_minor;
681
682 /* This entry is a shared object */
683 char is_dynamic;
684};
685
686typedef struct localsymbol localsymbol_t;
687
688/* Vector of entries for input files specified by arguments.
689 These are all the input files except for members of specified libraries. */
690struct file_entry *file_table;
691
692/* Length of that vector. */
693int number_of_files;
694
695/* Current link mode */
696#define DYNAMIC 1 /* Consider shared libraries */
697#define SYMBOLIC 2 /* Force symbolic resolution */
698#define FORCEARCHIVE 4 /* Force inclusion of all members
699 of archives */
700#define SHAREABLE 8 /* Build a shared object */
701int link_mode;
702
703/*
704 * Runtime Relocation Section (RRS).
705 * This describes the data structures that go into the output text and data
706 * segments to support the run-time linker. The RRS can be empty (plain old
707 * static linking), or can just exist of GOT and PLT entries (in case of
708 * statically linked PIC code).
709 */
710
711int rrs_section_type;
712#define RRS_NONE 0
713#define RRS_PARTIAL 1
714#define RRS_FULL 2
715
716int rrs_text_size;
717int rrs_data_size;
718int rrs_text_start;
719int rrs_data_start;
720
721/* Version number to put in __DYNAMIC (set by -V) */
722int soversion;
723
724/* When loading the text and data, we can avoid doing a close
725 and another open between members of the same library.
726
727 These two variables remember the file that is currently open.
728 Both are zero if no file is open.
729
730 See `each_file' and `file_close'. */
731
732struct file_entry *input_file;
733int input_desc;
734
735/* The name of the file to write; "a.out" by default. */
736
737char *output_filename;
738
739/* Descriptor for writing that file with `mywrite'. */
740
741int outdesc;
742
743/* Header for that file (filled in by `write_header'). */
744
745struct exec outheader;
746
747/* The following are computed by `digest_symbols'. */
748
749int text_size; /* total size of text of all input files. */
750int data_size; /* total size of data of all input files. */
751int bss_size; /* total size of bss of all input files. */
752int text_reloc_size; /* total size of text relocation of all input files. */
753int data_reloc_size; /* total size of data relocation of all input files. */
754
755/* Relocation offsets set by perform_relocation(). Defined globaly here
756 because some of the RRS routines need access to them */
757int text_relocation;
758int data_relocation;
759int bss_relocation;
760int pc_relocation;
761
762/* Specifications of start and length of the area reserved at the end
763 of the data segment for the set vectors. Computed in 'digest_symbols' */
764int set_sect_start;
765int set_sect_size;
766
767/* Amount of cleared space to leave between the text and data segments. */
768int text_pad;
769
770/* Amount of bss segment to include as part of the data segment. */
771int data_pad;
772
773
774/* Record most of the command options. */
775
776/* Address we assume the text section will be loaded at.
777 We relocate symbols and text and data for this, but we do not
778 write any padding in the output file for it. */
779int text_start;
780
781/* Offset of default entry-pc within the text section. */
782int entry_offset;
783
784/* Address we decide the data section will be loaded at. */
785int data_start;
786int bss_start;
787
788/* Keep a list of any symbols referenced from the command line (so
789 that error messages for these guys can be generated). This list is
790 zero terminated. */
791struct glosym **cmdline_references;
792int cl_refs_allocated;
793
794/*
795 * Actual vector of directories to search; this contains those specified with
796 * -L plus the standard ones.
797 */
798char **search_dirs;
799
800/* Length of the vector `search_dirs'. */
801int n_search_dirs;
802
803void digest_symbols __P((void));
804void load_symbols __P((void));
805void decode_command __P((int, char **));
806void read_header __P((int, struct file_entry *));
807void read_entry_symbols __P((int, struct file_entry *));
808void read_entry_strings __P((int, struct file_entry *));
809void read_entry_relocation __P((int, struct file_entry *));
810void write_output __P((void));
811void write_header __P((void));
812void write_text __P((void));
813void write_data __P((void));
814void write_rel __P((void));
815void write_syms __P((void));
816void write_symsegs __P((void));
817void mywrite ();
818
819/* In warnings.c: */
820void perror_name __P((char *));
821void perror_file __P((struct file_entry *));
822void fatal_with_file __P((char *, struct file_entry *, ...));
823void print_symbols __P((FILE *));
824char *get_file_name __P((struct file_entry *));
825void print_file_name __P((struct file_entry *, FILE *));
826void prline_file_name __P((struct file_entry *, FILE *));
827int do_warnings __P((FILE *));
828
829/* In etc.c: */
830void *xmalloc __P((int));
831void *xrealloc __P((void *, int));
832void fatal __P((char *, ...));
833void error __P((char *, ...));
834void padfile __P((int,int));
835char *concat __P((char *, char *, char *));
836int parse __P((char *, char *, char *));
837
838/* In symbol.c: */
839void symtab_init __P((int));
840symbol *getsym __P((char *)), *getsym_soft __P((char *));
841
842/* In lib.c: */
843void search_library __P((int, struct file_entry *));
844void read_shared_object __P((int, struct file_entry *));
845int findlib __P((struct file_entry *));
846
847/* In shlib.c: */
848char *findshlib __P((char *, int *, int *));
849void add_search_dir __P((char *));
850void std_search_dirs __P((char *));
851
852/* In rrs.c: */
853void init_rrs __P((void));
854void rrs_add_shobj __P((struct file_entry *));
855void alloc_rrs_reloc __P((symbol *));
856void alloc_rrs_segment_reloc __P((struct relocation_info *));
857void alloc_rrs_jmpslot __P((symbol *));
858void alloc_rrs_gotslot __P((struct relocation_info *, localsymbol_t *));
859void alloc_rrs_copy_reloc __P((symbol *));
860
861/* In <md>.c */
862void md_init_header __P((struct exec *, int, int));
863long md_get_addend __P((struct relocation_info *, unsigned char *));
864void md_relocate __P((struct relocation_info *, long, unsigned char *, int));
865void md_make_jmpslot __P((jmpslot_t *, long, long));
866void md_fix_jmpslot __P((jmpslot_t *, long, u_long));
867int md_make_reloc __P((struct relocation_info *, struct relocation_info *, int));
868void md_make_jmpreloc __P((struct relocation_info *, struct relocation_info *, int));
869void md_make_gotreloc __P((struct relocation_info *, struct relocation_info *, int));
870void md_make_copyreloc __P((struct relocation_info *, struct relocation_info *));
871
872#ifdef NEED_SWAP
873void md_swapin_exec_hdr __P((struct exec *));
874void md_swapout_exec_hdr __P((struct exec *));
875void md_swapin_reloc __P((struct relocation_info *, int));
876void md_swapout_reloc __P((struct relocation_info *, int));
877void md_swapout_jmpslot __P((jmpslot_t *, int));
878
879/* In xbits.c: */
880void swap_longs __P((long *, int));
881void swap_symbols __P((struct nlist *, int));
882void swap_zsymbols __P((struct nzlist *, int));
883void swap_ranlib_hdr __P((struct ranlib *, int));
884void swap_link_dynamic __P((struct link_dynamic *));
885void swap_link_dynamic_2 __P((struct link_dynamic_2 *));
886void swap_ld_debug __P((struct ld_debug *));
887void swapin_link_object __P((struct link_object *, int));
888void swapout_link_object __P((struct link_object *, int));
889void swapout_fshash __P((struct fshash *, int));
890#endif