scripts: gen_relocate_app.py: add custom align size for relocation

add custom align size for code relocation to reduce alignment memory
wasting.

Fixes: #17337.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
diff --git a/scripts/gen_relocate_app.py b/scripts/gen_relocate_app.py
index a5c1a7b..85e13d4 100644
--- a/scripts/gen_relocate_app.py
+++ b/scripts/gen_relocate_app.py
@@ -84,7 +84,11 @@
         {{
                 __{0}_{1}_start = .;
                 {4}
+#if {6}
+                . = ALIGN({6});
+#else
                 MPU_ALIGN(__{0}_{1}_size);
+#endif
                 __{0}_{1}_end = .;
 	}} {5}
         __{0}_{1}_size = __{0}_{1}_end - __{0}_{1}_start;
@@ -187,6 +191,12 @@
             iteration_sections["text"] or iteration_sections["rodata"]):
         all_regions = True
 
+    pos = memory_type.find('_')
+    if pos in range(len(memory_type)):
+        align_size = int(memory_type[pos+1:])
+        memory_type = memory_type[:pos]
+        mpu_align[memory_type] = align_size
+
     if memory_type in complete_list_of_sections:
         for iter_sec in ["text", "rodata", "data", "bss"]:
             if ((iteration_sections[iter_sec] or all_regions) and
@@ -229,8 +239,12 @@
             linker_string += tmp
         else:
             if memory_type != 'SRAM' and region == 'rodata':
+                align_size = 0
+                if memory_type in mpu_align.keys():
+                    align_size = mpu_align[memory_type]
+
                 linker_string += LINKER_SECTION_SEQ_MPU.format(memory_type.lower(), region, memory_type.upper(),
-                                                               region.upper(), tmp, load_address_string)
+                                                               region.upper(), tmp, load_address_string, align_size)
             else:
                 linker_string += LINKER_SECTION_SEQ.format(memory_type.lower(), region, memory_type.upper(),
                                                            region.upper(), tmp, load_address_string)
@@ -389,6 +403,8 @@
 
 
 def main():
+    global mpu_align
+    mpu_align = {}
     parse_args()
     searchpath = args.directory
     linker_file = args.output