0

我试图通过管道从 gcc 获取输出,但它抛出了上面的错误。命令行是gcc -pipe -c -o - -xc -. 代码通过 STDIN 输入。显然,BFD 库需要一个可搜索的描述符。有没有办法解决这个限制?

4

1 回答 1

1

Object files contain a lot of cross-references to binary offsets in various headers, and since the compiler doesn't know how large the various sections in the object file will be until it's finished writing them out, it follows that it has to go back and fill in these references after it's done writing the actual machine code. As such, most compilers will require that the object file be seekable - otherwise they would need to keep the entire file buffered in memory until they're done compiling everything!

The workaround is simply to compile to a temporary file, then cat this file into the rest of whatever pipeline you're trying to use this in.

于 2012-10-21T11:19:59.737 回答