diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-01-17 19:35:10 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-01-17 19:35:10 -0500 |
commit | db802adcfbfc22df158d498777b5150fa018a1c2 (patch) | |
tree | d9c62555d31f7a935388cd10b15596157b41a5cd /tools | |
parent | 308537650feeabcd953283e828cf7f51495c11c5 (diff) |
Have layoutrom.py show info on utilization of fixed area.
Also, try harder to fit sections with alignment greater than 1.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/layoutrom.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/tools/layoutrom.py b/tools/layoutrom.py index 592893b..7848957 100755 --- a/tools/layoutrom.py +++ b/tools/layoutrom.py @@ -29,6 +29,8 @@ def alignpos(pos, alignbytes): mask = alignbytes - 1 return (pos + mask) & ~mask +MAXPOS = 0x10000 + def doLayout(sections, outname): textsections = [] rodatasections = [] @@ -66,7 +68,7 @@ def doLayout(sections, outname): fixedsectioninfo = fixedsections[i] addr, section, extrasectionslist = fixedsectioninfo if i == len(fixedsections) - 1: - nextaddr = 0x10000 + nextaddr = MAXPOS else: nextaddr = fixedsections[i+1][0] avail = nextaddr - addr - section[0] @@ -75,6 +77,7 @@ def doLayout(sections, outname): # Attempt to fit other sections into fixed area fixedAddr.sort() canrelocate.sort() + unused = 0 for freespace, fixedsectioninfo in fixedAddr: fixedaddr, fixedsection, extrasections = fixedsectioninfo addpos = fixedaddr + fixedsection[0] @@ -85,14 +88,19 @@ def doLayout(sections, outname): canfit = None for fixedaddrinfo in canrelocate: fitsection, inlist = fixedaddrinfo - fitnextaddr = alignpos(addpos, fitsection[1]) + fitsection[0] + fitsize, fitalign, fitname = fitsection + if addpos + fitsize > nextfixedaddr: + # Can't fit and nothing else will fit. + break + fitnextaddr = alignpos(addpos, fitalign) + fitsize # print "Test %s - %x vs %x" % ( -# fitsection[2], fitnextaddr, nextfixedaddr) +# fitname, fitnextaddr, nextfixedaddr) if fitnextaddr > nextfixedaddr: - # Can't fit. - break + # This item can't fit. + continue canfit = (fitnextaddr, fixedaddrinfo) if canfit is None: + unused += nextfixedaddr - addpos break # Found a section that can fit. fitnextaddr, fixedaddrinfo = canfit @@ -101,9 +109,17 @@ def doLayout(sections, outname): inlist.remove(fitsection) extrasections.append(fitsection) addpos = fitnextaddr + unused += alignpos(addpos, fitsection[1]) - addpos # print " Adding %s (size %d align %d)" % ( # fitsection[2], fitsection[0], fitsection[1]) + firstfixed = fixedsections[0][0] + total = MAXPOS-firstfixed + totalused = total - unused + print "Fixed space: 0x%x-0x%x total: %d used: %d Percent used: %.1f%%" % ( + firstfixed, MAXPOS, total, totalused, + (float(totalused) / total) * 100.0) + # Write regular sections output = open(outname, 'wb') for section in textsections: |