Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Ioannis Glaropoulos | 560357b | 2018-11-23 09:39:53 +0100 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2018 Intel Corporation |
| 4 | # |
| 5 | # SPDX-License-Identifier: Apache-2.0 |
| 6 | |
Andrew Boie | c78c5e6 | 2019-03-11 14:45:43 -0700 | [diff] [blame] | 7 | """ |
| 8 | Script to generate a linker script organizing application memory partitions |
| 9 | |
| 10 | Applications may declare build-time memory domain partitions with |
| 11 | K_APPMEM_PARTITION_DEFINE, and assign globals to them using K_APP_DMEM |
| 12 | or K_APP_BMEM macros. For each of these partitions, we need to |
| 13 | route all their data into appropriately-sized memory areas which meet the |
| 14 | size/alignment constraints of the memory protection hardware. |
| 15 | |
| 16 | This linker script is created very early in the build process, before |
| 17 | the build attempts to link the kernel binary, as the linker script this |
| 18 | tool generates is a necessary pre-condition for kernel linking. We extract |
| 19 | the set of memory partitions to generate by looking for variables which |
| 20 | have been assigned to input sections that follow a defined naming convention. |
| 21 | We also allow entire libraries to be pulled in to assign their globals |
| 22 | to a particular memory partition via command line directives. |
| 23 | |
| 24 | This script takes as inputs: |
| 25 | |
| 26 | - The base directory to look for compiled objects |
| 27 | - key/value pairs mapping static library files to what partitions their globals |
| 28 | should end up in. |
| 29 | |
| 30 | The output is a linker script fragment containing the definition of the |
| 31 | app shared memory section, which is further divided, for each partition |
| 32 | found, into data and BSS for each partition. |
| 33 | """ |
| 34 | |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 35 | import sys |
| 36 | import argparse |
Torsten Rasmussen | f643b8b | 2021-11-24 15:35:47 +0100 | [diff] [blame^] | 37 | import json |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 38 | import os |
| 39 | import re |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 40 | from collections import OrderedDict |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 41 | from elftools.elf.elffile import ELFFile |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 42 | from elftools.elf.sections import SymbolTableSection |
Anas Nashif | 2c5a37c | 2021-11-22 16:09:31 -0500 | [diff] [blame] | 43 | import elftools.common.exceptions |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 44 | |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 45 | SZ = 'size' |
| 46 | SRC = 'sources' |
| 47 | LIB = 'libraries' |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 48 | |
Andrew Boie | 7adff46 | 2019-01-30 13:44:54 -0800 | [diff] [blame] | 49 | # This script will create sections and linker variables to place the |
| 50 | # application shared memory partitions. |
| 51 | # these are later read by the macros defined in app_memdomain.h for |
Andrew Boie | 4ce652e | 2019-02-22 16:08:44 -0800 | [diff] [blame] | 52 | # initialization purpose when USERSPACE is enabled. |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 53 | data_template = """ |
Adithya Baglody | ae92f2b | 2018-09-19 11:20:09 +0530 | [diff] [blame] | 54 | /* Auto generated code do not modify */ |
Andrew Boie | f084c38 | 2019-03-04 17:57:06 -0800 | [diff] [blame] | 55 | SMEM_PARTITION_ALIGN(z_data_smem_{0}_bss_end - z_data_smem_{0}_part_start); |
| 56 | z_data_smem_{0}_part_start = .; |
Eugeniy Paltsev | 0a7b65e | 2020-09-02 16:52:09 +0300 | [diff] [blame] | 57 | KEEP(*(data_smem_{0}_data*)) |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 58 | """ |
| 59 | |
| 60 | library_data_template = """ |
Jim Shu | 46eb3e5 | 2021-09-28 10:03:21 +0800 | [diff] [blame] | 61 | *{0}:*(.data .data.* .sdata .sdata.*) |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 62 | """ |
| 63 | |
| 64 | bss_template = """ |
Andrew Boie | f084c38 | 2019-03-04 17:57:06 -0800 | [diff] [blame] | 65 | z_data_smem_{0}_bss_start = .; |
Eugeniy Paltsev | 0a7b65e | 2020-09-02 16:52:09 +0300 | [diff] [blame] | 66 | KEEP(*(data_smem_{0}_bss*)) |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 67 | """ |
| 68 | |
| 69 | library_bss_template = """ |
Jim Shu | 46eb3e5 | 2021-09-28 10:03:21 +0800 | [diff] [blame] | 70 | *{0}:*(.bss .bss.* .sbss .sbss.* COMMON COMMON.*) |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 71 | """ |
| 72 | |
| 73 | footer_template = """ |
Andrew Boie | f084c38 | 2019-03-04 17:57:06 -0800 | [diff] [blame] | 74 | z_data_smem_{0}_bss_end = .; |
| 75 | SMEM_PARTITION_ALIGN(z_data_smem_{0}_bss_end - z_data_smem_{0}_part_start); |
| 76 | z_data_smem_{0}_part_end = .; |
Adithya Baglody | ae92f2b | 2018-09-19 11:20:09 +0530 | [diff] [blame] | 77 | """ |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 78 | |
Adithya Baglody | ae92f2b | 2018-09-19 11:20:09 +0530 | [diff] [blame] | 79 | linker_start_seq = """ |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 80 | SECTION_PROLOGUE(_APP_SMEM{1}_SECTION_NAME,,) |
| 81 | {{ |
Adithya Baglody | 10c6a0c | 2018-09-21 10:17:58 +0530 | [diff] [blame] | 82 | APP_SHARED_ALIGN; |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 83 | _app_smem{0}_start = .; |
Adithya Baglody | ae92f2b | 2018-09-19 11:20:09 +0530 | [diff] [blame] | 84 | """ |
| 85 | |
| 86 | linker_end_seq = """ |
Adithya Baglody | 10c6a0c | 2018-09-21 10:17:58 +0530 | [diff] [blame] | 87 | APP_SHARED_ALIGN; |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 88 | _app_smem{0}_end = .; |
| 89 | }} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) |
| 90 | """ |
| 91 | |
| 92 | empty_app_smem = """ |
| 93 | SECTION_PROLOGUE(_APP_SMEM{1}_SECTION_NAME,,) |
| 94 | {{ |
Jaxson Han | f079e66 | 2021-08-31 14:14:03 +0800 | [diff] [blame] | 95 | #ifdef EMPTY_APP_SHARED_ALIGN |
| 96 | EMPTY_APP_SHARED_ALIGN; |
| 97 | #endif |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 98 | _app_smem{0}_start = .; |
| 99 | _app_smem{0}_end = .; |
| 100 | }} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) |
Adithya Baglody | ae92f2b | 2018-09-19 11:20:09 +0530 | [diff] [blame] | 101 | """ |
| 102 | |
| 103 | size_cal_string = """ |
Andrew Boie | f084c38 | 2019-03-04 17:57:06 -0800 | [diff] [blame] | 104 | z_data_smem_{0}_part_size = z_data_smem_{0}_part_end - z_data_smem_{0}_part_start; |
| 105 | z_data_smem_{0}_bss_size = z_data_smem_{0}_bss_end - z_data_smem_{0}_bss_start; |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 106 | """ |
| 107 | |
Eugeniy Paltsev | 0a7b65e | 2020-09-02 16:52:09 +0300 | [diff] [blame] | 108 | section_regex = re.compile(r'data_smem_([A-Za-z0-9_]*)_(data|bss)*') |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 109 | |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 110 | elf_part_size_regex = re.compile(r'z_data_smem_(.*)_part_size') |
| 111 | |
| 112 | def find_obj_file_partitions(filename, partitions): |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 113 | with open(filename, 'rb') as f: |
Anas Nashif | 2c5a37c | 2021-11-22 16:09:31 -0500 | [diff] [blame] | 114 | try: |
| 115 | full_lib = ELFFile(f) |
| 116 | except elftools.common.exceptions.ELFError as e: |
| 117 | exit(f"Error: {filename}: {e}") |
| 118 | |
Ulf Magnusson | ba312fe | 2019-03-20 19:30:29 +0100 | [diff] [blame] | 119 | if not full_lib: |
Ulf Magnusson | e9c1d6d | 2019-03-20 22:40:22 +0100 | [diff] [blame] | 120 | sys.exit("Error parsing file: " + filename) |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 121 | |
Andrew Boie | 7adff46 | 2019-01-30 13:44:54 -0800 | [diff] [blame] | 122 | sections = [x for x in full_lib.iter_sections()] |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 123 | for section in sections: |
Andrew Boie | 7adff46 | 2019-01-30 13:44:54 -0800 | [diff] [blame] | 124 | m = section_regex.match(section.name) |
| 125 | if not m: |
| 126 | continue |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 127 | |
Andrew Boie | 7adff46 | 2019-01-30 13:44:54 -0800 | [diff] [blame] | 128 | partition_name = m.groups()[0] |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 129 | if partition_name not in partitions: |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 130 | partitions[partition_name] = {SZ: section.header.sh_size} |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 131 | |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 132 | if args.verbose: |
| 133 | partitions[partition_name][SRC] = filename |
| 134 | |
| 135 | else: |
| 136 | partitions[partition_name][SZ] += section.header.sh_size |
| 137 | |
| 138 | |
| 139 | return partitions |
| 140 | |
| 141 | |
| 142 | def parse_obj_files(partitions): |
| 143 | # Iterate over all object files to find partitions |
Ulf Magnusson | 12ba9df | 2019-03-19 19:28:24 +0100 | [diff] [blame] | 144 | for dirpath, _, files in os.walk(args.directory): |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 145 | for filename in files: |
Ulf Magnusson | 0d39a10 | 2019-09-06 11:13:19 +0200 | [diff] [blame] | 146 | if re.match(r".*\.obj$", filename): |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 147 | fullname = os.path.join(dirpath, filename) |
Anas Nashif | 2c5a37c | 2021-11-22 16:09:31 -0500 | [diff] [blame] | 148 | fsize = os.path.getsize(fullname) |
| 149 | if fsize != 0: |
| 150 | find_obj_file_partitions(fullname, partitions) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 151 | |
| 152 | |
Torsten Rasmussen | f643b8b | 2021-11-24 15:35:47 +0100 | [diff] [blame^] | 153 | def parse_compile_command_file(partitions): |
| 154 | # Iterate over all entries to find object files. |
| 155 | # Thereafter process each object file to find partitions |
| 156 | object_pattern = re.compile(r'-o\s+(\S*)') |
| 157 | with open(args.compile_commands_file, 'rb') as f: |
| 158 | commands = json.load(f) |
| 159 | for command in commands: |
| 160 | build_dir = command.get('directory') |
| 161 | compile_command = command.get('command') |
| 162 | compile_arg = object_pattern.search(compile_command) |
| 163 | obj_file = None if compile_arg is None else compile_arg.group(1) |
| 164 | if obj_file: |
| 165 | fullname = os.path.join(build_dir, obj_file) |
| 166 | # Because of issue #40635, then not all objects referenced by |
| 167 | # the compile_commands.json file may be available, therefore |
| 168 | # only include existing files. |
| 169 | if os.path.exists(fullname): |
| 170 | find_obj_file_partitions(fullname, partitions) |
| 171 | |
| 172 | |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 173 | def parse_elf_file(partitions): |
| 174 | with open(args.elf, 'rb') as f: |
Anas Nashif | 2c5a37c | 2021-11-22 16:09:31 -0500 | [diff] [blame] | 175 | try: |
| 176 | elffile = ELFFile(f) |
| 177 | except elftools.common.exceptions.ELFError as e: |
| 178 | exit(f"Error: {args.elf}: {e}") |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 179 | |
| 180 | symbol_tbls = [s for s in elffile.iter_sections() |
| 181 | if isinstance(s, SymbolTableSection)] |
| 182 | |
| 183 | for section in symbol_tbls: |
Ulf Magnusson | 12ba9df | 2019-03-19 19:28:24 +0100 | [diff] [blame] | 184 | for symbol in section.iter_symbols(): |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 185 | if symbol['st_shndx'] != "SHN_ABS": |
| 186 | continue |
| 187 | |
| 188 | x = elf_part_size_regex.match(symbol.name) |
| 189 | if not x: |
| 190 | continue |
| 191 | |
| 192 | partition_name = x.groups()[0] |
| 193 | size = symbol['st_value'] |
| 194 | if partition_name not in partitions: |
| 195 | partitions[partition_name] = {SZ: size} |
| 196 | |
| 197 | if args.verbose: |
| 198 | partitions[partition_name][SRC] = args.elf |
| 199 | |
| 200 | else: |
| 201 | partitions[partition_name][SZ] += size |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 202 | |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 203 | |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 204 | def generate_final_linker(linker_file, partitions, lnkr_sect=""): |
| 205 | string = "" |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 206 | |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 207 | if len(partitions) > 0: |
| 208 | string = linker_start_seq.format(lnkr_sect, lnkr_sect.upper()) |
| 209 | size_string = '' |
| 210 | for partition, item in partitions.items(): |
| 211 | string += data_template.format(partition) |
| 212 | if LIB in item: |
| 213 | for lib in item[LIB]: |
| 214 | string += library_data_template.format(lib) |
| 215 | string += bss_template.format(partition, lnkr_sect) |
| 216 | if LIB in item: |
| 217 | for lib in item[LIB]: |
| 218 | string += library_bss_template.format(lib) |
| 219 | string += footer_template.format(partition) |
| 220 | size_string += size_cal_string.format(partition) |
| 221 | |
| 222 | string += linker_end_seq.format(lnkr_sect) |
| 223 | string += size_string |
| 224 | else: |
| 225 | string = empty_app_smem.format(lnkr_sect, lnkr_sect.upper()) |
| 226 | |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 227 | with open(linker_file, "w") as fw: |
| 228 | fw.write(string) |
| 229 | |
| 230 | |
| 231 | def parse_args(): |
| 232 | global args |
| 233 | parser = argparse.ArgumentParser( |
| 234 | description=__doc__, |
| 235 | formatter_class=argparse.RawDescriptionHelpFormatter) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 236 | parser.add_argument("-d", "--directory", required=False, default=None, |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 237 | help="Root build directory") |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 238 | parser.add_argument("-e", "--elf", required=False, default=None, |
| 239 | help="ELF file") |
Torsten Rasmussen | f643b8b | 2021-11-24 15:35:47 +0100 | [diff] [blame^] | 240 | parser.add_argument("-f", "--compile-commands-file", required=False, |
| 241 | default=None, help="CMake compile commands file") |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 242 | parser.add_argument("-o", "--output", required=False, |
| 243 | help="Output ld file") |
Ulf Magnusson | 0d39a10 | 2019-09-06 11:13:19 +0200 | [diff] [blame] | 244 | parser.add_argument("-v", "--verbose", action="count", default=0, |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 245 | help="Verbose Output") |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 246 | parser.add_argument("-l", "--library", nargs=2, action="append", default=[], |
| 247 | metavar=("LIBRARY", "PARTITION"), |
| 248 | help="Include globals for a particular library or object filename into a designated partition") |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 249 | parser.add_argument("--pinoutput", required=False, |
| 250 | help="Output ld file for pinned sections") |
| 251 | parser.add_argument("--pinpartitions", action="store", required=False, default="", |
| 252 | help="Comma separated names of partitions to be pinned in physical memory") |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 253 | |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 254 | args = parser.parse_args() |
| 255 | |
| 256 | |
| 257 | def main(): |
| 258 | parse_args() |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 259 | partitions = {} |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 260 | |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 261 | if args.directory is not None: |
| 262 | parse_obj_files(partitions) |
Torsten Rasmussen | f643b8b | 2021-11-24 15:35:47 +0100 | [diff] [blame^] | 263 | if args.compile_commands_file is not None: |
| 264 | parse_compile_command_file(partitions) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 265 | elif args.elf is not None: |
| 266 | parse_elf_file(partitions) |
| 267 | else: |
| 268 | return |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 269 | |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 270 | for lib, ptn in args.library: |
| 271 | if ptn not in partitions: |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 272 | partitions[ptn] = {} |
Andrew Boie | 686bd91 | 2019-02-01 11:52:20 -0800 | [diff] [blame] | 273 | |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 274 | if LIB not in partitions[ptn]: |
| 275 | partitions[ptn][LIB] = [lib] |
| 276 | else: |
| 277 | partitions[ptn][LIB].append(lib) |
| 278 | |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 279 | if args.pinoutput: |
| 280 | pin_part_names = args.pinpartitions.split(',') |
| 281 | |
| 282 | generic_partitions = {key: value for key, value in partitions.items() |
| 283 | if key not in pin_part_names} |
| 284 | pinned_partitions = {key: value for key, value in partitions.items() |
| 285 | if key in pin_part_names} |
| 286 | else: |
| 287 | generic_partitions = partitions |
Marc Herbert | eefea9d | 2019-06-27 16:09:26 -0700 | [diff] [blame] | 288 | |
| 289 | # Sample partitions.items() list before sorting: |
| 290 | # [ ('part1', {'size': 64}), ('part3', {'size': 64}, ... |
| 291 | # ('part0', {'size': 334}) ] |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 292 | decreasing_tuples = sorted(generic_partitions.items(), |
Marc Herbert | eefea9d | 2019-06-27 16:09:26 -0700 | [diff] [blame] | 293 | key=lambda x: (x[1][SZ], x[0]), reverse=True) |
| 294 | |
| 295 | partsorted = OrderedDict(decreasing_tuples) |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 296 | |
| 297 | generate_final_linker(args.output, partsorted) |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 298 | if args.verbose: |
Andrew Boie | 7adff46 | 2019-01-30 13:44:54 -0800 | [diff] [blame] | 299 | print("Partitions retrieved:") |
Daniel Leung | 212ec9a | 2019-03-10 14:20:21 -0700 | [diff] [blame] | 300 | for key in partsorted: |
| 301 | print(" {0}: size {1}: {2}".format(key, |
| 302 | partsorted[key][SZ], |
| 303 | partsorted[key][SRC])) |
| 304 | |
Daniel Leung | 2117a2a | 2021-07-12 13:33:32 -0700 | [diff] [blame] | 305 | if args.pinoutput: |
| 306 | decreasing_tuples = sorted(pinned_partitions.items(), |
| 307 | key=lambda x: (x[1][SZ], x[0]), reverse=True) |
| 308 | |
| 309 | partsorted = OrderedDict(decreasing_tuples) |
| 310 | |
| 311 | generate_final_linker(args.pinoutput, partsorted, lnkr_sect="_pinned") |
| 312 | if args.verbose: |
| 313 | print("Pinned partitions retrieved:") |
| 314 | for key in partsorted: |
| 315 | print(" {0}: size {1}: {2}".format(key, |
| 316 | partsorted[key][SZ], |
| 317 | partsorted[key][SRC])) |
| 318 | |
Adithya Baglody | c69fb0d | 2018-08-04 19:48:52 +0530 | [diff] [blame] | 319 | |
| 320 | if __name__ == '__main__': |
| 321 | main() |