我的交叉编译器总是编译同一个文件

发布于 2024-09-10 17:19:46 字数 153 浏览 1 评论 0原文

我正在测试以确保我的交叉编译器正常工作。当我编译 hello world 时,它似乎编译得很好,但是当我将 hello.cpp 更改为循环 1000 次的同一程序时,生成的 elf 文件大小完全相同。无论我进行什么更改,文件的大小始终相同,并且据我所知,具有相同的内容。什么会导致这种情况呢?

I'm testing to make sure that my cross compiler is working. When I compile hello world it seems to compile fine but when I change hello.cpp to the same program that loops 1000 times the elf file generated is exactly the same size. No matter what changes I make the file is always the same size and as far as I can tell, has the same contents. What would cause this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

顾挽 2024-09-17 17:19:46

“据我所知”是什么意思?您可以使用 diff 或其他一些实用程序进行检查。如果您在某些小型设备上使用交叉编译器,则可能有理由以指定大小的块分配输出,甚至预分配目标的设备大小。您可以使用某种工具验证您确实获得了完全相同的文件吗?

What does it mean "as far as I can tell"? You can check that with diff or some other utility. If you're using a cross-compiler to some small device, it might have a reason to allocate the output in blocks of a specified size, or even preallocate the target's device size. Can you verify with some tool that you indeed get exactly the same file?

我家小可爱 2024-09-17 17:19:46

如果没有更多细节,很难为您提供多大帮助。但这里有一些想法:

  1. 正如 Bobby 所说,您确定将正确的文件传递给它吗?

  2. 您确定您正在运行的可执行文件就是正在生成的可执行文件吗?

  3. 编译真的成功了吗?您正在运行的可执行文件可能是编译器上次成功运行的可执行文件,而不是您当前尝试编译的可执行文件。

  4. 正如 viraptor 所建议的,您绝对确定这些文件是相同的吗? diff 是否说它们是相同的?您所做的任何更改都可能会被优化 - 特别是如果您在甚至没有调用的代码中进行更改。

确实,很可能你并没有真正做你认为自己在做的事情。

  1. 确保您的编译命令 - 无论是在命令行上还是在 make 文件中或其他任何位置 - 都是正确的。

    确保

  2. 您可能应该删除可执行文件以确保实际生成新的可执行文件。

  3. 如果您专门尝试编译垃圾,请查看编译器会做什么。它不应该编译。如果是,那么您没有编译您认为正在编译的内容。

Without more details, it would be hard to help you much. But here are some ideas:

  1. As Bobby says, are you sure that you're passing the right files to it?

  2. Are you sure that the executable that you're running is the one being generated?

  3. Is the compilation actually succeeding? The executable you're running could be the one from the last successful run of the compiler rather than your current attempts to compile.

  4. As viraptor suggested, are you absolutely sure that the files are the same? Does diff say that they're the same? It's possible that whatever changes you're making are getting optimized out - especially if you're making changes in code that isn't even called.

Really, the odds are that you're not really doing what you think your doing.

  1. Make sure that your compilation commands - be they on the command-line or in a make file or whatever - are correct.

  2. You should probably delete your executable to make sure that a new one is actually being generated.

  3. See what the compiler does if you specifically try and compile junk. It shouldn't compile. If it is, then you're not compiling what you think you're compiling.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文