0

This is related to GNU linker.If I have a section which is other than .text , .data or .bss how do I tell linker not to include that section in any of those segments.

Ex:

SECTIONS {
.text {}
.data {}
.bss {}
.sec_var {}

}

Actually in my case sec_var has some global variable I dont want it to be part of data segment but by default linker has this concept of orphan section so it tries to put that section in .data. Due to this the final binary size is grown the same .

I read in the GCC linker :

You can use :NONE to tell the linker to not put the section in any segment at all. 

Anybody has used it or has any other method so that , sec_var is not placed under .data section ?

user2807984
  • 23
  • 2
  • 7

1 Answers1

0

something like this,

MEMORY
{
    bob : ORIGIN = 0x8000, LENGTH = 0x1000
    ted : ORIGIN = 0xA000, LENGTH = 0x1000
}

SECTIONS
{
   .text : { *(.text*) } > bob
   .rodata : { *(.rodata*) } > bob
   .bss : { *(.bss*) } > ted
}

I assume you dont really mean that you want .rodata in .text actually but perhaps you want .text and .rodata to be in the same chunk of memory space together...

old_timer
  • 62,459
  • 8
  • 79
  • 150