[PATCH] D144783: [ELF] Move getSectionAndRelocations to ELF.cpp from ELFDumper.cpp

Rahman Lavaee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 22:08:05 PST 2023


rahmanl accepted this revision.
rahmanl added a comment.
This revision is now accepted and ready to land.

Thanks for your patience with the code review. And please wait for James's approval too.



================
Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:7052
+
+  for (const auto &CGMapEntry : *SecToRelocMapOrErr) {
     const Elf_Shdr *CGSection = CGMapEntry.first;
----------------
Just noticed this loop doesn't check that the map value is not nullptr.

If you're willing to fix it, please add something similar:
```
    // Warn about call graph profile sections without a relocation section.
    if (!CGRelSection) {
      reportWarning(createError("SHT_LLVM_CALL_GRAPH_PROFILE (" + describe(*CGSection) +
                                ") does not have a corresponding "
                                "relocation section"),
                    FileName);
      continue;
    }
```


================
Comment at: llvm/unittests/Object/ELFObjectFileTest.cpp:892
+  auto ErroringMatcher = [](const Elf_Shdr &Sec) -> Expected<bool> {
+    if(Sec.sh_type == ELF::SHT_PROGBITS) {
+      return createError("This was supposed to fail.");
----------------
remove brace for single-line if statements per LLVM coding style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144783



More information about the llvm-commits mailing list