aboutsummaryrefslogtreecommitdiff
path: root/lld/MachO/ICF.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/MachO/ICF.cpp')
-rw-r--r--lld/MachO/ICF.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp
index ad029142681f..d06fbc6db840 100644
--- a/lld/MachO/ICF.cpp
+++ b/lld/MachO/ICF.cpp
@@ -384,23 +384,18 @@ void macho::markAddrSigSymbols() {
continue;
assert(addrSigSection->subsections.size() == 1);
- Subsection *subSection = &addrSigSection->subsections[0];
- ArrayRef<unsigned char> &contents = subSection->isec->data;
-
- const uint8_t *pData = contents.begin();
- while (pData != contents.end()) {
- unsigned size;
- const char *err;
- uint32_t symIndex = decodeULEB128(pData, &size, contents.end(), &err);
- if (err)
- fatal(toString(file) + ": could not decode addrsig section: " + err);
- markSymAsAddrSig(obj->symbols[symIndex]);
- pData += size;
+ const InputSection *isec = addrSigSection->subsections[0].isec;
+
+ for (const Reloc &r : isec->relocs) {
+ if (auto *sym = r.referent.dyn_cast<Symbol *>())
+ markSymAsAddrSig(sym);
+ else
+ error(toString(isec) + ": unexpected section relocation");
}
}
}
-void macho::foldIdenticalSections() {
+void macho::foldIdenticalSections(bool onlyCfStrings) {
TimeTraceScope timeScope("Fold Identical Code Sections");
// The ICF equivalence-class segregation algorithm relies on pre-computed
// hashes of InputSection::data for the ConcatOutputSection::inputs and all
@@ -420,10 +415,12 @@ void macho::foldIdenticalSections() {
uint64_t icfUniqueID = inputSections.size();
for (ConcatInputSection *isec : inputSections) {
// FIXME: consider non-code __text sections as hashable?
- bool isHashable = (isCodeSection(isec) || isCfStringSection(isec) ||
- isClassRefsSection(isec)) &&
- !isec->keepUnique && !isec->shouldOmitFromOutput() &&
- sectionType(isec->getFlags()) == MachO::S_REGULAR;
+ bool isHashable =
+ (!onlyCfStrings || isCfStringSection(isec)) &&
+ (isCodeSection(isec) || isCfStringSection(isec) ||
+ isClassRefsSection(isec) || isGccExceptTabSection(isec)) &&
+ !isec->keepUnique && !isec->shouldOmitFromOutput() &&
+ sectionType(isec->getFlags()) == MachO::S_REGULAR;
if (isHashable) {
hashable.push_back(isec);
for (Defined *d : isec->symbols)