From c0f5de14ac600965cc3e5cd33f98156894980b1e Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Wed, 18 Aug 2021 13:07:26 +0200 Subject: [PATCH] fixed packaging script - added more sections to the included sections list - fixed imports - better output - fixed argument usage --- package.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/package.py b/package.py index db75d43..4fdfa2d 100644 --- a/package.py +++ b/package.py @@ -1,5 +1,4 @@ #!/usr/bin/env python3 -from enum import Enum from dataclasses import dataclass from elftools.elf.elffile import ELFFile from elftools.elf.sections import Section, SymbolTableSection @@ -8,7 +7,7 @@ from typing import List, Tuple, Dict, Generator, Union import os, sys # A set of sections that we want to include in the image -INCLUDE_THESE_SECTIONS = set(('.text', '.stack', '.bss', '.sdata', '.sbss', '.data')) +INCLUDE_THESE_SECTIONS = set(('.text', '.stack', '.bss', '.sdata', '.sbss', '.data', '.stack')) # sector size of the img file in bytes @@ -94,7 +93,7 @@ class MemImageCreator: raise Exception("seeking already passed position!") if len(self.data) == pos: return - print(f" - zeros {len(self.data):x}:{pos:x}") + print(f" - zeros {pos-len(self.data):8x} {len(self.data):x}:{pos:x}") self.put(bytes(pos - len(self.data))) assert len(self.data) == pos @@ -190,4 +189,4 @@ if __name__ == '__main__': if '--help' in sys.argv or len(sys.argv) == 1: print_help() else: - package(sys.argv[1], sys.argv[2:], 'memory.img') + package(sys.argv[1], sys.argv[2:-1], sys.argv[-1])