* aoutx.h (translate_to_native_sym_flags): Set the type of a
[deliverable/binutils-gdb.git] / ld / ldmain.c
1 /* Copyright (C) 1991, 1993 Free Software Foundation, Inc.
2 Written by Steve Chamberlain steve@cygnus.com
3
4 This file is part of GLD, the Gnu Linker.
5
6 GLD is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GLD is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GLD; see the file COPYING. If not, write to
18 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21 #include "bfd.h"
22 #include "sysdep.h"
23 #include <stdio.h>
24 #include "bfdlink.h"
25
26 #include "config.h"
27 #include "ld.h"
28 #include "ldmain.h"
29 #include "ldmisc.h"
30 #include "ldwrite.h"
31 #include "ldgram.h"
32 #include "ldexp.h"
33 #include "ldlang.h"
34 #include "ldemul.h"
35 #include "ldlex.h"
36 #include "ldfile.h"
37 #include "ldctor.h"
38
39 /* Somewhere above, sys/stat.h got included . . . . */
40 #if !defined(S_ISDIR) && defined(S_IFDIR)
41 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
42 #endif
43
44 #include <string.h>
45
46 static char *get_emulation PARAMS ((int, char **));
47 static void set_scripts_dir PARAMS ((void));
48
49 /* EXPORTS */
50
51 char *default_target;
52 const char *output_filename = "a.out";
53
54 /* Name this program was invoked by. */
55 char *program_name;
56
57 /* The file that we're creating */
58 bfd *output_bfd = 0;
59
60 /* Set by -G argument, for MIPS ECOFF target. */
61 int g_switch_value = 8;
62
63 /* Nonzero means print names of input files as processed. */
64 boolean trace_files;
65
66 /* Nonzero means same, but note open failures, too. */
67 boolean trace_file_tries;
68
69 /* 1 => write load map. */
70 boolean write_map;
71
72 args_type command_line;
73
74 ld_config_type config;
75
76 static boolean check_for_scripts_dir PARAMS ((char *dir));
77 static boolean add_archive_element PARAMS ((struct bfd_link_info *, bfd *,
78 const char *));
79 static boolean multiple_definition PARAMS ((struct bfd_link_info *,
80 const char *,
81 bfd *, asection *, bfd_vma,
82 bfd *, asection *, bfd_vma));
83 static boolean multiple_common PARAMS ((struct bfd_link_info *,
84 const char *, bfd *,
85 enum bfd_link_hash_type, bfd_vma,
86 bfd *, enum bfd_link_hash_type,
87 bfd_vma));
88 static boolean add_to_set PARAMS ((struct bfd_link_info *,
89 struct bfd_link_hash_entry *,
90 unsigned int bitsize,
91 bfd *, asection *, bfd_vma));
92 static boolean constructor_callback PARAMS ((struct bfd_link_info *,
93 boolean constructor,
94 unsigned int bitsize,
95 const char *name,
96 bfd *, asection *, bfd_vma));
97 static boolean warning_callback PARAMS ((struct bfd_link_info *,
98 const char *));
99 static boolean undefined_symbol PARAMS ((struct bfd_link_info *,
100 const char *, bfd *,
101 asection *, bfd_vma));
102 static boolean reloc_overflow PARAMS ((struct bfd_link_info *, bfd *,
103 asection *, bfd_vma));
104 static boolean reloc_dangerous PARAMS ((struct bfd_link_info *, const char *,
105 bfd *, asection *, bfd_vma));
106 static boolean unattached_reloc PARAMS ((struct bfd_link_info *,
107 const char *, bfd *, asection *,
108 bfd_vma));
109 static boolean notice_ysym PARAMS ((struct bfd_link_info *, const char *,
110 bfd *, asection *, bfd_vma));
111
112 static struct bfd_link_callbacks link_callbacks =
113 {
114 add_archive_element,
115 multiple_definition,
116 multiple_common,
117 add_to_set,
118 constructor_callback,
119 warning_callback,
120 undefined_symbol,
121 reloc_overflow,
122 reloc_dangerous,
123 unattached_reloc,
124 notice_ysym
125 };
126
127 struct bfd_link_info link_info;
128 \f
129 extern int main PARAMS ((int, char **));
130
131 int
132 main (argc, argv)
133 int argc;
134 char **argv;
135 {
136 char *emulation;
137
138 program_name = argv[0];
139
140 bfd_init ();
141
142 /* Initialize the data about options. */
143 trace_files = trace_file_tries = false;
144 write_map = false;
145 config.build_constructors = true;
146 command_line.force_common_definition = false;
147
148 link_info.callbacks = &link_callbacks;
149 link_info.relocateable = false;
150 link_info.strip = strip_none;
151 link_info.discard = discard_none;
152 link_info.lprefix_len = 1;
153 link_info.lprefix = "L";
154 link_info.keep_memory = true;
155 link_info.input_bfds = NULL;
156 link_info.create_object_symbols_section = NULL;
157 link_info.hash = NULL;
158 link_info.keep_hash = NULL;
159 link_info.notice_hash = NULL;
160
161 ldfile_add_arch ("");
162
163 config.make_executable = true;
164 force_make_executable = false;
165 config.magic_demand_paged = true;
166 config.text_read_only = true;
167 config.make_executable = true;
168
169 emulation = get_emulation (argc, argv);
170 ldemul_choose_mode (emulation);
171 default_target = ldemul_choose_target ();
172 lang_init ();
173 ldemul_before_parse ();
174 lang_has_input_file = false;
175 parse_args (argc, argv);
176
177 /* This essentially adds another -L directory so this must be done after
178 the -L's in argv have been processed. */
179 set_scripts_dir ();
180
181 if (had_script == false)
182 {
183 /* Read the emulation's appropriate default script. */
184 int isfile;
185 char *s = ldemul_get_script (&isfile);
186
187 if (isfile)
188 {
189 /* sizeof counts the terminating NUL. */
190 size_t size = strlen (s) + sizeof ("-T ");
191 char *buf = (char *) ldmalloc(size);
192 sprintf (buf, "-T %s", s);
193 parse_line (buf, 0);
194 free (buf);
195 }
196 else
197 parse_line (s, 1);
198 }
199
200 if (link_info.relocateable && command_line.relax)
201 {
202 einfo ("%P%F: -relax and -r may not be used together\n");
203 }
204 lang_final ();
205
206 if (lang_has_input_file == false)
207 {
208 einfo ("%P%F: no input files\n");
209 }
210
211 if (trace_files)
212 {
213 info_msg ("%P: mode %s\n", emulation);
214 }
215
216 ldemul_after_parse ();
217
218
219 if (config.map_filename)
220 {
221 if (strcmp (config.map_filename, "-") == 0)
222 {
223 config.map_file = stdout;
224 }
225 else
226 {
227 config.map_file = fopen (config.map_filename, FOPEN_WT);
228 if (config.map_file == (FILE *) NULL)
229 {
230 einfo ("%P%F: cannot open map file %s: %E\n",
231 config.map_filename);
232 }
233 }
234 }
235
236
237 lang_process ();
238
239 /* Print error messages for any missing symbols, for any warning
240 symbols, and possibly multiple definitions */
241
242
243 if (config.text_read_only)
244 {
245 /* Look for a text section and mark the readonly attribute in it */
246 asection *found = bfd_get_section_by_name (output_bfd, ".text");
247
248 if (found != (asection *) NULL)
249 {
250 found->flags |= SEC_READONLY;
251 }
252 }
253
254 if (link_info.relocateable)
255 output_bfd->flags &= ~EXEC_P;
256 else
257 output_bfd->flags |= EXEC_P;
258
259 ldwrite ();
260
261 /* Even if we're producing relocateable output, some non-fatal errors should
262 be reported in the exit status. (What non-fatal errors, if any, do we
263 want to ignore for relocateable output?) */
264
265 if (config.make_executable == false && force_make_executable == false)
266 {
267 if (trace_files == true)
268 {
269 einfo ("%P: link errors found, deleting executable `%s'\n",
270 output_filename);
271 }
272
273 if (output_bfd->iostream)
274 fclose ((FILE *) (output_bfd->iostream));
275
276 unlink (output_filename);
277 exit (1);
278 }
279 else
280 {
281 bfd_close (output_bfd);
282 }
283
284 if (config.stats)
285 {
286 extern char **environ;
287 char *lim = (char *) sbrk (0);
288
289 fprintf (stderr, "%s: data size %ld\n", program_name,
290 (long) (lim - (char *) &environ));
291 }
292
293 exit (0);
294 return 0;
295 }
296
297 /* We need to find any explicitly given emulation in order to initialize the
298 state that's needed by the lex&yacc argument parser (parse_args). */
299
300 static char *
301 get_emulation (argc, argv)
302 int argc;
303 char **argv;
304 {
305 char *emulation;
306 int i;
307
308 emulation = (char *) getenv (EMULATION_ENVIRON);
309 if (emulation == NULL)
310 emulation = DEFAULT_EMULATION;
311
312 for (i = 1; i < argc; i++)
313 {
314 if (!strncmp (argv[i], "-m", 2))
315 {
316 if (argv[i][2] == '\0')
317 {
318 /* -m EMUL */
319 if (i < argc - 1)
320 {
321 emulation = argv[i + 1];
322 i++;
323 }
324 else
325 {
326 einfo("%P%F: missing argument to -m\n");
327 }
328 }
329 else if (strcmp (argv[i], "-mips1") == 0
330 || strcmp (argv[i], "-mips2") == 0
331 || strcmp (argv[i], "-mips3") == 0)
332 {
333 /* FIXME: The arguments -mips1, -mips2 and -mips3 are
334 passed to the linker by some MIPS compilers. They
335 generally tell the linker to use a slightly different
336 library path. Perhaps someday these should be
337 implemented as emulations; until then, we just ignore
338 the arguments and hope that nobody ever creates
339 emulations named ips1, ips2 or ips3. */
340 }
341 else
342 {
343 /* -mEMUL */
344 emulation = &argv[i][2];
345 }
346 }
347 }
348
349 return emulation;
350 }
351
352 /* If directory DIR contains an "ldscripts" subdirectory,
353 add DIR to the library search path and return true,
354 else return false. */
355
356 static boolean
357 check_for_scripts_dir (dir)
358 char *dir;
359 {
360 size_t dirlen;
361 char *buf;
362 struct stat s;
363 boolean res;
364
365 dirlen = strlen (dir);
366 /* sizeof counts the terminating NUL. */
367 buf = (char *) ldmalloc (dirlen + sizeof("/ldscripts"));
368 sprintf (buf, "%s/ldscripts", dir);
369
370 res = stat (buf, &s) == 0 && S_ISDIR (s.st_mode);
371 free (buf);
372 if (res)
373 ldfile_add_library_path (dir);
374 return res;
375 }
376
377 /* Set the default directory for finding script files.
378 Libraries will be searched for here too, but that's ok.
379 We look for the "ldscripts" directory in:
380
381 SCRIPTDIR (passed from Makefile)
382 the dir where this program is (for using it from the build tree)
383 the dir where this program is/../lib (for installing the tool suite elsewhere) */
384
385 static void
386 set_scripts_dir ()
387 {
388 char *end, *dir;
389 size_t dirlen;
390
391 if (check_for_scripts_dir (SCRIPTDIR))
392 return; /* We've been installed normally. */
393
394 /* Look for "ldscripts" in the dir where our binary is. */
395 end = strrchr (program_name, '/');
396 if (end)
397 {
398 dirlen = end - program_name;
399 /* Make a copy of program_name in dir.
400 Leave room for later "/../lib". */
401 dir = (char *) ldmalloc (dirlen + 8);
402 strncpy (dir, program_name, dirlen);
403 dir[dirlen] = '\0';
404 }
405 else
406 {
407 dirlen = 1;
408 dir = (char *) ldmalloc (dirlen + 8);
409 strcpy (dir, ".");
410 }
411
412 if (check_for_scripts_dir (dir))
413 return; /* Don't free dir. */
414
415 /* Look for "ldscripts" in <the dir where our binary is>/../lib. */
416 strcpy (dir + dirlen, "/../lib");
417 if (check_for_scripts_dir (dir))
418 return;
419
420 free (dir); /* Well, we tried. */
421 }
422
423 void
424 add_ysym (name)
425 const char *name;
426 {
427 if (link_info.notice_hash == (struct bfd_hash_table *) NULL)
428 {
429 link_info.notice_hash = ((struct bfd_hash_table *)
430 ldmalloc (sizeof (struct bfd_hash_table)));
431 if (! bfd_hash_table_init_n (link_info.notice_hash,
432 bfd_hash_newfunc,
433 61))
434 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
435 }
436
437 if (bfd_hash_lookup (link_info.notice_hash, name, true, true)
438 == (struct bfd_hash_entry *) NULL)
439 einfo ("%P%F: bfd_hash_lookup failed: %E\n");
440 }
441
442 /* Handle the -retain-symbols-file option. */
443
444 void
445 add_keepsyms_file (filename)
446 const char *filename;
447 {
448 FILE *file;
449 char *buf;
450 size_t bufsize;
451 int c;
452
453 if (link_info.strip == strip_some)
454 einfo ("%X%P: error: duplicate retain-symbols-file\n");
455
456 file = fopen (filename, "r");
457 if (file == (FILE *) NULL)
458 {
459 bfd_error = system_call_error;
460 einfo ("%X%P: %s: %E", filename);
461 return;
462 }
463
464 link_info.keep_hash = ((struct bfd_hash_table *)
465 ldmalloc (sizeof (struct bfd_hash_table)));
466 if (! bfd_hash_table_init (link_info.keep_hash, bfd_hash_newfunc))
467 einfo ("%P%F: bfd_hash_table_init failed: %E\n");
468
469 bufsize = 100;
470 buf = (char *) ldmalloc (bufsize);
471
472 c = getc (file);
473 while (c != EOF)
474 {
475 while (isspace (c))
476 c = getc (file);
477
478 if (c != EOF)
479 {
480 size_t len = 0;
481
482 while (! isspace (c) && c != EOF)
483 {
484 buf[len] = c;
485 ++len;
486 if (len >= bufsize)
487 {
488 bufsize *= 2;
489 buf = ldrealloc (buf, bufsize);
490 }
491 c = getc (file);
492 }
493
494 buf[len] = '\0';
495
496 if (bfd_hash_lookup (link_info.keep_hash, buf, true, true)
497 == (struct bfd_hash_entry *) NULL)
498 einfo ("%P%F: bfd_hash_lookup for insertion failed: %E");
499 }
500 }
501
502 if (link_info.strip != strip_none)
503 einfo ("%P: `-retain-symbols-file' overrides `-s' and `-S'\n");
504
505 link_info.strip = strip_some;
506 }
507 \f
508 /* Callbacks from the BFD linker routines. */
509
510 /* This is called when BFD has decided to include an archive member in
511 a link. */
512
513 /*ARGSUSED*/
514 static boolean
515 add_archive_element (info, abfd, name)
516 struct bfd_link_info *info;
517 bfd *abfd;
518 const char *name;
519 {
520 lang_input_statement_type *input;
521
522 input = ((lang_input_statement_type *)
523 ldmalloc ((bfd_size_type) sizeof (lang_input_statement_type)));
524 input->filename = abfd->filename;
525 input->local_sym_name = abfd->filename;
526 input->the_bfd = abfd;
527 input->asymbols = NULL;
528 input->subfiles = NULL;
529 input->next = NULL;
530 input->just_syms_flag = false;
531 input->loaded = false;
532 input->chain = NULL;
533
534 /* FIXME: This is wrong. It should point to an entry for the
535 archive itself. However, it doesn't seem to matter. */
536 input->superfile = NULL;
537
538 /* FIXME: The following fields are not set: header.next,
539 header.type, closed, passive_position, symbol_count, total_size,
540 next_real_file, is_archive, search_dirs_flag, target, real,
541 common_section, common_output_section, complained. This bit of
542 code is from the old decode_library_subfile function. I don't
543 know whether any of those fields matters. */
544
545 ldlang_add_file (input);
546
547 if (write_map)
548 info_msg ("%s needed due to %T\n", abfd->filename, name);
549
550 return true;
551 }
552
553 /* This is called when BFD has discovered a symbol which is defined
554 multiple times. */
555
556 /*ARGSUSED*/
557 static boolean
558 multiple_definition (info, name, obfd, osec, oval, nbfd, nsec, nval)
559 struct bfd_link_info *info;
560 const char *name;
561 bfd *obfd;
562 asection *osec;
563 bfd_vma oval;
564 bfd *nbfd;
565 asection *nsec;
566 bfd_vma nval;
567 {
568 einfo ("%X%C: multiple definition of `%T'\n",
569 nbfd, nsec, nval, name);
570 if (obfd != (bfd *) NULL)
571 einfo ("%C: first defined here\n", obfd, osec, oval);
572 return true;
573 }
574
575 /* This is called when there is a definition of a common symbol, or
576 when a common symbol is found for a symbol that is already defined,
577 or when two common symbols are found. We only do something if
578 -warn-common was used. */
579
580 /*ARGSUSED*/
581 static boolean
582 multiple_common (info, name, obfd, otype, osize, nbfd, ntype, nsize)
583 struct bfd_link_info *info;
584 const char *name;
585 bfd *obfd;
586 enum bfd_link_hash_type otype;
587 bfd_vma osize;
588 bfd *nbfd;
589 enum bfd_link_hash_type ntype;
590 bfd_vma nsize;
591 {
592 if (! config.warn_common)
593 return true;
594
595 if (ntype == bfd_link_hash_defined)
596 {
597 ASSERT (otype == bfd_link_hash_common);
598 einfo ("%B: warning: definition of `%T' overriding common\n",
599 nbfd, name);
600 einfo ("%B: warning: common is here\n", obfd);
601 }
602 else if (otype == bfd_link_hash_defined)
603 {
604 ASSERT (ntype == bfd_link_hash_common);
605 einfo ("%B: warning: common of `%T' overridden by definition\n",
606 nbfd, name);
607 einfo ("%B: warning: defined here\n", obfd);
608 }
609 else
610 {
611 ASSERT (otype == bfd_link_hash_common && ntype == bfd_link_hash_common);
612 if (osize > nsize)
613 {
614 einfo ("%B: warning: common of `%T' overridden by larger common\n",
615 nbfd, name);
616 einfo ("%B: warning: larger common is here\n", obfd);
617 }
618 else if (nsize > osize)
619 {
620 einfo ("%B: warning: common of `%T' overriding smaller common\n",
621 nbfd, name);
622 einfo ("%B: warning: smaller common is here\n", obfd);
623 }
624 else
625 {
626 einfo ("%B: warning: multiple common of `%T'\n", nbfd, name);
627 einfo ("%B: warning: previous common is here\n", obfd);
628 }
629 }
630
631 return true;
632 }
633
634 /* This is called when BFD has discovered a set element. H is the
635 entry in the linker hash table for the set. SECTION and VALUE
636 represent a value which should be added to the set. */
637
638 /*ARGSUSED*/
639 static boolean
640 add_to_set (info, h, bitsize, abfd, section, value)
641 struct bfd_link_info *info;
642 struct bfd_link_hash_entry *h;
643 unsigned int bitsize;
644 bfd *abfd;
645 asection *section;
646 bfd_vma value;
647 {
648 ldctor_add_set_entry (h, bitsize, section, value);
649 return true;
650 }
651
652 /* This is called when BFD has discovered a constructor. This is only
653 called for some object file formats--those which do not handle
654 constructors in some more clever fashion. This is similar to
655 adding an element to a set, but less general. */
656
657 static boolean
658 constructor_callback (info, constructor, bitsize, name, abfd, section, value)
659 struct bfd_link_info *info;
660 boolean constructor;
661 unsigned int bitsize;
662 const char *name;
663 bfd *abfd;
664 asection *section;
665 bfd_vma value;
666 {
667 char *set_name;
668 char *s;
669 struct bfd_link_hash_entry *h;
670
671 if (! config.build_constructors)
672 return true;
673
674 set_name = (char *) alloca (1 + sizeof "__CTOR_LIST__");
675 s = set_name;
676 if (bfd_get_symbol_leading_char (abfd) != '\0')
677 *s++ = bfd_get_symbol_leading_char (abfd);
678 if (constructor)
679 strcpy (s, "__CTOR_LIST__");
680 else
681 strcpy (s, "__DTOR_LIST__");
682
683 if (write_map)
684 info_msg ("Adding %s to constructor/destructor set %s\n", name, set_name);
685
686 h = bfd_link_hash_lookup (info->hash, set_name, true, true, true);
687 if (h == (struct bfd_link_hash_entry *) NULL)
688 einfo ("%P%F: bfd_link_hash_lookup failed: %E");
689 if (h->type == bfd_link_hash_new)
690 {
691 h->type = bfd_link_hash_undefined;
692 h->u.undef.abfd = abfd;
693 /* We don't call bfd_link_add_undef to add this to the list of
694 undefined symbols because we are going to define it
695 ourselves. */
696 }
697
698 ldctor_add_set_entry (h, bitsize, section, value);
699 return true;
700 }
701
702 /* This is called when there is a reference to a warning symbol. */
703
704 /*ARGSUSED*/
705 static boolean
706 warning_callback (info, warning)
707 struct bfd_link_info *info;
708 const char *warning;
709 {
710 einfo ("%P: %s\n", warning);
711 return true;
712 }
713
714 /* This is called when an undefined symbol is found. */
715
716 /*ARGSUSED*/
717 static boolean
718 undefined_symbol (info, name, abfd, section, address)
719 struct bfd_link_info *info;
720 const char *name;
721 bfd *abfd;
722 asection *section;
723 bfd_vma address;
724 {
725 static char *error_name;
726 static unsigned int error_count;
727
728 #define MAX_ERRORS_IN_A_ROW 5
729
730 /* We never print more than a reasonable number of errors in a row
731 for a single symbol. */
732 if (error_name != (char *) NULL
733 && strcmp (name, error_name) == 0)
734 ++error_count;
735 else
736 {
737 error_count = 0;
738 if (error_name != (char *) NULL)
739 free (error_name);
740 error_name = buystring (name);
741 }
742
743 if (error_count < MAX_ERRORS_IN_A_ROW)
744 einfo ("%X%C: undefined reference to `%T'\n",
745 abfd, section, address, name);
746 else if (error_count == MAX_ERRORS_IN_A_ROW)
747 einfo ("%C: more undefined references to `%T' follow\n",
748 abfd, section, address, name);
749
750 return true;
751 }
752
753 /* This is called when a reloc overflows. */
754
755 /*ARGSUSED*/
756 static boolean
757 reloc_overflow (info, abfd, section, address)
758 struct bfd_link_info *info;
759 bfd *abfd;
760 asection *section;
761 bfd_vma address;
762 {
763 einfo ("%X%C: relocation truncated to fit\n", abfd, section, address);
764 return true;
765 }
766
767 /* This is called when a dangerous relocation is made. */
768
769 /*ARGSUSED*/
770 static boolean
771 reloc_dangerous (info, message, abfd, section, address)
772 struct bfd_link_info *info;
773 const char *message;
774 bfd *abfd;
775 asection *section;
776 bfd_vma address;
777 {
778 einfo ("%X%C: dangerous relocation: %s\n", abfd, section, address, message);
779 return true;
780 }
781
782 /* This is called when a reloc is being generated attached to a symbol
783 that is not being output. */
784
785 /*ARGSUSED*/
786 static boolean
787 unattached_reloc (info, name, abfd, section, address)
788 struct bfd_link_info *info;
789 const char *name;
790 bfd *abfd;
791 asection *section;
792 bfd_vma address;
793 {
794 einfo ("%X%C: reloc refers to symbol `%T' which is not being output\n",
795 abfd, section, address, name);
796 return true;
797 }
798
799 /* This is called when a symbol in notice_hash is found. Symbols are
800 put in notice_hash using the -y option. */
801
802 /*ARGSUSED*/
803 static boolean
804 notice_ysym (info, name, abfd, section, value)
805 struct bfd_link_info *info;
806 const char *name;
807 bfd *abfd;
808 asection *section;
809 bfd_vma value;
810 {
811 einfo ("%B: %s %s\n", abfd,
812 section != &bfd_und_section ? "definition of" : "reference to",
813 name);
814 return true;
815 }
This page took 0.046187 seconds and 4 git commands to generate.