On Tue, 1 Apr 2025, Jeremy Drake via Cygwin-patches wrote:

> On Tue, 1 Apr 2025, Corinna Vinschen wrote:
>
> > And btw., I checked the file size again, and it turns out that after
> > stripping the debug symbols the DLL takes ~30 pages or 120 K more memory
> > than before udis86.  I hope that's ok.  But if you see ways to shave a
> > few pages off by dropping code from udis86, I wouldn't be too unhappy :}
>
> Hmm, I only tested on top of msys2 (which is on gcc 13.3.0), but here's
> what I see:
>
> $ ls -l
> total 47952
> -rwxr-xr-x 1 XXX None 24682293 Apr  1 10:14 postmsys-2.0.dll
> -rwxr-xr-x 1 XXX None 24417887 Apr  1 10:12 premsys-2.0.dll
>
> $ echo $(( $(stat -c %s postmsys-2.0.dll) - $(stat -c %s premsys-2.0.dll) ))
> 264406
>
> $ strip premsys-2.0.dll
> $ strip postmsys-2.0.dll
>
> $ ls -l
> total 6428
> -rwxr-xr-x 1 XXX None 3330598 Apr  1 10:15 postmsys-2.0.dll
> -rwxr-xr-x 1 XXX None 3246118 Apr  1 10:15 premsys-2.0.dll
>
> $ echo $(( $(stat -c %s postmsys-2.0.dll) - $(stat -c %s premsys-2.0.dll) ))
> 84480
>
> One thing I noticed that could make the code using udis86 smaller and
> faster is to use members of the ud_t struct directly instead of calling
> accessor functions.  I don't know for sure if these members are intended
> to be public or not (but they do seem to know how to declare members as
> non-public: in ud_operand_t, they have an "internal use only" comment
> followed by members named with leading underscores).  I don't think it
> would make a large dent in the size of the code relative to the size of
> udis86 itself though.

I changed the code to use the struct directly, and amazingly the dll was
the exact same size after stripping.  I then tried building the udis86/*.c
with -ffunction-sections -fdata-sections, and that resulted in a *larger*
dll.  Building just udis86.c with -ffunction-sections (in addition to the
struct access change) resulted in a 1k savings.  Instead #ifdef'ing out
the unused functions (including those now unused because the struct
members are read directly) in udis86.c resulted in a 2k savings.  In
addition to ifdef'ing out functions, building all 3 udis86/*.c files with
-Os resulted in an overall 4608 byte savings in stripped dll size.

Reply via email to