Skip to content

Commit a5fdb52

Browse files
committed
address codereviews
1 parent af4668c commit a5fdb52

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

lld/ELF/ICF.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
#include "SymbolTable.h"
8282
#include "Symbols.h"
8383
#include "SyntheticSections.h"
84+
#include "Target.h"
8485
#include "llvm/ADT/ArrayRef.h"
8586
#include "llvm/BinaryFormat/ELF.h"
8687
#include "llvm/Object/ELF.h"
@@ -484,16 +485,7 @@ void ICF<ELFT>::applySafeThunksToRange(size_t begin, size_t end) {
484485
return;
485486

486487
// Find the symbol to create the thunk for.
487-
Symbol *masterSym = nullptr;
488-
for (Symbol *sym : masterIsec->file->getSymbols()) {
489-
if (auto *d = dyn_cast<Defined>(sym)) {
490-
if (d->section == masterIsec) {
491-
masterSym = sym;
492-
break;
493-
}
494-
}
495-
}
496-
488+
Symbol *masterSym = masterIsec->getEnclosingSymbol(0);
497489
if (!masterSym)
498490
return;
499491

@@ -514,8 +506,11 @@ void ICF<ELFT>::applySafeThunksToRange(size_t begin, size_t end) {
514506

515507
for (Symbol *sym : thunk->file->getSymbols())
516508
if (auto *d = dyn_cast<Defined>(sym))
517-
if (d->section == isec)
518-
d->size = thunkSize;
509+
if (d->section == isec) {
510+
d->value = 0;
511+
if (d->size != 0)
512+
d->size = thunkSize;
513+
}
519514
}
520515
}
521516

lld/ELF/ICF.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@
99
#ifndef LLD_ELF_ICF_H
1010
#define LLD_ELF_ICF_H
1111

12-
#include "Target.h"
1312
namespace lld::elf {
1413
struct Ctx;
15-
class TargetInfo;
1614

1715
template <class ELFT> void doIcf(Ctx &);
1816
}

lld/ELF/Target.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ class TargetInfo {
108108
llvm_unreachable("target does not support ICF safe thunks");
109109
}
110110
// Returns the size of the safe thunk in ICF for the target.
111-
virtual uint32_t getICFSafeThunkSize() const { return 0; }
111+
virtual uint32_t getICFSafeThunkSize() const {
112+
llvm_unreachable("target does not support ICF safe thunks");
113+
}
112114

113115
virtual ~TargetInfo();
114116

0 commit comments

Comments
 (0)