From: Kevin O'Connor Date: Sat, 23 May 2009 21:49:44 +0000 (-0400) Subject: Pack 16bit code into last part of f-segment. X-Git-Tag: rel-0.4.1~53 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=b1a0d3a2ee7dce27066b742444634bdf7ecbef7a;p=seabios.git Pack 16bit code into last part of f-segment. Locate 16bit code into the top of the f-segment. (Before some of the 16bit code was located just after the 32bit code.) --- diff --git a/src/rombios16.lds.S b/src/rombios16.lds.S index a25392c..4793f56 100644 --- a/src/rombios16.lds.S +++ b/src/rombios16.lds.S @@ -10,16 +10,11 @@ OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") OUTPUT_ARCH("i386") SECTIONS { - .text16 ALIGN(_code32_code32_end - _code32_code32_start, 16) : { - code16_start = ABSOLUTE(.) ; // The actual placement of the 16bit sections is determined by the // script tools/layoutrom.py #include "../out/romlayout.lds" - code16_end = ABSOLUTE(.) ; - } - // Discard regular data sections to force a link error if // 16bit code attempts to access data not marked with VAR16. /DISCARD/ : { *(.text*) *(.rodata*) *(.data*) *(.bss*) *(COMMON) } diff --git a/src/rombios32.lds.S b/src/rombios32.lds.S index 311da25..908201c 100644 --- a/src/rombios32.lds.S +++ b/src/rombios32.lds.S @@ -19,6 +19,7 @@ SECTIONS *(.data) *(.bss) *(COMMON) + freespace_start = . ; code32_end = ABSOLUTE(.) ; } } diff --git a/tools/checkrom.py b/tools/checkrom.py index d03c794..7dc5afc 100755 --- a/tools/checkrom.py +++ b/tools/checkrom.py @@ -24,8 +24,8 @@ def main(): c16e, f16e) sys.exit(1) - sizefree = syms['freespace1_end'] - syms['freespace1_start'] - size16 = syms['code16_end'] - syms['code16_start'] - sizefree + sizefree = syms['freespace_end'] - syms['freespace_start'] + size16 = syms['code16_end'] - syms['code16_start'] size32 = syms['code32_end'] - syms['code32_start'] totalc = size16+size32 print "16bit size: %d" % size16 diff --git a/tools/layoutrom.py b/tools/layoutrom.py index bdafec0..319111b 100755 --- a/tools/layoutrom.py +++ b/tools/layoutrom.py @@ -31,6 +31,9 @@ def alignpos(pos, alignbytes): MAXPOS = 0x10000 +def outsection(file, name): + file.write("*(%s)\n" % (name,)) + def doLayout(sections, outname): textsections = [] rodatasections = [] @@ -113,39 +116,57 @@ def doLayout(sections, outname): # print " Adding %s (size %d align %d) pos=%x avail=%d" % ( # fitsection[2], fitsection[0], fitsection[1] # , fitnextaddr, nextfixedaddr - fitnextaddr) - firstfixed = fixedsections[0][0] + + # Find overall start position + restalign = 0 + restspace = 0 + restsections = [] + for section in textsections + rodatasections + datasections: + size, align, name = section + if align > restalign: + restalign = align + restspace = alignpos(restspace, align) + size + restsections.append(section) + startrest = (firstfixed - restspace) / restalign * restalign + + # Report stats total = MAXPOS-firstfixed - print "Fixed space: 0x%x-0x%x total: %d used: %d Percent used: %.1f%%" % ( - firstfixed, MAXPOS, total, totalused, - (float(totalused) / total) * 100.0) + slack = total - totalused + print ("Fixed space: 0x%x-0x%x total: %d slack: %d" + " Percent slack: %.1f%%" % ( + firstfixed, MAXPOS, total, slack, + (float(slack) / total) * 100.0)) - # Write regular sections + # Write header output = open(outname, 'wb') - for section in textsections: - name = section[2] - output.write("*(%s)\n" % (name,)) - output.write("code16_rodata = . ;\n") - for section in rodatasections: - name = section[2] - output.write("*(%s)\n" % (name,)) - for section in datasections: + output.write(""" + .text16 0x%x : { + code16_start = ABSOLUTE(.) ; + freespace_end = . ; +""" % startrest) + + # Write regular sections + for section in restsections: name = section[2] - output.write("*(%s)\n" % (name,)) + if name == rodatasections[0][2]: + output.write("code16_rodata = . ;\n") + outsection(output, name) # Write fixed sections - output.write("freespace1_start = . ;\n") - first = 1 for addr, section, extrasections in fixedsections: name = section[2] output.write(". = ( 0x%x - code16_start ) ;\n" % (addr,)) - if first: - first = 0 - output.write("freespace1_end = . ;\n") output.write("*(%s)\n" % (name,)) for extrasection in extrasections: - name = extrasection[2] - output.write("*(%s)\n" % (name,)) + outsection(output, extrasection[2]) + + # Write trailer + output.write(""" + code16_end = ABSOLUTE(.) ; + } +""") + if __name__ == '__main__': main()