<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57331>57331</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Missing Guard EH Continuation Table when linking with lld-link
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          alvinhochun
      </td>
    </tr>
</table>

<pre>
    With this source code:

```c++
#include <cstdio>

struct my_exception_t {
    int code;
};

__attribute__((noinline))
void do_test(bool should_throw) {
    printf("Starting test, should_throw = %d\n", should_throw);
    try {
        if (should_throw) {
            throw my_exception_t { 1234 };
        }
        puts("Exception not thrown.");
    } catch (my_exception_t ex) {
        printf("Caught exception with value %d.\n", ex.code);
    }
}

int main(int argc, char *argv[]) {
    if (argc > 1) {
        do_test(true);
    } else {
        do_test(false);
    }
    return 0;
}
```

When linked with `link.exe`, the output contains a Guard EH Continuation Table:

```
C:\>clang++ ehcont_guard_msvc.cpp -o ehcont_guard_msvc.exe -target x86_64-pc-windows-msvc -Xclang -ehcontguard  -O -Wl,-guard:cf,-guard:ehcont
C:\>llvm-readobj --coff-load-config ehcont_guard_msvc.exe
...
LoadConfig [
...
  GuardEHContinuationTable: 0x1400152F0
  GuardEHContinuationCount: 14
]
GuardFidTable [
...
]
GuardEHContTable [
  0x140001035
...
]
```

But when linked with LLD, the Guard EH Continuation Table is missing:

```
C:\>clang++ ehcont_guard_msvc.cpp -o ehcont_guard_msvc.exe -target x86_64-pc-windows-msvc -Xclang -ehcontguard  -O -Wl,-guard:ehcont -fuse-ld=lld
C:\>llvm-readobj --coff-load-config ehcont_guard_msvc.exe
...
LoadConfig [
...
  GuardEHContinuationTable: 0x0
  GuardEHContinuationCount: 0
]
GuardFidTable [
...
]
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVc-PqzYQ_mvgM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