2011-06-01 38 views
1

我正在构建一个交叉编译器,将c代码转换为我正在使用的此处理器的程序集。经过几个小时的工作,我设法得到xgcc.exe进行编译,以便我可以开始将其吐出实际的操作码。不过,我已经打了试图编译一个简单无效的主要代码,当一个障碍:GCC交叉编译器无法通过void main()测试

void main(){} 

当我运行它,我得到以下内部编译器错误

(call_ins 3 2 5 2 (call (mem SI ("__main") [flags 0x41]) [0 S4 A8]) 

(const_int 0 [0])) test.c:1 -1 

(expr_list REG_EH_REGION (const_int 0 [0]) (nil)) (nil)) 

Internal compiler error: in extract_insn, at recog.c: 2109 

我硬是抄机器描述符文件来自类似于mine(moxie)的工作处理器,但它仍然会产生相同的错误。该线应该与此错误合作是这样的:

(define_expand "call_value" 
    [(set (match_operand:SI 0 "memory_operand" "") 
     (call (match_operand:SI 1 "memory_operand" "") 
     (match_operand:SI 2 "memory_operand" "")))] 
    "" 
{ 
    gcc_assert (MEM_P (operands[1])); 
})" 

但我已经改变了它的很多部分,我还没有成功。任何想法是什么导致这个错误?

+2

如果这样可以解决你的问题,但是'main'应该有一个返回类型'int',而不是'void'。使用符合标准的代码可能是一个好开始,至少 – jalf 2011-06-01 17:37:58

+0

int main只是在编译器中返回一个非特定的段错误。理想情况下,一旦我得到无效的工作,我可以弄清楚如何让int工作,但如果甚至无效的工作,那么我不知道。 – RGroppa 2011-06-01 18:50:54

回答

0

一群黑客左右后,我解决了这个问题:

(define_expand "call" 
    [(call (match_operand:SI 0 "memory_operand" "") 
     (match_operand 1 "general_operand" ""))] 
    "" 
{ 
    gcc_assert (MEM_P (operands[0])); 
}) 


(define_insn "*call" 
    [(call (mem:SI (match_operand:SI 
      0 "nonmemory_operand" "i,r")) 
    (match_operand 1 "" ""))] 
    "" 
    "@ 
    call %0 
    call %0" 
) 

简单地说,它没有找到调用指令,因为它不匹配。