wget code shrink (recent change)

Raffaello D. Di Napoli rafdev at dinapo.li
Fri Nov 16 13:21:55 UTC 2018


On 16/11/2018 03:20, Xabier Oneca -- xOneca wrote:
> How is this actually possible to happen? I've been trying to reproduce
> it (on x86_64) without success... :/
>
> https://git.busybox.net/busybox/commit/?id=fe836d84554c007916adc1c2e5f5daae2f878947
>
> tls: code shrink
> function         old new delta
> spawn_ssl_client 219 218 -1
>
> diff --git a/networking/wget.c b/networking/wget.c
> index a9a0f5f..65262e1 100644
> --- a/networking/wget.c
> +++ b/networking/wget.c
> @@ -717,8 +717,8 @@ static void spawn_ssl_client(const char *host, int
> network_fd, int flags)
> char *servername, *p;
> if (!(option_mask32 & WGET_OPT_NO_CHECK_CERT)) {
> - bb_error_msg("note: TLS certificate validation not implemented");
> option_mask32 |= WGET_OPT_NO_CHECK_CERT;
> + bb_error_msg("note: TLS certificate validation not implemented");
> }
> servername = xstrdup(host);
> --
>
> I can't see why that change would generate less asm. Out of curiosity,
> anybody cares to explain?

Not hard to guess… option_mask32 will already be in a register right after the if, while it might need to be reloaded after the bb_error_msg() call. Or if the architecture supports indirect operands (like x86-64), the compiler might still generate shorter opcodes by replacing two indirect instructions with a load, two register instructions, and a store.

--
Raf



More information about the busybox mailing list