[lld] [ELF] Add BPSectionOrderer options (PR #120514)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 2 15:55:39 PST 2025
================
@@ -0,0 +1,95 @@
+//===- BPSectionOrderer.cpp -----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "BPSectionOrderer.h"
+#include "InputFiles.h"
+#include "InputSection.h"
+#include "SymbolTable.h"
+#include "Symbols.h"
+#include "lld/Common/BPSectionOrdererBase.inc"
+#include "llvm/Support/Endian.h"
+
+using namespace llvm;
+using namespace lld::elf;
+
+namespace {
+struct BPOrdererELF;
+}
+template <> struct lld::BPOrdererTraits<struct BPOrdererELF> {
+ using Section = elf::InputSectionBase;
+ using Defined = elf::Defined;
+};
+namespace {
+struct BPOrdererELF : lld::BPOrderer<BPOrdererELF> {
+ DenseMap<const InputSectionBase *, Defined *> secToSym;
+
+ static uint64_t getSize(const Section &sec) { return sec.getSize(); }
+ static bool isCodeSection(const Section &sec) {
+ return sec.flags & llvm::ELF::SHF_EXECINSTR;
+ }
+ ArrayRef<Defined *> getSymbols(const Section &sec) {
----------------
MaskRay wrote:
The previous getSymbols iterated over all symbols in sec.file, which could be very slow. I rewrote this to use a member variable.
https://github.com/llvm/llvm-project/pull/120514
More information about the llvm-commits
mailing list