build: Use customized entry point for each type of build.
Set an appropriate elf entry point (entry_elf, entry_csm, reset_vector) for each type of build (coreboot, csm, qemu). Use that entry point when determining which sections to keep. Also, remove the '.export.' mechanism to keep a section in the final binary - it is no longer used. This allows the build to slightly reduce the overall size as entry_elf is no longer needed on non-coreboot builds and entry_csm is no longer needed on non-csm builds. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
c228d70473
commit
ee95253403
|
@ -166,7 +166,7 @@ class LayoutInfo:
|
||||||
zonefseg_start = zonefseg_end = None
|
zonefseg_start = zonefseg_end = None
|
||||||
final_readonly_start = None
|
final_readonly_start = None
|
||||||
zonelow_base = final_sec32low_start = None
|
zonelow_base = final_sec32low_start = None
|
||||||
exportsyms = varlowsyms = None
|
varlowsyms = entrysym = None
|
||||||
|
|
||||||
# Determine final memory addresses for sections
|
# Determine final memory addresses for sections
|
||||||
def doLayout(sections, config, genreloc):
|
def doLayout(sections, config, genreloc):
|
||||||
|
@ -394,7 +394,7 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
|
||||||
sec32all_start -= numrelocs * 4
|
sec32all_start -= numrelocs * 4
|
||||||
out = outXRefs(li.sections32low, exportsyms=li.varlowsyms
|
out = outXRefs(li.sections32low, exportsyms=li.varlowsyms
|
||||||
, forcedelta=li.final_sec32low_start-li.sec32low_start)
|
, forcedelta=li.final_sec32low_start-li.sec32low_start)
|
||||||
out += outXRefs(sections32all, exportsyms=li.exportsyms) + """
|
out += outXRefs(sections32all, exportsyms=[li.entrysym]) + """
|
||||||
_reloc_min_align = 0x%x ;
|
_reloc_min_align = 0x%x ;
|
||||||
zonefseg_start = 0x%x ;
|
zonefseg_start = 0x%x ;
|
||||||
zonefseg_end = 0x%x ;
|
zonefseg_end = 0x%x ;
|
||||||
|
@ -434,12 +434,12 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
|
||||||
li.sec32seg_start,
|
li.sec32seg_start,
|
||||||
li.sec16_start)
|
li.sec16_start)
|
||||||
out = COMMONHEADER + out + COMMONTRAILER + """
|
out = COMMONHEADER + out + COMMONTRAILER + """
|
||||||
ENTRY(entry_elf)
|
ENTRY(%s)
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
text PT_LOAD AT ( code32flat_start ) ;
|
text PT_LOAD AT ( code32flat_start ) ;
|
||||||
}
|
}
|
||||||
"""
|
""" % (li.entrysym.name,)
|
||||||
outfile = open(out32flat, 'w')
|
outfile = open(out32flat, 'w')
|
||||||
outfile.write(out)
|
outfile.write(out)
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
@ -480,7 +480,7 @@ def findInit(sections):
|
||||||
anchorsections = [
|
anchorsections = [
|
||||||
section for section in sections
|
section for section in sections
|
||||||
if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name
|
if ('.data.varlow.' in section.name or '.data.varfseg.' in section.name
|
||||||
or '.runtime.' in section.name or '.export.' in section.name)]
|
or '.runtime.' in section.name)]
|
||||||
runtimesections = findReachable(anchorsections, checkRuntime, None)
|
runtimesections = findReachable(anchorsections, checkRuntime, None)
|
||||||
for section in sections:
|
for section in sections:
|
||||||
if section.fileid == '32flat' and section not in runtimesections:
|
if section.fileid == '32flat' and section not in runtimesections:
|
||||||
|
@ -660,9 +660,15 @@ def main():
|
||||||
# Figure out which sections to keep.
|
# Figure out which sections to keep.
|
||||||
allsections = info16[0] + info32seg[0] + info32flat[0]
|
allsections = info16[0] + info32seg[0] + info32flat[0]
|
||||||
symbols = {'16': info16[1], '32seg': info32seg[1], '32flat': info32flat[1]}
|
symbols = {'16': info16[1], '32seg': info32seg[1], '32flat': info32flat[1]}
|
||||||
anchorsections = [section for section in info16[0]
|
if config.get('CONFIG_COREBOOT'):
|
||||||
if (section.name.startswith('.fixedaddr.')
|
entrysym = symbols['16'].get('entry_elf')
|
||||||
or '.export.' in section.name)]
|
elif config.get('CONFIG_CSM'):
|
||||||
|
entrysym = symbols['16'].get('entry_csm')
|
||||||
|
else:
|
||||||
|
entrysym = symbols['16'].get('reset_vector')
|
||||||
|
anchorsections = [entrysym.section] + [
|
||||||
|
section for section in info16[0]
|
||||||
|
if section.name.startswith('.fixedaddr.')]
|
||||||
keepsections = findReachable(anchorsections, checkKeep, symbols)
|
keepsections = findReachable(anchorsections, checkKeep, symbols)
|
||||||
sections = [section for section in allsections if section in keepsections]
|
sections = [section for section in allsections if section in keepsections]
|
||||||
|
|
||||||
|
@ -680,15 +686,12 @@ def main():
|
||||||
li = doLayout(sections, config, genreloc)
|
li = doLayout(sections, config, genreloc)
|
||||||
|
|
||||||
# Exported symbols
|
# Exported symbols
|
||||||
li.exportsyms = [symbol for symbol in symbols['16'].values()
|
|
||||||
if (symbol.section is not None
|
|
||||||
and '.export.' in symbol.section.name
|
|
||||||
and symbol.name != symbol.section.name)]
|
|
||||||
li.varlowsyms = [symbol for symbol in symbols['32flat'].values()
|
li.varlowsyms = [symbol for symbol in symbols['32flat'].values()
|
||||||
if (symbol.section is not None
|
if (symbol.section is not None
|
||||||
and symbol.section.finalloc is not None
|
and symbol.section.finalloc is not None
|
||||||
and '.data.varlow.' in symbol.section.name
|
and '.data.varlow.' in symbol.section.name
|
||||||
and symbol.name != symbol.section.name)]
|
and symbol.name != symbol.section.name)]
|
||||||
|
li.entrysym = entrysym
|
||||||
|
|
||||||
# Write out linker script files.
|
# Write out linker script files.
|
||||||
writeLinkerScripts(li, out16, out32seg, out32flat)
|
writeLinkerScripts(li, out16, out32seg, out32flat)
|
||||||
|
|
|
@ -149,9 +149,3 @@
|
||||||
.section .text.asm.\func
|
.section .text.asm.\func
|
||||||
.global \func
|
.global \func
|
||||||
.endm
|
.endm
|
||||||
|
|
||||||
// Declare an exported function
|
|
||||||
.macro EXPORTFUNC func
|
|
||||||
.section .text.asm.export.\func
|
|
||||||
.global \func
|
|
||||||
.endm
|
|
||||||
|
|
|
@ -440,7 +440,7 @@ entry_bios32:
|
||||||
lretl
|
lretl
|
||||||
|
|
||||||
// 32bit elf entry point
|
// 32bit elf entry point
|
||||||
EXPORTFUNC entry_elf
|
DECLFUNC entry_elf
|
||||||
entry_elf:
|
entry_elf:
|
||||||
cli
|
cli
|
||||||
cld
|
cld
|
||||||
|
@ -458,7 +458,7 @@ entry_elf:
|
||||||
.code16
|
.code16
|
||||||
|
|
||||||
// UEFI Compatibility Support Module (CSM) entry point
|
// UEFI Compatibility Support Module (CSM) entry point
|
||||||
EXPORTFUNC entry_csm
|
DECLFUNC entry_csm
|
||||||
entry_csm:
|
entry_csm:
|
||||||
// Backup register state
|
// Backup register state
|
||||||
pushfw
|
pushfw
|
||||||
|
|
Loading…
Reference in New Issue