On Thu, 2022-09-01 at 15:58 +1000, Benjamin Gray wrote: > So not having a local entry point implies not using a TOC > pointer, which > implies r2 is volatile if the trampoline does not guarantee that > it preserves > r2. However experimenting with such a trampoline showed the > caller still did > not preserve its TOC when necessary, even when the trampoline > used instructions > that wrote to r2. Possibly there's an attribute that can be used > to mark the > necessary info, but I could not find one.
The `.localentry` directive is more general than just specifying where the local entry is: it can be used to set the relevant ELF bits directly. So the solution here is setting `.localentry NAME, 1` on the SC trampoline. It's not an optimal solution, as it inserts another trampoline to save r2 before calling the SC trampoline, but it would allow a correct implementation without the work needed in the other choices.