Georg-Johann Lay <[email protected]> writes: > Am 21.06.26 um 11:27 schrieb Georg-Johann Lay: >> Here is a related one: >> #define AS1 const __flash >> extern AS1 int array[] = { 1 }; >> The object is located in AS0 (.rodata) but should be in the section >> for AS1 (.progmem.data). In avr_insert_attributes the node looks fine: >> <var_decl 0x7fc286cb8c78 array> >> <array_type 0x7fc286caebd0> >> <integer_type 0x7fc286cae0a8 int address-space-1> read-only >> Simple values like >> extern AS1 int value = 1; >> are located correctly. >> Johann > > Strange things are happening. With the correct > > extern AS1 int value = 1; > > the TARGET_ASM_NAMED_SECTION hook is called with > flags = 0x8100000 which is 1<<20 for SECTION_NAMED and > 0x8000000 for SECTION_MACH_DEP which encodes the AS. > > In > > extern AS1 int array[] = { 1 }; > > however, the section flags are 0x140000 which is > SECTION_NAMED plus SECTION_NOTYPE where they should > be SECTION NAMED | SECTION_MACH_DEP, too.
ISTM that this is just a result of the C++ FE not propagating the TYPE_ADDR_SPACE from element type to array type. Can you try the following on AVR (it worked for GCN): modified gcc/cp/tree.cc @@ -1174,6 +1174,7 @@ build_min_array_type (tree elt_type, tree index_type) tree t = cxx_make_type (ARRAY_TYPE); TREE_TYPE (t) = elt_type; TYPE_DOMAIN (t) = index_type; + TYPE_ADDR_SPACE (t) = TYPE_ADDR_SPACE (elt_type); return t; } This seems to be equivalent to what tree.cc:build_array_type_1 is doing. -- Arsen Arsenović
signature.asc
Description: PGP signature
