mirror of
https://github.com/golang/go
synced 2024-11-19 23:44:43 -07:00
cmd/ld: make lldb happy with Mach-O 6.out files
Apparently all the __DWARF sections need addresses even though they are marked as "do not load from disk". Continue the address numbering from the data segment. With this change: g% lldb helloworld Current executable set to 'helloworld' (x86_64). (lldb) b main.main Breakpoint 1: where = helloworld`main.main + 25 at helloworld.go:12, address = 0x0000000000002019 (lldb) r Process 68509 launched: '/Users/rsc/g/go/src/cmd/6l/helloworld' (x86_64) 1 location added to breakpoint 1 (lldb) [KProcess 68509 stopped * thread #1: tid = 0x8b7a27, 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12, stop reason = breakpoint 1.2 frame #0: 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12 9 package main 10 11 func main() { -> 12 print("hello, world\n") 13 } (lldb) bt * thread #1: tid = 0x8b7a27, 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12, stop reason = breakpoint 1.2 * frame #0: 0x0000000000002019 helloworld`main.main + 25 at helloworld.go:12 (lldb) disas helloworld`main.main at helloworld.go:11: 0x2000: movq %gs:0x8a0, %rcx 0x2009: cmpq (%rcx), %rsp 0x200c: ja 0x2015 ; main.main + 21 at helloworld.go:11 0x200e: callq 0x20da0 ; runtime.morestack00_noctxt at atomic_amd64x.c:28 0x2013: jmp 0x2000 ; main.main at helloworld.go:11 0x2015: subq $0x10, %rsp -> 0x2019: leaq 0x2c2e0, %rbx 0x2021: leaq (%rsp), %rbp 0x2025: movq %rbp, %rdi 0x2028: movq %rbx, %rsi 0x202b: movsq 0x202d: movsq 0x202f: callq 0x10300 ; runtime.printstring at compiler.go:1 0x2034: addq $0x10, %rsp 0x2038: ret 0x2039: addb %al, (%rax) 0x203b: addb %al, (%rax) 0x203d: addb %al, (%rax) (lldb) quit Quitting LLDB will kill one or more processes. Do you really want to proceed: [Y/n] y g% Fixes #7070. LGTM=iant R=golang-codereviews, iant CC=golang-codereviews https://golang.org/cl/93510043
This commit is contained in:
parent
9cd759aecc
commit
a4a1fadfa2
@ -2353,31 +2353,37 @@ dwarfaddmachoheaders(void)
|
|||||||
ms = newMachoSeg("__DWARF", nsect);
|
ms = newMachoSeg("__DWARF", nsect);
|
||||||
ms->fileoffset = fakestart;
|
ms->fileoffset = fakestart;
|
||||||
ms->filesize = abbrevo-fakestart;
|
ms->filesize = abbrevo-fakestart;
|
||||||
|
ms->vaddr = ms->fileoffset + segdata.vaddr - segdata.fileoff;
|
||||||
|
|
||||||
msect = newMachoSect(ms, "__debug_abbrev", "__DWARF");
|
msect = newMachoSect(ms, "__debug_abbrev", "__DWARF");
|
||||||
msect->off = abbrevo;
|
msect->off = abbrevo;
|
||||||
msect->size = abbrevsize;
|
msect->size = abbrevsize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
|
|
||||||
msect = newMachoSect(ms, "__debug_line", "__DWARF");
|
msect = newMachoSect(ms, "__debug_line", "__DWARF");
|
||||||
msect->off = lineo;
|
msect->off = lineo;
|
||||||
msect->size = linesize;
|
msect->size = linesize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
|
|
||||||
msect = newMachoSect(ms, "__debug_frame", "__DWARF");
|
msect = newMachoSect(ms, "__debug_frame", "__DWARF");
|
||||||
msect->off = frameo;
|
msect->off = frameo;
|
||||||
msect->size = framesize;
|
msect->size = framesize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
|
|
||||||
msect = newMachoSect(ms, "__debug_info", "__DWARF");
|
msect = newMachoSect(ms, "__debug_info", "__DWARF");
|
||||||
msect->off = infoo;
|
msect->off = infoo;
|
||||||
msect->size = infosize;
|
msect->size = infosize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
|
|
||||||
if (pubnamessize > 0) {
|
if (pubnamessize > 0) {
|
||||||
msect = newMachoSect(ms, "__debug_pubnames", "__DWARF");
|
msect = newMachoSect(ms, "__debug_pubnames", "__DWARF");
|
||||||
msect->off = pubnameso;
|
msect->off = pubnameso;
|
||||||
msect->size = pubnamessize;
|
msect->size = pubnamessize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2385,6 +2391,7 @@ dwarfaddmachoheaders(void)
|
|||||||
msect = newMachoSect(ms, "__debug_pubtypes", "__DWARF");
|
msect = newMachoSect(ms, "__debug_pubtypes", "__DWARF");
|
||||||
msect->off = pubtypeso;
|
msect->off = pubtypeso;
|
||||||
msect->size = pubtypessize;
|
msect->size = pubtypessize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2392,6 +2399,7 @@ dwarfaddmachoheaders(void)
|
|||||||
msect = newMachoSect(ms, "__debug_aranges", "__DWARF");
|
msect = newMachoSect(ms, "__debug_aranges", "__DWARF");
|
||||||
msect->off = arangeso;
|
msect->off = arangeso;
|
||||||
msect->size = arangessize;
|
msect->size = arangessize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2400,6 +2408,7 @@ dwarfaddmachoheaders(void)
|
|||||||
msect = newMachoSect(ms, "__debug_gdb_scripts", "__DWARF");
|
msect = newMachoSect(ms, "__debug_gdb_scripts", "__DWARF");
|
||||||
msect->off = gdbscripto;
|
msect->off = gdbscripto;
|
||||||
msect->size = gdbscriptsize;
|
msect->size = gdbscriptsize;
|
||||||
|
msect->addr = msect->off + segdata.vaddr - segdata.fileoff;
|
||||||
ms->filesize += msect->size;
|
ms->filesize += msect->size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user