Commit Graph
152 Commits
Author SHA1 Message Date
Dean da0f097c78 Merge pull request #11107 from AdnanKhan-ak47/feat/relinker-lower-bzhi-bextr
feat(relinker): lower BZHI and BEXTR under --to-rosetta
2026-11-02 23:26:58 +13:00
Dean 36564b6b4f Merge pull request #10970 from AdnanKhan-ak47/feat/relinker-lower-bls
feat(relinker): lower BLSI, BLSMSK and BLSR under --to-rosetta
2026-11-02 23:26:20 +13:00
Adrià 62bc07d3f0 Merge pull request #13046 from Nciibi/fix/relinker-address32-wide-store
fix(relinker): split 32-bit absolute wide stores at the displacement boundary
2026-10-30 18:58:21 +01:00
AdriàandClaude Sonnet 5.5 f0aac7e014 fix(relinker): treat VEX.X as an index when splitting 32-bit absolute wide stores
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
2026-10-30 14:16:42 +01:00
Nciibi 5fc3344955 fix(relinker): restrict 32-bit wide-store splits to absolute operands 2026-10-30 14:16:32 +01:00
Nciibi b6f5abaf9f fix(relinker): split 32-bit absolute wide stores at the displacement boundary 2026-10-30 14:16:32 +01:00
atinseau 96581cb7d6 fix(relinker): keep moved instructions off a function entry after padding
An island or relocation window could start in the int3 or nop padding after a jump or return and run into the next function. A function that only a pointer reaches, such as a virtual method, is not a known branch target, so its first bytes became the middle of a jump to a stub. An instruction that follows a jump, a return, a trap or padding after one of them can now only start a window. An int3 inside a window does not count as such an instruction, so a window that lies entirely in int3 padding is still used, as before; nop padding stays excluded, since a function built with -fpatchable-function-entry can begin with a nop.
2026-10-30 09:58:27 +01:00
Adnan Khan 6ad23bffdd fix(relinker): restore an RSP destination in one load in the BZHI and BEXTR stub and list MULX as lowered 2026-10-30 12:55:03 +05:30
Adnan Khan 4ff00abf28 fix(relinker): restore an RSP destination in one load in the BLS stub and list MULX as lowered 2026-10-30 12:55:03 +05:30
Adnan Khan cf78130042 feat(relinker): lower BZHI and BEXTR under --to-rosetta 2026-10-30 12:55:03 +05:30
Adnan Khan 7f0b73575b fix(relinker): restore an RSP destination in one load in the shift stub, list MULX as lowered and drop the title note 2026-10-30 12:55:03 +05:30
Adnan Khan 5d3b53fc83 fix(relinker): keep the RORX immediate out of the shift lowering's register set 2026-10-30 12:55:03 +05:30
Adnan Khan d70efacd6e feat(relinker): lower SHLX, SHRX, SARX and RORX under --to-rosetta 2026-10-30 12:55:03 +05:30
Adnan Khan 0f56374dc3 test(relinker): build the BLS source list portably 2026-10-30 12:55:02 +05:30
Adnan Khan f1d15c5f51 feat(relinker): lower BLSI, BLSMSK and BLSR under --to-rosetta 2026-10-30 12:55:02 +05:30
Dean 951f374c87 Merge pull request #12843 from PolkadotDom/fix/eip-relative-stub-relocations
fix(relinker): preserve 32-bit wrapping in stub memory relocations
2026-10-30 09:21:14 +13:00
Adrià 8943b50e27 Merge pull request #12408 from SHOnnay/fix-relinker-ud0-trap
fix(relinker): classify UD0 as a trap
2026-10-29 21:00:52 +01:00
dom 7521123fb0 fix(relinker): preserve 32-bit wrapping in stub memory relocations 2026-10-29 08:20:14 -04:00
Dean 4004c97114 Merge pull request #12255 from Mherberts/codex/feat-rosetta-mulx
feat(relinker): lower MULX under --to-rosetta
2026-10-29 17:34:58 +13:00
SAKIBUL HUDA ONNAY 9604538873 refactor(relinker): name the UD0 opcode 2026-10-28 23:25:01 +06:00
SAKIBUL HUDA ONNAY 3cdefa5aa3 fix(relinker): decode UD0 ModRM operands before trapping 2026-10-28 23:20:21 +06:00
Adrià fb39cc928c Merge pull request #11722 from cocoa55/fix/rewriter-truncated-branch-into-cut
fix(codegen): reject 16-bit branches into a rewritten instruction
2026-10-28 17:35:42 +01:00
SAKIBUL HUDA ONNAY 2287ebbe00 fix(relinker): classify UD0 as a trap 2026-10-28 18:32:24 +06:00
Matheus Herberts 46f658e8dd feat(relinker): lower MULX under --to-rosetta 2026-10-28 02:28:56 -03:00
Dean 415e87a180 Merge pull request #10999 from plexerPK/fix/redzone-opcode-rsp-uses
fix(relinker): preserve opcode-encoded stack register uses
2026-10-28 13:50:41 +13:00
Dean 737f17291a Merge pull request #10680 from dkdhanda8/fix/relinker-to-intel-branch-target-overflow
fix(relinker): collect --to-intel branch targets without signed overflow
2026-10-28 05:56:34 +13:00
Adrià 2635028370 Merge pull request #11061 from roboterspinne/fix/relinker-red-zone-body-pushes
fix(relinker): refuse red-zone leaves without a frame pointer that push or pop
2026-10-27 12:00:25 +01:00
robbie d995f6223d fix(codegen): reject 16-bit branches into a rewritten instruction
Operand-size-prefixed (0x66) relative branches are classified as having
no branch target, so the AdjustedDelta check never saw them. The
truncated-branch guard only checked whether the branch and its target
move apart, so `66 EB 01 B8 11 22 33 44 C3` rewritten at offset 3 was
accepted and the branch landed in the middle of the new bytes.

