Skip to content

Commit 9af38fb

Browse files
committed
[LLD][COFF] Implement ECExportThunkChunk::classof
Fixes dyn_cast_or_null usage in maybeAddAddressTakenFunction (llvm#128440).
1 parent edfc89d commit 9af38fb

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

lld/COFF/Chunks.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class Chunk {
5959
SectionKind,
6060
SectionECKind,
6161
OtherKind,
62-
ImportThunkKind
62+
ImportThunkKind,
63+
ECExportThunkKind
6364
};
6465
Kind kind() const { return chunkKind; }
6566

@@ -827,7 +828,10 @@ static const uint8_t ECExportThunkCode[] = {
827828

828829
class ECExportThunkChunk : public NonSectionCodeChunk {
829830
public:
830-
explicit ECExportThunkChunk(Defined *targetSym) : target(targetSym) {}
831+
explicit ECExportThunkChunk(Defined *targetSym)
832+
: NonSectionCodeChunk(ECExportThunkKind), target(targetSym) {}
833+
static bool classof(const Chunk *c) { return c->kind() == ECExportThunkKind; }
834+
831835
size_t getSize() const override { return sizeof(ECExportThunkCode); };
832836
void writeTo(uint8_t *buf) const override;
833837
MachineTypes getMachine() const override { return AMD64; }

lld/test/COFF/build-id-sym.s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# REQUIRES: x86
22
# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s
3-
# RUN: lld-link -debug:symtab -entry:main %t.obj -build-id -Brepro -out:%t.exe
3+
# RUN: lld-link -debug:symtab -entry:main %t.obj -build-id -Brepro -out:%t.exe -guard:cf
44
# RUN: llvm-objdump -s -t %t.exe | FileCheck %s
55

66
# Check __buildid points to 0x14000203c which is after the signature RSDS.
@@ -21,3 +21,6 @@ main:
2121
.section .bss,"bw",discard,__buildid
2222
.global __buildid
2323
__buildid:
24+
25+
.data
26+
.quad __buildid

0 commit comments

Comments
 (0)