从C到汇编
如何从我使用的C程序中获取汇编代码 我在Eclipse中使用了类似这样的东西从C到汇编,c,eclipse,assembly,C,Eclipse,Assembly,如何从我使用的C程序中获取汇编代码 我在Eclipse中使用了类似这样的东西-c-fmessage length=0-O2-S,但我遇到了一个错误,提前感谢您的帮助 现在我有了这个错误 atam.c:11: error: conflicting types for 'select' /usr/include/sys/select.h:112: error: previous declaration of 'select' was here atam.c:11: error: conflic
-c-fmessage length=0-O2-S
,但我遇到了一个错误,提前感谢您的帮助
现在我有了这个错误
atam.c:11: error: conflicting types for 'select'
/usr/include/sys/select.h:112: error: previous declaration of 'select' was here
atam.c:11: error: conflicting types for 'select'
/usr/include/sys/select.h:112: error: previous declaration of 'select' was here
这是我的职责
int select(int board[],int length,int search){
int left=0, right=length-1;
while(1){
int pivot_index=(right+left)/2;
int ordered_pivot=partition(board,left,right,pivot_index);
if(ordered_pivot==search){
return board[ordered_pivot];
}
else if(search<ordered_pivot){
right=ordered_pivot-1;
}
else{
left=ordered_pivot+1;
}
}
}
int-select(int-board[],int-length,int-search){
int left=0,right=length-1;
而(1){
int pivot_index=(右+左)/2;
int ordered_pivot=分区(板、左、右、pivot_索引);
if(有序_pivot==搜索){
返回板[ordered_pivot];
}
else if(searchEclipse仍将输出视为对象文件
gcc -O0 -g3 -Wall -c -fmessage-length=0 -O2 -S -oatam.o ..\atam.c
正在生成您想要的程序集,但由于传递给GCC的-oatam.o
(通常您会将程序集存储在atam.s
中),因此将其存储在atam.o
中会产生混淆。下一个命令:
gcc -oatam.exe atam.o
尝试链接atam.o
并生成可执行文件,但atam.o
是程序集源,而不是对象文件,因此链接器失败。您需要告诉eclipse不要运行第二个命令(并且您可能希望更改第一个命令的输出文件名)-S
指示编译器不要执行实际的编译和链接步骤,并在发出程序集后停止。另一方面,您也告诉编译器在同一行编译文件(以及其他冲突设置)
试试这个:
gcc -O0 -S ../atam.c
优化将使生成的程序集文件远离源代码,因此我指示gcc关闭优化。也不要运行链接器。发生错误,因为select是Unix系统调用,并且您的定义与相关系统标头中的声明冲突。您需要重命名您的函数。Eclipse不是C编译器,但我猜您使用的是GCC作为后端,因此,-S
应该足够了,但我到底输入了什么?@legoGCC-S..\atam.C
是您严格需要的全部;这将生成名为atam.S
的程序集文件“它不工作”没有任何帮助。从命令行运行时会出现什么错误?在查看修订历史记录之前,我完全搞不懂你在说什么;他显然编辑了问题,说了一些与原始问题完全不同的内容,然后在你回答后再次编辑,删除了大部分信息信息,包括对select()
的所有引用。我将其回滚,因为这似乎是他正在寻找的答案