0

How to put all object files into a section? For example, i have a.obj b.obj c.obj and main.obj. where a``b``care in a static library lib.lib.

Now my linker script is like this:

 MYSECTION 0x1800000:
  {
  a*(*);
  b*(*);
  c*(*);
  main*(*);
 }

But I want to use library name in the input section, how to do it?

 MYSECTION 0x1800000:
  {
  lib.lib:*(*);
  main*(*);
  }

is not valid.

demonguy
  • 1,977
  • 5
  • 22
  • 34
  • 1
    Not clear what you want to do. An object file typically has multiple sections and you definitively don't want them all to be merged into a single one. And libraries are collections of multiple objects. And that depends on the linker, not gcc, which is the compiler/frontend. – too honest for this site Mar 14 '17 at 01:59
  • Yes, I do. Because my embedded board have limit memory, i have to adjust their section into different address – demonguy Mar 14 '17 at 02:01
  • You seem to have a missconception what sections are, how they are used. You typically have multiple sections in an object file as you have multiple memory areas in your device. That is not a matter of "limited memory". Did you even had a look at the object file's structure? Maybe you should first read the documentation about your toolchain. That should also include the syntax of the linker-control file. – too honest for this site Mar 14 '17 at 02:06
  • It's hard to explain, i can't put all `.text` into a continuous memory, it's limit by some features of my board and it's out of my control. And it's not related to my issue. You can replace all `(*)` of `(.text)` in my example if you want – demonguy Mar 14 '17 at 02:07
  • That contradicts what you write in your question. And there is not only a `.text` section. That is not even the only generated by gcc you want to put into Flash/ROM – too honest for this site Mar 14 '17 at 02:09
  • It's just part of my linker script. What i want is use library name instead of object file name – demonguy Mar 14 '17 at 02:24

0 Answers0