aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorHiroshi Ioka <hirochachacha@gmail.com>2017-09-21 12:56:30 +0900
committerIan Lance Taylor <iant@golang.org>2017-09-21 19:17:33 +0000
commit2f7b57e9d82c1d8d0bc15bd35b1acf084e1367d3 (patch)
tree6c9422871a450596aa6a4557a5fe89707c26bf14 /src/cmd
parentdd5a86f18c8d00e47a03ed11523307cafe1f2f1c (diff)
downloadgo-2f7b57e9d82c1d8d0bc15bd35b1acf084e1367d3.tar.xz
cmd/nm: accept macho files which don't have symbol table in the archive
After https://golang.org/cl/64793, we started to include Mach-O object files which don't have symbol table into cgo archive. However, toolchains didn't handle those files yet. Fixes #21959 Change-Id: Ibb2f6492f1fa59368f2dfd4cff19783997539875 Reviewed-on: https://go-review.googlesource.com/65170 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/internal/objfile/macho.go2
-rw-r--r--src/cmd/nm/nm.go10
2 files changed, 10 insertions, 2 deletions
diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go
index d6d545c23e..7a8999e5ba 100644
--- a/src/cmd/internal/objfile/macho.go
+++ b/src/cmd/internal/objfile/macho.go
@@ -30,7 +30,7 @@ func openMacho(r io.ReaderAt) (rawFile, error) {
func (f *machoFile) symbols() ([]Sym, error) {
if f.macho.Symtab == nil {
- return nil, fmt.Errorf("missing symbol table")
+ return nil, nil
}
// Build sorted list of addresses of all symbols.
diff --git a/src/cmd/nm/nm.go b/src/cmd/nm/nm.go
index 65ef5b4295..457239921b 100644
--- a/src/cmd/nm/nm.go
+++ b/src/cmd/nm/nm.go
@@ -110,15 +110,19 @@ func nm(file string) {
entries := f.Entries()
+ var found bool
+
for _, e := range entries {
syms, err := e.Symbols()
if err != nil {
errorf("reading %s: %v", file, err)
}
if len(syms) == 0 {
- errorf("reading %s: no symbols", file)
+ continue
}
+ found = true
+
switch *sortOrder {
case "address":
sort.Slice(syms, func(i, j int) bool { return syms[i].Addr < syms[j].Addr })
@@ -155,5 +159,9 @@ func nm(file string) {
}
}
+ if !found {
+ errorf("reading %s: no symbols", file)
+ }
+
w.Flush()
}