]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AVR: Always define __AVR_PM_BASE_ADDRESS__ in specs provided the core has it.
authorGeorg-Johann Lay <avr@gjlay.de>
Thu, 8 Feb 2024 10:39:53 +0000 (11:39 +0100)
committerGeorg-Johann Lay <avr@gjlay.de>
Thu, 8 Feb 2024 10:41:43 +0000 (11:41 +0100)
gcc/
* config/avr/gen-avr-mmcu-specs.cc (print_mcu) <*cpp_mcu>: Spec always
defines __AVR_PM_BASE_ADDRESS__ if the core has it.

gcc/config/avr/gen-avr-mmcu-specs.cc

index 06d9d3c8d7d39261bcb5c1aa215f9eb91c963b21..41ebfa82eb56b89af1614b67c92422fb87e8a170 100644 (file)
@@ -199,13 +199,21 @@ print_mcu (const avr_mcu_t *mcu)
   bool flmap = (mcu->dev_attribute & AVR_ISA_FLMAP);
   bool is_arch = mcu->macro == NULL;
   bool is_device = ! is_arch;
-  int flash_pm_offset = 0;
+  int rodata_pm_offset = 0;
+  int pm_base_address = 0;
 
   if (arch->flash_pm_offset
       && mcu->flash_pm_offset
       && mcu->flash_pm_offset != arch->flash_pm_offset)
     {
-      flash_pm_offset = mcu->flash_pm_offset;
+      rodata_pm_offset = mcu->flash_pm_offset;
+    }
+
+  if (arch->flash_pm_offset)
+    {
+      pm_base_address = mcu->flash_pm_offset
+       ? mcu->flash_pm_offset
+       : arch->flash_pm_offset;
     }
 
   if (is_arch
@@ -339,8 +347,8 @@ print_mcu (const avr_mcu_t *mcu)
 
   fprintf (f, "*link_arch:\n\t%s", link_arch_spec);
   if (is_device
-      && flash_pm_offset)
-    fprintf (f, " --defsym=__RODATA_PM_OFFSET__=0x%x", flash_pm_offset);
+      && rodata_pm_offset)
+    fprintf (f, " --defsym=__RODATA_PM_OFFSET__=0x%x", rodata_pm_offset);
   fprintf (f, "\n\n");
 
   if (is_device)
@@ -381,10 +389,10 @@ print_mcu (const avr_mcu_t *mcu)
 
       fprintf (f, "*cpp_mcu:\n");
       fprintf (f, "\t-D%s", mcu->macro);
-      if (flash_pm_offset)
+      if (pm_base_address)
        {
          fprintf (f, " -U__AVR_PM_BASE_ADDRESS__");
-         fprintf (f, " -D__AVR_PM_BASE_ADDRESS__=0x%x", flash_pm_offset);
+         fprintf (f, " -D__AVR_PM_BASE_ADDRESS__=0x%x", pm_base_address);
        }
       if (have_flmap)
        fprintf (f, " -D__AVR_HAVE_FLMAP__");