Reject a truncated branch whose target is inside the cut, and run that
check for same-length rewrites too, matching the rel8/rel32 path.
2026-10-27 05:15:16 +00:00
Dean 6e719cc497 Merge pull request #11276 from plexerPK/fix/ignored-string-segments
fix(relinker): ignore segment overrides on fixed-ES string instructions
2026-10-27 15:01:59 +13:00
roboterspinne de3c2d9536 fix(relinker): refuse red-zone leaves without a frame pointer that push or pop
In a leaf without a frame pointer, --frame-red-zone lowers RSP after
the prologue and adds the shift to every RSP operand in the body,
assuming RSP does not move between the prologue and the exits. It
refused explicit RSP arithmetic but not opcode-encoded pushes and pops,
so after "push rax" in the body the read of the pushed slot at [rsp]
became [rsp+0x10], a red-zone slot, and "pushfq; and qword [rsp], -2;
popfq" changed that slot instead of the saved flags. Such a leaf now
keeps its red zone and is reported as "push or pop inside the body":
push and pop of a register, push imm, push r/m, pop r/m, pushf, popf
and push or pop of fs or gs outside the exits. The pops of an exit
still frame, and leaves with a frame pointer, whose RSP operands are
already refused, still frame when they push and pop.
2026-10-27 02:36:47 +01:00
Dean 1748d26517 Merge pull request #10871 from Chronyyx/feat/relinker-frame-short-exits
feat(relinker): frame red-zone leaves whose prologue or exit is shorter than a jump
2026-10-27 10:55:26 +13:00
Dean 613a877ab9 Merge pull request #11232 from MarcZX10/marc/fix-relinker-island-overflow
fix(relinker): place 256-bit store islands across 2^63 without signed overflow
2026-10-27 10:39:59 +13:00
Dean 728266059d Merge pull request #11063 from roboterspinne/fix/relinker-red-zone-pop-rm-xop
fix(relinker): stop reading pop r/m without REX as XOP in red-zone framing
2026-10-27 05:40:19 +13:00
plexerPK bb45d3315d fix(relinker): ignore segment overrides on fixed-ES string instructions 2026-10-26 00:26:01 +01:00
Adrià 2b5225605b Merge pull request #9719 from AasishDairelSahayaGrinspan/fix/relinker-gs-non-memory-operands
fix(relinker): leave GS-prefixed LEA and NOP instructions unchanged
2026-10-26 00:15:58 +01:00
MarcZX10 8ce7f0f657 fix(relinker): encode the short jump to a 256-bit store's island without signed overflow 2026-10-25 22:08:32 +00:00
MarcZX10 98584c547d fix(relinker): seek and return in a 256-bit store's island without signed overflow 2026-10-25 22:08:32 +00:00
MarcZX10 23d20e4405 fix(relinker): measure a 256-bit store's island reach without signed overflow 2026-10-25 22:08:32 +00:00
Dean 1926a56886 Merge pull request #9454 from cocoa55/fix/rewriter-branch-into-cut
fix(codegen): reject branches into a rewritten instruction
2026-10-26 11:00:51 +13:00
Dean d7493d7226 Merge pull request #10713 from Filip722/fix/reject-lock-movnts-20261024
fix(relinker): reject LOCK-prefixed MOVNTSS and MOVNTSD
2026-10-26 05:57:30 +13:00
roboterspinne 3398046c3c fix(relinker): stop reading pop r/m without REX as XOP in red-zone framing
extensionBits and memoryUse in the red-zone framer took every 8F lead
byte without REX for an XOP prefix. For pop r/m (8F /0) that read the
ModRM byte as XOP's inverted R, X and B bits, so the base of
"pop qword [rsp-0x10]" looked like R12, and "pop rsp" through 8F was
not seen as a use of RSP. A leaf with a frame pointer that pops to an
RSP operand was framed with the operand left in place, and leaves that
pop into RSP through 8F were framed, while the REX.W forms were refused
as other use of rsp. Both now take 8F for XOP only when the map field
of the next byte is 8 or more, the rule the instruction decoder
applies.
2026-10-25 17:18:47 +01:00
plexerPK de2b5de1b7 fix(relinker): detect opcode-encoded bswap stack operands 2026-10-25 15:41:22 +01:00
plexerPK 46566d2d03 fix(relinker): preserve opcode-encoded stack register uses 2026-10-25 14:40:31 +01:00
ChronyyxandClaude Opus 5.5 07798774b6 fix(relinker): frame red-zone leaves whose only push is rbp
The check that refuses leaves without pushes that push or pop also refused
`push rbp; mov rbp, rsp` leaves without other pushes, whose `pop rbp` it
counted, since rbp is not in their list of pushes. A unit test and an
execution test now cover such a leaf with a 4-byte prologue and a 2-byte
exit. The debt entry also notes that the check refuses shrink-wrapped leaves
whose later pushes and pops balance.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 03:23:34 -04:00
ChronyyxandClaude Opus 5.5 c697fb0ba9 feat(relinker): frame red-zone leaves whose prologue or exit is shorter than a jump
--frame-red-zone replaces a leaf's prologue and each exit with a 5-byte jump
to a stub, so it skipped leaves whose pushes or pop-and-ret exit were shorter
than that, and leaves with neither pushes nor an allocation. A short prologue
now takes in the straight-line instructions after it and a short exit those
before it, re-encoded in the stub with the moved displacement. Widening stops
at branches, rets, RIP-relative instructions, pushes and pops, and the leaf is
skipped when a branch targets the instructions taken in or the first
instruction of a widened prologue, or when a leaf without pushes pushes or
pops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 02:47:12 -04:00
Dean a512780d58 Merge pull request #10340 from Filip722/submit/lock-20261023
fix(relinker): reject LOCK-prefixed SIMD lowerings
2026-10-25 13:28:53 +13:00
Filip Michalski 50dc1c93c8 fix(relinker): reject LOCK-prefixed MOVNTSS and MOVNTSD 2026-10-24 20:43:16 +02:00
Filip Michalski cfa8c10d21 fix(relinker): clarify LOCK SHA failures and cover conversion 2026-10-24 20:43:14 +02:00
dkdhanda8 bec41e57ae fix(relinker): collect --to-intel branch targets without signed overflow
Branch target collection added the branch displacement to the next
instruction address as std::int64_t, which is undefined behaviour for
a segment mapped at or above 2^63 (found by fuzzing with UBSan, see
#10653). The addresses now add as unsigned values and only targets
that wrap past 2^64 are dropped, so the branch-target check also
applies to segments mapped across 2^63.

Fixes #10653
2026-10-24 22:47:41 +05:30
Adrià d01070d6c3 Merge pull request #5640 from EagleBearerYS/feat/relinker-frame-frameless-leaves
feat(relinker): frame red-zone leaves without a frame pointer by moving their rsp operands
2026-10-24 18:14:53 +02:00