Skip to content

Commit ff3a1e0

Browse files
committed
replace command-line-arguments pkgpath and rename example pkgpath
1 parent 119a032 commit ff3a1e0

18 files changed

+25
-16
lines changed
File renamed without changes.
File renamed without changes.

Diff for: constants/pkgpath.go

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package constants
2+
3+
const (
4+
CommandLinePkgPath = `command-line-arguments`
5+
)
File renamed without changes.
File renamed without changes.

Diff for: examples/const/const.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package constant
22

33
import "fmt"
44

Diff for: examples/gctest/gctest.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package gctest
22

33
import (
44
"fmt"

Diff for: examples/http/http.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package http
22

33
import (
44
"fmt"

Diff for: examples/inline/inline.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package inline
22

33
func throw() {
44
panic("panic call function")

Diff for: examples/inter/go.mod

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
module github.com/pkujhd/goloader/examples/inter
22

3-
replace github.com/pkujhd/goloader/examples/basecontext => ../basecontext
4-
53
go 1.11
64

7-
require github.com/pkujhd/goloader/examples/basecontext v0.0.0-00010101000000-000000000000
5+
require github.com/pkujhd/goloader/examples/basecontext v0.0.0-20240113081730-119a03230cfa

Diff for: examples/inter/go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/pkujhd/goloader/examples/basecontext v0.0.0-20240113081730-119a03230cfa h1:A3mFXZXQuBEZ33MMeXS1Dp4wHyz5ghSGRn1JCdvxZcw=
2+
github.com/pkujhd/goloader/examples/basecontext v0.0.0-20240113081730-119a03230cfa/go.mod h1:KeIVzLyKuAAfJrZ0LPojfvKG28TwpzVuk6LrDNxZIiE=

Diff for: examples/inter/inter.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package inter
22

33
import (
44
"fmt"

Diff for: examples/schedule/schedule.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package schedule
22

33
import (
44
"fmt"

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/pkujhd/goloader
22

3-
go 1.8
3+
go 1.11

Diff for: obj/readobj.1.16.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func (pkg *Pkg) addSym(r *goobj.Reader, index uint32, refNames *map[goobj.SymRef
9696
}
9797
if symbol.Size > 0 {
9898
symbol.Data = r.Data(index)
99-
grow(&symbol.Data, (int)(symbol.Size))
99+
Grow(&symbol.Data, (int)(symbol.Size))
100100
} else {
101101
symbol.Data = make([]byte, 0)
102102
}

Diff for: obj/readobj.1.8.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (pkg *Pkg) Symbols() error {
4747
if err != nil {
4848
return fmt.Errorf("read error: %v", err)
4949
}
50-
grow(&symbol.Data, (int)(symbol.Size))
50+
Grow(&symbol.Data, (int)(symbol.Size))
5151
for _, loc := range sym.Reloc {
5252
reloc := Reloc{
5353
Offset: int(loc.Offset),

Diff for: obj/utils.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ func FindFileTab(filename string, namemap map[string]int, filetab []uint32) int3
1616
return -1
1717
}
1818

19-
func grow(bytes *[]byte, size int) {
19+
//go:inline
20+
func Grow(bytes *[]byte, size int) {
2021
if len(*bytes) < size {
2122
*bytes = append(*bytes, make([]byte, size-len(*bytes))...)
2223
}
2324
}
2425

26+
//go:inline
2527
func ReplacePkgPath(name, pkgpath string) string {
2628
if !strings.HasPrefix(name, constants.TypeStringPrefix) {
2729
name = strings.Replace(name, constants.EmptyPkgPath, pkgpath, -1)
30+
//golang 1.13 - 1.19 go build -gcflags="-p xxx" xxx.go ineffective
31+
name = strings.Replace(name, constants.CommandLinePkgPath, pkgpath, -1)
2832
}
2933
return name
3034
}

Diff for: utils.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"unsafe"
99

1010
"github.com/pkujhd/goloader/mmap"
11+
"github.com/pkujhd/goloader/obj"
1112
)
1213

1314
func isOverflowInt32(offset int) bool {
@@ -136,10 +137,9 @@ func loadp(ptr unsafe.Pointer) unsafe.Pointer {
136137
return *(*unsafe.Pointer)(ptr)
137138
}
138139

140+
//go:inline
139141
func grow(bytes *[]byte, size int) {
140-
if len(*bytes) < size {
141-
*bytes = append(*bytes, make([]byte, size-len(*bytes))...)
142-
}
142+
obj.Grow(bytes, size)
143143
}
144144

145145
func getArch(archName string) *sys.Arch {

0 commit comments

Comments
 (0)