aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2010-01-01 12:46:54 -0500
committerKevin O'Connor <kevin@koconnor.net>2010-01-01 13:05:23 -0500
commitfdca41825dd5ed2f2d1ced2f6ecbd9077c4f6b86 (patch)
tree5db7205e68e436bb0541c8a0b6cc94f815e4be1f /tools
parentdad41d9f217cef9dc6c404d409f6c27b0454b73f (diff)
downloadseabios-fdca41825dd5ed2f2d1ced2f6ecbd9077c4f6b86.tar.gz
Force a link error if a function is used from the wrong code chunk.
Force functions intended for other code segments to be discarded during link - this will cause a link error if it used. Clean up rom layout code to ensure discarded sections are not used.
Diffstat (limited to 'tools')
-rwxr-xr-xtools/layoutrom.py27
1 files changed, 15 insertions, 12 deletions
diff --git a/tools/layoutrom.py b/tools/layoutrom.py
index 31134078..d0ca9a65 100755
--- a/tools/layoutrom.py
+++ b/tools/layoutrom.py
@@ -274,6 +274,14 @@ def getSectionsList(info, names):
out.append(i)
return out
+# Find and keep the section associated with a symbol (if available).
+def keepsymbol(symbol, infos, pos):
+ addr, section = infos[pos][1].get(symbol, (None, None))
+ if section is None or '*' in section or section[:9] == '.discard.':
+ return -1
+ keepsection(section, infos, pos)
+ return 0
+
# Note required section, and recursively set all referenced sections
# as required.
def keepsection(name, infos, pos=0):
@@ -286,21 +294,16 @@ def keepsection(name, infos, pos=0):
return
# Keep all sections that this section points to
for symbol in relocs:
- addr, section = infos[pos][1].get(symbol, (None, None))
- if (section is not None and '*' not in section
- and section[:9] != '.discard.'):
- keepsection(section, infos, pos)
+ ret = keepsymbol(symbol, infos, pos)
+ if not ret:
continue
# Not in primary sections - it may be a cross 16/32 reference
- newpos = (pos+1)%3
- addr, section = infos[newpos][1].get(symbol, (None, None))
- if section is not None and '*' not in section:
- keepsection(section, infos, newpos)
+ ret = keepsymbol(symbol, infos, (pos+1)%3)
+ if not ret:
+ continue
+ ret = keepsymbol(symbol, infos, (pos+2)%3)
+ if not ret:
continue
- newpos = (pos+2)%3
- addr, section = infos[(pos+2)%3][1].get(symbol, (None, None))
- if section is not None and '*' not in section:
- keepsection(section, infos, newpos)
# Determine which sections are actually referenced and need to be
# placed into the output file.