how to set .bss section type to PROGBITS within linker script

Michael Matz matz@suse.de
Tue Sep 29 13:34:29 GMT 2020


Hello,

On Mon, 28 Sep 2020, H.J. Lu via Binutils wrote:

> On Mon, Sep 28, 2020 at 7:38 AM William Tambe via Binutils
> <binutils@sourceware.org> wrote:
> >
> > Is there a way to set .bss section type to PROGBITS within a linker script ?
> 
> By definition, a .bss output section is NOBITS.  You can't make a NOBITS
> output section PROGBITS.

Well, technically you can make all input .bss sections be part of output 
.data, and get the above effect:

...
SECTIONS {
  ...
  .data
  {
    *(.data .data.* .gnu.linkonce.d.*)
    *(.bss .bss.* .gnu.linkonce.b.*)
    SORT(CONSTRUCTORS)
  }
  ...
}

(Of course the side-effect will be that there's no output .bss anymore, so 
if you really want to have the output .bss be SHT_PROGBITS, then H.J. is 
right).


Ciao,
Michael.


More information about the Binutils mailing list