cancel
Showing results for 
Search instead for 
Did you mean: 

How To Extract Input Sections From A Particular Object File

Kier
Associate III

Hello,

I'd like to create an output section called .cal_data capturing constants from a particular object file called const_params.o so I have created the following additional linker script entry based on the GNU syntax:

  .cal_data :
  {
    const_params.o(.rodata)
  } > FLASH

However, the linker (I'm using version 1.10.1) can't find the file:

ld.exe: cannot find const_params.o

Please can you help me find the correct syntax to achieve my objective.

Thank you very much.

2 REPLIES 2

Does the file exist?

Inspecting final .ELF perhaps look at objcopy, objdump, fromelf, etc.

Understand exactly what the compiler is outputting/generating..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you.

Yes the file exists albeit in sub folder.

Kier_3-1719837607670.png

This got me thinking that I need to qualify the object filename with a relative path:

 

  .cal_data :
  {
    ./ASW/ASW_Utils/const_params.o(.rodata)
  } > FLASH

 

Now the linker completes its .elf output without error. However, the cal_data output section still does not appear.

Next, I noticed there's an apparent duplication of most input section names in a typical .ld file, e.g. .data and .data*

Following the hint, I added a wildcard to .rodata even though there's no basis for doing so since the target section name (.rodata) in unambiguous.

 

  .cal_data :
  {
    ./ASW/ASW_Utils/const_params.o(.rodata*)
  } > FLASH

 

Fortunately this now triggers the correct result:

Kier_4-1719839205012.png

The implication is that only a wildcard for the input section is effective and indeed that is born out by experiment. For example, commenting out line 134 here does precisely nothing:

Kier_5-1719840263091.png

So this begs the question why the wildcard for the input section name is mandatory or, put another way, when would the line on 134 above be effective? I guess it's not critical, just curious.