fix: staticcheck and deadcode findings repo-wide, modernize counting loops

This commit is contained in:
2026-08-29 15:25:15 +02:00
parent 9a34733615
commit eacf33d0f7
33 changed files with 88 additions and 250 deletions
-24
View File
@@ -3,8 +3,6 @@
package asm
import "encoding/binary"
// dwarfELFSections holds the laid-out DWARF sections ready for inclusion
// in an ELF file.
type dwarfELFSections struct {
@@ -114,28 +112,6 @@ func appendDWARFSections(out *[]byte, img *Image, srcFile string, symIdx map[str
return result
}
// dwarfRelaRecords returns the ELF RELA records for DWARF address fixups.
// Each record uses R_X86_64_64 (absolute 64-bit) relocation type.
func dwarfRelaRecords(dw *dwarfELFSections, relType uint32) []byte {
le := binary.LittleEndian
var out []byte
for _, r := range dw.infoRelocs {
var b [24]byte
le.PutUint64(b[0:], r.off)
le.PutUint64(b[8:], uint64(r.sym)<<32|uint64(relType))
le.PutUint64(b[16:], uint64(r.addend))
out = append(out, b[:]...)
}
for _, r := range dw.lineRelocs {
var b [24]byte
le.PutUint64(b[0:], r.off)
le.PutUint64(b[8:], uint64(r.sym)<<32|uint64(relType))
le.PutUint64(b[16:], uint64(r.addend))
out = append(out, b[:]...)
}
return out
}
// dwarfSectionNames returns the DWARF section names for the string table.
var dwarfSectionNames = []string{
".debug_abbrev", ".debug_info", ".debug_line", ".debug_line_str",