[Toybox] imgtec patch: Fix static linkage of toybox binary.

Rich Felker dalias at libc.org
Fri May 6 22:23:44 PDT 2016


On Fri, May 06, 2016 at 10:16:46PM -0700, Evgenii Stepanov wrote:
> Sorry, I did not look at the problem hard enough.
> The real issue is interaction of this code with safestack
> (http://clang.llvm.org/docs/SafeStack.html), which splits the stack in
> 2 disjoint memory regions. If the two variables are allocated on
> different stacks, the comparison result is truly undefined.

No, the calculation is always defined unless it overflows; it's the
difference between two integers. If you're concerned about the
overflow case, which is possibly an issue, use unsigned integers and
cast the result to a signed type after the subtraction.

Of course whether the difference is meaningful for the purpose it's
being used for is another question, and depends on ABI stack
conventions which are affected by safe-stack. But it's not
"undefined".

> I don't really understand what this code is tying to do. Is it
> catching unlimited stack growth? Why does the comment speak about
> heap?

Yes I was confused by that too.

> Maybe we could use __builtin_frame_address(0) instead?

I don't think it's always available or meaningful, especially older
compilers.

Rich



More information about the Toybox mailing list