diff --git a/fxconv/fxconv.py b/fxconv/fxconv.py index e3321f5..20a4e34 100644 --- a/fxconv/fxconv.py +++ b/fxconv/fxconv.py @@ -1186,20 +1186,6 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None, Produces an output file and returns nothing. """ - # Unfold ObjectData into data and assembly - if isinstance(data, ObjectData): - asm = ".section .rodata\n" - 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: - raise FxconvError("elf() but no data and no assembly") - # Toolchain parameters if toolchain is None: @@ -1220,6 +1206,20 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None, raise FxconvError(f"non-trivial architecture for {toolchain} must be "+ "specified") + # Unfold ObjectData into data and assembly + if isinstance(data, ObjectData): + asm = ".section " + section.split(",",1)[0] + "\n" + 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: + raise FxconvError("elf() but no data and no assembly") + # Generate data - in directly if there is no assembly if data: