comparison lwlink/main.c @ 185:b89adfb0d174

Added support for outputting a linkmap
author lost
date Sat, 21 Mar 2009 19:47:45 +0000
parents 833d392fec82
children 857cb407229e
comparison
equal deleted inserted replaced
184:220a760ec654 185:b89adfb0d174
94 break; 94 break;
95 95
96 case 0x100: 96 case 0x100:
97 add_section_base(arg); 97 add_section_base(arg);
98 break; 98 break;
99 99
100 case 'm':
101 map_file = arg;
102 break;
103
100 case ARGP_KEY_ARG: 104 case ARGP_KEY_ARG:
101 add_input_file(arg); 105 add_input_file(arg);
102 break; 106 break;
103 107
104 default: 108 default:
125 "Read library libLIBSPEC.a from the search path" }, 129 "Read library libLIBSPEC.a from the search path" },
126 { "library-path", 'L', "DIR", 0, 130 { "library-path", 'L', "DIR", 0,
127 "Add DIR to the library search path" }, 131 "Add DIR to the library search path" },
128 { "section-base", 0x100, "SECT=BASE", 0, 132 { "section-base", 0x100, "SECT=BASE", 0,
129 "Load section SECT at BASE" }, 133 "Load section SECT at BASE" },
134 { "map", 'm', "FILE", 0,
135 "Output informaiton about the link" },
130 { 0 } 136 { 0 }
131 }; 137 };
132 138
133 static struct argp argp = 139 static struct argp argp =
134 { 140 {
141 extern void read_files(void); 147 extern void read_files(void);
142 extern void setup_script(void); 148 extern void setup_script(void);
143 extern void resolve_sections(void); 149 extern void resolve_sections(void);
144 extern void resolve_references(void); 150 extern void resolve_references(void);
145 extern void do_output(void); 151 extern void do_output(void);
152 extern void display_map(void);
146 153
147 // main function; parse command line, set up assembler state, and run the 154 // main function; parse command line, set up assembler state, and run the
148 // assembler on the first file 155 // assembler on the first file
149 int main(int argc, char **argv) 156 int main(int argc, char **argv)
150 { 157 {
169 // resolve incomplete references 176 // resolve incomplete references
170 resolve_references(); 177 resolve_references();
171 178
172 // do the actual output 179 // do the actual output
173 do_output(); 180 do_output();
174 181
182 // display/output the link map
183 if (map_file)
184 display_map();
185
175 exit(0); 186 exit(0);
176 } 187 }