Update the description of the linker script's TYPE directive.

PR 29861
	* ld.texi (Output Section Type): Note that setting the output
	section type only works if the section contains untyped data.
This commit is contained in:
Nick Clifton
2022-12-08 13:06:31 +00:00
parent 05a1f6468e
commit dcb53d93eb
2 changed files with 30 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2022-12-08 Nick Clifton <nickc@redhat.com>
PR 29861
* ld.texi (Output Section Type): Note that setting the output
section type only works if the section contains untyped data.
2022-12-05 Nick Clifton <nickc@redhat.com> 2022-12-05 Nick Clifton <nickc@redhat.com>
PR 29849 PR 29849

View File

@ -5548,11 +5548,14 @@ Each output section may have a type. The type is a keyword in
parentheses. The following types are defined: parentheses. The following types are defined:
@table @code @table @code
@item NOLOAD @item NOLOAD
The section should be marked as not loadable, so that it will not be The section should be marked as not loadable, so that it will not be
loaded into memory when the program is run. loaded into memory when the program is run.
@item READONLY @item READONLY
The section should be marked as read-only. The section should be marked as read-only.
@item DSECT @item DSECT
@item COPY @item COPY
@item INFO @item INFO
@ -5561,6 +5564,7 @@ These type names are supported for backward compatibility, and are
rarely used. They all have the same effect: the section should be rarely used. They all have the same effect: the section should be
marked as not allocatable, so that no memory is allocated for the marked as not allocatable, so that no memory is allocated for the
section when the program is run. section when the program is run.
@item TYPE = @var{type} @item TYPE = @var{type}
Set the section type to the integer @var{type}. When generating an ELF Set the section type to the integer @var{type}. When generating an ELF
output file, type names @code{SHT_PROGBITS}, @code{SHT_STRTAB}, output file, type names @code{SHT_PROGBITS}, @code{SHT_STRTAB},
@ -5568,9 +5572,29 @@ output file, type names @code{SHT_PROGBITS}, @code{SHT_STRTAB},
@code{SHT_FINI_ARRAY}, and @code{SHT_PREINIT_ARRAY} are also allowed @code{SHT_FINI_ARRAY}, and @code{SHT_PREINIT_ARRAY} are also allowed
for @var{type}. It is the user's responsibility to ensure that any for @var{type}. It is the user's responsibility to ensure that any
special requirements of the section type are met. special requirements of the section type are met.
Note - the TYPE only is used if some or all of the contents of the
section do not have an implicit type of their own. So for example:
@smallexample
.foo . TYPE = SHT_PROGBITS @{ *(.bar) @}
@end smallexample
will set the type of section @samp{.foo} to the type of the section
@samp{.bar} in the input files, which may not be the SHT_PROGBITS
type. Whereas:
@smallexample
.foo . TYPE = SHT_PROGBITS @{ BYTE(1) @}
@end smallexample
will set the type of @samp{.foo} to SHT_PROGBBITS. If it is necessary
to override the type of incoming sections and force the output section
type then an extra piece of untyped data will be needed:
@smallexample
.foo . TYPE = SHT_PROGBITS @{ BYTE(1); *(.bar) @}
@end smallexample
@item READONLY ( TYPE = @var{type} ) @item READONLY ( TYPE = @var{type} )
This form of the syntax combines the @var{READONLY} type with the This form of the syntax combines the @var{READONLY} type with the
type specified by @var{type}. type specified by @var{type}.
@end table @end table
@kindex NOLOAD @kindex NOLOAD