From 64ae3d63b0366291f0453ba8fd3be894d1c0eafe Mon Sep 17 00:00:00 2001 From: CFC4N Date: Wed, 10 Apr 2024 21:32:21 +0800 Subject: [PATCH] fix: amd64, offset read error issue for PIE executable. On amd64, when the executable program in PIE format compiled by golang reads the return instruction of the function, the start address of inst is incorrect, resulting in an exception, see PR #516 for details. Signed-off-by: CFC4N --- user/config/config_gotls.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user/config/config_gotls.go b/user/config/config_gotls.go index 7194a79c6..016458f45 100644 --- a/user/config/config_gotls.go +++ b/user/config/config_gotls.go @@ -340,7 +340,7 @@ func (gc *GoTLSConfig) findRetOffsetsPie(lfunc string) ([]int, error) { continue } data := make([]byte, funcLen) - _, err = prog.ReadAt(data, int64(address)) + _, err = prog.ReadAt(data, int64(address-prog.Vaddr)) if err != nil { return offsets, fmt.Errorf("finding function return: %w", err) }