[lld] [llvm] [llvm-objdump][ARM] Find ELF file PLT entries for arm, thumb (PR #130764)

Vladislav Dzhidzhoev via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 13 05:21:54 PDT 2025


================
@@ -431,6 +431,112 @@ class ARMMCInstrAnalysis : public MCInstrAnalysis {
   std::optional<uint64_t>
   evaluateMemoryOperandAddress(const MCInst &Inst, const MCSubtargetInfo *STI,
                                uint64_t Addr, uint64_t Size) const override;
+
+  std::vector<std::pair<uint64_t, uint64_t>> findPltEntries(
+      uint64_t PltSectionVA, ArrayRef<uint8_t> PltContents,
+      const Triple &TargetTriple,
+      std::optional<llvm::endianness> InstrEndiannessHint) const override {
+    llvm::endianness DataEndianness =
+        TargetTriple.isLittleEndian() ? endianness::little : endianness::big;
+    llvm::endianness InstrEndianness =
+        InstrEndiannessHint.value_or(DataEndianness);
+
+    std::vector<std::pair<uint64_t, uint64_t>> Result;
+    // Do a lightweight parsing of PLT entries.
+    for (uint64_t Byte = 0, End = PltContents.size(); Byte + 12 < End;
+         Byte += 4) {
+      uint32_t InsnPart1 =
+          support::endian::read16(PltContents.data() + Byte, InstrEndianness);
+
+      // Is Thumb? Check for movw.
+      if ((InsnPart1 & 0xffb0) == 0xf200) {
----------------
dzhidzhoev wrote:

Added comments for every case

https://github.com/llvm/llvm-project/pull/130764


More information about the llvm-commits mailing list