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

Rob Landley rob at landley.net
Fri May 6 22:58:03 PDT 2016


On 05/07/2016 12:16 AM, 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.
> 
> 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?

It's a heuristic that enables an optimization. You could select
CONFIG_TOYBOX_NORECURSE to disable this optimization.

The help text of that option describes it a little: when one toybox
command calls another, it can either recurse into the new command's
main() function, or call the actual execve() to relaunch the toybox
binary with a fresh environment. Recursing is much faster, but has the
downside that if you do enough in a row you tend to accumulate debris
(open filehandles and unfreed mallocs and such from being halfway
through another program). (Plus if you do it _forever_, you'll actualy
run out of stack.) So it checks how much stack we've used as a simple
heuristic to see whether we should recurse or should exec.

This heuristic has not been particularly tuned, that's one of my toysh
todo items. (toysh is likely to be the heaviest user.)

Rob



More information about the Toybox mailing list