[clang] [lld] [Clang][MinGW] Pass --functionpadmin to the linker when -fms-hotpatch is used (PR #116512)

Jacek Caban via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 16 14:43:05 PST 2024


cjacek wrote:

GCC offers the `ms_hook_prologue` function attribute as an alternative. It provides similar guarantees: it inserts a hardcoded prologue and adds padding. However, it applies on a per-function basis, so there isn’t an easy way to make the entire module hotpatchable. In GCC, the padding is handled directly by the compiler, with no linker involvement, which emits assembly like:
```
        .globl  _func
        .def    _func;  .scl    2;      .type   32;     .endef
        .long    0xcccccccc
        .long    0xcccccccc
        .long    0xcccccccc
        .long    0xcccccccc
_func:
        .byte   0x8b, 0xff, 0x55, 0x8b, 0xec
        movl    $1, %eax
        popl    %ebp
        ret
```

https://github.com/llvm/llvm-project/pull/116512


More information about the cfe-commits mailing list