[PATCH] D82479: [llvm-size] Output REL, RELA and STRTAB sections in some cases

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 26 01:04:12 PDT 2020


grimar added inline comments.


================
Comment at: llvm/tools/llvm-size/llvm-size.cpp:199
+  if (Section.getIndex() == getShstrndx(Obj))
+    return false;
+
----------------
grimar wrote:
> I'd make the `isAllocatable` just to return what it says. I.e:
> 
> 
> ```
> static bool isAllocatableSec(ObjectFile *Obj, SectionRef Section) {
>   assert(Obj->isELF());
>   ELFSectionRef ElfSection = static_cast<ELFSectionRef>(Section);
>   return ElfSection.getFlags() & ELF::SHF_ALLOC;
> }
> ```
> 
> And you can have another method, like `isShStrTab` to check if a section is one with the index == `e_shstrndx` (but see below).
Or, given that `considerForSize()` already only used for ELFs,
you can probably just inline it, like:

```
static bool considerForSize(ObjectFile *Obj, SectionRef Section) {
  if (!Obj->isELF())
    return true;

  ELFSectionRef ElfSection = static_cast<ELFSectionRef>(Section);
  switch (ElfSection .getType()) {
    ...
    case ELF::SHT_STRTAB:
      return ElfSection.getFlags() & ELF::SHF_ALLOC;
  }
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82479





More information about the llvm-commits mailing list