[lld] [LLD] [MinGW] Fall back to using default target if no -m flag given. (PR #134700)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 8 11:11:31 PDT 2025
jeremyd2019 wrote:
test source:
```c
#include <assert.h>
#include <stdio.h>
#include <winsock2.h>
#include <windows.h>
__attribute__((__used__))
const IMAGE_LOAD_CONFIG_DIRECTORY _load_config_used = {
.Size = sizeof(_load_config_used),
.GuardFlags = 0x3000, /*IMAGE_GUARD_PROTECT_DELAYLOAD_IAT|IMAGE_GUARD_DELAYLOAD_IAT_IN_ITS_OWN_SECTION*/
};
int global_var = 42;
int main(void) {
unsigned short ret;
setvbuf(stdout, NULL, _IONBF, 0);
printf("MAIN: starting\n");
printf("MAIN: incremented global var = %d\n", ++global_var);
printf("MAIN: about to call htons\n");
ret = htons(0x1234);
printf("MAIN: htons returned %hx\n", ret);
printf("MAIN: incremented global var = %d\n", ++global_var);
printf("MAIN: OK\n");
return 0;
}
```
build with
```
clang -fuse-ld=lld -o main.exe main.c -lws2_32 -Wl,-delayload,WS2_32.dll
```
main.exe crashes when the loader tries to set up TLS stuff, which is now in a read-only page apparently.
https://github.com/llvm/llvm-project/pull/134700
More information about the llvm-commits
mailing list