+# Layout the 32bit segmented code. This places the code as high as possible.
+def doLayout32seg(sections, outname, endat):
+ # Find sections to output
+ textsections = getSectionsPrefix(sections, '.text.')
+ rodatasections = (getSectionsPrefix(sections, '.rodata.str1.1')
+ + getSectionsPrefix(sections, '.rodata.__func__.'))
+ datasections = getSectionsPrefix(sections, '.data32seg.')
+ startat = getSectionsStart(
+ textsections + rodatasections + datasections, endat)
+
+ # Write sections
+ output = open(outname, 'wb')
+ output.write(COMMONHEADER + """
+ code32seg_start = 0x%x ;
+ .text32seg code32seg_start : {
+ freespace_end = . ;
+""" % startat)
+
+ outSections(output, textsections)
+ output.write("code32seg_rodata = . ;\n")
+ outSections(output, rodatasections)
+ outSections(output, datasections)
+
+ output.write("""
+ code32seg_end = ABSOLUTE(.) ;
+ }
+ /DISCARD/ : { *(.text*) *(.rodata*) *(.data*) *(.bss*) *(COMMON) }
+""" + COMMONTRAILER)
+ return startat
+
+# Layout the 32bit flat code. This places the code as high as possible.
+def doLayout32flat(sections, outname, endat):
+ endat += 0xf0000