使GCC编译而不插入调用memcpy [英] Getting GCC to compile without inserting call to memcpy

查看:1075
本文介绍了使GCC编译而不插入调用memcpy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用GCC 4.5.3,为PowerPC 440编译,并编译一些不需要libc的代码。我没有对memcpy()的任何直接调用,但编译器似乎在构建期间插入一个。



有链接器选项,如-nostdlib,-nostartfiles ,-nodefaultlibs,但我无法使用它们,因为我不是在链接阶段。我只是编译。用这样的:

  $ powerpc-440-eabi-gcc -O2 -g -c -o output.o input。 c 

如果我用nm检查output.o,我看到memcpy的引用:

  $ powerpc-440-eabi-nm output.o | grep memcpy 
U memcpy
$

GCC手册页删除调用memcpy和其他libc调用与链接器,但我不想让编译器插入他们在第一位,因为我使用一个完全不同的链接器(不是GNU的ld,它不知道感谢您提供任何帮助。

解决方案

>您需要使用-fno-builtin禁用该优化。我有一个问题,当试图编译memcpy的C库。它自称。糟糕!


I'm currently using GCC 4.5.3, compiled for PowerPC 440, and am compiling some code that doesn't require libc. I don't have any direct calls to memcpy(), but the compiler seems to be inserting one during the build.

There are linker options like -nostdlib, -nostartfiles, -nodefaultlibs but I'm unable to use them as I'm not doing the linking phase. I'm only compiling. With something like this:

$ powerpc-440-eabi-gcc -O2 -g -c -o output.o input.c

If I check the output.o with nm, I see a reference to memcpy:

$ powerpc-440-eabi-nm output.o | grep memcpy
     U memcpy
$ 

The GCC man page makes it clear how to remove calls to memcpy and other libc calls with the linker, but I don't want the compiler to insert them in the first place, as I'm using a completely different linker (not GNU's ld, and it doesn't know about libc).

Thanks for any help you can provide.

解决方案

You need to disable a that optimization with -fno-builtin. I had this problem once when trying to compile memcpy for a C library. It called itself. Oops!

这篇关于使GCC编译而不插入调用memcpy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