1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // Package flags implements top-level flags and the usage message for the assembler.
18 Debug = flag.Bool("debug", false, "dump instructions as they are parsed")
19 OutputFile = flag.String("o", "", "output file; default foo.o for /a/b/c/foo.s as first argument")
20 PrintOut = flag.Bool("S", false, "print assembly and machine code")
21 TrimPath = flag.String("trimpath", "", "remove prefix from recorded source file paths")
22 Shared = flag.Bool("shared", false, "generate code that can be linked into a shared library")
23 Dynlink = flag.Bool("dynlink", false, "support references to Go symbols defined in other shared libraries")
24 AllErrors = flag.Bool("e", false, "no limit on number of errors reported")
25 SymABIs = flag.Bool("gensymabis", false, "write symbol ABI information to output file, don't assemble")
26 Importpath = flag.String("p", "", "set expected package import to path")
27 Spectre = flag.String("spectre", "", "enable spectre mitigations in `list` (all, ret)")
29 Go115Newobj = flag.Bool("go115newobj", true, "use new object file format")
38 flag.Var(&D, "D", "predefined symbol with optional simple value -D=identifier=value; can be set multiple times")
39 flag.Var(&I, "I", "include directory; can be set multiple times")
40 objabi.AddVersionFlag() // -V
43 // MultiFlag allows setting a value multiple times to collect a list, as in -I=dir1 -I=dir2.
44 type MultiFlag []string
46 func (m *MultiFlag) String() string {
53 func (m *MultiFlag) Set(val string) error {
54 (*m) = append(*m, val)
59 fmt.Fprintf(os.Stderr, "usage: asm [options] file.s ...\n")
60 fmt.Fprintf(os.Stderr, "Flags:\n")
73 if *OutputFile == "" {
77 input := filepath.Base(flag.Arg(0))
78 if strings.HasSuffix(input, ".s") {
79 input = input[:len(input)-2]
81 *OutputFile = fmt.Sprintf("%s.o", input)