Skip to content

[LLD][COFF] Implement ECExportThunkChunk::classof #130106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 7, 2025
Merged

Conversation

cjacek
Copy link
Contributor

@cjacek cjacek commented Mar 6, 2025

Fixes dyn_cast_or_null usage in maybeAddAddressTakenFunction (#128440).

Fixes dyn_cast_or_null usage in maybeAddAddressTakenFunction (llvm#128440).
@llvmbot
Copy link
Member

llvmbot commented Mar 6, 2025

@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld-coff

Author: Jacek Caban (cjacek)

Changes

Fixes dyn_cast_or_null usage in maybeAddAddressTakenFunction (#128440).


Full diff: https://github.com/llvm/llvm-project/pull/130106.diff

2 Files Affected:

  • (modified) lld/COFF/Chunks.h (+6-2)
  • (modified) lld/test/COFF/build-id-sym.s (+4-1)
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index 06e9aae0e6f6e..9f68d5a325cc5 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -59,7 +59,8 @@ class Chunk {
     SectionKind,
     SectionECKind,
     OtherKind,
-    ImportThunkKind
+    ImportThunkKind,
+    ECExportThunkKind
   };
   Kind kind() const { return chunkKind; }
 
@@ -827,7 +828,10 @@ static const uint8_t ECExportThunkCode[] = {
 
 class ECExportThunkChunk : public NonSectionCodeChunk {
 public:
-  explicit ECExportThunkChunk(Defined *targetSym) : target(targetSym) {}
+  explicit ECExportThunkChunk(Defined *targetSym)
+      : NonSectionCodeChunk(ECExportThunkKind), target(targetSym) {}
+  static bool classof(const Chunk *c) { return c->kind() == ECExportThunkKind; }
+
   size_t getSize() const override { return sizeof(ECExportThunkCode); };
   void writeTo(uint8_t *buf) const override;
   MachineTypes getMachine() const override { return AMD64; }
diff --git a/lld/test/COFF/build-id-sym.s b/lld/test/COFF/build-id-sym.s
index faed7bc40fd06..004a012cba0be 100644
--- a/lld/test/COFF/build-id-sym.s
+++ b/lld/test/COFF/build-id-sym.s
@@ -1,6 +1,6 @@
 # REQUIRES: x86
 # RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
-# RUN: lld-link -debug:symtab -entry:main %t.obj -build-id -Brepro -out:%t.exe
+# RUN: lld-link -debug:symtab -entry:main %t.obj -build-id -Brepro -out:%t.exe -guard:cf
 # RUN: llvm-objdump -s -t %t.exe | FileCheck %s
 
 # Check __buildid points to 0x14000203c which is after the signature RSDS.
@@ -21,3 +21,6 @@ main:
 .section .bss,"bw",discard,__buildid
 .global __buildid
 __buildid:
+
+.data
+.quad __buildid

Copy link
Member

@mstorsjo mstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cjacek cjacek merged commit c53e527 into llvm:main Mar 7, 2025
15 checks passed
@cjacek cjacek deleted the ecexp-kind branch March 7, 2025 17:34
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Mar 10, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Mar 20, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
jph-13 pushed a commit to jph-13/llvm-project that referenced this pull request Mar 21, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Apr 2, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Apr 17, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Apr 30, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request May 15, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request May 29, 2025
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants