- 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.2k
 
cmake: Adjust LMA for user-specified sections #68040
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -704,6 +704,23 @@ config BUILD_OUTPUT_ADJUST_LMA | |||||
| default "$(dt_chosen_reg_addr_hex,$(DT_CHOSEN_IMAGE_M4))-\ | ||||||
| $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))" | ||||||
| 
     | 
||||||
| config BUILD_OUTPUT_ADJUST_LMA_SECTIONS | ||||||
| def_string "*" | ||||||
| depends on BUILD_OUTPUT_ADJUST_LMA!="" | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
        Suggested change
       
    
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment seems to have been overlooked.  | 
||||||
| help | ||||||
| This determines the output sections to which the above LMA adjustment | ||||||
| will be applied. | ||||||
| The value can be the name of a section in the final ELF, like "text". | ||||||
| It can also be a pattern with wildcards, such as "*bss", which could | ||||||
| match more than one section name. Multiple such patterns can be given | ||||||
| as a ";"-separated list. It's possible to supply a 'negative' pattern | ||||||
| starting with "!", to exclude sections matched by a preceding pattern. | ||||||
| 
     | 
||||||
| By default, all sections will have their LMA adjusted. The following | ||||||
| example excludes one section produced by the code relocation feature: | ||||||
| config BUILD_OUTPUT_ADJUST_LMA_SECTIONS | ||||||
| default "*;!.extflash_text_reloc" | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this becomes very GNU bintools centric, something we try to abstract away in order to ease support for 3rd party toolchains. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value format is indeed GNU-centric, but I don't necessarily see this as a blocker: 
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
 I didn't say it was a blocker, but we should always be careful in such cases, and always consider if code can be made in a way which abstracts such setting in more generic way. And keeping values separated often ease later processing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. accepted for now, although this probably has to be reworked if toolchains like ARM Compiler 6 or arc metaware is going to work with this.  | 
||||||
| 
     | 
||||||
| config BUILD_OUTPUT_INFO_HEADER | ||||||
| bool "Create a image information header" | ||||||
| help | ||||||
| 
          
            
          
           | 
    ||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -41,7 +41,7 @@ set_property(TARGET bintools PROPERTY elfconvert_flag_section_remove "--remove-s | |
| set_property(TARGET bintools PROPERTY elfconvert_flag_section_only "--only-section=") | ||
| set_property(TARGET bintools PROPERTY elfconvert_flag_section_rename "--rename-section;") | ||
| 
     | 
||
| set_property(TARGET bintools PROPERTY elfconvert_flag_lma_adjust "--change-section-lma;*+") | ||
| set_property(TARGET bintools PROPERTY elfconvert_flag_lma_adjust "--change-section-lma;") | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the old property allowed to pass just the value of the adjustment to the property, thus any other bintool implementation provided by the toolchain infrastructure would have the ability to just process the value, but now such value may suddenly contain section patterns and   | 
||
| 
     | 
||
| # Note, placing a ';' at the end results in the following param to be a list, | ||
| # and hence space separated. | ||
| 
          
            
          
           | 
    ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appending
+here makes this quite GNU bintools centric, thus harder for other 3rd party toolchains to add support for this feature.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the real blocker here, now that I realize it, is the
lma_adjustflag being repeated.For GNU, this translates to:
But if a CMake wrapper were involved, then this wouldn't work at all:
One solution could be to port existing CMake wrappers to Python, and have
argparsetake care of "append" style arguments, but that's probably overkill.Another solution could be to have separate flags for
lma_adjust(number) andlma_adjust_sections(list). This would require translation on the part of a CMake wrapper for objcopy, which might be odd as well.As it stands, I'm not sure how the current toolchain abstraction scheme should handle this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you wouldn't believe the kind of tricks one can do in CMake 😉
Code:
but as this requires special CMake skills, then it's harder for others to implement such code.
Note, it's generally required to have all
-Ds before-P <script>when invoking CMake in script mode.yep, regardless of the path, it's gonna add even extra complexity on top of the complexity we already have.