[lld] [llvm] [feature][riscv] handle target address calculation in llvm-objdump disassembly for riscv (PR #109914)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 9 11:15:58 PDT 2025


================
@@ -2392,14 +2393,20 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj,
                     [=](const std::pair<uint64_t, SectionRef> &O) {
                       return O.first <= Target;
                     });
-                uint64_t TargetSecAddr = 0;
+                uint64_t TargetSecAddr = It == SectionAddresses.end() ? 0 : It->first;
+                bool FoundSymbols = false;
                 while (It != SectionAddresses.begin()) {
                   --It;
-                  if (TargetSecAddr == 0)
-                    TargetSecAddr = It->first;
-                  if (It->first != TargetSecAddr)
-                    break;
+                  if (It->first != TargetSecAddr) {
+                    if (!FoundSymbols) {
----------------
topperc wrote:

Can we do this to avoid the `else`

```
if (FoundSymbols)
  break;
TargetSecAddr = It->first
```

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


More information about the llvm-commits mailing list