[PATCH 01/19] elf: Use memcmp to make suitable for PBL
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Jan 5 03:46:18 PST 2026
On 1/5/26 12:26 PM, Sascha Hauer wrote:
> In preparation of adding ELF support to the PBL use memcmp rather than
> strncmp for checking against the ELF magic. The other possibility would
> be to add strncmp to the PBL, but for the sake of binary size use a
> function that is already there.
>
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
Reviewed-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
I am still not sure if we want to reuse the ELF code in PBL instead of
duplicating it, but I will read along.
Cheers,
Ahmad
> ---
> common/elf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/common/elf.c b/common/elf.c
> index c68ea0be3fa668d988b27530644bbb77eb62ff48..692323c6beab2dd8aae9a9e874fb4980152a74e0 100644
> --- a/common/elf.c
> +++ b/common/elf.c
> @@ -201,7 +201,7 @@ static int load_elf_image_segments(struct elf_image *elf)
>
> static int elf_check_image(struct elf_image *elf, void *buf)
> {
> - if (strncmp(buf, ELFMAG, SELFMAG)) {
> + if (memcmp(buf, ELFMAG, SELFMAG)) {
> pr_err("ELF magic not found.\n");
> return -EINVAL;
> }
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
More information about the barebox
mailing list