| Summary: | need a simple linker command file escape | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Technology] RTSC | Reporter: | Dave Russo <d-russo> | ||||
| Component: | Targets | Assignee: | Sasha Slijepcevic <sascha> | ||||
| Status: | CLOSED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P1 | CC: | mtakatz | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | target:3.21 | ||||||
| Attachments: |
|
||||||
One possibility is to add the following configs to xdc.cfg.Program
/* regexp of section names to exclude from generation */
config String excludeSects = null;
/* exclude compiler sections from linker command file generation */
config Bool excludeTargetSects = false;
This would allow the user to take _complete_ control of the sections specified with their own linker command file.
Suppose, for example, you want explicit control of the .text and .const sections. Within the program's config script, you'd add:
Program.excludeSects = "\.text|\.const";
Then you would add your own linker command file to the link step with the following content (for example):
SECTIONS {
.text:load > FLASH START(_text_load) SIZE(_text_size)
.text:run > SRAM START(_text_run)
.const: LOAD = FLASHA, PAGE 1, RUN = DSRAM, PAGE 1, LOAD_START(__C_LoadStart) RUN_START(__ConstRunStart), SIZE(__ConstSize)
}
Initial fix added to 3.21 stream. Note target linker templates need updating for this to work.
Added two config new config params to xdc.cfg.Program:
sectionsExclude: a regexp string naming sections to exclude during generation
sectionsTemplate: a template that is expanded inside SECTIONS
sectionsExclude allows users to take control of specific sections (or all sections if they specify ".*").
sectionsTemplate provides a means to easily specify the contents that should replace the sections excluded above. The template can be a file whose contents are literally copied _or_ it may contain expressions that leverage the Program object. For example, to add start/size symbols to all sections one can specify the following template:
%var sectMap = $args[0];
%for (var sn in sectMap) {
% var sym = sn.replace(/\./g, '_');
`sn`: START(`sym`_start) SIZE(`sym`_size)
%}
Using 3.21.00.22, I verified that sectionsTemplate and sectionsExclude are implemented and work as expected. The only change I would make is in the documentation for sectionsTemplate. The part that says: "This is useful especially when excluding specific sections via sectionsExclude or when taking full control of the linker command file via linkTemplate is unnecessary." leaves an impression that a user can use sectionsExclude and sectionsTemplate at the same time. However, if sectionsTemplate is specified, the whole generated content of the SECTIONS directive is removed, so the specified template must allocate all compiler sections, not only the ones removed by sectionsExclude. If the intent of the change was what the documentation hints to, then the functionality should be implemented differently. Actually you can use sectionsExclude with this parameter since the original content is computed and passed to the template as an argument which can be used to generate the new content.
Added the following clarification:
"The original
* "`SECTIONS`" content is computed and passed as an argument to this
* template, which makes it relatively simple to perform small changes to
* the "`SECTIONS`" content without having to explicitly handle every
* section required by the compiler toolchain."
Shipped in XDCtools 3.21. Shipped in XDCtools 3.21 |
Created attachment 171983 [details] thread describing problem and "heavy" solution The attached newsgroup post contains a use-case that deserves a better, "lighter weight", solution.