Re: single-binary for execline programs?

From: Laurent Bercot <ska-skaware_at_skarnet.org>
Date: Thu, 02 Feb 2023 21:30:14 +0000

>Yes, this is only possible because you did a very good job in the first
>place. Good work! This cannot be said enough.

  Thanks.
  I managed to de-global the arrays in trap.c, so now the only
unavoidable
global is in forstdin: a pointer to a structure accessed by a signal
handler.
  You'd think with all the siginfo stuff, POSIX would have thought of
mandating a void * auxiliary pointer you'd give to sigaction() and that
would be stored and provided to the signal handler, but no, there's just
no room to pass user data other than globally. Yet another example of
wonderful, user-friendly design.

  But yeah, 8 bytes of bss/data for the whole thing is pretty good, the
crt and the libc are basically the only static RAM users, so there's
nothing more to do here.


>I was also curious about starting time and should have done that in my
>previous mail, it's a bit slower as expected.

  Yeah, a 0.2 ms difference is fine, I think. :P But I'm not sure if
it's possible to get an accurate benchmark, because the cost of 4-5
strcmp()s are negligible before the cost of the execve's in the first
place. I suspect at least half of the difference comes from mapping a
bigger executable.


>I think the main reason to like shared libraries as a distribution is
>that if you upgrade it, you get the upgrade for all programs that depend
>on it -- which isn't reall a problem for this.

  Oh, absolutely, and that's why it's hard to advocate static linking to
distributions. It's a very reasonable argument for dynamic linking.


>At the risk of repeating myself, I'll be happy to help with anything
>related to this -- that's the least I can do given I brought it up.

  Thank you. I might seriously take you up on that offer further down
the road. :)
  But really, since the "cat everything together" method works in this
case, there's not much more to do except pay attention when writing
or editing normal programs in the future.

  I pushed "multicall-strip" and "multicall-install" targets in git,
and documented the setup in the INSTALL file. As experimental, because
although I *think* everything is working, there may still be some
interaction I've missed.

--
  Laurent
Received on Thu Feb 02 2023 - 22:30:14 CET

This archive was generated by hypermail 2.4.0 : Thu Feb 02 2023 - 22:30:45 CET