1 // ld.c -- linker main function
11 #include "workqueue.h"
12 #include "dirsearch.h"
18 const char* program_name
;
21 gold_exit(bool status
)
23 exit(status
? EXIT_SUCCESS
: EXIT_FAILURE
);
27 gold_fatal(const char* msg
, bool perrno
)
29 fprintf(stderr
, "%s: ", program_name
);
33 fprintf(stderr
, "%s\n", msg
);
40 // We are out of memory, so try hard to print a reasonable message.
41 // Note that we don't try to translate this message, since the
42 // translation process itself will require memory.
43 write(2, program_name
, strlen(program_name
));
44 const char* const s
= ": out of memory\n";
45 write(2, s
, strlen(s
));
55 } // End namespace gold.
62 // Queue up the initial set of tasks for this link job.
65 queue_initial_tasks(const General_options
& options
,
66 const Dirsearch
& search_path
,
67 const Command_line::Input_argument_list
& inputs
,
71 gold_fatal(_("no input files"), false);
73 // Read the input files. We have to add the symbols to the symbol
74 // table in order. We do this by creating a separate blocker for
75 // each input file. We associate the blocker with the following
76 // input file, to give us a convenient place to delete it.
77 Task_token
* this_blocker
= NULL
;
78 for (Command_line::Input_argument_list::const_iterator p
= inputs
.begin();
82 Task_token
* next_blocker
= new Task_token();
83 next_blocker
->add_blocker();
84 workqueue
->queue(new Read_symbols(options
, search_path
, *p
, this_blocker
,
86 this_blocker
= next_blocker
;
89 // workqueue->queue(new Layout(options, inputs, this_blocker));
92 } // end anonymous namespace.
95 main(int argc
, char** argv
)
97 #if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
98 setlocale (LC_MESSAGES
, "");
100 #if defined (HAVE_SETLOCALE)
101 setlocale (LC_CTYPE
, "");
103 bindtextdomain (PACKAGE
, LOCALEDIR
);
104 textdomain (PACKAGE
);
106 gold::program_name
= argv
[0];
108 // Handle the command line options.
109 gold::Command_line command_line
;
110 command_line
.process(argc
- 1, argv
+ 1);
113 gold::Workqueue
workqueue(command_line
.options());
117 // Get the search path from the -L options.
118 Dirsearch search_path
;
119 search_path
.add(&workqueue
, command_line
.options().search_path());
121 // Queue up the first set of tasks.
122 queue_initial_tasks(command_line
.options(), search_path
,
123 command_line
.inputs(), &workqueue
);
125 // Run the main task processing loop.
128 gold::gold_exit(true);