Fix cant found RET offset in gotls mode. fix #502.#512
Merged
Conversation
Fix the issue of not being able to fetch the function RET offset in the gotls model when building a Golang binary with pie mode. Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
Contributor
Member
Author
|
is please use command : CGO_ENABLED=1 go build -buildmode=pie -o test main.gops: |
Contributor
It looks the same as before. I'm going to wait until this PR is complete before I run these tests, in order to understand what's changed in this PR. |
see PR #512 for more info . Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
sancppp
approved these changes
Mar 30, 2024
cfc4n
added a commit
that referenced
this pull request
Mar 30, 2024
see PR #512 for more info . Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fix the issue of not being able to fetch the function RET offset in the gotls model when building a Golang binary with pie mode.
GO_BUILDMODE="-buildmode=pie"ref: https://github.com/docker/cli/blob/799bf5268039a92c9af197abd612b0f36cf9efe1/scripts/build/.variables#L75C13-L75C42
Here, a constant
IdaProOffset = 0x120is used. I found through IDA static symbol analysis that the address ofcrypto/tls.(*Conn).Readis46EE50. The address calculated by the program is always0x120less than this number. By analyzing multiple compiled programs, I found that the difference is always0x120. Therefore, I defined a constant and added it to the address calculated by the program. However, I don't know the reason, if you know, please let me know.这里,使用了一个常量
IdaProOffset = 0x120,我是通过IDA静态分析符号发现crypto/tls.(*Conn).Read的地址是46EE50,我用程序计算出来的总是比这个数字少了0x120,通过分析其他多个编译的程序,发现差值总是0x120,所以,我定义了一个常量,增加到程序计算的地址上。但是我不知道原因,如果你知道,请告诉我。