What's the “correct” way to determine target and architecture for GNU binutils?

拟墨画扇 提交于 2021-02-07 20:52:23

问题


In my build chain, I need to do this:

objcopy -I binary -O $BFDNAME -B $BFDARCH <this> <that>

in order to get a binary file into library form. Because I want other people to be able to use this, I need to know how to get $BFDNAME and $BFDARCH from their toolchain when they run the build. I can get the values locally by running objdump -f against a file I've already built, but is there a better way which won't leave me compiling throw-away files just to get configuration values?


回答1:


Thank you for pointing this out, regularfry! Your answer helped me to find another solution which works without specifying the architecture at all:

ld -r -b binary -o data.o data.txt

On my system (Ubuntu Linux, binutils 2.22) both objcopy and ld approaches produce identical object files.

All credit goes to: http://stupefydeveloper.blogspot.de/2008/08/cc-embed-binary-data-into-elf.html




回答2:


For future reference, the answer seems to be this: the first entry in the output of objdump -i is the default, native format of the system.



来源:https://stackoverflow.com/questions/5381254/whats-the-correct-way-to-determine-target-and-architecture-for-gnu-binutils

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!