mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link/internal/ld: skip DWARF combining for iOS binaries
The macOS and iOS external linker strips DWARF information from binaries because it assumes the information will go into separate DWARF information .dSYM files. To preserve the embedded debugging information, the Go linker re-combines the separate DWARF information into the unmapped __DWARF segment of the final executable. However, the iOS dyld linker does not allow unmapped segments, so use the presence of the LC_VERSION_MIN_IPHONEOS linker command to skip DWARF combining. Note that we can't use GOARCH for detection since the iOS emulator runs on GOARCH=386 and GOARCH=amd64 and we will run into https://golang.org/issues/25148. Updates #25148. Change-Id: I29a1bc468fdee74ab3b27c46931501a0a8120c66 Reviewed-on: https://go-review.googlesource.com/111275 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
506d6a32ce
commit
bcdbd58ce4
3 changed files with 88 additions and 47 deletions
|
|
@ -1343,12 +1343,15 @@ func (ctxt *Link) hostlink() {
|
|||
}
|
||||
// For os.Rename to work reliably, must be in same directory as outfile.
|
||||
combinedOutput := *flagOutfile + "~"
|
||||
if err := machoCombineDwarf(*flagOutfile, dsym, combinedOutput, ctxt.BuildMode); err != nil {
|
||||
isIOS, err := machoCombineDwarf(*flagOutfile, dsym, combinedOutput, ctxt.BuildMode)
|
||||
if err != nil {
|
||||
Exitf("%s: combining dwarf failed: %v", os.Args[0], err)
|
||||
}
|
||||
os.Remove(*flagOutfile)
|
||||
if err := os.Rename(combinedOutput, *flagOutfile); err != nil {
|
||||
Exitf("%s: %v", os.Args[0], err)
|
||||
if !isIOS {
|
||||
os.Remove(*flagOutfile)
|
||||
if err := os.Rename(combinedOutput, *flagOutfile); err != nil {
|
||||
Exitf("%s: %v", os.Args[0], err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue