mirror of
https://git.planet-casio.com/Lephenixnoir/fxsdk.git
synced 2024-12-29 13:03:37 +01:00
fxconv: add an elf_multi() function to produce multiple variables
This commit is contained in:
parent
cf3ab5d5e0
commit
11e3b614c2
1 changed files with 27 additions and 10 deletions
|
@ -1174,6 +1174,14 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None,
|
||||||
Produces an output file and returns nothing.
|
Produces an output file and returns nothing.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# Unfold ObjectData into data and assembly
|
||||||
|
if isinstance(data, ObjectData):
|
||||||
|
assembly = f".global {symbol}\n" + \
|
||||||
|
f"{symbol}:\n" + \
|
||||||
|
data.link(symbol)[0] + \
|
||||||
|
(assembly or "")
|
||||||
|
data = None
|
||||||
|
|
||||||
# Toolchain parameters
|
# Toolchain parameters
|
||||||
|
|
||||||
if toolchain is None:
|
if toolchain is None:
|
||||||
|
@ -1194,16 +1202,9 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None,
|
||||||
raise FxconvError(f"non-trivial architecture for {toolchain} must be "+
|
raise FxconvError(f"non-trivial architecture for {toolchain} must be "+
|
||||||
"specified")
|
"specified")
|
||||||
|
|
||||||
# Unfold ObjectData into data and assembly
|
if assembly:
|
||||||
if isinstance(data, ObjectData):
|
sec = ".section " + section.split(",",1)[0]
|
||||||
asm = ".section " + section.split(",",1)[0] + "\n"
|
assembly = sec + "\n" + assembly
|
||||||
asm += f".global {symbol}\n"
|
|
||||||
asm += f"{symbol}:\n"
|
|
||||||
asm += data.link(symbol)[0]
|
|
||||||
asm += (assembly or "")
|
|
||||||
|
|
||||||
data = None
|
|
||||||
assembly = asm
|
|
||||||
|
|
||||||
if data is None and assembly is None:
|
if data is None and assembly is None:
|
||||||
raise FxconvError("elf() but no data and no assembly")
|
raise FxconvError("elf() but no data and no assembly")
|
||||||
|
@ -1263,6 +1264,22 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None,
|
||||||
if assembly:
|
if assembly:
|
||||||
fp_asm.close()
|
fp_asm.close()
|
||||||
|
|
||||||
|
def elf_multi(vars, output, assembly=None, **kwargs):
|
||||||
|
"""
|
||||||
|
Like elf(), but instead of one symbol/data pair, allows defining multiple
|
||||||
|
variables. vars should be a list [(symbol, ObjectData), ...]. Keyword
|
||||||
|
arguments are passed to elf().
|
||||||
|
"""
|
||||||
|
|
||||||
|
asm = ""
|
||||||
|
for symbol, objdata in vars:
|
||||||
|
asm += f".global {symbol}\n"
|
||||||
|
asm += f"{symbol}:\n"
|
||||||
|
asm += objdata.link(symbol)[0]
|
||||||
|
asm += assembly or ""
|
||||||
|
|
||||||
|
return elf(None, output, None, assembly=asm, **kwargs)
|
||||||
|
|
||||||
#
|
#
|
||||||
# Meta API
|
# Meta API
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue