Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-08 Thread Martin Storsjö
On Fri, 8 Oct 2021, LIU Hao wrote: 在 2021-10-08 17:36, Martin Storsjö 写道: Normally, when correctly configured, the pseudo relocations should be in fields that are large enough to hold the full target offset/address. But if the relocations nevertheless end up truncated, error out clearly

Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-08 Thread LIU Hao
在 2021-10-08 17:36, Martin Storsjö 写道: Normally, when correctly configured, the pseudo relocations should be in fields that are large enough to hold the full target offset/address. But if the relocations nevertheless end up truncated, error out clearly instead of running into a hard to diagnose

[Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-08 Thread Martin Storsjö
Normally, when correctly configured, the pseudo relocations should be in fields that are large enough to hold the full target offset/address. But if the relocations nevertheless end up truncated, error out clearly instead of running into a hard to diagnose crash at runtime. The pseudo relocations

Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-08 Thread Martin Storsjö
On Fri, 8 Oct 2021, LIU Hao wrote: 在 10/7/21 5:54 PM, Martin Storsjö 写道: + ptrdiff_t max_unsigned = (1LL << bits) - 1; + ptrdiff_t min_signed = (~(ptrdiff_t)0) << (bits - 1); The idea sounds correct. However it is undefined behavior to shift a negative number to the left,

Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-08 Thread LIU Hao
在 10/7/21 5:54 PM, Martin Storsjö 写道: + ptrdiff_t max_unsigned = (1LL << bits) - 1; + ptrdiff_t min_signed = (~(ptrdiff_t)0) << (bits - 1); The idea sounds correct. However it is undefined behavior to shift a negative number to the left, so would you like to change the

Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-07 Thread Martin Storsjö
On Thu, 7 Oct 2021, Jeremy Drake via Mingw-w64-public wrote: I thought pseudo-relocs were only needed when auto-importing an offset from an exported symbol (ie, a struct member or something like that), and that otherwse something in the normal Windows loader was leveraged. No, they're needed

Re: [Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-07 Thread Jeremy Drake via Mingw-w64-public
On Thu, 7 Oct 2021, Martin Storsjö wrote: > This can also happen if calling a function which is marked "DATA" in > the def files as it's not meant to be called/used normally (because we > provide a replacement in libmingwex or lib*crt* that we think should > be used instead). If the function that

[Mingw-w64-public] [PATCH] crt: Check pseudo relocations for overflows and error out clearly

2021-10-07 Thread Martin Storsjö
Normally, when correctly configured, the pseudo relocations should be in fields that are large enough to hold the full target offset/address. But if the relocations nevertheless end up truncated, error out clearly instead of running into a hard to diagnose crash at runtime. The pseudo relocations