[PATCH] D49700: [LLD] [COFF] Treat .xdata/.pdata$<sym> as implicitly associative to <sym> for MinGW

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 26 13:31:03 PDT 2018


rnk added a comment.

In https://reviews.llvm.org/D49700#1177256, @rnk wrote:

> In https://reviews.llvm.org/D49700#1174174, @mstorsjo wrote:
>
> > - clang + ld.bfd (@rnk fixed an issue for this case in llvm, which triggered all of this)
>
>
> As long as this works, https://reviews.llvm.org/D49757 is fine with me. I'm going to check.


Unfortunately, it doesn't work. ld.bfd will not discard the duplicate associated .pdata and .xdata sections. Here was my program:

  $ cat t.h
  void bar(int*);
  inline int foo() {
    volatile int x = 42;
    ++x;
    try {
    bar((int*)&x);
    } catch(...) {}
    return x;
  }
  
  $ cat a.cpp
  #include "t.h"
  void baz();
  void bar(int *) {}
  int main() {
    foo();
    baz();
  }
  
  $ cat b.cpp
  #include "t.h"
  void baz() {
    foo();
  }
  
  $ clang -c a.cpp b.cpp --target=x86_64-windows-gnu && g++ a.o b.o -o t.exe
  
  $ llvm-objdump -u -d t.exe | less

There's only one _Z3foov copy in .text, so that's good:

  ...
  _Z3foov:
    402c60:       48 83 ec 48     subq    $72, %rsp
    402c64:       c7 44 24 44 2a 00 00 00         movl    $42, 68(%rsp)
    402c6c:       8b 44 24 44     movl    68(%rsp), %eax
    402c70:       83 c0 01        addl    $1, %eax
    402c73:       89 44 24 44     movl    %eax, 68(%rsp)
    402c77:       48 8d 4c 24 44  leaq    68(%rsp), %rcx
  ...

But there are two pdata / xdata sets for it in the unwind info:

  ...
  Function Table:
    Start Address: 0x2c60
    End Address: 0x2cb3
    Unwind Info Address: 0x608c
      Version: 1
      Flags: 3 UNW_ExceptionHandler UNW_TerminateHandler
      Size of prolog: 4
      Number of Codes: 1
      No frame pointer used
      Unwind Codes:
        0x04: UOP_AllocSmall 72
  
  Function Table:
    Start Address: 0x2c60
    End Address: 0x2cb3
    Unwind Info Address: 0x60b8
      Version: 1
      Flags: 3 UNW_ExceptionHandler UNW_TerminateHandler
      Size of prolog: 4
      Number of Codes: 1
      No frame pointer used
      Unwind Codes:
        0x04: UOP_AllocSmall 72

For any medium sized C++ application, that's going to add up.


https://reviews.llvm.org/D49700





More information about the llvm-commits mailing list