[PATCH] D85579: [ELF] --gdb-index: skip SHF_GROUP .debug_info

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 14:47:39 PDT 2020


MaskRay added a subscriber: hans.
MaskRay added a comment.

@hans This patch can be cleanly cherry-picked to release/11.x It addresses a pain for DWARF v5 -fdebug-types-section users.



================
Comment at: lld/ELF/SyntheticSections.cpp:2889
+    nameAttrs[i] = readPubNamesAndTypes<ELFT>(dobj, chunks[i].compilationUnits);
   });
 
----------------
grimar wrote:
> Previously, `parallelForEachN` loop assumed that there is a one `.debug_info` section in an object.
> Now it is not true and parallelizing for sections by itself (instead of doing it for files) doesn't look optimal.
> 
> Also, you do not need to build a list sections, because you are not using them (you call `dobj.getInfoSection();` anyways), so
> you only need a list of files to work with.
> 
> With that we can have a simpler code:
> 
> ```
>   SetVector<ObjFile<ELFT> *> files;
>   for (InputSectionBase *s : inputSections) {
>     InputSection *isec = dyn_cast<InputSection>(s);
>     if (!isec)
>       continue;
>     // .debug_gnu_pub{names,types} are useless in executables.
>     // They are present in input object files solely for creating
>     // a .gdb_index. So we can remove them from the output.
>     if (s->name == ".debug_gnu_pubnames" || s->name == ".debug_gnu_pubtypes")
>       s->markDead();
>     else if (isec->name == ".debug_info")
>       files.insert(isec->getFile<ELFT>());
>   }
> 
>   std::vector<GdbChunk> chunks(files.size());
>   std::vector<std::vector<NameAttrEntry>> nameAttrs(files.size());
> 
>   parallelForEachN(0, files.size(), [&](size_t i) {
>     // To keep memory usage low, we don't want to keep cached DWARFContext, so
>     // avoid getDwarf() here.
>     DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(files[i]));
>     auto &dobj = static_cast<const LLDDwarfObj<ELFT> &>(dwarf.getDWARFObj());
> ...
> ```
Forgot to push this comment:

Thanks! I'll make a small change: `SetVector<InputFile *>`, just so that we don't need to instantiate nearly identical code for 4 instantiations of ELFT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85579



More information about the llvm-commits mailing list