[PATCH] D90903: [llvm-readelf/obj] - Allow dumping of ELF header even if some elements are corrupt.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 6 03:06:20 PST 2020


grimar added a comment.

In D90903#2378439 <https://reviews.llvm.org/D90903#2378439>, @jhenderson wrote:

> LGTM. About the only other viable alternative I could think of would be to have the sections that are initialised early stored in some sort of container that does the lazy initialization itself, and then being a transparent object thereafter (like the Proxy design pattern). This would delay the error reporting until later. However, that would probably require call sites to be updated to handle errors where they don't currently, which I can understand might be a pain.

I've tried to delay the initialization when experimented with possible solutions. In that experiment I had 3 additional functions: `getDynSymSec()`, `getSymtabSec()` and `getSymtabShndxSec()` which lazily initialized the
pointers to corresponding sections on call. It was a pain, because some tools, like llvm-ar still want to see the old behavior, i.e. to report an error early when they are unable to
initialize an object because of broken section header table. For them I had to add the new `validate()`/`initialize()` method, but this did not look nice:
it is easy to forget to call such method after creating an object and it also required too many call sites to be updated.


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

https://reviews.llvm.org/D90903



More information about the llvm-commits mailing list