OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [tools/] [pyelf/] [lmanext.py] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
#! /usr/bin/env python2.6
2
# -*- mode: python; coding: utf-8; -*-
3
#
4
#  Codezero -- Virtualization microkernel for embedded systems.
5
#
6
#  Copyright © 2009  B Labs Ltd
7
#
8
import os, sys
9
from optparse import OptionParser
10
from os.path import join
11
from os import path
12
import elf, sys
13
 
14
def conv_hex(val):
15
    hexval = hex(val)
16
    if hexval[-1:] == 'L':
17
        hexval = hexval[:-1]
18
    return hexval
19
 
20
def next_available_lma(srcfile):
21
    elffile = elf.ElfFile.from_file(srcfile)
22
    paddr_max = 0
23
    p_align = 0
24
    for pheader in elffile.pheaders:
25
        x = pheader.ai
26
        if str(x.p_type) == "LOAD":
27
            paddr = x.p_paddr + x.p_memsz
28
            p_align = x.p_align
29
            if paddr > paddr_max:
30
                paddr_max = paddr
31
    paddr_aligned = paddr_max & ~(p_align.value - 1)
32
    #print "paddr_max %s " % hex(paddr_max)
33
    #print "paddr_aligned %s " % hex(paddr_aligned)
34
    if paddr_max & (p_align.value - 1):
35
        paddr_aligned += p_align.value
36
    return conv_hex(paddr_aligned)
37
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.