From 2f1c4cb9eec582a6e381fa866738aa17278005c2 Mon Sep 17 00:00:00 2001 From: Vyacheslav Pachkov Date: Tue, 10 Aug 2021 18:44:08 +0300 Subject: [PATCH] cmd/link: resolve magic value in gdbscript section generation According to the .debug_gdb_scripts section specification, each entry begins with a non-null prefix byte that specifies the kind of entry. This commit resolves a question about magic byte and replaces a hardcoded value with a meaningful constant "GDB_SCRIPT_PYTHON_FILE_ID" inside writegdbscript function. --- src/cmd/link/internal/ld/dwarf.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index c53d2408cb..156c36bdda 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -187,6 +187,16 @@ func isDwarf64(ctxt *Link) bool { return ctxt.HeadType == objabi.Haix } +// https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html +// Each entry inside .debug_gdb_scripts section begins with a non-null prefix +// byte that specifies the kind of entry. The following entries are supported: +const ( + GdbScriptPythonFileId = 1 + GdbScriptSchemeFileId = 3 + GdbScriptPythonTextId = 4 + GdbScriptSchemeTextId = 6 +) + var gdbscript string // dwarfSecInfo holds information about a DWARF output section, @@ -1618,7 +1628,7 @@ func (d *dwctxt) writegdbscript() dwarfSecInfo { gs := d.ldr.CreateSymForUpdate(".debug_gdb_scripts", 0) gs.SetType(sym.SDWARFSECT) - gs.AddUint8(1) // magic 1 byte? + gs.AddUint8(GdbScriptPythonFileId) gs.Addstring(gdbscript) return dwarfSecInfo{syms: []loader.Sym{gs.Sym()}} }