From fb1de576cb14107d4421ae902d154c6caa3a9f82 Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Mon, 28 Sep 2009 14:04:19 +0300 Subject: [PATCH] Fixed hexadecimal conversions where output has the most significant bit as 1 If hex converted had a 1 in the MSB, an L was appended to the number. The conversion routine removes this. --- config/lib.py | 9 +++++++++ scripts/bare/bare_generator.py | 11 ++++++----- scripts/loader/generate_loader_asm.py | 1 + 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 config/lib.py diff --git a/config/lib.py b/config/lib.py new file mode 100644 index 0000000..6fbda20 --- /dev/null +++ b/config/lib.py @@ -0,0 +1,9 @@ +#! /usr/bin/env python2.6 +# -*- mode: python; coding: utf-8; -*- +# + +def conv_hex(val): + hexval = hex(val) + if hexval[-1:] == 'L': + hexval = hexval[:-1] + return hexval diff --git a/scripts/bare/bare_generator.py b/scripts/bare/bare_generator.py index df4112e..5a848e8 100755 --- a/scripts/bare/bare_generator.py +++ b/scripts/bare/bare_generator.py @@ -17,6 +17,7 @@ SCRIPTROOT = os.path.abspath(os.path.dirname(__file__)) from config.projpaths import * from config.configuration import * +from config.lib import * class BareContGenerator: def __init__(self): @@ -68,11 +69,11 @@ class BareContGenerator: fout.write(name_header) fout.write('\t' + cont.name + '\n') fout.write(pager_lma_header) - fout.write('\t' + hex(cont.pager_lma) + '\n') + fout.write('\t' + conv_hex(cont.pager_lma) + '\n') fout.write(pager_size_header) - fout.write('\t' + hex(cont.pager_size) + '\n') + fout.write('\t' + conv_hex(cont.pager_size) + '\n') fout.write(pager_vma_header) - fout.write('\t' + hex(cont.pager_vma) + '\n') + fout.write('\t' + conv_hex(cont.pager_vma) + '\n') for ireg in range(cont.virt_regions): fout.write(pager_virtmem_header % ireg) fout.write('\t' + cont.virtmem["START"][ireg] + ' - ' + cont.virtmem["END"][ireg] + '\n') @@ -133,8 +134,8 @@ class BareContGenerator: with open(self.linker_lds_in) as fin: str = fin.read() with open(self.linker_lds_out, 'w+') as fout: - fout.write(str % (hex(cont.pager_vma), \ - hex(cont.pager_lma))) + fout.write(str % (conv_hex(cont.pager_vma), \ + conv_hex(cont.pager_lma))) def bare_container_generate(self, config): self.check_create_bare_sources(config) diff --git a/scripts/loader/generate_loader_asm.py b/scripts/loader/generate_loader_asm.py index 3f57bbe..4d6b389 100755 --- a/scripts/loader/generate_loader_asm.py +++ b/scripts/loader/generate_loader_asm.py @@ -14,6 +14,7 @@ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), PROJRELR from config.projpaths import * from config.configuration import * +from config.lib import * # Convert address from python literal to numeric value def address_remove_literal(address):