diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 8e50e1e..5c6f773 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -3,6 +3,33 @@ name: Build All on: [push, pull_request] jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.1 + - name: Set up Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.0 + with: + go-version: '>=1.21.0' + - name: Check formatting + run: test -z "$(gofmt -l .)" + - name: Check vet + run: go vet ./... + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.1 + - name: Set up Go + uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.0.0 + with: + go-version: '>=1.21.0' + - name: Build test binaries + run: bash build_test_files.sh + - name: Run tests + run: go test ./... + build: runs-on: windows-latest permissions: diff --git a/bio/buf_mmap.go b/bio/buf_mmap.go index 4b43d74..89ae39f 100644 --- a/bio/buf_mmap.go +++ b/bio/buf_mmap.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd // +build darwin dragonfly freebsd linux netbsd openbsd package bio @@ -17,12 +18,12 @@ import ( // because some operating systems place a limit on the number of // distinct mapped regions per process. As of this writing: // -// Darwin unlimited -// DragonFly 1000000 (vm.max_proc_mmap) -// FreeBSD unlimited -// Linux 65530 (vm.max_map_count) // TODO: query /proc/sys/vm/max_map_count? -// NetBSD unlimited -// OpenBSD unlimited +// Darwin unlimited +// DragonFly 1000000 (vm.max_proc_mmap) +// FreeBSD unlimited +// Linux 65530 (vm.max_map_count) // TODO: query /proc/sys/vm/max_map_count? +// NetBSD unlimited +// OpenBSD unlimited var mmapLimit int32 = 1<<31 - 1 func init() { diff --git a/bio/buf_nommap.go b/bio/buf_nommap.go index f43c67a..533a931 100644 --- a/bio/buf_nommap.go +++ b/bio/buf_nommap.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !darwin && !dragonfly && !freebsd && !linux && !netbsd && !openbsd // +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd package bio diff --git a/build_test_files.sh b/build_test_files.sh index 22bb680..f4275b0 100755 --- a/build_test_files.sh +++ b/build_test_files.sh @@ -1,7 +1,7 @@ #!/bin/bash trap "exit" INT sudo rm -rf $(pwd)/test/build -versions=("1.22" "1.21" "1.20" "1.19" "1.18" "1.17" "1.16" "1.15" "1.14" "1.13" "1.12" "1.11" "1.10" "1.9" "1.8" "1.7" "1.6" "1.5") +versions=("1.24" "1.23" "1.22" "1.21" "1.20" "1.19" "1.18" "1.17" "1.16" "1.15" "1.14" "1.13" "1.12" "1.11" "1.10" "1.9" "1.8" "1.7" "1.6" "1.5") for v in "${versions[@]}" do GO_TAG=$v diff --git a/cmd/src/pos.go b/cmd/src/pos.go index b6816a5..5525148 100644 --- a/cmd/src/pos.go +++ b/cmd/src/pos.go @@ -214,8 +214,10 @@ func NewFileBase(filename, absFilename string) *PosBase { } // NewLinePragmaBase returns a new *PosBase for a line directive of the form -// //line filename:line:col -// /*line filename:line:col*/ +// +// //line filename:line:col +// /*line filename:line:col*/ +// // at position pos. func NewLinePragmaBase(pos Pos, filename, absFilename string, line, col uint) *PosBase { return &PosBase{pos, filename, absFilename, FileSymPrefix + absFilename, line, col, -1} diff --git a/goobj/mkbuiltin.go b/goobj/mkbuiltin.go index 07c3406..df50f62 100644 --- a/goobj/mkbuiltin.go +++ b/goobj/mkbuiltin.go @@ -2,6 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build ignore // +build ignore // Generate builtinlist.go from cmd/compile/internal/gc/builtin/runtime.go. diff --git a/goobj/objfile.go b/goobj/objfile.go index e1deaf8..c4551a0 100644 --- a/goobj/objfile.go +++ b/goobj/objfile.go @@ -271,15 +271,16 @@ func (p *ImportedPkg) Write(w *Writer) { // Symbol definition. // // Serialized format: -// Sym struct { -// Name string -// ABI uint16 -// Type uint8 -// Flag uint8 -// Flag2 uint8 -// Siz uint32 -// Align uint32 -// } +// +// Sym struct { +// Name string +// ABI uint16 +// Type uint8 +// Flag uint8 +// Flag2 uint8 +// Siz uint32 +// Align uint32 +// } type Sym [SymSize]byte const SymSize = stringRefSize + 2 + 1 + 1 + 1 + 4 + 4 @@ -375,13 +376,14 @@ const HashSize = sha1.Size // Relocation. // // Serialized format: -// Reloc struct { -// Off int32 -// Siz uint8 -// Type uint8 -// Add int64 -// Sym SymRef -// } +// +// Reloc struct { +// Off int32 +// Siz uint8 +// Type uint8 +// Add int64 +// Sym SymRef +// } type Reloc [RelocSize]byte const RelocSize = 4 + 1 + 1 + 8 + 8 @@ -419,10 +421,11 @@ func (r *Reloc) fromBytes(b []byte) { copy(r[:], b) } // Aux symbol info. // // Serialized format: -// Aux struct { -// Type uint8 -// Sym SymRef -// } +// +// Aux struct { +// Type uint8 +// Sym SymRef +// } type Aux [AuxSize]byte const AuxSize = 1 + 8 @@ -462,11 +465,12 @@ func (a *Aux) fromBytes(b []byte) { copy(a[:], b) } // Referenced symbol flags. // // Serialized format: -// RefFlags struct { -// Sym symRef -// Flag uint8 -// Flag2 uint8 -// } +// +// RefFlags struct { +// Sym symRef +// Flag uint8 +// Flag2 uint8 +// } type RefFlags [RefFlagsSize]byte const RefFlagsSize = 8 + 1 + 1 @@ -489,10 +493,11 @@ func (r *RefFlags) Write(w *Writer) { w.Bytes(r[:]) } // Referenced symbol name. // // Serialized format: -// RefName struct { -// Sym symRef -// Name string -// } +// +// RefName struct { +// Sym symRef +// Name string +// } type RefName [RefNameSize]byte const RefNameSize = 8 + stringRefSize diff --git a/io/fs/walk.go b/io/fs/walk.go index 06d0b17..9175fff 100644 --- a/io/fs/walk.go +++ b/io/fs/walk.go @@ -63,7 +63,6 @@ var SkipDir = errors.New("skip this directory") // to bypass the directory read entirely. // - If a directory read fails, the function is called a second time // for that directory to report the error. -// type WalkDirFunc func(path string, d DirEntry, err error) error // walkDir recursively descends path, calling walkDirFn. diff --git a/main_test.go b/main_test.go index d397540..b100c1f 100644 --- a/main_test.go +++ b/main_test.go @@ -11,7 +11,7 @@ import ( _ "net/http/pprof" ) -var versions = []string{"122", "121", "120", "119", "118", "117", "116", "115", "114", "113", "112", "111", "110", "19", "18", "17", "16", "15"} +var versions = []string{"124", "123", "122", "121", "120", "119", "118", "117", "116", "115", "114", "113", "112", "111", "110", "19", "18", "17", "16", "15"} var fileNames = []string{"testproject_lin", "testproject_lin_32", "testproject_lin_stripped", "testproject_lin_stripped_32", "testproject_mac", "testproject_mac_stripped", "testproject_win_32.exe", "testproject_win_stripped_32.exe", "testproject_win_stripped.exe", "testproject_win.exe"} func TestAllVersions(t *testing.T) { diff --git a/objabi/symkind.go b/objabi/symkind.go index 6c99112..018e229 100644 --- a/objabi/symkind.go +++ b/objabi/symkind.go @@ -37,6 +37,7 @@ type SymKind uint8 // These are used to index into cmd/link/internal/sym/AbiSymKindToSymKind // // TODO(rsc): Give idiomatic Go names. +// //go:generate stringer -type=SymKind const ( // An otherwise invalid zero value for the type diff --git a/objfile/layouts.go b/objfile/layouts.go index 7c1f3c0..89de486 100644 --- a/objfile/layouts.go +++ b/objfile/layouts.go @@ -11,26 +11,26 @@ type FieldName uint8 const ( // ModuleData fields - FieldFtab FieldName = iota // 0 - FieldMinpc // 1 - FieldText // 2 - FieldTypes // 3 - FieldEtypes // 4 - FieldTextsectmap // 5 - FieldTypelinks // 6 - FieldItablinks // 7 - FieldPkgPath // 8 (for Interface) - FieldMethods // 9 (for Interface) + FieldFtab FieldName = iota // 0 + FieldMinpc // 1 + FieldText // 2 + FieldTypes // 3 + FieldEtypes // 4 + FieldTextsectmap // 5 + FieldTypelinks // 6 + FieldItablinks // 7 + FieldPkgPath // 8 (for Interface) + FieldMethods // 9 (for Interface) // Rtype fields (Go reflection types) - FieldSize // 10 - FieldPtrdata // 11 - FieldHash // 12 - FieldUnused // 13 - FieldAlign // 14 - FieldFieldAlign // 15 - FieldKind // 16 - FieldStr // 17 - FieldTflag // 18 + FieldSize // 10 + FieldPtrdata // 11 + FieldHash // 12 + FieldUnused // 13 + FieldAlign // 14 + FieldFieldAlign // 15 + FieldKind // 16 + FieldStr // 17 + FieldTflag // 18 ) // String representation for debugging/logging @@ -83,14 +83,14 @@ func (f FieldName) String() string { type FieldType uint8 const ( - FieldTypePvoid FieldType = iota // 0 - pointer/address (void *) - FieldTypeSlice // 1 - Go slice (ptr, len, cap) - FieldTypeString // 2 - Go string (ptr, len) - FieldTypeInt // 3 - integer value - FieldTypeName // 4 - name offset (Go 1.18+) - FieldTypeUint32 // 5 - unsigned 32-bit integer - FieldTypeUint8 // 6 - unsigned 8-bit integer - FieldTypeInt32 // 7 - signed 32-bit integer + FieldTypePvoid FieldType = iota // 0 - pointer/address (void *) + FieldTypeSlice // 1 - Go slice (ptr, len, cap) + FieldTypeString // 2 - Go string (ptr, len) + FieldTypeInt // 3 - integer value + FieldTypeName // 4 - name offset (Go 1.18+) + FieldTypeUint32 // 5 - unsigned 32-bit integer + FieldTypeUint8 // 6 - unsigned 8-bit integer + FieldTypeInt32 // 7 - signed 32-bit integer ) // String representation for debugging @@ -167,89 +167,89 @@ var moduleDataLayouts = map[string]*ModuleDataLayout{ "1.21": { Version: "1.21", Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 128, Offset32: 64,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 160, Offset32: 80,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 176, Offset32: 88,Type: FieldTypePvoid}, - {Name: FieldTypes, Offset64: 296, Offset32: 148,Type: FieldTypePvoid}, - {Name: FieldEtypes, Offset64: 304, Offset32: 152,Type: FieldTypePvoid}, - {Name: FieldTextsectmap, Offset64: 328, Offset32: 164,Type: FieldTypeSlice}, - {Name: FieldTypelinks, Offset64: 352, Offset32: 176,Type: FieldTypeSlice}, - {Name: FieldItablinks, Offset64: 376, Offset32: 188,Type: FieldTypeSlice}, + {Name: FieldFtab, Offset64: 128, Offset32: 64, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 160, Offset32: 80, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 176, Offset32: 88, Type: FieldTypePvoid}, + {Name: FieldTypes, Offset64: 296, Offset32: 148, Type: FieldTypePvoid}, + {Name: FieldEtypes, Offset64: 304, Offset32: 152, Type: FieldTypePvoid}, + {Name: FieldTextsectmap, Offset64: 328, Offset32: 164, Type: FieldTypeSlice}, + {Name: FieldTypelinks, Offset64: 352, Offset32: 176, Type: FieldTypeSlice}, + {Name: FieldItablinks, Offset64: 376, Offset32: 188, Type: FieldTypeSlice}, }, }, "1.20": { Version: "1.20", Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 128, Offset32: 64,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 160, Offset32: 80,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 176, Offset32: 88,Type: FieldTypePvoid}, - {Name: FieldTypes, Offset64: 296, Offset32: 148,Type: FieldTypePvoid}, - {Name: FieldEtypes, Offset64: 304, Offset32: 152,Type: FieldTypePvoid}, - {Name: FieldTextsectmap, Offset64: 328, Offset32: 164,Type: FieldTypeSlice}, - {Name: FieldTypelinks, Offset64: 352, Offset32: 176,Type: FieldTypeSlice}, - {Name: FieldItablinks, Offset64: 376, Offset32: 188,Type: FieldTypeSlice}, + {Name: FieldFtab, Offset64: 128, Offset32: 64, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 160, Offset32: 80, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 176, Offset32: 88, Type: FieldTypePvoid}, + {Name: FieldTypes, Offset64: 296, Offset32: 148, Type: FieldTypePvoid}, + {Name: FieldEtypes, Offset64: 304, Offset32: 152, Type: FieldTypePvoid}, + {Name: FieldTextsectmap, Offset64: 328, Offset32: 164, Type: FieldTypeSlice}, + {Name: FieldTypelinks, Offset64: 352, Offset32: 176, Type: FieldTypeSlice}, + {Name: FieldItablinks, Offset64: 376, Offset32: 188, Type: FieldTypeSlice}, }, }, "1.18": { Version: "1.18", Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 128, Offset32: 64,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 160, Offset32: 80,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 176, Offset32: 88,Type: FieldTypePvoid}, - {Name: FieldTypes, Offset64: 280, Offset32: 140,Type: FieldTypePvoid}, - {Name: FieldEtypes, Offset64: 288, Offset32: 144,Type: FieldTypePvoid}, - {Name: FieldTextsectmap, Offset64: 312, Offset32: 156,Type: FieldTypeSlice}, - {Name: FieldTypelinks, Offset64: 336, Offset32: 168,Type: FieldTypeSlice}, - {Name: FieldItablinks, Offset64: 360, Offset32: 180,Type: FieldTypeSlice}, + {Name: FieldFtab, Offset64: 128, Offset32: 64, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 160, Offset32: 80, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 176, Offset32: 88, Type: FieldTypePvoid}, + {Name: FieldTypes, Offset64: 280, Offset32: 140, Type: FieldTypePvoid}, + {Name: FieldEtypes, Offset64: 288, Offset32: 144, Type: FieldTypePvoid}, + {Name: FieldTextsectmap, Offset64: 312, Offset32: 156, Type: FieldTypeSlice}, + {Name: FieldTypelinks, Offset64: 336, Offset32: 168, Type: FieldTypeSlice}, + {Name: FieldItablinks, Offset64: 360, Offset32: 180, Type: FieldTypeSlice}, }, }, "1.16": { Version: "1.16", Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 128, Offset32: 64,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 160, Offset32: 80,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 176, Offset32: 88,Type: FieldTypePvoid}, - {Name: FieldTypes, Offset64: 280, Offset32: 140,Type: FieldTypePvoid}, - {Name: FieldEtypes, Offset64: 288, Offset32: 144,Type: FieldTypePvoid}, - {Name: FieldTextsectmap, Offset64: 296, Offset32: 148,Type: FieldTypeSlice}, - {Name: FieldTypelinks, Offset64: 320, Offset32: 160,Type: FieldTypeSlice}, - {Name: FieldItablinks, Offset64: 344, Offset32: 172,Type: FieldTypeSlice}, + {Name: FieldFtab, Offset64: 128, Offset32: 64, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 160, Offset32: 80, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 176, Offset32: 88, Type: FieldTypePvoid}, + {Name: FieldTypes, Offset64: 280, Offset32: 140, Type: FieldTypePvoid}, + {Name: FieldEtypes, Offset64: 288, Offset32: 144, Type: FieldTypePvoid}, + {Name: FieldTextsectmap, Offset64: 296, Offset32: 148, Type: FieldTypeSlice}, + {Name: FieldTypelinks, Offset64: 320, Offset32: 160, Type: FieldTypeSlice}, + {Name: FieldItablinks, Offset64: 344, Offset32: 172, Type: FieldTypeSlice}, }, }, // Legacy Go versions (1.2-1.15) "1.8": { Version: "1.8", // Go 1.8-1.15 (ModuleData12_64/32) Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 24, Offset32: 12,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 80, Offset32: 40,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 96, Offset32: 48,Type: FieldTypePvoid}, - {Name: FieldTypes, Offset64: 200, Offset32: 100,Type: FieldTypePvoid}, - {Name: FieldEtypes, Offset64: 208, Offset32: 104,Type: FieldTypePvoid}, - {Name: FieldTextsectmap, Offset64: 216, Offset32: 108,Type: FieldTypeSlice}, - {Name: FieldTypelinks, Offset64: 240, Offset32: 120,Type: FieldTypeSlice}, - {Name: FieldItablinks, Offset64: 264, Offset32: 132,Type: FieldTypeSlice}, + {Name: FieldFtab, Offset64: 24, Offset32: 12, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 80, Offset32: 40, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 96, Offset32: 48, Type: FieldTypePvoid}, + {Name: FieldTypes, Offset64: 200, Offset32: 100, Type: FieldTypePvoid}, + {Name: FieldEtypes, Offset64: 208, Offset32: 104, Type: FieldTypePvoid}, + {Name: FieldTextsectmap, Offset64: 216, Offset32: 108, Type: FieldTypeSlice}, + {Name: FieldTypelinks, Offset64: 240, Offset32: 120, Type: FieldTypeSlice}, + {Name: FieldItablinks, Offset64: 264, Offset32: 132, Type: FieldTypeSlice}, }, }, "1.7": { Version: "1.7", // Go 1.7 (ModuleData12_r17_64/32) Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 24, Offset32: 12,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 80, Offset32: 40,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 96, Offset32: 48,Type: FieldTypePvoid}, - {Name: FieldTypes, Offset64: 200, Offset32: 100,Type: FieldTypePvoid}, - {Name: FieldEtypes, Offset64: 208, Offset32: 104,Type: FieldTypePvoid}, - {Name: FieldTypelinks, Offset64: 216, Offset32: 108,Type: FieldTypeSlice}, - {Name: FieldItablinks, Offset64: 240, Offset32: 120,Type: FieldTypeSlice}, + {Name: FieldFtab, Offset64: 24, Offset32: 12, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 80, Offset32: 40, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 96, Offset32: 48, Type: FieldTypePvoid}, + {Name: FieldTypes, Offset64: 200, Offset32: 100, Type: FieldTypePvoid}, + {Name: FieldEtypes, Offset64: 208, Offset32: 104, Type: FieldTypePvoid}, + {Name: FieldTypelinks, Offset64: 216, Offset32: 108, Type: FieldTypeSlice}, + {Name: FieldItablinks, Offset64: 240, Offset32: 120, Type: FieldTypeSlice}, }, }, "1.5": { Version: "1.5", // Go 1.5-1.6 (ModuleData12_r15_r16_64/32) Fields: []FieldInfo{ - {Name: FieldFtab, Offset64: 24, Offset32: 12,Type: FieldTypeSlice}, - {Name: FieldMinpc, Offset64: 80, Offset32: 40,Type: FieldTypePvoid}, - {Name: FieldText, Offset64: 96, Offset32: 48,Type: FieldTypePvoid}, + {Name: FieldFtab, Offset64: 24, Offset32: 12, Type: FieldTypeSlice}, + {Name: FieldMinpc, Offset64: 80, Offset32: 40, Type: FieldTypePvoid}, + {Name: FieldText, Offset64: 96, Offset32: 48, Type: FieldTypePvoid}, // Note: No Types/Etypes/Itablinks for 1.5-1.6 - {Name: FieldTypelinks, Offset64: 200, Offset32: 100,Type: FieldTypeSlice}, // Legacy format + {Name: FieldTypelinks, Offset64: 200, Offset32: 100, Type: FieldTypeSlice}, // Legacy format }, }, } @@ -900,17 +900,17 @@ func getRtypeFieldOffset(layout *RtypeLayout, fieldName FieldName, is64bit bool) type InterfaceMethodsFormat uint8 const ( - IFMethodsPre17 InterfaceMethodsFormat = iota // 1.5-1.6: pointers in imethod - IFMethodsPost17 // 1.7+: nameOff/typeOff in IMethod + IFMethodsPre17 InterfaceMethodsFormat = iota // 1.5-1.6: pointers in imethod + IFMethodsPost17 // 1.7+: nameOff/typeOff in IMethod ) // InterfaceLayout describes offsets relative to the rtype base for interfaceType // MethodsOffsetPtrs is the number of pointer-size units after base where the methods slice resides // PkgPathOffsetPtrs is the number of pointer-size units after base for pkgPath (or -1 if absent) type InterfaceLayout struct { - MethodsOffsetPtrs int - PkgPathOffsetPtrs int // -1 if not present - MethodsFormat InterfaceMethodsFormat + MethodsOffsetPtrs int + PkgPathOffsetPtrs int // -1 if not present + MethodsFormat InterfaceMethodsFormat } // getInterfaceLayout returns the interface layout info for a Go runtime version @@ -925,7 +925,7 @@ func getInterfaceLayout(version string) *InterfaceLayout { case "1.7", "1.8", "1.9", "1.10", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21", "1.22", "1.23", "1.24": return &InterfaceLayout{ - MethodsOffsetPtrs: 1, // pkgPath at +0, methods slice at +1 + MethodsOffsetPtrs: 1, // pkgPath at +0, methods slice at +1 PkgPathOffsetPtrs: 0, MethodsFormat: IFMethodsPost17, } diff --git a/objfile/layouts_test.go b/objfile/layouts_test.go index 0ea73e4..830c69d 100644 --- a/objfile/layouts_test.go +++ b/objfile/layouts_test.go @@ -236,7 +236,7 @@ func TestParseModuleDataGeneric_BackwardCompatibility(t *testing.T) { // TestVersionMapping verifies that version aliases work correctly func TestVersionMapping(t *testing.T) { testCases := []struct { - version string + version string expectedLayoutVer string }{ {"1.21", "1.21"}, diff --git a/objfile/strings_test.go b/objfile/strings_test.go index 18e2e05..fed0a23 100644 --- a/objfile/strings_test.go +++ b/objfile/strings_test.go @@ -8,7 +8,7 @@ import ( // TestExtractStrings_ELF tests string extraction from an ELF binary (Linux) func TestExtractStrings_ELF(t *testing.T) { testBinary := filepath.Join("..", "testproject", "testproject") - + file, err := Open(testBinary) if err != nil { t.Skipf("Could not open test binary: %v (run: cd testproject && go build)", err) @@ -33,7 +33,7 @@ func TestExtractStrings_ELF(t *testing.T) { // TestExtractStrings_PE tests string extraction from a PE binary (Windows) func TestExtractStrings_PE(t *testing.T) { testBinary := filepath.Join("..", "testproject", "testproject.exe") - + file, err := Open(testBinary) if err != nil { t.Skipf("Could not open Windows test binary: %v (run: cd testproject && GOOS=windows GOARCH=amd64 go build -o testproject.exe)", err) @@ -101,13 +101,13 @@ func TestIsFullyPrintable(t *testing.T) { }{ {"hello world", true}, {"runtime.error", true}, - {"line1\nline2", true}, // newlines are allowed - {"col1\tcol2", true}, // tabs are allowed - {"windows\r\n", true}, // carriage return allowed - {"\x00\x01\x02\x03", false}, // all non-printable - {"abc\x00\x01", false}, // any non-printable fails (was 80% threshold) - {"mostly ok \x01", false}, // even one non-printable byte fails - {"", false}, // empty string + {"line1\nline2", true}, // newlines are allowed + {"col1\tcol2", true}, // tabs are allowed + {"windows\r\n", true}, // carriage return allowed + {"\x00\x01\x02\x03", false}, // all non-printable + {"abc\x00\x01", false}, // any non-printable fails (was 80% threshold) + {"mostly ok \x01", false}, // even one non-printable byte fails + {"", false}, // empty string } for _, tt := range tests { @@ -121,7 +121,7 @@ func TestIsFullyPrintable(t *testing.T) { // TestExtractStrings_MinLength validates minimum length filtering func TestExtractStrings_MinLength(t *testing.T) { testBinary := filepath.Join("..", "testproject", "testproject") - + file, err := Open(testBinary) if err != nil { t.Skip("Test binary not available") diff --git a/testproject/testproject.exe b/testproject/testproject.exe new file mode 100755 index 0000000..90ee7f2 Binary files /dev/null and b/testproject/testproject.exe differ