-
Notifications
You must be signed in to change notification settings - Fork 0
/
elf.go
46 lines (41 loc) · 1.23 KB
/
elf.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// dcc - dependency-driven C/C++ compiler front end
//
// Copyright © A.Newman 2015.
//
// This source code is released under version 2 of the GNU Public License.
// See the file LICENSE for details.
//
// +build !windows !darwin
package main
import (
"fmt"
"os"
"strings"
)
// ElfCreateLibrary creates a static library file using the UNIX ar
// program.
//
func ElfCreateLibrary(filename string, objectFiles []string) error {
args := append([]string{"rc", filename}, objectFiles...)
if Verbose {
fmt.Fprintln(os.Stdout, "ar", strings.Join(args, " "))
} else if !Quiet {
fmt.Fprintln(os.Stdout, "ar", filename)
}
return Exec("ar", args, os.Stderr)
}
// ElfCreateDLL creates a dynamic library using the compiler, passing
// a -shared option.
//
func ElfCreateDLL(filename string, objectFiles []string, libraryFiles []string, linkerOptions []string, frameworks []string) error {
args := []string{"-shared", "-o", filename}
args = append(args, linkerOptions...)
args = append(args, objectFiles...)
args = append(args, libraryFiles...)
if Verbose {
fmt.Fprintln(os.Stdout, ActualCompiler.Name(), strings.Join(args, " "))
} else if !Quiet {
fmt.Fprintln(os.Stdout, "ld", filename)
}
return Exec(ActualCompiler.Name(), args, os.Stderr)
}