[PATCH] D71242: [LLD][ELF]{ARM][AArch64] Add missing classof to patch sections.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 18:00:28 PST 2019


MaskRay added a comment.

In D71242#1778767 <https://reviews.llvm.org/D71242#1778767>, @ruiu wrote:

> classof is an LLVM's way of implementing a dynamic casting, and the code is idiomatic -- we almost always dispatch only by an enum field. So this could be a bit confusing to those who are expecting that idiomatic mechanism? I wonder if it is better to define a new function instead of overloading classof.


We already have such a code pattern

  class EhFrameSection final : public SyntheticSection {
  public:
    EhFrameSection();
    void writeTo(uint8_t *buf) override;
    void finalizeContents() override;
    bool isNeeded() const override { return !sections.empty(); }
    size_t getSize() const override { return size; }
  
    static bool classof(const SectionBase *d) {
      return SyntheticSection::classof(d) && d->name == ".eh_frame";
    }



================
Comment at: lld/ELF/AArch64ErrataFix.cpp:385
+  static bool classof(const SectionBase *d) {
+    return d->kind() == InputSectionBase::Synthetic && d->name == ".text.patch";
+  }
----------------
Probably `return SyntheticSection::classof(d) && d->name == ".text.patch";`

See EhFrameSection::classof.



CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71242/new/

https://reviews.llvm.org/D71242





More information about the llvm-commits mailing list