diff options
author | Nicolas Pitre <nicolas.pitre@linaro.org> | 2015-06-09 23:06:29 -0400 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-06-17 08:52:00 +0930 |
commit | 451133cefa839104aa127d230436fb609dbef37f (patch) | |
tree | ed44f5a6279f32143a205119e38748759873a699 /gas/doc | |
parent | 4da680addb9f9c22f24f0294b8b9b9ca52cecd7f (diff) | |
download | binutils-451133cefa839104aa127d230436fb609dbef37f.zip binutils-451133cefa839104aa127d230436fb609dbef37f.tar.gz binutils-451133cefa839104aa127d230436fb609dbef37f.tar.bz2 |
gas: section name substitution sequence
This patch adds the ability to automatically construct a section name
based on the prior section.
When gas is invoked with --sectname-subst, the occurrence of %S in a
section name will be substituted by the name of the current section. For
example:
.macro exception_code
.pushsection %S.exception
[exception code here]
.popsection
.endm
.text
[code]
exception_code
[...]
.section .init
[init code]
exception_code
[...]
The first and second exception_code invocations create the
.text.exception and the .init.exception sections respectively. This is
useful e.g. to discriminate between anciliary sections that are tied to
.init code and can be discarded at run time when initialization is over
vs anciliary sections tied to .text sections that need to stay resident.
* as.c (show_usage): Document --sectname-subst.
(parse_args): Add --sectname-subst.
* as.h (flag_sectname_subst): New.
* config/obj-elf.c (obj_elf_section_name): Add %S substitution.
* doc/as.texinfo: Document it.
Diffstat (limited to 'gas/doc')
-rw-r--r-- | gas/doc/as.texinfo | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/gas/doc/as.texinfo b/gas/doc/as.texinfo index 5710e1c..6694b23 100644 --- a/gas/doc/as.texinfo +++ b/gas/doc/as.texinfo @@ -238,7 +238,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}. @var{objfile}] [@b{-R}] [@b{--reduce-memory-overheads}] [@b{--statistics}] [@b{-v}] [@b{-version}] [@b{--version}] [@b{-W}] [@b{--warn}] [@b{--fatal-warnings}] [@b{-w}] [@b{-x}] [@b{-Z}] [@b{@@@var{FILE}}] - [@b{--size-check=[error|warning]}] + [@b{--sectname-subst}] [@b{--size-check=[error|warning]}] [@b{--target-help}] [@var{target-options}] [@b{--}|@var{files} @dots{}] @c @@ -766,6 +766,14 @@ This option reduces GAS's memory requirements, at the expense of making the assembly processes slower. Currently this switch is a synonym for @samp{--hash-size=4051}, but in the future it may have other effects as well. +@ifset ELF +@item --sectname-subst +Honor substitution sequences in section names. +@ifclear man +@xref{Section Name Substitutions,,@code{.section @var{name}}}. +@end ifclear +@end ifset + @item --statistics Print the maximum space (in bytes) and total time (in seconds) used by assembly. @@ -6259,6 +6267,38 @@ For ELF targets, the @code{.section} directive is used like this: .section @var{name} [, "@var{flags}"[, @@@var{type}[,@var{flag_specific_arguments}]]] @end smallexample +@anchor{Section Name Substitutions} +@kindex --sectname-subst +@cindex section name substitution +If the @samp{--sectname-subst} command-line option is provided, the @var{name} +argument may contain a substitution sequence. Only @code{%S} is supported +at the moment, and substitutes the current section name. For example: + +@smallexample +.macro exception_code +.section %S.exception +[exception code here] +.previous +.endm + +.text +[code] +exception_code +[...] + +.section .init +[init code] +exception_code +[...] +@end smallexample + +The two @code{exception_code} invocations above would create the +@code{.text.exception} and @code{.init.exception} sections respectively. +This is useful e.g. to discriminate between anciliary sections that are +tied to setup code to be discarded after use from anciliary sections that +need to stay resident without having to define multiple @code{exception_code} +macros just for that purpose. + The optional @var{flags} argument is a quoted string which may contain any combination of the following characters: @table @code |