简体   繁体   English

如何使用Cargo构建目标文件?

[英]How can I build object files with Cargo?

To build an UEFI executable, I need to build an object file from my library. 要构建UEFI可执行文件,我需要从库中构建目标文件。 I can then link it to the right PE format with pei-x86-64 subsystem 10 然后,我可以使用pei-x86-64 subsystem 10将其链接到正确的PE格式

It's probably easier to just configure Cargo to use the linker you need. 仅将Cargo配置为使用所需的链接器可能会更容易。 Create a target file, which is a blob of JSON describing the target architecture. 创建一个目标文件,它是描述目标体系结构的JSON斑点。 Something like this may work, but I cannot test it: 这样的事情可能会起作用,但我无法对其进行测试:

{
  "linker": "pei-x86-64",
  "pre-link-args": [
    "subsystem",
    "10"
  ]
}

Then, execute Cargo with cargo --target=my-target.json build . 然后,使用cargo --target=my-target.json build执行Cargo。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM