简体   繁体   English

强制编译器不链接到某些目标文件

[英]Force the Compiler Not to Link to Certain Object Files

I'm currently investigating the possibility to force the rvct compiler not to link in specific translation units and just pretend that it has linked it.我目前正在研究强制 rvct 编译器不链接特定翻译单元并假装它已链接它的可能性。

Our product is running very tight on space constraints and have trouble integrating some unit tests with it while keeping the space under control.我们的产品在空间限制上运行得非常紧张,并且在控制空间的同时无法将一些单元测试与其集成。

Basically, the memory we can leverage during run time is more than sufficient to store our unit tests, but we don't have sufficient rom space to hold them.基本上,我们在运行时可以利用的内存足以存储我们的单元测试,但是我们没有足够的 rom 空间来保存它们。

We have means to control exactly which segment of memory of our code goes in on our device in the scatter file, so we're thinking along the lines of defining which region the unit test codes will be located and somehow force the compiler not to link in that specific code during compile time.我们有办法在分散文件中准确控制我们代码的哪个内存段进入我们的设备,所以我们正在考虑定义单元测试代码将位于哪个区域并以某种方式强制编译器不链接在编译期间的特定代码中。

Something like the following:类似于以下内容:

Result UnitTestEntryPoint (UnitTest suite) {
   if (hasTestInMemory) {
      switch (suite) {
          case EncrpytionTest:
              return EncrptyUnitTest();
          // more tests.
      }
   }
}

// Actual Tests, can we not link this code, but just pretend we link to them?
Result EncrpyUnitTest (void) {
    // Do stuff...
}

Then during runtime, we'll upload the unit test binaries to the specified memory region that we define in the scatter file, and flip the hasTestInMemory to true .然后在运行时,我们将单元测试二进制文件上传到我们在分散文件中定义的指定内存区域,并将hasTestInMemory翻转为true

Is this possible?这可能吗?

Or if not, can someone point me to the right direction of looking for a solution that somehow meets our space constraint and able to load unit tests during run time.或者,如果没有,有人可以指出我寻找解决方案的正确方向,该解决方案以某种方式满足我们的空间限制并能够在运行时加载单元测试。

Thanks,谢谢,

You should be able to use your scatter file to place all your unit test functions into a separate load region.您应该能够使用分散文件将所有单元测试功能放入单独的加载区域。 When you link your image you'll get one AXF but when you convert it into a binary file for loading into memory you should get two files, one for each region.当您链接图像时,您将获得一个 AXF,但是当您将其转换为二进制文件以加载到内存中时,您应该获得两个文件,每个区域一个。

You can also have some marker in the unit test image that your ROM image can check for to verify that the binary is loaded.您还可以在单​​元测试映像中有一些标记,您的 ROM 映像可以检查这些标记以验证二进制文件是否已加载。 This check would replace your hadTestInMemory check in your code.此检查将替换您代码中的 hadTestInMemory 检查。 Again you should be able to place some specific RO data at the beginning of the second binary file using your scatter file.同样,您应该能够使用分散文件在第二个二进制文件的开头放置一些特定的 RO 数据。

I can probably help out with some more details as you progress.随着你的进步,我可能会提供更多细节方面的帮助。

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

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