[lld] [lld-macho] Implement support for ObjC relative method lists (PR #86231)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 25 10:13:57 PDT 2024
================
@@ -692,6 +692,53 @@ class InitOffsetsSection final : public SyntheticSection {
std::vector<ConcatInputSection *> sections;
};
+// This SyntheticSection is for the __objc_methlist section, which contains
+// relative method lists if the -objc_relative_method_lists option is enabled.
+class ObjCMethListSection final : public SyntheticSection {
+public:
+ ObjCMethListSection();
+
+ static bool isMethodList(const ConcatInputSection *isec);
+ void addInput(ConcatInputSection *isec) { inputs.push_back(isec); }
+ std::vector<ConcatInputSection *> getInputs() { return inputs; }
+
+ void setUp();
+ void finalize() override;
+ bool isNeeded() const override { return !inputs.empty(); }
+ uint64_t getSize() const override { return m_size; }
+ void writeTo(uint8_t *bufStart) const override;
+
+private:
+ static void readMethodListHeader(const uint8_t *buf,
+ uint32_t &structSizeAndFlags,
+ uint32_t &structCount);
+ static void writeMethodListHeader(uint8_t *buf, uint32_t structSizeAndFlags,
+ uint32_t structCount);
+ static uint32_t methodListSizeToRelativeMethodListSize(uint32_t iSecSize);
+ void writeRelativeOffsetForIsec(const ConcatInputSection *isec, uint8_t *buf,
+ uint32_t &inSecOff, uint32_t &outSecOff,
+ bool useSelRef) const;
+ uint32_t writeRelativeMethodList(const ConcatInputSection *isec,
+ uint8_t *buf) const;
+
+ static constexpr uint32_t m_methodListHeaderSize =
----------------
kyulee-com wrote:
Can we drop `m_` in the name, which doesn't seem following the coding patterns in LLD.
https://github.com/llvm/llvm-project/pull/86231
More information about the llvm-commits
mailing list