goloader: the usage of `copy2Slice` here seems to be incorrect, PutInt64 should be used instead
https://github.com/pkujhd/goloader/blob/master/relocate.go#LL138C5-L138C5
copy2Slice
used to copy the 8 bytes from *addr
to *addr+7
into the TEXT segment, but the correct approach should be to copy the uint64 value addr
itself as [8]byte.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 30 (8 by maintainers)
Commits related to this issue
- Add -dynlink by default and add support for R_GOTPCREL and R_TLS_IE (arm64 still TODO) Add test for issue #78 — committed to eh-steve/goloader by invalid-email-address a year ago
- Multiple fixes: - rewrite PCREL reloc assembly to be correct - JIT uses -dynlink by default (TODO - implement GOTPCREL relocs for arm64) - make issue #78 test useful in demonstrating the desired be... — committed to eh-steve/goloader by invalid-email-address a year ago
- Add -dynlink by default and add support for R_GOTPCREL and R_TLS_IE (arm64 still TODO) Add test for issue #78 — committed to eh-steve/goloader by invalid-email-address a year ago
- Multiple fixes: - rewrite PCREL reloc assembly to be correct - JIT uses -dynlink by default (TODO - implement GOTPCREL relocs for arm64) - make issue #78 test useful in demonstrating the desired be... — committed to eh-steve/goloader by invalid-email-address a year ago
@fumeboy Just to let you know I’m now more happy with the implementation of x86 PCREL relocs in https://github.com/eh-steve/goloader/pull/5, and that branch fixes a bunch of other bugs. There’s still an issue I’d like to fix before merging, and I’d also like to see all 60 (x104) test variations (across OS/arch/±CGo/±dynlink) pass if possible
I think some problems not necessary to be solved. a safe design should not allow user modules to “write” to global variables outside of their own package. If access to specific global variables is required, it should be specifically injected by the linker like this:
however, this depends on the scene which we want to use goloader.
@eh-steve, I wirte some test code, I found some other things, if a global vaiable is not in current package but it is used in loader, use this golobal varable lead to far address problem,
Almost all instructions need to be processed, not just MOVQ/JMPL it is a big project.
`package main
import ( “fmt”
)
var a = 1
func main() { a = pppa.Val + 1 a = pppa.Val - 1 pppa.Test() fmt.Println(pppa.Val) } ` The above code has been generated INCQ/SUBQ/MOVQ(89)
@eh-steve @fumeboy ok, I will migrate the bug fix to my repos. thanks
If you encounter a bug,give me a testcase please. thx