[PATCH] D76081: [Object] object::ELFObjectFile::dynamic_symbol_begin(): skip symbol index 0

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 01:35:35 PDT 2020


grimar added a comment.

In D76081#1939346 <https://reviews.llvm.org/D76081#1939346>, @Higuoxing wrote:

> In D76081#1939223 <https://reviews.llvm.org/D76081#1939223>, @grimar wrote:
>
> > I do not have a good answer right now. Seems the API could be revisited and refined.
> >  `section_begin()` and `section_end()` just ignore errors now.
> >  `symbol_begin()` has a different logic from `dynamic_symbol_begin` that does not look ideal to me either:
> >
> >   DataRefImpl Sym =
> >       toDRI(DotSymtabSec,
> >             DotSymtabSec && DotSymtabSec->sh_size >= sizeof(Elf_Sym) ? 1 : 0);
> >   
> >
> > (it is unclear to me how it works when `sh_size==1`, for example)
>
>
> When `sh_size == 1`, it's similar to `toDRI(DotSymtabSec, 0)` and `symbol_end()` will return `toDRI(DotSymtabSec, sh_size / sizeof(Elf_Sym)`. Hence, no symbol is returned.


Exactly. It is unclear how **well** it works for callers now. It seems just hides errors and I would expect to see issues on their side related to this API.
A few methods around return `Expected<>`, i.e. they do not ignore errors. Perhaps we should think about returning `Expected<elf_symbol_iterator>` here too.
BTW, `getRelocatedSection` do this:

  Expected<section_iterator>
  ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const

while `section_begin()` don't:

  section_iterator ELFObjectFile<ELFT>::section_begin() const


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76081





More information about the llvm-commits mailing list