[PATCH] elf: error out if pyelftools could not be found
Tom Rini
trini at konsulko.com
Fri Jan 9 21:52:48 CET 2026
On Fri, Jan 09, 2026 at 09:26:04PM +0100, Dmitrii Sharshakov wrote:
> It is not possible to validate an ELF file without pyelftools, make the
> error more clear and informative to the user:
>
> > binman: Python: No module named 'elftools'
>
> rather than:
>
> > binman: name 'ELFError' is not defined
>
> Signed-off-by: Dmitrii Sharshakov <d3dx12.xx at gmail.com>
> ---
> Make the error more informative and indicative of environment issue and
> not a code one
> ---
> tools/binman/elf.py | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/binman/elf.py b/tools/binman/elf.py
> index 6ac960e0419..899c84ad36d 100644
> --- a/tools/binman/elf.py
> +++ b/tools/binman/elf.py
> @@ -570,6 +570,8 @@ def is_valid(data):
> Returns:
> bool: True if a valid Elf file, False if not
> """
> + if not ELF_TOOLS:
> + raise ValueError("Python: No module named 'elftools'")
> try:
> DecodeElf(data, 0)
> return True
>
In that this is the common way the file checks for elftools, this is
fine. But please re-word the commit message to be more akin to
commit 43176ed86d9f120efb3e86084d83a714bf076d29
Author: Lukas Funke <lukas.funke at weidmueller.com>
Date: Tue Jul 18 13:53:09 2023 +0200
binman: elf: Check for ELF_TOOLS availability and remove extra semicolon
Check if elf tools are available when running DecodeElf(). Also
remove superfuous semicolon at line ending.
Signed-off-by: Lukas Funke <lukas.funke at weidmueller.com>
Reviewed-by: Simon Glass <sjg at chromium.org>
Revert part of patch to make binman test pass
Signed-off-by: Simon Glass <sjg at chromium.org>
Thanks.
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20260109/a149e2f9/attachment.sig>
More information about the U-Boot
mailing list