diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2014-06-10 00:00:20 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2014-06-11 14:55:56 -0400 |
commit | bf70fbff23884b8a265adcead08c676a64b42b31 (patch) | |
tree | 48c88452e69f84f57a5a2e6eaf9b1d6b2025a417 /scripts | |
parent | ee952534039b32049404f26ccaae1b034f7e876b (diff) | |
download | seabios-bf70fbff23884b8a265adcead08c676a64b42b31.tar.gz |
build: Refactor findInit() function.
Push findInit() into main() and unify the category setting code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/layoutrom.py | 46 |
1 files changed, 18 insertions, 28 deletions
diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py index 7c96cd3b..a935b3dc 100755 --- a/scripts/layoutrom.py +++ b/scripts/layoutrom.py @@ -446,7 +446,7 @@ PHDRS ###################################################################### -# Detection of init code +# Detection of unused sections and init sections ###################################################################### # Visit all sections reachable from a given set of start sections @@ -465,9 +465,10 @@ def findReachable(anchorsections, checkreloc, data): pending.append(nextsection) return anchorsections +# Find "runtime" sections (ie, not init only sections). def checkRuntime(reloc, rsection, data, chain): section = reloc.symbol.section - if section is None or '.init.' in section.name or section.fileid != '32flat': + if section is None or '.init.' in section.name: return 0 if '.data.varinit.' in section.name: print("ERROR: %s is VARVERIFY32INIT but used from %s" % ( @@ -475,24 +476,6 @@ def checkRuntime(reloc, rsection, data, chain): sys.exit(1) return 1 -def findInit(sections): - # Recursively find and mark all "runtime" sections. - anchorsections = [ - section for section in sections - if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name - or '.runtime.' in section.name)] - runtimesections = findReachable(anchorsections, checkRuntime, None) - for section in sections: - if section.fileid == '32flat' and section not in runtimesections: - section.category = '32init' - else: - section.category = section.fileid - - -###################################################################### -# Section garbage collection -###################################################################### - # Find and keep the section associated with a symbol (if available). def checkKeepSym(reloc, syms, fileid, isxref): symbolname = reloc.symbolname @@ -672,14 +655,21 @@ def main(): keepsections = findReachable(anchorsections, checkKeep, symbols) sections = [section for section in allsections if section in keepsections] - # Separate 32bit flat into runtime and init parts - findInit(sections) - - # Note "low memory" and "fseg memory" parts - for section in getSectionsPrefix(sections, '.data.varlow.'): - section.category = '32low' - for section in getSectionsPrefix(sections, '.data.varfseg.'): - section.category = '32fseg' + # Separate 32bit flat into runtime, init, and special variable parts + anchorsections = [ + section for section in sections + if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name + or '.runtime.' in section.name)] + runtimesections = findReachable(anchorsections, checkRuntime, None) + for section in sections: + if section.name.startswith('.data.varlow.'): + section.category = '32low' + elif section.name.startswith('.data.varfseg.'): + section.category = '32fseg' + elif section.fileid == '32flat' and section not in runtimesections: + section.category = '32init' + else: + section.category = section.fileid # Determine the final memory locations of each kept section. genreloc = '_reloc_abs_start' in symbols['32flat'] |