* emultempl/spuelf.em: Abort on the missing required `spu_ovl.o'.
[deliverable/binutils-gdb.git] / ld / emultempl / spuelf.em
1 # This shell script emits a C file. -*- C -*-
2 # Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program 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 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program 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 this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # This file is sourced from elf32.em, and defines extra spu specific
23 # features.
24 #
25 fragment <<EOF
26 #include "ldctor.h"
27 #include "elf32-spu.h"
28
29 /* Non-zero if no overlay processing should be done. */
30 static int no_overlays = 0;
31
32 /* Non-zero if we want stubs on all calls out of overlay regions. */
33 static int non_overlay_stubs = 0;
34
35 /* Whether to emit symbols for stubs. */
36 static int emit_stub_syms = 0;
37
38 /* Non-zero to perform stack space analysis. */
39 static int stack_analysis = 0;
40
41 /* Whether to emit symbols with stack requirements for each function. */
42 static int emit_stack_syms = 0;
43
44 /* Range of valid addresses for loadable sections. */
45 static bfd_vma local_store_lo = 0;
46 static bfd_vma local_store_hi = 0x3ffff;
47
48 /* Control --auto-overlay feature. */
49 static int auto_overlay = 0;
50 static char *auto_overlay_file = 0;
51 static unsigned int auto_overlay_fixed = 0;
52 static unsigned int auto_overlay_reserved = 0;
53 static int extra_stack_space = 2000;
54 int my_argc;
55 char **my_argv;
56
57 static const char ovl_mgr[] = {
58 EOF
59
60 if ! ../binutils/bin2c < ${srcdir}/emultempl/spu_ovl.o >> e${EMULATION_NAME}.c
61 then
62 echo >&2 "Missing ${srcdir}/emultempl/spu_ovl.o"
63 echo >&2 "You must build gas/as-new with --target=spu to build spu_ovl.o"
64 exit 1
65 fi
66
67 fragment <<EOF
68 };
69
70 static const struct _ovl_stream ovl_mgr_stream = {
71 ovl_mgr,
72 ovl_mgr + sizeof (ovl_mgr)
73 };
74
75
76 static int
77 is_spu_target (void)
78 {
79 extern const bfd_target bfd_elf32_spu_vec;
80
81 return link_info.output_bfd->xvec == &bfd_elf32_spu_vec;
82 }
83
84 /* Create our note section. */
85
86 static void
87 spu_after_open (void)
88 {
89 if (is_spu_target ()
90 && !link_info.relocatable
91 && link_info.input_bfds != NULL
92 && !spu_elf_create_sections (&link_info,
93 stack_analysis, emit_stack_syms))
94 einfo ("%X%P: can not create note section: %E\n");
95
96 gld${EMULATION_NAME}_after_open ();
97 }
98
99 /* If O is NULL, add section S at the end of output section OUTPUT_NAME.
100 If O is not NULL, add section S at the beginning of output section O.
101
102 Really, we should be duplicating ldlang.c map_input_to_output_sections
103 logic here, ie. using the linker script to find where the section
104 goes. That's rather a lot of code, and we don't want to run
105 map_input_to_output_sections again because most sections are already
106 mapped. So cheat, and put the section in a fixed place, ignoring any
107 attempt via a linker script to put .stub, .ovtab, and built-in
108 overlay manager code somewhere else. */
109
110 static void
111 spu_place_special_section (asection *s, asection *o, const char *output_name)
112 {
113 lang_output_section_statement_type *os;
114
115 os = lang_output_section_find (o != NULL ? o->name : output_name);
116 if (os == NULL)
117 {
118 const char *save = s->name;
119 s->name = output_name;
120 gld${EMULATION_NAME}_place_orphan (s);
121 s->name = save;
122 }
123 else if (o != NULL && os->children.head != NULL)
124 {
125 lang_statement_list_type add;
126
127 lang_list_init (&add);
128 lang_add_section (&add, s, os);
129 *add.tail = os->children.head;
130 os->children.head = add.head;
131 }
132 else
133 lang_add_section (&os->children, s, os);
134
135 s->output_section->size += s->size;
136 }
137
138 /* Load built-in overlay manager, and tweak overlay section alignment. */
139
140 static void
141 spu_elf_load_ovl_mgr (void)
142 {
143 lang_output_section_statement_type *os;
144 struct elf_link_hash_entry *h;
145
146 h = elf_link_hash_lookup (elf_hash_table (&link_info),
147 "__ovly_load", FALSE, FALSE, FALSE);
148
149 if (h != NULL
150 && (h->root.type == bfd_link_hash_defined
151 || h->root.type == bfd_link_hash_defweak)
152 && h->def_regular)
153 {
154 /* User supplied __ovly_load. */
155 }
156 else if (ovl_mgr_stream.start == ovl_mgr_stream.end)
157 einfo ("%F%P: no built-in overlay manager\n");
158 else
159 {
160 lang_input_statement_type *ovl_is;
161
162 ovl_is = lang_add_input_file ("builtin ovl_mgr",
163 lang_input_file_is_file_enum,
164 NULL);
165
166 if (!spu_elf_open_builtin_lib (&ovl_is->the_bfd, &ovl_mgr_stream))
167 einfo ("%X%P: can not open built-in overlay manager: %E\n");
168 else
169 {
170 asection *in;
171
172 if (!load_symbols (ovl_is, NULL))
173 einfo ("%X%P: can not load built-in overlay manager: %E\n");
174
175 /* Map overlay manager sections to output sections. */
176 for (in = ovl_is->the_bfd->sections; in != NULL; in = in->next)
177 if ((in->flags & (SEC_ALLOC | SEC_LOAD))
178 == (SEC_ALLOC | SEC_LOAD))
179 spu_place_special_section (in, NULL, ".text");
180 }
181 }
182
183 /* Ensure alignment of overlay sections is sufficient. */
184 for (os = &lang_output_section_statement.head->output_section_statement;
185 os != NULL;
186 os = os->next)
187 if (os->bfd_section != NULL
188 && spu_elf_section_data (os->bfd_section) != NULL
189 && spu_elf_section_data (os->bfd_section)->u.o.ovl_index != 0)
190 {
191 if (os->bfd_section->alignment_power < 4)
192 os->bfd_section->alignment_power = 4;
193
194 /* Also ensure size rounds up. */
195 os->block_value = 16;
196 }
197 }
198
199 /* Go find if we need to do anything special for overlays. */
200
201 static void
202 spu_before_allocation (void)
203 {
204 if (is_spu_target ()
205 && !link_info.relocatable
206 && !no_overlays)
207 {
208 /* Size the sections. This is premature, but we need to know the
209 rough layout so that overlays can be found. */
210 expld.phase = lang_mark_phase_enum;
211 expld.dataseg.phase = exp_dataseg_none;
212 one_lang_size_sections_pass (NULL, TRUE);
213
214 /* Find overlays by inspecting section vmas. */
215 if (spu_elf_find_overlays (&link_info))
216 {
217 int ret;
218
219 if (auto_overlay != 0)
220 {
221 einfo ("%P: --auto-overlay ignored with user overlay script\n");
222 auto_overlay = 0;
223 }
224
225 ret = spu_elf_size_stubs (&link_info,
226 spu_place_special_section,
227 non_overlay_stubs);
228 if (ret == 0)
229 einfo ("%X%P: can not size overlay stubs: %E\n");
230 else if (ret == 2)
231 spu_elf_load_ovl_mgr ();
232 }
233
234 /* We must not cache anything from the preliminary sizing. */
235 lang_reset_memory_regions ();
236 }
237
238 gld${EMULATION_NAME}_before_allocation ();
239 }
240
241 struct tflist {
242 struct tflist *next;
243 char name[9];
244 };
245
246 static struct tflist *tmp_file_list;
247
248 static void clean_tmp (void)
249 {
250 for (; tmp_file_list != NULL; tmp_file_list = tmp_file_list->next)
251 unlink (tmp_file_list->name);
252 }
253
254 static int
255 new_tmp_file (char **fname)
256 {
257 struct tflist *tf;
258 int fd;
259
260 if (tmp_file_list == NULL)
261 atexit (clean_tmp);
262 tf = xmalloc (sizeof (*tf));
263 tf->next = tmp_file_list;
264 tmp_file_list = tf;
265 memcpy (tf->name, "ldXXXXXX", sizeof (tf->name));
266 *fname = tf->name;
267 #ifdef HAVE_MKSTEMP
268 fd = mkstemp (*fname);
269 #else
270 *fname = mktemp (*fname);
271 if (*fname == NULL)
272 return -1;
273 fd = open (fname, O_RDWR | O_CREAT | O_EXCL, 0600);
274 #endif
275 return fd;
276 }
277
278 static FILE *
279 spu_elf_open_overlay_script (void)
280 {
281 FILE *script = NULL;
282
283 if (auto_overlay_file == NULL)
284 {
285 int fd = new_tmp_file (&auto_overlay_file);
286 if (fd == -1)
287 goto file_err;
288 script = fdopen (fd, "w");
289 }
290 else
291 script = fopen (auto_overlay_file, "w");
292
293 if (script == NULL)
294 {
295 file_err:
296 einfo ("%F%P: can not open script: %E\n");
297 }
298 return script;
299 }
300
301 static void
302 spu_elf_relink (void)
303 {
304 char **argv = xmalloc ((my_argc + 4) * sizeof (*argv));
305
306 memcpy (argv, my_argv, my_argc * sizeof (*argv));
307 argv[my_argc++] = "--no-auto-overlay";
308 if (tmp_file_list->name == auto_overlay_file)
309 argv[my_argc - 1] = concat (argv[my_argc - 1], "=",
310 auto_overlay_file, (const char *) NULL);
311 argv[my_argc++] = "-T";
312 argv[my_argc++] = auto_overlay_file;
313 argv[my_argc] = 0;
314 execvp (argv[0], (char *const *) argv);
315 perror (argv[0]);
316 _exit (127);
317 }
318
319 /* Final emulation specific call. */
320
321 static void
322 gld${EMULATION_NAME}_finish (void)
323 {
324 int need_laying_out;
325
326 need_laying_out = bfd_elf_discard_info (link_info.output_bfd, &link_info);
327
328 gld${EMULATION_NAME}_map_segments (need_laying_out);
329
330 if (is_spu_target ())
331 {
332 if (local_store_lo < local_store_hi)
333 {
334 asection *s;
335
336 s = spu_elf_check_vma (&link_info, auto_overlay,
337 local_store_lo, local_store_hi,
338 auto_overlay_fixed, auto_overlay_reserved,
339 extra_stack_space,
340 spu_elf_load_ovl_mgr,
341 spu_elf_open_overlay_script,
342 spu_elf_relink);
343 if (s != NULL && !auto_overlay)
344 einfo ("%X%P: %A exceeds local store range\n", s);
345 }
346 else if (auto_overlay)
347 einfo ("%P: --auto-overlay ignored with zero local store range\n");
348
349 if (!spu_elf_build_stubs (&link_info,
350 emit_stub_syms || link_info.emitrelocations))
351 einfo ("%F%P: can not build overlay stubs: %E\n");
352 }
353
354 finish_default ();
355 }
356
357 static char *
358 gld${EMULATION_NAME}_choose_target (int argc, char *argv[])
359 {
360 my_argc = argc;
361 my_argv = argv;
362 return ldemul_default_target (argc, argv);
363 }
364
365 EOF
366
367 if grep -q 'ld_elf.*ppc.*_emulation' ldemul-list.h; then
368 fragment <<EOF
369 #include "filenames.h"
370 #include <fcntl.h>
371 #include <sys/wait.h>
372
373 static const char *
374 base_name (const char *path)
375 {
376 const char *file = strrchr (path, '/');
377 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
378 {
379 char *bslash = strrchr (path, '\\\\');
380
381 if (file == NULL || (bslash != NULL && bslash > file))
382 file = bslash;
383 if (file == NULL
384 && path[0] != '\0'
385 && path[1] == ':')
386 file = path + 1;
387 }
388 #endif
389 if (file == NULL)
390 file = path;
391 else
392 ++file;
393 return file;
394 }
395
396 /* This function is called when building a ppc32 or ppc64 executable
397 to handle embedded spu images. */
398 extern bfd_boolean embedded_spu_file (lang_input_statement_type *, const char *);
399
400 bfd_boolean
401 embedded_spu_file (lang_input_statement_type *entry, const char *flags)
402 {
403 const char *cmd[6];
404 const char *sym;
405 char *handle, *p;
406 char *oname;
407 int fd;
408 pid_t pid;
409 int status;
410 union lang_statement_union **old_stat_tail;
411 union lang_statement_union **old_file_tail;
412 union lang_statement_union *new_ent;
413 lang_input_statement_type *search;
414
415 if (entry->the_bfd->format != bfd_object
416 || strcmp (entry->the_bfd->xvec->name, "elf32-spu") != 0
417 || (entry->the_bfd->tdata.elf_obj_data->elf_header->e_type != ET_EXEC
418 && entry->the_bfd->tdata.elf_obj_data->elf_header->e_type != ET_DYN))
419 return FALSE;
420
421 /* Use the filename as the symbol marking the program handle struct. */
422 sym = base_name (entry->the_bfd->filename);
423
424 handle = xstrdup (sym);
425 for (p = handle; *p; ++p)
426 if (!(ISALNUM (*p) || *p == '$' || *p == '.'))
427 *p = '_';
428
429 fd = new_tmp_file (&oname);
430 if (fd == -1)
431 return FALSE;
432 close (fd);
433
434 for (search = (lang_input_statement_type *) input_file_chain.head;
435 search != NULL;
436 search = (lang_input_statement_type *) search->next_real_file)
437 if (search->filename != NULL)
438 {
439 const char *infile = base_name (search->filename);
440
441 if (strncmp (infile, "crtbegin", 8) == 0)
442 {
443 if (infile[8] == 'S')
444 flags = concat (flags, " -fPIC", (const char *) NULL);
445 else if (infile[8] == 'T')
446 flags = concat (flags, " -fpie", (const char *) NULL);
447 break;
448 }
449 }
450
451 /* Use fork() and exec() rather than system() so that we don't
452 need to worry about quoting args. */
453 cmd[0] = EMBEDSPU;
454 cmd[1] = flags;
455 cmd[2] = handle;
456 cmd[3] = entry->the_bfd->filename;
457 cmd[4] = oname;
458 cmd[5] = NULL;
459 if (trace_file_tries)
460 {
461 info_msg (_("running: %s \"%s\" \"%s\" \"%s\" \"%s\"\n"),
462 cmd[0], cmd[1], cmd[2], cmd[3], cmd[4]);
463 fflush (stdout);
464 }
465
466 pid = fork ();
467 if (pid == -1)
468 return FALSE;
469 if (pid == 0)
470 {
471 execvp (cmd[0], (char *const *) cmd);
472 if (strcmp ("embedspu", EMBEDSPU) != 0)
473 {
474 cmd[0] = "embedspu";
475 execvp (cmd[0], (char *const *) cmd);
476 }
477 perror (cmd[0]);
478 _exit (127);
479 }
480 #ifdef HAVE_WAITPID
481 #define WAITFOR(PID, STAT) waitpid (PID, STAT, 0)
482 #else
483 #define WAITFOR(PID, STAT) wait (STAT)
484 #endif
485 if (WAITFOR (pid, &status) != pid
486 || !WIFEXITED (status)
487 || WEXITSTATUS (status) != 0)
488 return FALSE;
489 #undef WAITFOR
490
491 old_stat_tail = stat_ptr->tail;
492 old_file_tail = input_file_chain.tail;
493 if (lang_add_input_file (oname, lang_input_file_is_file_enum, NULL) == NULL)
494 return FALSE;
495
496 /* lang_add_input_file put the new list entry at the end of the statement
497 and input file lists. Move it to just after the current entry. */
498 new_ent = *old_stat_tail;
499 *old_stat_tail = NULL;
500 stat_ptr->tail = old_stat_tail;
501 *old_file_tail = NULL;
502 input_file_chain.tail = old_file_tail;
503 new_ent->header.next = entry->header.next;
504 entry->header.next = new_ent;
505 new_ent->input_statement.next_real_file = entry->next_real_file;
506 entry->next_real_file = new_ent;
507
508 /* Ensure bfd sections are excluded from the output. */
509 bfd_section_list_clear (entry->the_bfd);
510 entry->loaded = TRUE;
511 return TRUE;
512 }
513
514 EOF
515 fi
516
517 # Define some shell vars to insert bits of code into the standard elf
518 # parse_args and list_options functions.
519 #
520 PARSE_AND_LIST_PROLOGUE='
521 #define OPTION_SPU_PLUGIN 301
522 #define OPTION_SPU_NO_OVERLAYS (OPTION_SPU_PLUGIN + 1)
523 #define OPTION_SPU_STUB_SYMS (OPTION_SPU_NO_OVERLAYS + 1)
524 #define OPTION_SPU_NON_OVERLAY_STUBS (OPTION_SPU_STUB_SYMS + 1)
525 #define OPTION_SPU_LOCAL_STORE (OPTION_SPU_NON_OVERLAY_STUBS + 1)
526 #define OPTION_SPU_STACK_ANALYSIS (OPTION_SPU_LOCAL_STORE + 1)
527 #define OPTION_SPU_STACK_SYMS (OPTION_SPU_STACK_ANALYSIS + 1)
528 #define OPTION_SPU_AUTO_OVERLAY (OPTION_SPU_STACK_SYMS + 1)
529 #define OPTION_SPU_AUTO_RELINK (OPTION_SPU_AUTO_OVERLAY + 1)
530 #define OPTION_SPU_OVERLAY_RODATA (OPTION_SPU_AUTO_RELINK + 1)
531 #define OPTION_SPU_FIXED_SPACE (OPTION_SPU_OVERLAY_RODATA + 1)
532 #define OPTION_SPU_RESERVED_SPACE (OPTION_SPU_FIXED_SPACE + 1)
533 #define OPTION_SPU_EXTRA_STACK (OPTION_SPU_RESERVED_SPACE + 1)
534 #define OPTION_SPU_NO_AUTO_OVERLAY (OPTION_SPU_EXTRA_STACK + 1)
535 '
536
537 PARSE_AND_LIST_LONGOPTS='
538 { "plugin", no_argument, NULL, OPTION_SPU_PLUGIN },
539 { "no-overlays", no_argument, NULL, OPTION_SPU_NO_OVERLAYS },
540 { "emit-stub-syms", no_argument, NULL, OPTION_SPU_STUB_SYMS },
541 { "extra-overlay-stubs", no_argument, NULL, OPTION_SPU_NON_OVERLAY_STUBS },
542 { "local-store", required_argument, NULL, OPTION_SPU_LOCAL_STORE },
543 { "stack-analysis", no_argument, NULL, OPTION_SPU_STACK_ANALYSIS },
544 { "emit-stack-syms", no_argument, NULL, OPTION_SPU_STACK_SYMS },
545 { "auto-overlay", optional_argument, NULL, OPTION_SPU_AUTO_OVERLAY },
546 { "auto-relink", no_argument, NULL, OPTION_SPU_AUTO_RELINK },
547 { "overlay-rodata", no_argument, NULL, OPTION_SPU_OVERLAY_RODATA },
548 { "fixed-space", required_argument, NULL, OPTION_SPU_FIXED_SPACE },
549 { "reserved-space", required_argument, NULL, OPTION_SPU_RESERVED_SPACE },
550 { "extra-stack-space", required_argument, NULL, OPTION_SPU_EXTRA_STACK },
551 { "no-auto-overlay", optional_argument, NULL, OPTION_SPU_NO_AUTO_OVERLAY },
552 '
553
554 PARSE_AND_LIST_OPTIONS='
555 fprintf (file, _("\
556 --plugin Make SPU plugin.\n\
557 --no-overlays No overlay handling.\n\
558 --emit-stub-syms Add symbols on overlay call stubs.\n\
559 --extra-overlay-stubs Add stubs on all calls out of overlay regions.\n\
560 --local-store=lo:hi Valid address range.\n\
561 --stack-analysis Estimate maximum stack requirement.\n\
562 --emit-stack-syms Add sym giving stack needed for each func.\n\
563 --auto-overlay [=filename] Create an overlay script in filename if\n\
564 executable does not fit in local store.\n\
565 --auto-relink Rerun linker using auto-overlay script.\n\
566 --overlay-rodata Place read-only data with associated function\n\
567 code in overlays.\n\
568 --fixed-space=bytes Local store for non-overlay code and data.\n\
569 --reserved-space=bytes Local store for stack and heap. If not specified\n\
570 ld will estimate stack size and assume no heap.\n\
571 --extra-stack-space=bytes Space for negative sp access (default 2000) if\n\
572 --reserved-space not given.\n"
573 ));
574 '
575
576 PARSE_AND_LIST_ARGS_CASES='
577 case OPTION_SPU_PLUGIN:
578 spu_elf_plugin (1);
579 break;
580
581 case OPTION_SPU_NO_OVERLAYS:
582 no_overlays = 1;
583 break;
584
585 case OPTION_SPU_STUB_SYMS:
586 emit_stub_syms = 1;
587 break;
588
589 case OPTION_SPU_NON_OVERLAY_STUBS:
590 non_overlay_stubs = 1;
591 break;
592
593 case OPTION_SPU_LOCAL_STORE:
594 {
595 char *end;
596 local_store_lo = strtoul (optarg, &end, 0);
597 if (*end == '\'':'\'')
598 {
599 local_store_hi = strtoul (end + 1, &end, 0);
600 if (*end == 0)
601 break;
602 }
603 einfo (_("%P%F: invalid --local-store address range `%s'\''\n"), optarg);
604 }
605 break;
606
607 case OPTION_SPU_STACK_ANALYSIS:
608 stack_analysis = 1;
609 break;
610
611 case OPTION_SPU_STACK_SYMS:
612 emit_stack_syms = 1;
613 break;
614
615 case OPTION_SPU_AUTO_OVERLAY:
616 auto_overlay |= 1;
617 if (optarg != NULL)
618 {
619 auto_overlay_file = optarg;
620 break;
621 }
622 /* Fall thru */
623
624 case OPTION_SPU_AUTO_RELINK:
625 auto_overlay |= 2;
626 break;
627
628 case OPTION_SPU_OVERLAY_RODATA:
629 auto_overlay |= 4;
630 break;
631
632 case OPTION_SPU_FIXED_SPACE:
633 {
634 char *end;
635 auto_overlay_fixed = strtoul (optarg, &end, 0);
636 if (*end != 0)
637 einfo (_("%P%F: invalid --fixed-space value `%s'\''\n"), optarg);
638 }
639 break;
640
641 case OPTION_SPU_RESERVED_SPACE:
642 {
643 char *end;
644 auto_overlay_reserved = strtoul (optarg, &end, 0);
645 if (*end != 0)
646 einfo (_("%P%F: invalid --reserved-space value `%s'\''\n"), optarg);
647 }
648 break;
649
650 case OPTION_SPU_EXTRA_STACK:
651 {
652 char *end;
653 extra_stack_space = strtol (optarg, &end, 0);
654 if (*end != 0)
655 einfo (_("%P%F: invalid --extra-stack-space value `%s'\''\n"), optarg);
656 }
657 break;
658
659 case OPTION_SPU_NO_AUTO_OVERLAY:
660 auto_overlay = 0;
661 if (optarg != NULL)
662 {
663 struct tflist *tf;
664 size_t len;
665
666 if (tmp_file_list == NULL)
667 atexit (clean_tmp);
668
669 len = strlen (optarg) + 1;
670 tf = xmalloc (sizeof (*tf) - sizeof (tf->name) + len);
671 memcpy (tf->name, optarg, len);
672 tf->next = tmp_file_list;
673 tmp_file_list = tf;
674 break;
675 }
676 break;
677 '
678
679 LDEMUL_AFTER_OPEN=spu_after_open
680 LDEMUL_BEFORE_ALLOCATION=spu_before_allocation
681 LDEMUL_FINISH=gld${EMULATION_NAME}_finish
682 LDEMUL_CHOOSE_TARGET=gld${EMULATION_NAME}_choose_target
This page took 0.043885 seconds and 4 git commands to generate.