So I am unable to find any information on the issue I am currently having. I am hoping someone here knows how to solve it.

I am using Clang 11.0.0 to compile a very simple C program. I want it to generate a .pdata section which contains unwind information following the Windows standard (see: https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-runtime_function).

If you would compile this for 64-bit and use the -funwind-tables flag. LLD will properly generate a .pdata section in the format I expect. But if you compile it for 32-bit (i686-w64-windows-gnu), then it always generates an .eh_fram section containing unwind information in a non Windows format.

How can I tell Clang/GCC or LLD to also use the .pdata style unwinding information for 32-bit compiled programs?

Is there any way to force the compiler or linker to use SEH for 32-bit?

This is what I currently test with:

clang -funwind-tables -fuse-ld=lld main.c

The C code:

__attribute__((noinline))
void call_3() {
  *(int *) (0x43000) = 0x3334;
}

__attribute__((noinline))
void call_2() {
  call_3();
}

__attribute__((noinline))
void call_1() {
  call_2();
}

int main() {
  call_1();
  return 0;
}

32-bit compiled sections:

32-bit compiled

64-bit compiled sections (this .pdata is what I also want on the 32-bit one):

64-bit compiled

0

There are 0 best solutions below