[patch] AVR: Tidy bfd/elf32-avr.c

Georg-Johann Lay avr@gjlay.de
Tue Aug 11 08:34:52 GMT 2026


This patch is a code cleanup for bfd/elf32-avr.c, in particular
the code in elf32_avr_relax_section which was long spaghetti with
indentation levels of 8 and more, which made the code harder to
grasp than necessary.

Now it uses new helper functions like avr_local_label_at and
avr_is_RCALL.

It also uses more C99 features like bool and for loop variables.
It uses ARRAY_SIZE if applicable, and uses XXX_t typedefs instead
of struct XXX.  It also avoids using the same names for structs
and objects.

The change is a no-op, though some of the --debug-relax messages
have been adjusted / unified, which has no impact on the testsuite.

There are no new regressions when tested in the GCC testsuite,
both with and without -mrelax.

Ok for trunk?

Johann

--

bfd/
	* elf32-avr.c (libiberty.h): Include for ARRAY_SIZE.
	(struct avr_reloc_map): Use typedef avr_reloc_map_t instead
	so we don't have the same name for an object and a type.
	(struct elf32_avr_stub_hash_entry): Use typedef
	elf32_avr_stub_hash_entry_t.
	(struct struct elf32_avr_link_hash_table): Use typedef
	elf32_avr_link_hash_table_t.
	(struct avr_relax_info): Use avr_relax_info_t.
	(struct elf_avr_section_data): use elf_avr_section_data_t.
	(avr_replace_call_ret_sequences): Is bool.
	(bfd_elf32_bfd_reloc_type_lookup): Use C99 loops.
	(elf32_avr_relax_delete_bytes): Use C99 loops.
	(avr_load_all_property_sections): Same.
	(avr_word): New static function.
	(avr_is_CALL): New static function outsourced from
	elf32_avr_relax_section.
	(avr_is_JMP): Same.
	(avr_is_RCALL): Same.
	(avr_is_RJMP): Same.
	(avr_is_RET): Same.
	(avr_is_skip): Same.
	(avr_read_symbuf): Same.
	(avr_local_label_at): Same.
	(avr_global_label_at): Same.
	(avr_reloc_at): Same.
	(elf32_avr_relax_section): Outsource functionality to the
	new static functions above.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-tidy-relax.diff
Type: text/x-patch
Size: 66743 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260811/2d9b498a/attachment-0001.bin>


More information about the Binutils mailing list