blob: 7c96cd3bf932fa251a85b1e48534cde4c535a069 [file] [log] [blame]
Kevin O'Connor202024a2009-01-17 10:41:28 -05001#!/usr/bin/env python
Kevin O'Connor5b8f8092009-09-20 19:47:45 -04002# Script to analyze code and arrange ld sections.
Kevin O'Connor202024a2009-01-17 10:41:28 -05003#
Kevin O'Connor1a4885e2010-09-15 21:28:31 -04004# Copyright (C) 2008-2010 Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connor202024a2009-01-17 10:41:28 -05005#
6# This file may be distributed under the terms of the GNU GPLv3 license.
7
Johannes Krampf0a82fc72014-01-12 11:39:57 -05008import operator
Kevin O'Connor202024a2009-01-17 10:41:28 -05009import sys
10
Kevin O'Connor5b8f8092009-09-20 19:47:45 -040011# LD script headers/trailers
12COMMONHEADER = """
13/* DO NOT EDIT! This is an autogenerated file. See tools/layoutrom.py. */
14OUTPUT_FORMAT("elf32-i386")
15OUTPUT_ARCH("i386")
16SECTIONS
17{
18"""
19COMMONTRAILER = """
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040020
21 /* Discard regular data sections to force a link error if
22 * code attempts to access data not marked with VAR16 (or other
23 * appropriate macro)
24 */
25 /DISCARD/ : {
26 *(.text*) *(.data*) *(.bss*) *(.rodata*)
Kevin O'Connor90ebed42012-06-21 20:54:53 -040027 *(COMMON) *(.discard*) *(.eh_frame) *(.note*)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040028 }
Kevin O'Connor5b8f8092009-09-20 19:47:45 -040029}
30"""
31
Kevin O'Connorc0693942009-06-10 21:56:01 -040032
33######################################################################
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040034# Determine section locations
Kevin O'Connorc0693942009-06-10 21:56:01 -040035######################################################################
36
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040037# Align 'pos' to 'alignbytes' offset
38def alignpos(pos, alignbytes):
39 mask = alignbytes - 1
40 return (pos + mask) & ~mask
41
42# Determine the final addresses for a list of sections that end at an
Kevin O'Connor5b8f8092009-09-20 19:47:45 -040043# address.
Kevin O'Connor46b82622012-05-13 12:10:30 -040044def setSectionsStart(sections, endaddr, minalign=1, segoffset=0):
Kevin O'Connor5b8f8092009-09-20 19:47:45 -040045 totspace = 0
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040046 for section in sections:
47 if section.align > minalign:
48 minalign = section.align
49 totspace = alignpos(totspace, section.align) + section.size
Johannes Krampf9d7d0442014-01-12 11:19:22 -050050 startaddr = int((endaddr - totspace) / minalign) * minalign
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040051 curaddr = startaddr
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040052 for section in sections:
53 curaddr = alignpos(curaddr, section.align)
54 section.finalloc = curaddr
Kevin O'Connor46b82622012-05-13 12:10:30 -040055 section.finalsegloc = curaddr - segoffset
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040056 curaddr += section.size
Kevin O'Connor46b82622012-05-13 12:10:30 -040057 return startaddr, minalign
Kevin O'Connorc0693942009-06-10 21:56:01 -040058
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040059# The 16bit code can't exceed 64K of space.
60BUILD_BIOS_ADDR = 0xf0000
61BUILD_BIOS_SIZE = 0x10000
Kevin O'Connor46b82622012-05-13 12:10:30 -040062BUILD_ROM_START = 0xc0000
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -040063BUILD_LOWRAM_END = 0xa0000
Kevin O'Connor6d152642013-02-19 21:35:20 -050064# Space to reserve in f-segment for dynamic allocations
65BUILD_MIN_BIOSTABLE = 2048
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040066
67# Layout the 16bit code. This ensures sections with fixed offset
68# requirements are placed in the correct location. It also places the
69# 16bit code as high as possible in the f-segment.
70def fitSections(sections, fillsections):
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040071 # fixedsections = [(addr, section), ...]
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040072 fixedsections = []
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040073 for section in sections:
74 if section.name.startswith('.fixedaddr.'):
75 addr = int(section.name[11:], 16)
Kevin O'Connor46b82622012-05-13 12:10:30 -040076 section.finalloc = addr + BUILD_BIOS_ADDR
77 section.finalsegloc = addr
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040078 fixedsections.append((addr, section))
79 if section.align != 1:
Johannes Krampf064fd062014-01-12 11:14:54 -050080 print("Error: Fixed section %s has non-zero alignment (%d)" % (
81 section.name, section.align))
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040082 sys.exit(1)
Johannes Krampf0a82fc72014-01-12 11:39:57 -050083 fixedsections.sort(key=operator.itemgetter(0))
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040084 firstfixed = fixedsections[0][0]
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040085
86 # Find freespace in fixed address area
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040087 # fixedAddr = [(freespace, section), ...]
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040088 fixedAddr = []
89 for i in range(len(fixedsections)):
90 fixedsectioninfo = fixedsections[i]
91 addr, section = fixedsectioninfo
92 if i == len(fixedsections) - 1:
93 nextaddr = BUILD_BIOS_SIZE
94 else:
95 nextaddr = fixedsections[i+1][0]
Kevin O'Connor1a4885e2010-09-15 21:28:31 -040096 avail = nextaddr - addr - section.size
97 fixedAddr.append((avail, section))
Johannes Krampf0a82fc72014-01-12 11:39:57 -050098 fixedAddr.sort(key=operator.itemgetter(0))
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -040099
100 # Attempt to fit other sections into fixed area
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400101 canrelocate = [(section.size, section.align, section.name, section)
102 for section in fillsections]
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400103 canrelocate.sort()
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400104 canrelocate = [section for size, align, name, section in canrelocate]
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400105 totalused = 0
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400106 for freespace, fixedsection in fixedAddr:
Kevin O'Connor46b82622012-05-13 12:10:30 -0400107 addpos = fixedsection.finalsegloc + fixedsection.size
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400108 totalused += fixedsection.size
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400109 nextfixedaddr = addpos + freespace
Johannes Krampf064fd062014-01-12 11:14:54 -0500110# print("Filling section %x uses %d, next=%x, available=%d" % (
111# fixedsection.finalloc, fixedsection.size, nextfixedaddr, freespace))
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400112 while 1:
113 canfit = None
114 for fitsection in canrelocate:
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400115 if addpos + fitsection.size > nextfixedaddr:
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400116 # Can't fit and nothing else will fit.
117 break
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400118 fitnextaddr = alignpos(addpos, fitsection.align) + fitsection.size
Johannes Krampf064fd062014-01-12 11:14:54 -0500119# print("Test %s - %x vs %x" % (
120# fitsection.name, fitnextaddr, nextfixedaddr))
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400121 if fitnextaddr > nextfixedaddr:
122 # This item can't fit.
123 continue
124 canfit = (fitnextaddr, fitsection)
125 if canfit is None:
126 break
127 # Found a section that can fit.
128 fitnextaddr, fitsection = canfit
129 canrelocate.remove(fitsection)
Kevin O'Connor46b82622012-05-13 12:10:30 -0400130 fitsection.finalloc = addpos + BUILD_BIOS_ADDR
131 fitsection.finalsegloc = addpos
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400132 addpos = fitnextaddr
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400133 totalused += fitsection.size
Johannes Krampf064fd062014-01-12 11:14:54 -0500134# print(" Adding %s (size %d align %d) pos=%x avail=%d" % (
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400135# fitsection[2], fitsection[0], fitsection[1]
Johannes Krampf064fd062014-01-12 11:14:54 -0500136# , fitnextaddr, nextfixedaddr - fitnextaddr))
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400137
138 # Report stats
139 total = BUILD_BIOS_SIZE-firstfixed
140 slack = total - totalused
141 print ("Fixed space: 0x%x-0x%x total: %d slack: %d"
142 " Percent slack: %.1f%%" % (
143 firstfixed, BUILD_BIOS_SIZE, total, slack,
144 (float(slack) / total) * 100.0))
145
Kevin O'Connor46b82622012-05-13 12:10:30 -0400146 return firstfixed + BUILD_BIOS_ADDR
147
148# Return the subset of sections with a given category
149def getSectionsCategory(sections, category):
150 return [section for section in sections if section.category == category]
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400151
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400152# Return the subset of sections with a given name prefix
Kevin O'Connor46b82622012-05-13 12:10:30 -0400153def getSectionsPrefix(sections, prefix):
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400154 return [section for section in sections
Kevin O'Connor46b82622012-05-13 12:10:30 -0400155 if section.name.startswith(prefix)]
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400156
Kevin O'Connor46b82622012-05-13 12:10:30 -0400157# The sections (and associated information) to be placed in output rom
158class LayoutInfo:
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500159 genreloc = None
Kevin O'Connor46b82622012-05-13 12:10:30 -0400160 sections16 = sec16_start = sec16_align = None
161 sections32seg = sec32seg_start = sec32seg_align = None
162 sections32flat = sec32flat_start = sec32flat_align = None
163 sections32init = sec32init_start = sec32init_align = None
164 sections32low = sec32low_start = sec32low_align = None
Kevin O'Connor41953492013-02-18 23:09:01 -0500165 sections32fseg = sec32fseg_start = sec32fseg_align = None
Kevin O'Connor6d152642013-02-19 21:35:20 -0500166 zonefseg_start = zonefseg_end = None
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500167 final_readonly_start = None
Kevin O'Connorc9243442013-02-17 13:58:28 -0500168 zonelow_base = final_sec32low_start = None
Kevin O'Connoree952532014-06-09 14:37:23 -0400169 varlowsyms = entrysym = None
Kevin O'Connor46b82622012-05-13 12:10:30 -0400170
171# Determine final memory addresses for sections
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500172def doLayout(sections, config, genreloc):
Kevin O'Connor46b82622012-05-13 12:10:30 -0400173 li = LayoutInfo()
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500174 li.genreloc = genreloc
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400175 # Determine 16bit positions
Kevin O'Connor46b82622012-05-13 12:10:30 -0400176 li.sections16 = getSectionsCategory(sections, '16')
177 textsections = getSectionsPrefix(li.sections16, '.text.')
Kevin O'Connor805ede22012-02-08 20:23:36 -0500178 rodatasections = (
Kevin O'Connor46b82622012-05-13 12:10:30 -0400179 getSectionsPrefix(li.sections16, '.rodata.str1.1')
180 + getSectionsPrefix(li.sections16, '.rodata.__func__.')
181 + getSectionsPrefix(li.sections16, '.rodata.__PRETTY_FUNCTION__.'))
182 datasections = getSectionsPrefix(li.sections16, '.data16.')
183 fixedsections = getSectionsPrefix(li.sections16, '.fixedaddr.')
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400184
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400185 firstfixed = fitSections(fixedsections, textsections)
186 remsections = [s for s in textsections+rodatasections+datasections
187 if s.finalloc is None]
Kevin O'Connor46b82622012-05-13 12:10:30 -0400188 li.sec16_start, li.sec16_align = setSectionsStart(
189 remsections, firstfixed, segoffset=BUILD_BIOS_ADDR)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400190
191 # Determine 32seg positions
Kevin O'Connor46b82622012-05-13 12:10:30 -0400192 li.sections32seg = getSectionsCategory(sections, '32seg')
193 textsections = getSectionsPrefix(li.sections32seg, '.text.')
Kevin O'Connor805ede22012-02-08 20:23:36 -0500194 rodatasections = (
Kevin O'Connor46b82622012-05-13 12:10:30 -0400195 getSectionsPrefix(li.sections32seg, '.rodata.str1.1')
196 + getSectionsPrefix(li.sections32seg, '.rodata.__func__.')
197 + getSectionsPrefix(li.sections32seg, '.rodata.__PRETTY_FUNCTION__.'))
198 datasections = getSectionsPrefix(li.sections32seg, '.data32seg.')
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400199
Kevin O'Connor46b82622012-05-13 12:10:30 -0400200 li.sec32seg_start, li.sec32seg_align = setSectionsStart(
201 textsections + rodatasections + datasections, li.sec16_start
202 , segoffset=BUILD_BIOS_ADDR)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400203
Kevin O'Connor41953492013-02-18 23:09:01 -0500204 # Determine "fseg memory" data positions
205 li.sections32fseg = getSectionsCategory(sections, '32fseg')
206
207 li.sec32fseg_start, li.sec32fseg_align = setSectionsStart(
208 li.sections32fseg, li.sec32seg_start, 16
209 , segoffset=BUILD_BIOS_ADDR)
210
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400211 # Determine 32flat runtime positions
Kevin O'Connor46b82622012-05-13 12:10:30 -0400212 li.sections32flat = getSectionsCategory(sections, '32flat')
213 textsections = getSectionsPrefix(li.sections32flat, '.text.')
214 rodatasections = getSectionsPrefix(li.sections32flat, '.rodata')
215 datasections = getSectionsPrefix(li.sections32flat, '.data.')
216 bsssections = getSectionsPrefix(li.sections32flat, '.bss.')
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400217
Kevin O'Connor46b82622012-05-13 12:10:30 -0400218 li.sec32flat_start, li.sec32flat_align = setSectionsStart(
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400219 textsections + rodatasections + datasections + bsssections
Kevin O'Connor41953492013-02-18 23:09:01 -0500220 , li.sec32fseg_start, 16)
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500221
222 # Determine 32flat init positions
223 li.sections32init = getSectionsCategory(sections, '32init')
224 init32_textsections = getSectionsPrefix(li.sections32init, '.text.')
225 init32_rodatasections = getSectionsPrefix(li.sections32init, '.rodata')
226 init32_datasections = getSectionsPrefix(li.sections32init, '.data.')
227 init32_bsssections = getSectionsPrefix(li.sections32init, '.bss.')
228
229 li.sec32init_start, li.sec32init_align = setSectionsStart(
230 init32_textsections + init32_rodatasections
231 + init32_datasections + init32_bsssections
232 , li.sec32flat_start, 16)
233
234 # Determine location of ZoneFSeg memory.
Kevin O'Connor6d152642013-02-19 21:35:20 -0500235 li.zonefseg_end = li.sec32flat_start
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500236 if not genreloc:
237 li.zonefseg_end = li.sec32init_start
Kevin O'Connor6d152642013-02-19 21:35:20 -0500238 li.zonefseg_start = BUILD_BIOS_ADDR
239 if li.zonefseg_start + BUILD_MIN_BIOSTABLE > li.zonefseg_end:
240 # Not enough ZoneFSeg space - force a minimum space.
241 li.zonefseg_end = li.sec32fseg_start
242 li.zonefseg_start = li.zonefseg_end - BUILD_MIN_BIOSTABLE
243 li.sec32flat_start, li.sec32flat_align = setSectionsStart(
244 textsections + rodatasections + datasections + bsssections
245 , li.zonefseg_start, 16)
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500246 li.sec32init_start, li.sec32init_align = setSectionsStart(
247 init32_textsections + init32_rodatasections
248 + init32_datasections + init32_bsssections
249 , li.sec32flat_start, 16)
250 li.final_readonly_start = min(BUILD_BIOS_ADDR, li.sec32flat_start)
251 if not genreloc:
252 li.final_readonly_start = min(BUILD_BIOS_ADDR, li.sec32init_start)
Kevin O'Connor46b82622012-05-13 12:10:30 -0400253
254 # Determine "low memory" data positions
255 li.sections32low = getSectionsCategory(sections, '32low')
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500256 sec32low_end = li.sec32init_start
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -0400257 if config.get('CONFIG_MALLOC_UPPERMEMORY'):
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500258 final_sec32low_end = li.final_readonly_start
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -0400259 zonelow_base = final_sec32low_end - 64*1024
260 li.zonelow_base = max(BUILD_ROM_START, alignpos(zonelow_base, 2*1024))
261 else:
262 final_sec32low_end = BUILD_LOWRAM_END
263 li.zonelow_base = final_sec32low_end - 64*1024
Kevin O'Connor3be89a12013-02-23 16:07:00 -0500264 relocdelta = final_sec32low_end - sec32low_end
Kevin O'Connor46b82622012-05-13 12:10:30 -0400265 li.sec32low_start, li.sec32low_align = setSectionsStart(
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500266 li.sections32low, sec32low_end, 16
Kevin O'Connorc9243442013-02-17 13:58:28 -0500267 , segoffset=li.zonelow_base - relocdelta)
Kevin O'Connorc91da7a2012-06-08 21:14:19 -0400268 li.final_sec32low_start = li.sec32low_start + relocdelta
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400269
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400270 # Print statistics
Kevin O'Connor46b82622012-05-13 12:10:30 -0400271 size16 = BUILD_BIOS_ADDR + BUILD_BIOS_SIZE - li.sec16_start
272 size32seg = li.sec16_start - li.sec32seg_start
Kevin O'Connor41953492013-02-18 23:09:01 -0500273 size32fseg = li.sec32seg_start - li.sec32fseg_start
274 size32flat = li.sec32fseg_start - li.sec32flat_start
Kevin O'Connor46b82622012-05-13 12:10:30 -0400275 size32init = li.sec32flat_start - li.sec32init_start
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500276 sizelow = sec32low_end - li.sec32low_start
Johannes Krampf064fd062014-01-12 11:14:54 -0500277 print("16bit size: %d" % size16)
278 print("32bit segmented size: %d" % size32seg)
279 print("32bit flat size: %d" % size32flat)
280 print("32bit flat init size: %d" % size32init)
281 print("Lowmem size: %d" % sizelow)
282 print("f-segment var size: %d" % size32fseg)
Kevin O'Connor46b82622012-05-13 12:10:30 -0400283 return li
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400284
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400285
286######################################################################
287# Linker script output
288######################################################################
289
290# Write LD script includes for the given cross references
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500291def outXRefs(sections, useseg=0, exportsyms=[], forcedelta=0):
Kevin O'Connora3c48f52013-02-05 22:36:13 -0500292 xrefs = dict([(symbol.name, symbol) for symbol in exportsyms])
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400293 out = ""
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400294 for section in sections:
295 for reloc in section.relocs:
296 symbol = reloc.symbol
Kevin O'Connora3c48f52013-02-05 22:36:13 -0500297 if (symbol.section is not None
298 and (symbol.section.fileid != section.fileid
299 or symbol.name != reloc.symbolname)):
300 xrefs[reloc.symbolname] = symbol
301 for symbolname, symbol in xrefs.items():
302 loc = symbol.section.finalloc
303 if useseg:
304 loc = symbol.section.finalsegloc
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500305 out += "%s = 0x%x ;\n" % (symbolname, loc + forcedelta + symbol.offset)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400306 return out
307
308# Write LD script includes for the given sections using relative offsets
Kevin O'Connor46b82622012-05-13 12:10:30 -0400309def outRelSections(sections, startsym, useseg=0):
310 sections = [(section.finalloc, section) for section in sections
311 if section.finalloc is not None]
Johannes Krampf0a82fc72014-01-12 11:39:57 -0500312 sections.sort(key=operator.itemgetter(0))
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400313 out = ""
Kevin O'Connor46b82622012-05-13 12:10:30 -0400314 for addr, section in sections:
315 loc = section.finalloc
316 if useseg:
317 loc = section.finalsegloc
318 out += ". = ( 0x%x - %s ) ;\n" % (loc, startsym)
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400319 if section.name == '.rodata.str1.1':
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400320 out += "_rodata = . ;\n"
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400321 out += "*(%s)\n" % (section.name,)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400322 return out
323
Kevin O'Connor46b82622012-05-13 12:10:30 -0400324# Build linker script output for a list of relocations.
325def strRelocs(outname, outrel, relocs):
326 relocs.sort()
327 return (" %s_start = ABSOLUTE(.) ;\n" % (outname,)
328 + "".join(["LONG(0x%x - %s)\n" % (pos, outrel)
329 for pos in relocs])
330 + " %s_end = ABSOLUTE(.) ;\n" % (outname,))
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500331
Kevin O'Connor46b82622012-05-13 12:10:30 -0400332# Find all relocations in the given sections with the given attributes
333def getRelocs(sections, type=None, category=None, notcategory=None):
334 out = []
335 for section in sections:
336 for reloc in section.relocs:
337 if reloc.symbol.section is None:
338 continue
339 destcategory = reloc.symbol.section.category
340 if ((type is None or reloc.type == type)
341 and (category is None or destcategory == category)
342 and (notcategory is None or destcategory != notcategory)):
343 out.append(section.finalloc + reloc.offset)
344 return out
345
Kevin O'Connor46b82622012-05-13 12:10:30 -0400346# Output the linker scripts for all required sections.
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500347def writeLinkerScripts(li, out16, out32seg, out32flat):
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400348 # Write 16bit linker script
Kevin O'Connor46b82622012-05-13 12:10:30 -0400349 out = outXRefs(li.sections16, useseg=1) + """
Kevin O'Connorc9243442013-02-17 13:58:28 -0500350 zonelow_base = 0x%x ;
351 _zonelow_seg = 0x%x ;
Kevin O'Connor46b82622012-05-13 12:10:30 -0400352
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400353 code16_start = 0x%x ;
354 .text16 code16_start : {
Kevin O'Connor46b82622012-05-13 12:10:30 -0400355%s
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400356 }
Kevin O'Connorc9243442013-02-17 13:58:28 -0500357""" % (li.zonelow_base,
Johannes Krampf9d7d0442014-01-12 11:19:22 -0500358 int(li.zonelow_base / 16),
Kevin O'Connor46b82622012-05-13 12:10:30 -0400359 li.sec16_start - BUILD_BIOS_ADDR,
360 outRelSections(li.sections16, 'code16_start', useseg=1))
Johannes Krampf19f789b2014-01-19 16:03:49 +0100361 outfile = open(out16, 'w')
Kevin O'Connor46b82622012-05-13 12:10:30 -0400362 outfile.write(COMMONHEADER + out + COMMONTRAILER)
363 outfile.close()
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500364
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400365 # Write 32seg linker script
Kevin O'Connor46b82622012-05-13 12:10:30 -0400366 out = outXRefs(li.sections32seg, useseg=1) + """
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400367 code32seg_start = 0x%x ;
368 .text32seg code32seg_start : {
Kevin O'Connor46b82622012-05-13 12:10:30 -0400369%s
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400370 }
Kevin O'Connor46b82622012-05-13 12:10:30 -0400371""" % (li.sec32seg_start - BUILD_BIOS_ADDR,
372 outRelSections(li.sections32seg, 'code32seg_start', useseg=1))
Johannes Krampf19f789b2014-01-19 16:03:49 +0100373 outfile = open(out32seg, 'w')
Kevin O'Connor46b82622012-05-13 12:10:30 -0400374 outfile.write(COMMONHEADER + out + COMMONTRAILER)
375 outfile.close()
Kevin O'Connor871e0a02009-12-30 12:14:53 -0500376
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400377 # Write 32flat linker script
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500378 sections32all = (li.sections32flat + li.sections32init + li.sections32fseg)
Kevin O'Connor46b82622012-05-13 12:10:30 -0400379 sec32all_start = li.sec32low_start
Kevin O'Connor402fd9c2010-09-15 00:26:19 -0400380 relocstr = ""
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500381 if li.genreloc:
Kevin O'Connor402fd9c2010-09-15 00:26:19 -0400382 # Generate relocations
Kevin O'Connor46b82622012-05-13 12:10:30 -0400383 absrelocs = getRelocs(
384 li.sections32init, type='R_386_32', category='32init')
385 relrelocs = getRelocs(
386 li.sections32init, type='R_386_PC32', notcategory='32init')
387 initrelocs = getRelocs(
388 li.sections32flat + li.sections32low + li.sections16
Kevin O'Connor41953492013-02-18 23:09:01 -0500389 + li.sections32seg + li.sections32fseg, category='32init')
Kevin O'Connor46b82622012-05-13 12:10:30 -0400390 relocstr = (strRelocs("_reloc_abs", "code32init_start", absrelocs)
391 + strRelocs("_reloc_rel", "code32init_start", relrelocs)
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500392 + strRelocs("_reloc_init", "code32flat_start", initrelocs))
393 numrelocs = len(absrelocs + relrelocs + initrelocs)
Kevin O'Connor46b82622012-05-13 12:10:30 -0400394 sec32all_start -= numrelocs * 4
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500395 out = outXRefs(li.sections32low, exportsyms=li.varlowsyms
396 , forcedelta=li.final_sec32low_start-li.sec32low_start)
Kevin O'Connoree952532014-06-09 14:37:23 -0400397 out += outXRefs(sections32all, exportsyms=[li.entrysym]) + """
Kevin O'Connor402fd9c2010-09-15 00:26:19 -0400398 _reloc_min_align = 0x%x ;
Kevin O'Connor6d152642013-02-19 21:35:20 -0500399 zonefseg_start = 0x%x ;
400 zonefseg_end = 0x%x ;
Kevin O'Connorc9243442013-02-17 13:58:28 -0500401 zonelow_base = 0x%x ;
402 final_varlow_start = 0x%x ;
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500403 final_readonly_start = 0x%x ;
Kevin O'Connor46b82622012-05-13 12:10:30 -0400404
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400405 code32flat_start = 0x%x ;
406 .text code32flat_start : {
Kevin O'Connor46b82622012-05-13 12:10:30 -0400407%s
Kevin O'Connorc9243442013-02-17 13:58:28 -0500408 varlow_start = ABSOLUTE(.) ;
Kevin O'Connor46b82622012-05-13 12:10:30 -0400409%s
Kevin O'Connorc9243442013-02-17 13:58:28 -0500410 varlow_end = ABSOLUTE(.) ;
Kevin O'Connor402fd9c2010-09-15 00:26:19 -0400411 code32init_start = ABSOLUTE(.) ;
Kevin O'Connor46b82622012-05-13 12:10:30 -0400412%s
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400413 code32init_end = ABSOLUTE(.) ;
Kevin O'Connor46b82622012-05-13 12:10:30 -0400414%s
Kevin O'Connor41953492013-02-18 23:09:01 -0500415%s
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400416 . = ( 0x%x - code32flat_start ) ;
417 *(.text32seg)
418 . = ( 0x%x - code32flat_start ) ;
419 *(.text16)
420 code32flat_end = ABSOLUTE(.) ;
421 } :text
Kevin O'Connora3c48f52013-02-05 22:36:13 -0500422""" % (li.sec32init_align,
Kevin O'Connor6d152642013-02-19 21:35:20 -0500423 li.zonefseg_start,
424 li.zonefseg_end,
Kevin O'Connorc9243442013-02-17 13:58:28 -0500425 li.zonelow_base,
Kevin O'Connorc91da7a2012-06-08 21:14:19 -0400426 li.final_sec32low_start,
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500427 li.final_readonly_start,
Kevin O'Connor46b82622012-05-13 12:10:30 -0400428 sec32all_start,
429 relocstr,
430 outRelSections(li.sections32low, 'code32flat_start'),
431 outRelSections(li.sections32init, 'code32flat_start'),
432 outRelSections(li.sections32flat, 'code32flat_start'),
Kevin O'Connor41953492013-02-18 23:09:01 -0500433 outRelSections(li.sections32fseg, 'code32flat_start'),
Kevin O'Connor46b82622012-05-13 12:10:30 -0400434 li.sec32seg_start,
435 li.sec16_start)
436 out = COMMONHEADER + out + COMMONTRAILER + """
Kevin O'Connoree952532014-06-09 14:37:23 -0400437ENTRY(%s)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400438PHDRS
439{
440 text PT_LOAD AT ( code32flat_start ) ;
441}
Kevin O'Connoree952532014-06-09 14:37:23 -0400442""" % (li.entrysym.name,)
Johannes Krampf19f789b2014-01-19 16:03:49 +0100443 outfile = open(out32flat, 'w')
Kevin O'Connor46b82622012-05-13 12:10:30 -0400444 outfile.write(out)
445 outfile.close()
Kevin O'Connorc0693942009-06-10 21:56:01 -0400446
447
448######################################################################
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400449# Detection of init code
450######################################################################
451
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400452# Visit all sections reachable from a given set of start sections
453def findReachable(anchorsections, checkreloc, data):
454 anchorsections = dict([(section, []) for section in anchorsections])
455 pending = list(anchorsections)
456 while pending:
457 section = pending.pop()
458 for reloc in section.relocs:
459 chain = anchorsections[section] + [section.name]
460 if not checkreloc(reloc, section, data, chain):
461 continue
462 nextsection = reloc.symbol.section
463 if nextsection not in anchorsections:
464 anchorsections[nextsection] = chain
465 pending.append(nextsection)
466 return anchorsections
467
468def checkRuntime(reloc, rsection, data, chain):
469 section = reloc.symbol.section
Kevin O'Connorc228d702014-06-09 14:59:25 -0400470 if section is None or '.init.' in section.name or section.fileid != '32flat':
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400471 return 0
Kevin O'Connor2af52da2013-03-08 19:36:28 -0500472 if '.data.varinit.' in section.name:
Johannes Krampf064fd062014-01-12 11:14:54 -0500473 print("ERROR: %s is VARVERIFY32INIT but used from %s" % (
474 section.name, chain))
Kevin O'Connor2af52da2013-03-08 19:36:28 -0500475 sys.exit(1)
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400476 return 1
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400477
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500478def findInit(sections):
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400479 # Recursively find and mark all "runtime" sections.
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400480 anchorsections = [
481 section for section in sections
Kevin O'Connor41953492013-02-18 23:09:01 -0500482 if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name
Kevin O'Connoree952532014-06-09 14:37:23 -0400483 or '.runtime.' in section.name)]
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400484 runtimesections = findReachable(anchorsections, checkRuntime, None)
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400485 for section in sections:
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400486 if section.fileid == '32flat' and section not in runtimesections:
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400487 section.category = '32init'
488 else:
489 section.category = section.fileid
490
491
492######################################################################
Kevin O'Connorc0693942009-06-10 21:56:01 -0400493# Section garbage collection
494######################################################################
495
Kevin O'Connorfdca4182010-01-01 12:46:54 -0500496# Find and keep the section associated with a symbol (if available).
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400497def checkKeepSym(reloc, syms, fileid, isxref):
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500498 symbolname = reloc.symbolname
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400499 mustbecfunc = symbolname.startswith('_cfunc')
500 if mustbecfunc:
501 symprefix = '_cfunc' + fileid + '_'
502 if not symbolname.startswith(symprefix):
503 return 0
504 symbolname = symbolname[len(symprefix):]
505 symbol = syms.get(symbolname)
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400506 if (symbol is None or symbol.section is None
507 or symbol.section.name.startswith('.discard.')):
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400508 return 0
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500509 isdestcfunc = (symbol.section.name.startswith('.text.')
510 and not symbol.section.name.startswith('.text.asm.'))
511 if ((mustbecfunc and not isdestcfunc)
512 or (not mustbecfunc and isdestcfunc and isxref)):
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400513 return 0
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500514
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400515 reloc.symbol = symbol
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400516 return 1
Kevin O'Connorfdca4182010-01-01 12:46:54 -0500517
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400518# Resolve a relocation and check if it should be kept in the final binary.
Kevin O'Connorc228d702014-06-09 14:59:25 -0400519def checkKeep(reloc, section, symbols, chain):
520 ret = checkKeepSym(reloc, symbols[section.fileid], section.fileid, 0)
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400521 if ret:
522 return ret
523 # Not in primary sections - it may be a cross 16/32 reference
524 for fileid in ('16', '32seg', '32flat'):
525 if fileid != section.fileid:
Kevin O'Connorc228d702014-06-09 14:59:25 -0400526 ret = checkKeepSym(reloc, symbols[fileid], fileid, 1)
Kevin O'Connorcc132ab2014-06-09 12:48:13 -0400527 if ret:
528 return ret
529 return 0
Kevin O'Connorc0693942009-06-10 21:56:01 -0400530
Kevin O'Connorc0693942009-06-10 21:56:01 -0400531
532######################################################################
533# Startup and input parsing
534######################################################################
535
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400536class Section:
537 name = size = alignment = fileid = relocs = None
Kevin O'Connorc228d702014-06-09 14:59:25 -0400538 finalloc = finalsegloc = category = None
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400539class Reloc:
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500540 offset = type = symbolname = symbol = None
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400541class Symbol:
542 name = offset = section = None
543
Kevin O'Connorc0693942009-06-10 21:56:01 -0400544# Read in output from objdump
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400545def parseObjDump(file, fileid):
546 # sections = [section, ...]
Kevin O'Connorc0693942009-06-10 21:56:01 -0400547 sections = []
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400548 sectionmap = {}
549 # symbols[symbolname] = symbol
Kevin O'Connorc0693942009-06-10 21:56:01 -0400550 symbols = {}
Kevin O'Connorc0693942009-06-10 21:56:01 -0400551
552 state = None
553 for line in file.readlines():
554 line = line.rstrip()
555 if line == 'Sections:':
556 state = 'section'
557 continue
558 if line == 'SYMBOL TABLE:':
559 state = 'symbol'
560 continue
Kevin O'Connor6c2e7812010-09-13 18:04:02 -0400561 if line.startswith('RELOCATION RECORDS FOR ['):
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400562 sectionname = line[24:-2]
563 if sectionname.startswith('.debug_'):
564 # Skip debugging sections (to reduce parsing time)
565 state = None
566 continue
Kevin O'Connorc0693942009-06-10 21:56:01 -0400567 state = 'reloc'
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400568 relocsection = sectionmap[sectionname]
Kevin O'Connorc0693942009-06-10 21:56:01 -0400569 continue
570
571 if state == 'section':
572 try:
573 idx, name, size, vma, lma, fileoff, align = line.split()
574 if align[:3] != '2**':
575 continue
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400576 section = Section()
577 section.name = name
578 section.size = int(size, 16)
579 section.align = 2**int(align[3:])
580 section.fileid = fileid
581 section.relocs = []
582 sections.append(section)
583 sectionmap[name] = section
584 except ValueError:
Kevin O'Connorc0693942009-06-10 21:56:01 -0400585 pass
586 continue
587 if state == 'symbol':
588 try:
Kevin O'Connor90ebed42012-06-21 20:54:53 -0400589 parts = line[17:].split()
590 if len(parts) == 3:
591 sectionname, size, name = parts
592 elif len(parts) == 4 and parts[2] == '.hidden':
593 sectionname, size, hidden, name = parts
594 else:
595 continue
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400596 symbol = Symbol()
597 symbol.size = int(size, 16)
598 symbol.offset = int(line[:8], 16)
599 symbol.name = name
600 symbol.section = sectionmap.get(sectionname)
601 symbols[name] = symbol
602 except ValueError:
Kevin O'Connorc0693942009-06-10 21:56:01 -0400603 pass
604 continue
605 if state == 'reloc':
606 try:
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400607 off, type, symbolname = line.split()
608 reloc = Reloc()
609 reloc.offset = int(off, 16)
610 reloc.type = type
Kevin O'Connorf3fe3aa2010-12-05 12:38:33 -0500611 reloc.symbolname = symbolname
Kevin O'Connor67863be2010-12-24 10:23:10 -0500612 reloc.symbol = symbols.get(symbolname)
613 if reloc.symbol is None:
614 # Some binutils (2.20.1) give section name instead
615 # of a symbol - create a dummy symbol.
616 reloc.symbol = symbol = Symbol()
617 symbol.size = 0
618 symbol.offset = 0
619 symbol.name = symbolname
620 symbol.section = sectionmap.get(symbolname)
621 symbols[symbolname] = symbol
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400622 relocsection.relocs.append(reloc)
623 except ValueError:
Kevin O'Connorc0693942009-06-10 21:56:01 -0400624 pass
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400625 return sections, symbols
Kevin O'Connorc0693942009-06-10 21:56:01 -0400626
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -0400627# Parser for constants in simple C header files.
628def scanconfig(file):
Johannes Krampf19f789b2014-01-19 16:03:49 +0100629 f = open(file, 'r')
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -0400630 opts = {}
631 for l in f.readlines():
632 parts = l.split()
633 if len(parts) != 3:
634 continue
635 if parts[0] != '#define':
636 continue
637 value = parts[2]
638 if value.isdigit() or (value.startswith('0x') and value[2:].isdigit()):
639 value = int(value, 0)
640 opts[parts[1]] = value
641 return opts
642
Kevin O'Connorc0693942009-06-10 21:56:01 -0400643def main():
644 # Get output name
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -0400645 in16, in32seg, in32flat, cfgfile, out16, out32seg, out32flat = sys.argv[1:]
Kevin O'Connorc0693942009-06-10 21:56:01 -0400646
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400647 # Read in the objdump information
Johannes Krampf19f789b2014-01-19 16:03:49 +0100648 infile16 = open(in16, 'r')
649 infile32seg = open(in32seg, 'r')
650 infile32flat = open(in32flat, 'r')
Kevin O'Connorc0693942009-06-10 21:56:01 -0400651
Kevin O'Connor1a4885e2010-09-15 21:28:31 -0400652 # infoX = (sections, symbols)
653 info16 = parseObjDump(infile16, '16')
654 info32seg = parseObjDump(infile32seg, '32seg')
655 info32flat = parseObjDump(infile32flat, '32flat')
Kevin O'Connorc0693942009-06-10 21:56:01 -0400656
Kevin O'Connor2b0fb8c2013-08-07 23:03:47 -0400657 # Read kconfig config file
658 config = scanconfig(cfgfile)
659
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400660 # Figure out which sections to keep.
Kevin O'Connorc228d702014-06-09 14:59:25 -0400661 allsections = info16[0] + info32seg[0] + info32flat[0]
662 symbols = {'16': info16[1], '32seg': info32seg[1], '32flat': info32flat[1]}
Kevin O'Connoree952532014-06-09 14:37:23 -0400663 if config.get('CONFIG_COREBOOT'):
664 entrysym = symbols['16'].get('entry_elf')
665 elif config.get('CONFIG_CSM'):
666 entrysym = symbols['16'].get('entry_csm')
667 else:
668 entrysym = symbols['16'].get('reset_vector')
669 anchorsections = [entrysym.section] + [
670 section for section in info16[0]
671 if section.name.startswith('.fixedaddr.')]
Kevin O'Connorc228d702014-06-09 14:59:25 -0400672 keepsections = findReachable(anchorsections, checkKeep, symbols)
673 sections = [section for section in allsections if section in keepsections]
Kevin O'Connorc0693942009-06-10 21:56:01 -0400674
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400675 # Separate 32bit flat into runtime and init parts
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500676 findInit(sections)
Kevin O'Connord1b4f962010-09-15 21:38:16 -0400677
Kevin O'Connor41953492013-02-18 23:09:01 -0500678 # Note "low memory" and "fseg memory" parts
Kevin O'Connorc9243442013-02-17 13:58:28 -0500679 for section in getSectionsPrefix(sections, '.data.varlow.'):
Kevin O'Connor46b82622012-05-13 12:10:30 -0400680 section.category = '32low'
Kevin O'Connor41953492013-02-18 23:09:01 -0500681 for section in getSectionsPrefix(sections, '.data.varfseg.'):
682 section.category = '32fseg'
Kevin O'Connor46b82622012-05-13 12:10:30 -0400683
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400684 # Determine the final memory locations of each kept section.
Kevin O'Connorc228d702014-06-09 14:59:25 -0400685 genreloc = '_reloc_abs_start' in symbols['32flat']
Kevin O'Connorb94170c2013-12-06 13:52:16 -0500686 li = doLayout(sections, config, genreloc)
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400687
Kevin O'Connora3c48f52013-02-05 22:36:13 -0500688 # Exported symbols
Kevin O'Connorc228d702014-06-09 14:59:25 -0400689 li.varlowsyms = [symbol for symbol in symbols['32flat'].values()
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500690 if (symbol.section is not None
691 and symbol.section.finalloc is not None
692 and '.data.varlow.' in symbol.section.name
693 and symbol.name != symbol.section.name)]
Kevin O'Connoree952532014-06-09 14:37:23 -0400694 li.entrysym = entrysym
Kevin O'Connora3c48f52013-02-05 22:36:13 -0500695
Kevin O'Connor9ba1dea2010-05-01 09:50:13 -0400696 # Write out linker script files.
Kevin O'Connor6afc6f82013-02-19 01:02:50 -0500697 writeLinkerScripts(li, out16, out32seg, out32flat)
Kevin O'Connorc0693942009-06-10 21:56:01 -0400698
Kevin O'Connor202024a2009-01-17 10:41:28 -0500699if __name__ == '__main__':
700 main()