add -nostdlib when compile assembler program that has _start
This commit is contained in:
parent
23d5bb85b6
commit
382da1d747
|
@ -18,6 +18,7 @@
|
|||
#include "utils.h"
|
||||
#include "../mainwindow.h"
|
||||
#include "compilermanager.h"
|
||||
#include "qsynedit/syntaxer/asm.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QFileInfo>
|
||||
|
@ -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;i<lines.count();i++) {
|
||||
QString line=lines[i];
|
||||
syntaxer.setLine(line,i+1);
|
||||
lastToken="";
|
||||
while(!syntaxer.eol()) {
|
||||
token=syntaxer.getToken();
|
||||
if (token==":" && lastToken=="_start") {
|
||||
hasStart=true;
|
||||
break;
|
||||
}
|
||||
attr = syntaxer.getTokenAttribute();
|
||||
if (attr->tokenType() != 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)
|
||||
|
|
Loading…
Reference in New Issue