Skip to content

Commit

Permalink
Fix formatting and remove unnecessary line
Browse files Browse the repository at this point in the history
  • Loading branch information
randomPoison committed Jan 27, 2025
1 parent 7389625 commit ce5231a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,18 @@ IA2_CAST(func, ty) // Get a struct of type `ty` pointing to `func`'s wrapper

## `static` Function Pointers

If a `static` function is used as an address-taken function for cross-compartment calls, then the rewriter needs to add `__attribute__((used))` to the function declaration in order for it to link correctly with the generated callgates. Normally the rewriter can achieve this, but if the `static` keyword comes from a macro the rewriter will not be able to insert the attribute. For example:
If a `static` function is used as an address-taken function for
cross-compartment calls, then the rewriter needs to add `__attribute__((used))`
to the function declaration in order for it to link correctly with the generated
callgates. Normally the rewriter can achieve this, but if the `static` keyword
comes from a macro the rewriter will not be able to insert the attribute. For
example:

```c
#define local static
local void function() {}
```
The same issue can happen when using
If this pattern occurs in your code, you can remove the `static` modifier or add
`__attribute__((used))` manually post-rewriter.
Expand Down

0 comments on commit ce5231a

Please sign in to comment.