[PATCH] D77289: [Object] Fix crash caused by unhandled error.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 2 05:24:15 PDT 2020


grimar added inline comments.


================
Comment at: llvm/include/llvm/Object/ELFObjectFile.h:629
 
-  auto DotSymtabSecSyms = EF.symbols(DotSymtabSec);
-  if (DotSymtabSecSyms && ESym == (*DotSymtabSecSyms).begin())
-    Result |= SymbolRef::SF_FormatSpecific;
-  auto DotDynSymSecSyms = EF.symbols(DotDynSymSec);
-  if (DotDynSymSecSyms && ESym == (*DotDynSymSecSyms).begin())
+  auto CheckSymbol = [&](const Elf_Shdr *Sec) {
+    if (Expected<Elf_Sym_Range> SymbolsOrErr = EF.symbols(Sec)) {
----------------
grimar wrote:
> With this implementation the `CheckSymbol` name probably does not make much sense anymore?
> It is unclear what does it check I think. It perhaps should be changed to `IsFormatSpecificSymbol` or something better.
> 
> In this case I'd expect to see a bit more related code inside.
> E.g. seems the following piece from above:
> 
> ```
>   if (ESym->getType() == ELF::STT_FILE || ESym->getType() == ELF::STT_SECTION)
>     Result |= SymbolRef::SF_FormatSpecific;
> ```
> 
> and the code for ARM from below :
> 
> ```
> if (EF.getHeader()->e_machine == ELF::EM_ARM) {
>     if (Expected<StringRef> NameOrErr = getSymbolName(Sym)) {
>       StringRef Name = *NameOrErr;
>       if (Name.startswith("$d") || Name.startswith("$t") ||
>           Name.startswith("$a"))
>         Result |= SymbolRef::SF_FormatSpecific;
> ```
> 
> can live there so that `IsFormatSpecificSymbol` would return `true` for all cases when we want to set the `SF_FormatSpecific` flag.
Let me debug this to see how well my suggestions works. I'll return with something soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77289





More information about the llvm-commits mailing list