Thank you for your reply. What I meant was actually dynamically loading a 
C-shared library written in go (buildmode=c-shared).


On Thursday, August 6, 2020 at 12:19:29 PM UTC+9 Kurtis Rader wrote:

> On Wed, Aug 5, 2020 at 8:02 PM Yosef Yo <[email protected]> wrote:
>
>> In go/src/runtime/os/linux.go, function futexsleep is defined as to call 
>> futex function of linux. runtime. futex is implemented in syscall assembly 
>> instruction. I am currently dynamically loading a golang c-shared library 
>> as a plugin, and I wanted to intercept the futex syscall and use my own 
>> implementation. Can anyone give me a hint on how to intercept runtime 
>> functions? OR is it even possible?
>
>
> What you want to do isn't possible without resorting to "monkey patching" 
> (see https://en.wikipedia.org/wiki/Monkey_patch) since the wrapper you 
> want to intercept is part of the runtime support code that is statically 
> linked into the binary. At least not in any practical manner. The 
> impractical solutions involve mechanisms such as the platform (not Go) 
> "ptrace" API. The only practical solution is to create your own custom Go 
> compiler that incorporates your modification to the use of the futex 
> syscall.
>
> On the other hand your question is unclear, even puzzling, because the use 
> of a dynamically loaded shared library, written in C, doesn't depend on the 
> Go runtime use of the futex API. At least not directly. That dynamically 
> loaded code won't be using the futex code in the Go runtime.
>
> -- 
> Kurtis Rader
> Caretaker of the exceptional canines Junior and Hank
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/1592850f-0fd3-4ec0-a77b-7f09b46bfaf1n%40googlegroups.com.

Reply via email to