annotate src/lwlink.h @ 300:48945dac8178

Fixed copyright year
author lost
date Wed, 21 Jan 2009 05:13:36 +0000
parents 460d96987670
children 376cc55361c7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
294
0f488febdc2b command line options
lost
parents:
diff changeset
1 /*
0f488febdc2b command line options
lost
parents:
diff changeset
2 lwlink.h
300
48945dac8178 Fixed copyright year
lost
parents: 299
diff changeset
3 Copyright © 2009 William Astle
294
0f488febdc2b command line options
lost
parents:
diff changeset
4
0f488febdc2b command line options
lost
parents:
diff changeset
5 This file is part of LWLINK.
0f488febdc2b command line options
lost
parents:
diff changeset
6
0f488febdc2b command line options
lost
parents:
diff changeset
7 LWLINK is free software: you can redistribute it and/or modify it under the
0f488febdc2b command line options
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
0f488febdc2b command line options
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
0f488febdc2b command line options
lost
parents:
diff changeset
10 version.
0f488febdc2b command line options
lost
parents:
diff changeset
11
0f488febdc2b command line options
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
0f488febdc2b command line options
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0f488febdc2b command line options
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
0f488febdc2b command line options
lost
parents:
diff changeset
15 more details.
0f488febdc2b command line options
lost
parents:
diff changeset
16
0f488febdc2b command line options
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
0f488febdc2b command line options
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
0f488febdc2b command line options
lost
parents:
diff changeset
19
0f488febdc2b command line options
lost
parents:
diff changeset
20 Contains the main defs used by the linker
0f488febdc2b command line options
lost
parents:
diff changeset
21 */
0f488febdc2b command line options
lost
parents:
diff changeset
22
0f488febdc2b command line options
lost
parents:
diff changeset
23
0f488febdc2b command line options
lost
parents:
diff changeset
24 #ifndef __lwlink_h_seen__
0f488febdc2b command line options
lost
parents:
diff changeset
25 #define __lwlink_h_seen__
0f488febdc2b command line options
lost
parents:
diff changeset
26
298
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
27 #include "expr.h"
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
28
294
0f488febdc2b command line options
lost
parents:
diff changeset
29 #define OUTPUT_DECB 0 // DECB multirecord format
0f488febdc2b command line options
lost
parents:
diff changeset
30 #define OUTPUT_RAW 1 // raw sequence of bytes
0f488febdc2b command line options
lost
parents:
diff changeset
31
298
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
32 typedef struct symtab_s symtab_t;
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
33 struct symtab_s
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
34 {
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
35 unsigned char *sym; // symbol name
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
36 int offset; // local offset
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
37 int realval; // resolved value
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
38 symtab_t *next; // next symbol
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
39 };
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
40
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
41 typedef struct reloc_s reloc_t;
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
42 struct reloc_s
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
43 {
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
44 int offset; // where in the section
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
45 lw_expr_stack_t *expr; // the expression to calculate it
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
46 reloc_t *next; // ptr to next relocation
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
47 };
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
48
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
49 #define SECTION_BSS 1
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
50 typedef struct
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
51 {
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
52 unsigned char *name; // name of the section
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
53 int flags; // section flags
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
54 int codesize; // size of the code
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
55 unsigned char *code; // pointer to the code
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
56 int loadaddress; // the actual load address of the section
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
57
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
58 symtab_t *localsyms; // local symbol table
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
59 symtab_t *exportedsyms; // exported symbols table
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
60
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
61 reloc_t *incompletes; // table of incomplete references
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
62 } section_t;
297
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
63
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
64 typedef struct
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
65 {
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
66 char *filename;
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
67 unsigned char *filedata;
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
68 long filesize;
298
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
69 section_t *sections;
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
70 int nsections;
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
71
297
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
72 } fileinfo_t;
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
73
298
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
74
96a35a4245f3 reading files implemented
lost
parents: 297
diff changeset
75
294
0f488febdc2b command line options
lost
parents:
diff changeset
76 #ifndef __lwlink_c_seen__
0f488febdc2b command line options
lost
parents:
diff changeset
77
0f488febdc2b command line options
lost
parents:
diff changeset
78 extern int debug_level;
0f488febdc2b command line options
lost
parents:
diff changeset
79 extern int outformat;
0f488febdc2b command line options
lost
parents:
diff changeset
80 extern char *outfile;
296
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
81 extern int ninputfiles;
297
c52ad3135bd3 implement reading files
lost
parents: 296
diff changeset
82 extern fileinfo_t **inputfiles;
299
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
83 extern char *scriptfile;
294
0f488febdc2b command line options
lost
parents:
diff changeset
84
296
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
85 #define __lwlink_E__ extern
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
86 #else
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
87 #define __lwlink_E__
294
0f488febdc2b command line options
lost
parents:
diff changeset
88 #endif // __lwlink_c_seen__
0f488febdc2b command line options
lost
parents:
diff changeset
89
296
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
90 __lwlink_E__ void add_input_file(char *fn);
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
91
14d835cf02d9 Handle input files on command line and add some memory management utility functions
lost
parents: 294
diff changeset
92 #undef __lwlink_E__
299
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
93
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
94 struct scriptline_s
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
95 {
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
96 char *sectname; // name of section, NULL for wildcard
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
97 int loadat; // address to load at (or -1)
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
98 int noflags; // flags to NOT have
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
99 int yesflags; // flags to HAVE
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
100 };
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
101
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
102 typedef struct
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
103 {
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
104 int nlines; // number of lines in the script
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
105 struct scriptline_s *lines; // the parsed script lines (section)
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
106 int padsize; // the size to pad to, -1 for none
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
107 } linkscript_t;
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
108
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
109 #ifndef __script_c_seen__
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
110 extern linkscript_t linkscript;
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
111 #endif
460d96987670 parse linking scripts
lost
parents: 298
diff changeset
112
294
0f488febdc2b command line options
lost
parents:
diff changeset
113 #endif //__lwlink_h_seen__