This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to explicitly place input section at the end of output section without generating warning

Hello.

I would like to place the input section from a certain object file at the end of a output section. 

At the moment the relevant part of my linker script looks like this:

calib_ram :

{

 *(calib_ram)                                                               (line 87)
source\sys_main.obj (calib_ram)                           (line 88)

} > RAM, RUN_START(CALIBRAM_START_ADDR), SIZE(CALIBRAM_SIZE)

This does what I want by placing the calib_ram section in sys_main.obj at the end of the output section. But it produces the following warning:

line 88: warning #10261-D: section specifier matches no sections; potential matches are consumed by section specifier at "../source/sys_link.cmd", line 87 

I understand and appreciate why the linker  complains about this. So if I could rephrase this question: does a linker command exist that will search all object files except sys_main.obj?

This is using TMS570 with TI ARM compiler.

Many thanks,

James.

  • Yes, you could enumerate all of the other files rather than use a wildcard, or you could use partial filenames:
    source\a*.obj(calib_ram)
    source\b*.obj(calib_ram)
    source\c*.obj(calib_ram)
    I'm not sure if there is a more direct way, I'd have to think about it.
  • The easiest way I can think of to do this is to put your data in subsections like calib_ram:early, with one of them being calib_ram:last, and then write the linker command file like so:
    calib_ram :
    {
    *(calib_ram:early)
    *(calib_ram:late)
    } > RAM, RUN_START(CALIBRAM_START_ADDR), SIZE(CALIBRAM_SIZE)
  • Yes this makes sense and is practical. Thank you for your help!
  • In addition to the good suggestion from archaeologist, you can modify your original example as follows:

    calib_ram :
    {
        *(calib_ram*)                                                               (line 87)
        source\sys_main.obj (calib_ram)                           (line 88)
    } > RAM, RUN_START(CALIBRAM_START_ADDR), SIZE(CALIBRAM_SIZE)

    The addition is the wildcard '*' as part of the section name on line 87.

    The reason that works is that when the linker matches input sections to patterns, it tries the most restrictive section name patterns first. In this case the pattern 'calib_ram' is more restrictive than 'calib_ram*', so it's tried first. The calib_ram section from sys_main.obj is the only one that matches the filename part of the pattern. The result is that sys_main.obj(calib_ram) matches line 88 and all the other calib_rams match line 87, which I think is what you want.

    In considering restrictiveness, only the section name part of the pattern is used, not the filename. I can't explain why that is, but at least for your purpose what I've described should work.