From 382da1d747c6cc29e12e3ddd46a757b557516f23 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 12 Feb 2023 15:13:04 +0800 Subject: [PATCH] add -nostdlib when compile assembler program that has _start --- RedPandaIDE/compiler/filecompiler.cpp | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/RedPandaIDE/compiler/filecompiler.cpp b/RedPandaIDE/compiler/filecompiler.cpp index 5c3a9618..6a208731 100644 --- a/RedPandaIDE/compiler/filecompiler.cpp +++ b/RedPandaIDE/compiler/filecompiler.cpp @@ -18,6 +18,7 @@ #include "utils.h" #include "../mainwindow.h" #include "compilermanager.h" +#include "qsynedit/syntaxer/asm.h" #include #include @@ -126,6 +127,39 @@ bool FileCompiler::prepareForCompile() if (!mOnlyCheckSyntax) mArguments += getLibraryArguments(fileType); + if (fileType==FileType::GAS) { + bool hasStart=false; + QStringList lines=readFileToLines(mFilename); + QSynedit::ASMSyntaxer syntaxer; + syntaxer.resetState(); + QString lastToken; + QString token; + QSynedit::PTokenAttribute attr; + for (int i=0;itokenType() != QSynedit::TokenType::Space + && attr->tokenType()!=QSynedit::TokenType::String + && attr->tokenType()!=QSynedit::TokenType::Character) + lastToken=token; + syntaxer.next(); + } + if (hasStart) + break; + } + if (hasStart) { + mArguments+=" -nostdlib"; + } + } + if (!fileExists(mCompiler)) { throw CompileError( tr("The Compiler '%1' doesn't exists!").arg(mCompiler)