inst v1.0.0
#7
RE: inst v1.0.0
(11-24-2022, 05:05 AM)robespierre Wrote:  
Quote:To implement this double call before and after the system function, the wrapper function in libinstw.so would just need to call first the prologue function, then the system libinst.so function, and finally the epilogue function. In the source code, prologue functions are called pre functions, and epilogue functions are called post functions. Both are stored in the file prepost.c (conveniently named).

One of the common uses for wrapping functions is to change what arguments they receive. In your framework, how is this accomplished? Does the dispatcher put the arguments on its stack where a prologue callee can modify them? What about epilogues that wish to modify the return values?
With a little twist to make this more efficient codewise: wrapper functions don't modify their arguments directly, they handle only two things:

1. Save their arguments
2. Call into an internal helper function called wrapper() which is the "dispatcher" that invokes pre, system libinst.so and post functions

This dispatcher restores the saved arguments prior to calling pre, system libinst.so and post functions. That way, the system libinst.so does not even notice that a pre function was invoked just before or a post function right after it.

The programmer in turn, can access the exact same arguments of the system libinst.so function from the pre and post functions.

Refer also to point 2.3. Improving wrapper functions where I forgot to add an image and some explanatory text about this. This has been corrected.

Regarding epilogues (post functions) that wish to modify return values after the system libinst.so call:

Code:
...


                        ret = (*pre_routine)((unsigned long long *) params_pre,
                                              &internal_ret);
                        if ((ret == 0) ||
                            (ret != 1))
                        {
                                // NOTE: Custom return values from pre routine


                                return internal_ret;
                        }


                        // NOTE: Restore parameters
                        //
                        //  Restore parameters saved on entering the routine.


                        __asm_restore_parameters(params);


                        (*internal_routine)();


                        __asm_save_retval();


                        ret = (*post_routine)((unsigned long long *) params_pre,
                                              &internal_ret);
                        if ((ret == 0) ||
                            (ret != 1))
                        {
                                // NOTE: Custom return values from post routine


...
The post function (post_routine in the above code) receives the internal_ret variable which contains the return value(s) returned from the system libinst.so function in registers v0 and v1.

(11-23-2022, 10:24 PM)Raion Wrote:  Links to the code:

https://gitea.irixce.org/TruHobbyist/inst-1.0.0

Perl Module:

https://gitea.irixce.org/TruHobbyist/Inst.pm-1.0.0

This will be incorporated into IRIXCE eventually. I thank Tru for doing this because it enables us to remove the old /sbin/tar and add bsdtar as the default system tar. I will be looking into/testing the inst code extensively before we jump the gun, but I'm excited.
Thanks for the links! I totally forgot to include them.
(This post was last modified: 11-24-2022, 09:53 AM by TruHobbyist.)
TruHobbyist
Developer

Trade Count: (0)
Posts: 195
Threads: 21
Joined: May 2018
Find Reply
11-24-2022, 09:52 AM


Messages In This Thread
inst v1.0.0 - by TruHobbyist - 11-23-2022, 09:04 PM
RE: inst v1.0.0 - by Raion - 11-23-2022, 09:50 PM
RE: inst v1.0.0 - by Raion - 11-23-2022, 10:24 PM
RE: inst v1.0.0 - by robespierre - 11-24-2022, 05:05 AM
RE: inst v1.0.0 - by TruHobbyist - 11-24-2022, 09:52 AM
RE: inst v1.0.0 - by Raion - 11-24-2022, 05:16 AM
RE: inst v1.0.0 - by robespierre - 11-24-2022, 05:43 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)