Commit b72bd9e
Patch LIBCMT.LIB instead of linking separate goldp_libcmt static lib
Two issues with the previous approach prevented 100% reccmp match on the
heap CRT functions and operator new/delete:
1. Linking goldp_libcmt as a separate static lib alongside RTM's LIBCMT.LIB
left the linker with two definitions of _calloc/_malloc/etc. With certain
optimization combinations the linker pulled the LIBCMT.LIB version, not
ours, dropping calloc/malloc/heap_alloc to <30% match.
2. Compiling the SP3 sources with RelWithDebInfo emitted S_GPROC32 PDB entries
with the C source name (_nh_malloc, one underscore) which shadowed the
PUBLIC entry's linker-decorated name (__nh_malloc, two underscores).
LR's binary has no S_GPROC32 for CRT internals, so reccmp displayed the
PUBLIC name for LR and the GPROC name for ours — name mismatch even when
bytes were byte-identical (operator new dropped to 83%, delete to 75%).
Fix:
- Compile the SP3 overlay as an OBJECT library so we can grab the raw .obj
files. Use lib /REMOVE to strip RTM's heap .obj members from a copy of
LIBCMT.LIB, then lib /OUT to add ours. The patched LIBCMT.LIB contains
exactly one definition of each heap symbol — ours — and the linker has
no other choice.
- Suppress MSVC_DEBUG_INFORMATION_FORMAT on goldp_libcmt_objs so its PDB
contains only PUBLIC symbol entries (matching LR's PDB granularity).
- Use /NODEFAULTLIB:LIBCMT plus an explicit reference to the patched lib
so the linker pulls our patched version instead of the system default.
Result: _free, _calloc, _malloc, __nh_malloc, __heap_alloc, _realloc,
_expand, _msize, all __sbh_* functions, operator new, and operator delete
are now at 100% reccmp match. The four remaining sub-100% CRT functions
(__dosmaperr, __flsbuf, __NMSG_WRITE, __setmbcp) have layout-dependent
address-literal mismatches and are unrelated to this change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent ba658c5 commit b72bd9e
1 file changed
Lines changed: 49 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
566 | 566 | | |
567 | 567 | | |
568 | 568 | | |
569 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
570 | 572 | | |
571 | 573 | | |
572 | 574 | | |
| |||
580 | 582 | | |
581 | 583 | | |
582 | 584 | | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
591 | 631 | | |
592 | 632 | | |
0 commit comments