[PATCH v4 0/5] find_fast_cwd_pointer rewrite
Jeremy Drake
cygwin@jdrake.com
Wed Apr 2 17:24:47 GMT 2025
On Wed, 2 Apr 2025, Corinna Vinschen wrote:
> On Apr 1 22:25, Jeremy Drake via Cygwin-patches wrote:
> > 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.
>
> Yeah, that doesn't make sense. No worries, don't put too much time into
> that. But thanks for looking anyway.
NP. I'm thinking I'll send a patch for the struct member access change
for consideration anyway, I think it's cleaner (I used some const
references to keep my short names insn opr0 and opr1 instead of
ud_obj.mnemonic ud_obj.operand[0] and ud_obj.operand[1] respectively)
I also had the idea to sort of "change my perspective" on these functions:
instead of looking at these conditions as "sanity checks" to make sure the
code hasn't changed, and bailing out if it has, instead look at them as
"guideposts" to find on the way to identifying the correct pointer. For,
instead of bailing if the first lea is not loading FastPebLock, keep
looking for an lea that does. Actually, now that I think about it, for
x86_64, that's probably the only one that'd change. After that, we'd
still need to find the first call after that value ends up in rcx being to
RtlEnterCriticalSection, and then the first mov rXX, QWORD PTR [rip+XXX]
being immediately followed by test rXX, rXX.
I think the aarch64 code could be improved in this way also, I seem to
recall when I did the prototype immediately looking for the ldr of
RtlpCurDirRef and then looking for the other operations and returning if
they're not found.
More information about the Cygwin-patches
mailing list