Skip to content

Commit c7f7cb1

Browse files
cjacekSquallATF
authored andcommitted
[LLD][COFF] Implement ECExportThunkChunk::classof (NFC) (llvm#130106)
Allows using `dyn_cast_or_null` in `maybeAddAddressTakenFunction` in llvm#128440.
1 parent 5dd36a0 commit c7f7cb1

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)