lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Two entry points for a function


From: Marc Nieper-Wißkirchen
Subject: Two entry points for a function
Date: Mon, 8 Aug 2022 22:16:28 +0200

I am looking for a way to implement a function (pointer) with GNU lightning that has two entry points.

In native assembly, I would code something like this:

        .align 16
entry1: jmp L0
        .align 16
entry2: ...
        ...
L0:     ...

The function would be represented by a pointer to entry1.  If I wanted to jump to the second entry point, I would just add 16 to the pointer.

How can a similar thing be achieved with GNU lightning?  So far, the best that has come to my mind is to use one more indirection.  The "function pointer" points to a structure having the addresses of entry1 and entry2 as fields.  (Let us assume we are in a trampoline so that the stack is already set up).  But this is less efficient due to the extra indirection.

Is there a way to emulate the above native code with GNU lightning?  And, if not, what would have to be added?

Marc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]