diff options
| author | ruki <[email protected]> | 2025-12-15 22:41:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-15 22:41:55 +0800 |
| commit | 0edd8ff4b884eebc30ab04870ab0ea2bb9e4bb60 (patch) | |
| tree | 84a39e33c6483f459e5b97cc3b46e9619bb3e9db /xmake/modules/utils/binary/bin2obj.lua | |
| parent | f23872ba7f507474cd3ee77e718f3ff5e30035a9 (diff) | |
improve cosmocc for binutils
Diffstat (limited to 'xmake/modules/utils/binary/bin2obj.lua')
| -rw-r--r-- | xmake/modules/utils/binary/bin2obj.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/xmake/modules/utils/binary/bin2obj.lua b/xmake/modules/utils/binary/bin2obj.lua index 13ff633e1..e77cfad6f 100644 --- a/xmake/modules/utils/binary/bin2obj.lua +++ b/xmake/modules/utils/binary/bin2obj.lua @@ -49,6 +49,35 @@ function main(binarypath, outputpath, opt) -- do conversion binutils.bin2obj(binarypath, outputpath, opt) + -- generate concomitant object file for cosmocc + if opt.cosmocc then + local arch = opt.arch or "x86_64" + local arch_concomitant + local objectfile_concomitant + if arch == "x86_64" or arch == "x64" then + arch_concomitant = "aarch64" + objectfile_concomitant = path.join(path.directory(outputpath), ".aarch64", path.filename(outputpath)) + elseif arch == "aarch64" or arch == "arm64" then + arch_concomitant = "x86_64" + objectfile_concomitant = path.join(path.directory(outputpath), ".x86_64", path.filename(outputpath)) + end + + if arch_concomitant and objectfile_concomitant then + + -- clone options for concomitant + local opt_concomitant = table.clone(opt) + opt_concomitant.arch = arch_concomitant + opt_concomitant.cosmocc = false + + -- trace + print("converting binary file %s to %s object file %s ..", binarypath, format or "coff", objectfile_concomitant) + + -- do conversion + os.mkdir(path.directory(objectfile_concomitant)) + binutils.bin2obj(binarypath, objectfile_concomitant, opt_concomitant) + end + end + -- trace cprint("${bright}%s generated!", outputpath) end |
