NOLOAD attribute

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

NOLOAD attribute

Nathan Sidwell
Whet exactly should be the behaviour of the NOLOAD section attribute in a linker
script?

I find that it doesn't inhibit an elf load segment for the region, but it does
set the file size of that segment to zero.  It also doesn't affect whether the
output section is PROGBITS or not.  Is this correct, or should it also set the
section type to NOBITS?

I attach an assembly file and linker script.  On i686-gnu-linux, the executable
has the following attributes,


Section Headers:
   [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
   [ 0]                   NULL            00000000 000000 000000 00      0   0  0
   [ 1] .progbits         PROGBITS        00010000 000074 000002 00   A  0   0  1
   [ 2] .nobits           NOBITS          00020000 000076 000002 00   A  0   0  1
   [ 3] .shstrtab         STRTAB          00000000 000076 00002d 00      0   0  1
   [ 4] .symtab           SYMTAB          00000000 000194 000060 10      5   6  4
   [ 5] .strtab           STRTAB          00000000 0001f4 000001 00      0   0  1
Key to Flags:
   W (write), A (alloc), X (execute), M (merge), S (strings)
   I (info), L (link order), G (group), x (unknown)
   O (extra OS processing required) o (OS specific), p (processor specific)

Program Headers:
   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
   LOAD           0x000000 0x00010000 0x00010000 0x00000 0x00002 R   0x1000
   LOAD           0x000000 0x00020000 0x00020000 0x00000 0x00002 R   0x1000

  Section to Segment mapping:
   Segment Sections...
    00     .progbits
    01     .nobits

*) is it correct to even create the LOAD segments?
*) is it correct for .progbits section type to be PROGBITS?

nathan
--
Nathan Sidwell    ::   http://www.codesourcery.com   ::         CodeSourcery
[hidden email]    ::     http://www.planetfall.pwp.blueyonder.co.uk


        .section ".progbits","a",@progbits
        .word 0

        .section ".nobits","a",@nobits
        .word 0


MEMORY
{
  other (w) : ORIGIN = 0, LENGTH = 0x10000
  progbits (w) : ORIGIN = 0x10000, LENGTH = 0x10000
  nobits (w) : ORIGIN = 0x20000, LENGTH = 0x10000
}
SECTIONS
{
  PROVIDE(_start = .);
  .text : { *(.text) *(.data) *(.bss) } > other
  .progbits (NOLOAD): { *(.progbits) } >progbits
  .nobits (NOLOAD): { *(.nobits) } >nobits
}
Reply | Threaded
Open this post in threaded view
|

Re: NOLOAD attribute

Ian Lance Taylor
Nathan Sidwell <[hidden email]> writes:

> Whet exactly should be the behaviour of the NOLOAD section attribute
> in a linker script?

I don't think anybody really knows.

The original meaning was that it set the STYP_NOLOAD bit for a COFF
section.  What that means in the ELF world is anybody's guess.

Ian