[llvm] [llvm][ELF] Add statistics on various section sizes (PR #102363)

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 13:06:38 PDT 2024


================
@@ -951,6 +965,38 @@ void ELFWriter::writeSectionHeader(const MCAssembler &Asm) {
     else
       Size = Offsets.second - Offsets.first;
 
+    auto SectionHasFlag = [&](uint64_t Flag) -> bool {
+      return Section->getFlags() & Flag;
+    };
+    auto SectionIsType = [&](uint64_t Type) -> bool {
+      return Section->getType() == Type;
+    };
+
+    if (SectionIsType(ELF::SHT_STRTAB)) {
+      stats::StrtabBytes += Size;
+    } else if (SectionIsType(ELF::SHT_SYMTAB)) {
+      stats::SymtabBytes += Size;
+    } else if (SectionIsType(ELF::SHT_DYNSYM)) {
+      stats::DynsymBytes += Size;
+    } else if (SectionIsType(ELF::SHT_REL) || SectionIsType(ELF::SHT_RELA) ||
+               SectionIsType(ELF::SHT_RELR) || SectionIsType(ELF::SHT_CREL)) {
+      stats::RelocationBytes += Size;
+    } else if (SectionIsType(ELF::SHT_X86_64_UNWIND)) {
----------------
aeubanks wrote:

done

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


More information about the llvm-commits mailing list