[patch, ping, pushed] AVR: Add support for .gnu_attribute 4 (Tag_GNU_AVR_VTABLE_AS)
Georg-Johann Lay
avr@gjlay.de
Sun Aug 16 10:11:19 GMT 2026
https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=8818c47980038800239da822cfef2aa63e0fac1f
Approved here:
https://gcc.gnu.org/pipermail/gcc-patches/2026-August/727700.html
There was quite some internal changes in the generic .gnu-attribute
handling, so that the applied patch needed some more adjustments,
see the attached patch.
Johann
--
Am 11.08.26 um 17:04 schrieb Georg-Johann Lay via Binutils:
> Ping: https://sourceware.org/pipermail/binutils/2026-July/149967.html
>
> The upcoming support for ISO/IEC TR 18037 "Embedded C" named
> address spaces in G++ would allow to put C++ virtual tables
> into such an address spaces, see https://gcc.gnu.org/PR69549.
>
> The current address space used for vtables is the generic
> one, which means that RAM is wasted on machines where
> .rodata is located in RAM.
>
> The TARGET_ADDR_SPACE_FOR_ARTIFICIAL_RODATA GCC target hook
> allows to chose a custom vtable address space. However, in
> contrast to current user-selectable address spaces, placing
> vtables in a different address space is an ABI change, so
> that a means to detect ABI violations is highly appreciated.
>
> The feature of choice is .gnu_attribute 4 (Tag_GNU_AVR_VTABLE_AS)
> which would tag an object file with one of the following values:
>
> 0 (Val_GNU_AVR_VTABLE_NONE) for files that neither define nor access
> vtables.
> 1 (Val_GNU_AVR_VTABLE_RAM) use the generic address space.
> 2 (Val_GNU_AVR_VTABLE_FLASH) use the 16-bit address space __flash.
> 3 (Val_GNU_AVR_VTABLE_FLASH1) use the 16-bit address space __flash1.
> 4 (Val_GNU_AVR_VTABLE_FLASH2) use the 16-bit address space __flash2.
> 5 (Val_GNU_AVR_VTABLE_FLASH3) use the 16-bit address space __flash3.
> 6 (Val_GNU_AVR_VTABLE_FLASH4) use the 16-bit address space __flash4.
> 7 (Val_GNU_AVR_VTABLE_FLASH5) use the 16-bit address space __flash5.
> 8 (Val_GNU_AVR_VTABLE_FLASHX) use the 24-bit address space __flashx.
>
> A tag value of zero is compatible with all other tag values.
> Two non-zero tag values are compatible iff they are the same.
>
> Unknown tag values are silently accepted an treated just like
> the values above so as to allow for compatibility with future
> extensions.
>
> Ok for trunk?
>
> Johann
>
> --
>
> PR ld/34305
> include/
> * elf/avr.h (libiberty.h): Include for ARRAY_SIZE.
> (Tag_GNU_AVR_VTABLE_AS = 4): New enum.
> (Val_GNU_AVR_VTABLE_NONE, Val_GNU_AVR_VTABLE_RAM)
> (Val_GNU_AVR_VTABLE_FLASH, Val_GNU_AVR_VTABLE_FLASH1)
> (Val_GNU_AVR_VTABLE_FLASH2, Val_GNU_AVR_VTABLE_FLASH3)
> (Val_GNU_AVR_VTABLE_FLASH4, Val_GNU_AVR_VTABLE_FLASH5)
> (Val_GNU_AVR_VTABLE_FLASHX, Val_GNU_AVR_VTABLE_Sentinel): New
> enum values for Tag_GNU_AVR_VTABLE_AS.
> (avr_tag_vtable_as_name): New static function.
>
> bfd/
> * elf32-avr.h (bfd_avr_elf_merge_private_bfd_data): New proto.
> * elf32-avr.c (libiberty.h): Include for ARRAY_SIZE.
> (avr_elf_merge_obj_attributes): New static function.
> (bfd_avr_elf_merge_private_bfd_data): New function that calls it.
> (bfd_elf32_bfd_merge_private_bfd_data): Define to
> bfd_avr_elf_merge_private_bfd_data.
>
> gas/
> * doc/as.texi (GNU Object Attributes) [AVR Attributes]: New
> subsection.
>
> ld/
> * testsuite/ld-avr/attr-gnu-4-1.s: New source.
> * testsuite/ld-avr/attr-gnu-4-2.s: New source.
> * testsuite/ld-avr/attr-gnu-4-1.d: New test.
> * testsuite/ld-avr/attr-gnu-4-2.d: New test.
> * testsuite/ld-avr/attr-gnu-4-1_2.d: New test.
>
> binutils/
> * readelf.c (display_avr_gnu_attribute): New static function.
> (process_arch_specific) <EM_AVR>: Call process_attributes
> with display_avr_gnu_attribute as a callback.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: binutils-attr-gnu-vtable-as-v3.diff
Type: text/x-patch
Size: 17447 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20260816/d319aa26/attachment-0001.bin>
More information about the Binutils
mailing list