gpt4 book ai didi

gcc - gcc "-Xlinker"和 "-Wl,"选项之间的区别?

转载 作者:行者123 更新时间:2023-12-05 05:23:18 27 4
gpt4 key购买 nike

根据GCC 6.1 manual on Link Options :

-Wl, option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas.

-Xlinker option

Pass option as an option to the linker. You can use this to supply system-specific linker options that GCC does not recognize.

为什么我们需要其中 2 个?

加1

同样,为什么我们需要 -Xassembler-Wa 作为汇编选项?

引自 GCC 6.1 doc on Assembler Options :

-Wa,option

Pass option as an option to the assembler. If option contains commas, it is split into multiple options at the commas.

-Xassembler option

Pass option as an option to the assembler. You can use this to supply system-specific assembler options that GCC does not recognize.

最佳答案

区别在于下面的粗体字

-Wl,option

Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option. For example, -Wl,-Map,output.map passes -Map output.map to the linker. When using the GNU linker, you can also get the same effect with -Wl,-Map=output.map.

-Xlinker option

Pass option as an option to the linker. You can use this to supply system-specific linker options that GCC does not recognize. If you want to pass an option that takes a separate argument, you must use -Xlinker twice, once for the option and once for the argument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions. It does not work to write -Xlinker "-assert definitions", because this passes the entire string as a single argument, which is not what the linker expects.

When using the GNU linker, it is usually more convenient to pass arguments to linker options using the option=value syntax than as separate arguments. For example, you can specify -Xlinker -Map=output.map rather than -Xlinker -Map -Xlinker output.map. Other linkers may not support this syntax for command-line options.

由于向后兼容性,我猜 2 个类似的功能仍然存在。

关于gcc - gcc "-Xlinker"和 "-Wl,"选项之间的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38236767/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com