[PATCH] D64779: [llvm-objdump] Emit warning if --start-address/--stop-address specify range outside file's address range.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 15 18:54:16 PDT 2019


MaskRay added inline comments.


================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2016
+  if (const auto *Elf = dyn_cast<ELFObjectFileBase>(Obj)) {
+    if (Elf->getEType() == ELF::ET_EXEC ||
+        Elf->getEType() == ELF::ET_DYN)
----------------
Why don't ET_CORE and ET_REL need the warning?


================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2043
+  else
+    warn("no section covers the range [0x" +
+        Twine::utohexstr(Start) + ",0x" + Twine::utohexstr(Stop) +
----------------
> covers

`Start < BaseAddr + Size) && Stop > BaseAddr` checks whether two ranges **overlap**.


================
Comment at: llvm/tools/llvm-objdump/llvm-objdump.cpp:2061
+  if (StartAddress.getNumOccurrences() || StopAddress.getNumOccurrences())
+    warnForInvalidStartStopAddress(O, StartAddress, StopAddress);
+
----------------
I suggest prefixing the function with `maybeWarn` (or `check`) because it doesn't always warn.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64779





More information about the llvm-commits mailing list