Code Monkey home page Code Monkey logo

Comments (7)

johnno1962 avatar johnno1962 commented on June 1, 2024

You can't inject c functions across files though the Curren implementation will inject C++ functions. It could inject C functions I guess provided they are not static; No-one has ever asked before so I don't have any current plans to do this.

from hotreloading.

johnno1962 avatar johnno1962 commented on June 1, 2024

If this is actually important to you, try changing this line to be:

        filterImageSymbols(ST_LAST_IMAGE, .any, { _ in return true }) {

This means it will try to interpose all symbols which will only work for function calls. It may be much slower. This will of course also require -Xlinker -interposable.

from hotreloading.

johnno1962 avatar johnno1962 commented on June 1, 2024

If you're looking for more information on what "interposing" is up to read this where it is referred to as "indirection" in the section "linking".

from hotreloading.

qmkCamel avatar qmkCamel commented on June 1, 2024

Got it, thanks~

from hotreloading.

qmkCamel avatar qmkCamel commented on June 1, 2024

I am still a little confused with -interposable. I checked the man ld and found the interpretation as below

-interposable_list filename
             The specified filename contains a list of global symbol names that should always be accessed
             indirectly.  For instance, if libSystem.dylib is linked such that _malloc is interposable, then
             calls to malloc() from within libSystem will go through a dyld stub and could potentially
             indirected to an alternate malloc.  If libSystem.dylib were built without making _malloc
             interposable then if _malloc was interposed at runtime, calls to malloc from with libSystem
             would be missed (not interposed) because they would be direct calls.
-interposable
             Indirects access to all to exported symbols when creating a dynamic library. 

It looks like the -interposable only affect the dynamic library. But I test it in a executable binary, and found the follow info, the c_func_in_demovc is a c func in a .m file.

// objdump -m --lazy-bind /path/to/executable_binary
__DATA   __la_symbol_ptr    0x10000C058 this-image       _c_func_in_demovc

So is the man ld inaccurate, or I have a misunderstand with the interpretation?

from hotreloading.

johnno1962 avatar johnno1962 commented on June 1, 2024

I guess the ld man page is inaccurate, it seems to work for all images, not just dynamic libraries.

from hotreloading.

qmkCamel avatar qmkCamel commented on June 1, 2024

Agree with you.

from hotreloading.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.