From dc522072e7129d03d877fe65b0b2d9f80e4a0de2 Mon Sep 17 00:00:00 2001 From: Lephenixnoir Date: Sun, 15 Jan 2023 16:32:51 +0100 Subject: [PATCH] fxconv: honor section setting for ASM conversions --- fxconv/fxconv.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) 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: