1 /* Id */
2 /* $NetBSD: prog_link.c,v 1.1.1.1 2016/02/09 20:29:13 plunky Exp $ */
3
4 /*-
5 * Copyright (c) 2014 Iain Hibbert.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26 #include "driver.h"
27
28 static int
link_exec(const char * infile,const char * outfile)29 link_exec(const char *infile, const char *outfile)
30 {
31 list_t *l;
32 char *prog;
33
34 l = list_alloc();
35
36 /* startfiles */
37 if (target->crtbegin) list_add(l, "crtbegin.o");
38 if (target->crtbeginS) list_add(l, "crtbeginS.o");
39 if (target->crtbeginT) list_add(l, "crtbeginT.o");
40 if (target->crt0) list_add(l, "crt0.o");
41 if (target->crt1) list_add(l, "crt1.o");
42 if (target->crt2) list_add(l, "crt2.o");
43 if (target->crti) list_add(l, "crti.o");
44 if (target->dllcrt2) list_add(l, "dllcrt2.o");
45 if (target->gcrt0) list_add(l, "gcrt0.o");
46 if (target->gcrt1) list_add(l, "gcrt1.o");
47
48 /* endfiles */
49 if (target->crtend) list_add(l, "crtend.o");
50 if (target->crtendS) list_add(l, "crtendS.o");
51 if (target->crtn) list_add(l, "crtn.o");
52
53 /* early link */
54 &use.always, "-dynamic-linker"
55 &os.netbsd, "/libexec/ld.elf.so"
56 &os.linux, "/lib64/ld-linux-x86-64.so.2"
57 &use.always, "-m"
58 &mach.i386, "elf_386"
59 &mach.amd64, "elf_x86_64"
60
61 /* sysincdir */
62 "=/usr/include"
63 "=/usr/lib/gcc/x86_64-linux-gnu/4.4/include"
64
65 /* crtdir */
66 "=/usr/lib/i386", "=/usr/lib"
67 "=/usr/lib"
68 "=/usr/lib64", "=/usr/lib/gcc/x86_64-linux-gnu/4.4"
69
70 /* stdlib */
71 "-L/usr/lib/gcc/x86_64-linux-gnu/4.4"
72 "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed", "-lc", "-lgcc", "--as-needed", "-lgcc_s", "--no-as-needed"
73 }
74