From 76ac54b50ea39bbb1389ecfed71f4f0991cb4289 Mon Sep 17 00:00:00 2001 From: qmuntal Date: Mon, 16 Jan 2023 16:21:48 +0100 Subject: cmd/internal/obj: generate SEH aux symbols for windows/amd64 This CL updates the Go compiler so it generate SEH unwind info [1] as a function auxiliary symbol when building for windows/amd64. A follow up CL will teach the Go linker how to assemble these codes into the PE .xdata section. Updates #57302 [1] https://learn.microsoft.com/en-us/cpp/build/exception-handling-x64#struct-unwind_info Change-Id: I40ae0437bfee326c1a67c2b5e1496f0bf3ecea17 Reviewed-on: https://go-review.googlesource.com/c/go/+/461749 Reviewed-by: Davis Goodin Reviewed-by: Michael Knyszek TryBot-Result: Gopher Robot Reviewed-by: Than McIntosh Run-TryBot: Quim Muntal --- src/cmd/internal/obj/objfile.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/cmd/internal/obj/objfile.go') diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index 78fa4c1076..1e9e5a827b 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -602,6 +602,9 @@ func (w *writer) Aux(s *LSym) { if fn.Pcln.Pcinline != nil && fn.Pcln.Pcinline.Size != 0 { w.aux1(goobj.AuxPcinline, fn.Pcln.Pcinline) } + if fn.sehUnwindInfoSym != nil && fn.sehUnwindInfoSym.Size != 0 { + w.aux1(goobj.AuxSehUnwindInfo, fn.sehUnwindInfoSym) + } for _, pcSym := range fn.Pcln.Pcdata { w.aux1(goobj.AuxPcdata, pcSym) } @@ -707,6 +710,9 @@ func nAuxSym(s *LSym) int { if fn.Pcln.Pcinline != nil && fn.Pcln.Pcinline.Size != 0 { n++ } + if fn.sehUnwindInfoSym != nil && fn.sehUnwindInfoSym.Size != 0 { + n++ + } n += len(fn.Pcln.Pcdata) if fn.WasmImport != nil { if fn.WasmImportSym == nil || fn.WasmImportSym.Size == 0 { @@ -770,7 +776,7 @@ func genFuncInfoSyms(ctxt *Link) { fn.FuncInfoSym = isym b.Reset() - auxsyms := []*LSym{fn.dwarfRangesSym, fn.dwarfLocSym, fn.dwarfDebugLinesSym, fn.dwarfInfoSym, fn.WasmImportSym} + auxsyms := []*LSym{fn.dwarfRangesSym, fn.dwarfLocSym, fn.dwarfDebugLinesSym, fn.dwarfInfoSym, fn.WasmImportSym, fn.sehUnwindInfoSym} for _, s := range auxsyms { if s == nil || s.Size == 0 { continue -- cgit v1.3-5-g9baa