[PATCH 1/4] debugedit-classify-ar: Break early for found_debug

Mark Wielaard mark@klomp.org
Mon May 25 15:33:53 GMT 2026


Hi,

I pushed all 4 patches in this series.

> No need to check any more sections if we found one debug section.
> 
> 	* tools/debugedit-classify-ar.c (classify_ar_member): Break
> 	from while loop after setting find_debug to true.
> 
> Signed-off-by: Mark Wielaard <mark@klomp.org>

> Would leak Elf handle otherwise. Although we will quit failure soon
> afterwards.
> 
> 	* tools/debugedit-classify-ar.c (classify_ar_elf): Call
> 	elf_end on failure.
> 
> Signed-off-by: Mark Wielaard <mark@klomp.org>

> We were using atoi to part the -m argument. atoi doesn't do any error
> checking, so we might accept bogus arguments. Use strtol instead and
> perform sanity checking producing an error when invoked with negative,
> zero or non-numbers as argument.
> 
> Also pull max_members check into the elf = elf_begin while loop of
> classify_ar_elf to stop iterating early.
> 
> 	* tools/debugedit-classify-ar.c (max_members): Define as long.
> 	(classify_ar_elf): Define members as long. Pull max_members
> 	check into while loop.
> 	(main): Parse 'm' with strtol, reject non-numbers, zero or
> 	negative numbers.
> 
> Signed-off-by: Mark Wielaard <mark@klomp.org>

> The while loop calling elf_begin to check all ar members in
> classify_ar_elf will end with elf == NULL when all ar members are
> checked, or if there was an error reading the next ar member.
> Explicitly check which case it was and set err if the loop failed.
> 
> 	* tools/debugedit-classify-ar.c (classify_ar_elf): Check why
> 	elf == NULL at end of loop.
> 
> Signed-off-by: Mark Wielaard <mark@klomp.org>

Cheers,

Mark


More information about the Debugedit mailing list