This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: means of .previous directive
- To: qiaogp at krdl dot org dot sg
- Subject: Re: means of .previous directive
- From: Nick Clifton <nickc at cygnus dot com>
- Date: Fri, 4 Aug 2000 13:38:03 -0700
- CC: binutils at sourceware dot cygnus dot com
Hi Guopei,
I hope that Alan's explanation helped you.
Since you pointed out that this directive was not documented in the
GAS sources I took a look, and sure enough you were right. As it
turns out several other ELF directives were not documented either,
so I am going to check in the following patch to update the
documentation.
Cheers
Nick
2000-08-04 Nick Clifton <nickc@cygnus.com>
* doc/as.texinfo (Pseudo Ops): Update to include descriptions
of .popsection, .previous, .pushsection, .subsection,
.version, .vtable_entry, .vtable_inherit and .weak.
Index: gas/doc/as.texinfo
===================================================================
RCS file: /cvs/src//src/gas/doc/as.texinfo,v
retrieving revision 1.16
diff -p -r1.16 as.texinfo
*** as.texinfo 2000/08/01 01:57:46 1.16
--- as.texinfo 2000/08/04 20:28:13
*************** Some machine configurations provide addi
*** 3181,3187 ****
@ifset COFF
* ABORT:: @code{.ABORT}
@end ifset
-
* Align:: @code{.align @var{abs-expr} , @var{abs-expr}}
* Ascii:: @code{.ascii "@var{string}"}@dots{}
* Asciz:: @code{.asciz "@var{string}"}@dots{}
--- 3181,3186 ----
*************** Some machine configurations provide addi
*** 3198,3204 ****
@ifset COFF
* Dim:: @code{.dim}
@end ifset
-
* Double:: @code{.double @var{flonums}}
* Eject:: @code{.eject}
* Else:: @code{.else}
--- 3197,3202 ----
*************** Some machine configurations provide addi
*** 3207,3213 ****
@ifset COFF
* Endef:: @code{.endef}
@end ifset
-
* Endfunc:: @code{.endfunc}
* Endif:: @code{.endif}
* Equ:: @code{.equ @var{symbol}, @var{expression}}
--- 3205,3210 ----
*************** Some machine configurations provide addi
*** 3219,3234 ****
@ifclear no-file-dir
* File:: @code{.file @var{string}}
@end ifclear
-
* Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
* Float:: @code{.float @var{flonums}}
* Func:: @code{.func}
* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
* hword:: @code{.hword @var{expressions}}
* Ident:: @code{.ident}
* If:: @code{.if @var{absolute expression}}
* Include:: @code{.include "@var{file}"}
* Int:: @code{.int @var{expressions}}
* Irp:: @code{.irp @var{symbol},@var{values}}@dots{}
* Irpc:: @code{.irpc @var{symbol},@var{values}}@dots{}
* Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
--- 3216,3236 ----
@ifclear no-file-dir
* File:: @code{.file @var{string}}
@end ifclear
* Fill:: @code{.fill @var{repeat} , @var{size} , @var{value}}
* Float:: @code{.float @var{flonums}}
* Func:: @code{.func}
* Global:: @code{.global @var{symbol}}, @code{.globl @var{symbol}}
+ @ifset ELF
+ * Hidden:: @code{.hidden @var{names}}
+ @end ifset
* hword:: @code{.hword @var{expressions}}
* Ident:: @code{.ident}
* If:: @code{.if @var{absolute expression}}
* Include:: @code{.include "@var{file}"}
* Int:: @code{.int @var{expressions}}
+ @ifset ELF
+ * Internal:: @code{.internal @var{names}}
+ @end ifset
* Irp:: @code{.irp @var{symbol},@var{values}}@dots{}
* Irpc:: @code{.irpc @var{symbol},@var{values}}@dots{}
* Lcomm:: @code{.lcomm @var{symbol} , @var{length}}
*************** Some machine configurations provide addi
*** 3236,3242 ****
@ifclear no-line-dir
* Line:: @code{.line @var{line-number}}
@end ifclear
-
* Ln:: @code{.ln @var{line-number}}
* Linkonce:: @code{.linkonce [@var{type}]}
* List:: @code{.list}
--- 3238,3243 ----
*************** Some machine configurations provide addi
*** 3244,3260 ****
@ignore
* Lsym:: @code{.lsym @var{symbol}, @var{expression}}
@end ignore
-
* Macro:: @code{.macro @var{name} @var{args}}@dots{}
* MRI:: @code{.mri @var{val}}
-
* Nolist:: @code{.nolist}
* Octa:: @code{.octa @var{bignums}}
* Org:: @code{.org @var{new-lc} , @var{fill}}
* P2align:: @code{.p2align @var{abs-expr} , @var{abs-expr}}
* Print:: @code{.print @var{string}}
* Psize:: @code{.psize @var{lines}, @var{columns}}
* Purgem:: @code{.purgem @var{name}}
* Quad:: @code{.quad @var{bignums}}
* Rept:: @code{.rept @var{count}}
* Sbttl:: @code{.sbttl "@var{subheading}"}
--- 3245,3269 ----
@ignore
* Lsym:: @code{.lsym @var{symbol}, @var{expression}}
@end ignore
* Macro:: @code{.macro @var{name} @var{args}}@dots{}
* MRI:: @code{.mri @var{val}}
* Nolist:: @code{.nolist}
* Octa:: @code{.octa @var{bignums}}
* Org:: @code{.org @var{new-lc} , @var{fill}}
* P2align:: @code{.p2align @var{abs-expr} , @var{abs-expr}}
+ @ifset ELF
+ * PopSection:: @code{.popsection}
+ * Previous:: @code{.previous}
+ @end ifset
* Print:: @code{.print @var{string}}
+ @ifset ELF
+ * Protected:: @code{.protected @var{names}}
+ @end ifset
* Psize:: @code{.psize @var{lines}, @var{columns}}
* Purgem:: @code{.purgem @var{name}}
+ @ifset ELF
+ * PushSection:: @code{.pushsection @var{name}}
+ @end ifset
* Quad:: @code{.quad @var{bignums}}
* Rept:: @code{.rept @var{count}}
* Sbttl:: @code{.sbttl "@var{subheading}"}
*************** Some machine configurations provide addi
*** 3262,3306 ****
* Scl:: @code{.scl @var{class}}
* Section:: @code{.section @var{name}, @var{subsection}}
@end ifset
-
* Set:: @code{.set @var{symbol}, @var{expression}}
* Short:: @code{.short @var{expressions}}
* Single:: @code{.single @var{flonums}}
! @ifset COFF
! * Size:: @code{.size}
! @end ifset
!
* Skip:: @code{.skip @var{size} , @var{fill}}
* Sleb128:: @code{.sleb128 @var{expressions}}
* Space:: @code{.space @var{size} , @var{fill}}
@ifset have-stabs
* Stab:: @code{.stabd, .stabn, .stabs}
@end ifset
-
* String:: @code{.string "@var{str}"}
* Struct:: @code{.struct @var{expression}}
@ifset ELF
* Symver:: @code{.symver @var{name},@var{name2@@nodename}}
@end ifset
@ifset COFF
* Tag:: @code{.tag @var{structname}}
@end ifset
-
* Text:: @code{.text @var{subsection}}
* Title:: @code{.title "@var{heading}"}
@ifset COFF
- * Type:: @code{.type @var{int}}
* Val:: @code{.val @var{addr}}
@end ifset
@ifset ELF
! * Visibility:: @code{.internal @var{name}, .hidden @var{name}, .protected @var{name}}
@end ifset
!
! * Uleb128:: @code{.uleb128 @var{expressions}}
* Word:: @code{.word @var{expressions}}
* Deprecated:: Deprecated Directives
@end menu
@node Abort
@section @code{.abort}
--- 3271,3317 ----
* Scl:: @code{.scl @var{class}}
* Section:: @code{.section @var{name}, @var{subsection}}
@end ifset
* Set:: @code{.set @var{symbol}, @var{expression}}
* Short:: @code{.short @var{expressions}}
* Single:: @code{.single @var{flonums}}
! * Size:: @code{.size [@var{name} , @var{expression}]}
* Skip:: @code{.skip @var{size} , @var{fill}}
* Sleb128:: @code{.sleb128 @var{expressions}}
* Space:: @code{.space @var{size} , @var{fill}}
@ifset have-stabs
* Stab:: @code{.stabd, .stabn, .stabs}
@end ifset
* String:: @code{.string "@var{str}"}
* Struct:: @code{.struct @var{expression}}
@ifset ELF
+ * SubSection:: @code{.subsection}
* Symver:: @code{.symver @var{name},@var{name2@@nodename}}
@end ifset
@ifset COFF
* Tag:: @code{.tag @var{structname}}
@end ifset
* Text:: @code{.text @var{subsection}}
* Title:: @code{.title "@var{heading}"}
+ * Type:: @code{.type <@var{int} | @var{name} , @var{type description}>}
+ * Uleb128:: @code{.uleb128 @var{expressions}}
@ifset COFF
* Val:: @code{.val @var{addr}}
@end ifset
@ifset ELF
! * Version:: @code{.version "@var{string}"}
@end ifset
! @ifset ELF
! * VTableEntry:: @code{.vtable_entry @var{table}, @var{offset}}
! * VTableInherit:: @code{.vtable_inherit @var{child}, @var{parent}}
! @end ifset
! @ifset ELF
! * Weak:: @code{.weak @var{names}}
! @end ifset
* Word:: @code{.word @var{expressions}}
* Deprecated:: Deprecated Directives
@end menu
+
@node Abort
@section @code{.abort}
*************** partial programs. You may need the HPPA
*** 3754,3759 ****
--- 3765,3785 ----
@xref{HPPA Directives,, HPPA Assembler Directives}.
@end ifset
+ @ifset ELF
+ @node Hidden
+ @section @code{.hidden @var{names}}
+
+ @cindex @code{.hidden} directive
+ @cindex Visibility
+ This one of the ELF visibility directives. The other two are
+ @pxref{Internal,,@code{.internal}} and @pxref{Protected,,@code{.protected}}
+
+ This directive overrides the named symbols default visibility (which is set by
+ their binding: local, global or weak). The directive sets the visibility to
+ @code{hidden} which means that the symbols are not visible to other components.
+ Such symbols are always considered to be @code{protected} as well.
+ @end ifset
+
@node hword
@section @code{.hword @var{expressions}}
*************** integers. On the H8/300H and the Hitach
*** 3896,3901 ****
--- 3922,3943 ----
@end ifset
@end ifclear
+ @ifset ELF
+ @node Internal
+ @section @code{.internal @var{names}}
+
+ @cindex @code{.internal} directive
+ @cindex Visibility
+ This one of the ELF visibility directives. The other two are
+ @pxref{Hidden,,@code{.hidden}} and @pxref{Protected,,@code{.protected}}
+
+ This directive overrides the named symbols default visibility (which is set by
+ their binding: local, global or weak). The directive sets the visibility to
+ @code{internal} which means that the symbols are considered to be @code{hidden}
+ (ie not visible to other components), and that some extra, processor specific
+ processing must also be performed upon the symbols as well.
+ @end ifset
+
@node Irp
@section @code{.irp @var{symbol},@var{values}}@dots{}
*************** filled in with the value 0x368d (the exa
*** 4323,4328 ****
--- 4365,4405 ----
the endianness of the processor). If it skips 1 or 3 bytes, the fill value is
undefined.
+ @ifset ELF
+ @node Previous
+ @section @code{.previous}
+
+ @cindex @code{.previous} directive
+ @cindex Section Stack
+ This is one of the ELF section stack manipulation directives. The others are
+ @pxref{Section}, @xref{SubSection}, @pxref{PushSection}, and
+ @pxref{PopSection}.
+
+ This directive swaps the current section (and subsection) with most recently
+ referenced section (and subsection) prior to this one. Multiple
+ @code{.previous} directives in a row will flip between two sections (and their
+ subsections).
+
+ In terms of the section stack, this directive swaps the current section with
+ the top section on the section stack.
+ @end ifset
+
+ @ifset ELF
+ @node PopSection
+ @section @code{.popsection}
+
+ @cindex @code{.popsection} directive
+ @cindex Section Stack
+ This is one of the ELF section stack manipulation directives. The others are
+ @pxref{Section}, @xref{SubSection}, @pxref{PushSection}, and
+ @pxref{Previous}.
+
+ This directive replaces the current section (and subsection) with the top
+ section (and subsection) on the section stack. This section is popped off the
+ stack.
+
+ @end ifset
+
@node Print
@section @code{.print @var{string}}
*************** undefined.
*** 4330,4335 ****
--- 4407,4429 ----
@code{@value{AS}} will print @var{string} on the standard output during
assembly. You must put @var{string} in double quotes.
+ @ifset ELF
+ @node Protected
+ @section @code{.protected @var{names}}
+
+ @cindex @code{.protected} directive
+ @cindex Visibility
+ This one of the ELF visibility directives. The other two are
+ @pxref{Hidden} and @pxref{Internal}
+
+ This directive overrides the named symbols default visibility (which is set by
+ their binding: local, global or weak). The directive sets the visibility to
+ @code{protected} which means that any references to the symbols from within the
+ components that defines them must be resolved to the definition in that
+ component, even if a definition in another component would normally preempt
+ this.
+ @end ifset
+
@node Psize
@section @code{.psize @var{lines} , @var{columns}}
*************** those explicitly specified with @code{.e
*** 4357,4362 ****
--- 4451,4472 ----
Undefine the macro @var{name}, so that later uses of the string will not be
expanded. @xref{Macro}.
+ @ifset ELF
+ @node PushSection
+ @section @code{.pushsection @var{name} , @var{subsection}}
+
+ @cindex @code{.pushsection} directive
+ @cindex Section Stack
+ This is one of the ELF section stack manipulation directives. The others are
+ @pxref{Section}, @xref{SubSection}, @pxref{PopSection}, and
+ @pxref{Previous}.
+
+ This directive is a synonym for @code{.section}. It psuhes the current section
+ (and subsection) onto the top of the section stack, and then replaces the
+ current section and subsection with @code{name} and @code{subsection}.
+
+ @end ifset
+
@node Quad
@section @code{.quad @var{bignums}}
*************** accepts this directive but ignores it.
*** 4434,4440 ****
@end ifset
@node Section
! @section @code{.section @var{name}}
@cindex @code{section} directive
@cindex named section
--- 4544,4550 ----
@end ifset
@node Section
! @section @code{.section @var{name}} (COFF version)
@cindex @code{section} directive
@cindex named section
*************** This directive is only supported for tar
*** 4445,4453 ****
named sections; on @code{a.out} targets, for example, it is not accepted, even
with a standard @code{a.out} section name.
- @ifset COFF
For COFF targets, the @code{.section} directive is used in one of the following
ways:
@smallexample
.section @var{name}[, "@var{flags}"]
.section @var{name}[, @var{subsegment}]
--- 4555,4563 ----
named sections; on @code{a.out} targets, for example, it is not accepted, even
with a standard @code{a.out} section name.
For COFF targets, the @code{.section} directive is used in one of the following
ways:
+
@smallexample
.section @var{name}[, "@var{flags}"]
.section @var{name}[, @var{subsegment}]
*************** loaded and writable.
*** 4478,4490 ****
If the optional argument to the @code{.section} directive is not quoted, it is
taken as a subsegment number (@pxref{Sub-Sections}).
- @end ifset
@ifset ELF
For ELF targets, the @code{.section} directive is used like this:
@smallexample
! .section @var{name}[, "@var{flags}"[, @@@var{type}]]
@end smallexample
The optional @var{flags} argument is a quoted string which may contain any
combintion of the following characters:
@table @code
--- 4588,4612 ----
If the optional argument to the @code{.section} directive is not quoted, it is
taken as a subsegment number (@pxref{Sub-Sections}).
+
+ @section @code{.section @var{name}} (ELF version)
+
+ @cindex @code{section} directive
+ @cindex named section
@ifset ELF
+ @cindex Section Stack
+ This is one of the ELF section stack manipulation directives. The others are
+ @xref{SubSection}, @pxref{PushSection}@pxref{PopSection}, and
+ @pxref{Previous}.
+ @end ifset
+
For ELF targets, the @code{.section} directive is used like this:
+
@smallexample
! .section @var{name} [, "@var{flags}"[, @@@var{type}]]
@end smallexample
+
The optional @var{flags} argument is a quoted string which may contain any
combintion of the following characters:
@table @code
*************** executable. The section will contain da
*** 4511,4519 ****
--- 4633,4643 ----
For ELF targets, the assembler supports another type of @code{.section}
directive for compatibility with the Solaris assembler:
+
@smallexample
.section "@var{name}"[, @var{flags}...]
@end smallexample
+
Note that the section name is quoted. There may be a sequence of comma
separated flags:
@table @code
*************** section is writable
*** 4524,4531 ****
@item #execinstr
section is executable
@end table
- @end ifset
@node Set
@section @code{.set @var{symbol}, @var{expression}}
--- 4648,4659 ----
@item #execinstr
section is executable
@end table
+ This directive replaces the current section and subsection. The replaced
+ section and subsection are pushed onto the section stack. See the contents of
+ the gas testsuite directory @code{gas/testsuite/gas/elf} for some examples of
+ how this directive and the other section stack directives work.
+
@node Set
@section @code{.set @var{symbol}, @var{expression}}
*************** numbers in @sc{ieee} format.
*** 4585,4606 ****
@end ifset
@end ifclear
- @ifset COFF
@node Size
! @section @code{.size}
!
@cindex @code{size} directive
This directive is generated by compilers to include auxiliary debugging
information in the symbol table. It is only permitted inside
@code{.def}/@code{.endef} pairs.
- @ifset BOUT
@samp{.size} is only meaningful when generating COFF format output; when
@code{@value{AS}} is generating @code{b.out}, it accepts this directive but
ignores it.
@end ifset
- @end ifset
@node Sleb128
@section @code{.sleb128 @var{expressions}}
--- 4713,4740 ----
@end ifset
@end ifclear
@node Size
! @section @code{.size} (COFF version)
@cindex @code{size} directive
+
This directive is generated by compilers to include auxiliary debugging
information in the symbol table. It is only permitted inside
@code{.def}/@code{.endef} pairs.
+ @ifset BOUT
@samp{.size} is only meaningful when generating COFF format output; when
@code{@value{AS}} is generating @code{b.out}, it accepts this directive but
ignores it.
@end ifset
+ @section @code{.size @var{name} , @var{expression}} (ELF version)
+ @cindex @code{size} directive
+
+ This directive is used to set the size associated with a symbol @var{name}.
+ The size in bytes is computed from @var{expression} which can make use of label
+ arithmetic. This directive is typically used to set the size of function
+ symbols.
+
@node Sleb128
@section @code{.sleb128 @var{expressions}}
*************** value 8. Assembly would be left in the
*** 4753,4759 ****
--- 4887,4911 ----
use a @code{.section} directive of some sort to change to some other section
before further assembly.
+
@ifset ELF
+ @node SubSection
+ @section @code{.subsection @var{name}}
+
+ @cindex @code{.subsection} directive
+ @cindex Section Stack
+ This is one of the ELF section stack manipulation directives. The others are
+ @pxref{Section}, @xref{PushSection}, @pxref{PopSection}, and
+ @pxref{Previous}.
+
+ This directive replaces the current subsection with @code{name}. The current
+ section is not changed. The replaced subsection is put onto the section stack
+ in place of the then current top of stack subsection.
+
+ @end ifset
+
+
+ @ifset ELF
@node Symver
@section @code{.symver}
@cindex @code{symver} directive
*************** source file name and pagenumber) when ge
*** 4825,4846 ****
This directive affects subsequent pages, as well as the current page if
it appears within ten lines of the top of a page.
- @ifset COFF
@node Type
! @section @code{.type @var{int}}
@cindex COFF symbol type
@cindex symbol type, COFF
@cindex @code{type} directive
This directive, permitted only within @code{.def}/@code{.endef} pairs,
records the integer @var{int} as the type attribute of a symbol table entry.
- @ifset BOUT
@samp{.type} is associated only with COFF format output; when
@code{@value{AS}} is configured for @code{b.out} output, it accepts this
directive but ignores it.
@end ifset
! @end ifset
@ifset COFF
@node Val
--- 4977,5031 ----
This directive affects subsequent pages, as well as the current page if
it appears within ten lines of the top of a page.
@node Type
! @section @code{.type @var{int}} (COFF version)
@cindex COFF symbol type
@cindex symbol type, COFF
@cindex @code{type} directive
This directive, permitted only within @code{.def}/@code{.endef} pairs,
records the integer @var{int} as the type attribute of a symbol table entry.
+ @ifset BOUT
@samp{.type} is associated only with COFF format output; when
@code{@value{AS}} is configured for @code{b.out} output, it accepts this
directive but ignores it.
@end ifset
!
! @section @code{.type @var{name} , @var{type description}} (ELF version)
!
! @cindex ELF symbol type
! @cindex symbol type, ELF
! @cindex @code{type} directive
! This directive is used to set the type of symbol @var{name} to be either a
! function symbol or an ojbect symbol. There are five different syntaxes
! supported for the @var{type description} field, in order to provide
! comptability with various other assemblers. The syntaxes supported are:
!
! @smallexample
! .type <name>,#function
! .type <name>,#object
!
! .type <name>,@@function
! .type <name>,@@object
!
! .type <name>,%function
! .type <name>,%object
!
! .type <name>,"function"
! .type <name>,"object"
!
! .type <name> STT_FUNCTION
! .type <name> STT_OBJECT
! @end smallexample
!
! @node Uleb128
! @section @code{.uleb128 @var{expressions}}
!
! @cindex @code{uleb128} directive
! @var{uleb128} stands for ``unsigned little endian base 128.'' This is a
! compact, variable length representation of numbers used by the DWARF
! symbolic debugging format. @xref{Sleb128,@code{.sleb128}}.
@ifset COFF
@node Val
*************** configured for @code{b.out}, it accepts
*** 4859,4904 ****
@end ifset
@end ifset
! @node Uleb128
! @section @code{.uleb128 @var{expressions}}
! @cindex @code{uleb128} directive
! @var{uleb128} stands for ``unsigned little endian base 128.'' This is a
! compact, variable length representation of numbers used by the DWARF
! symbolic debugging format. @xref{Sleb128,@code{.sleb128}}.
@ifset ELF
! @node Visibility
! @section @code{.internal}, @code{.hidden}, @code{.protected}
! @cindex @code{internal} directive
! @cindex @code{hidden} directive
! @cindex @code{protected} directive
! @cindex symbol visibility
!
! These directives can be used to set the visibility of a specified symbol. By
! default a symbol's visibility is set by its binding (local, global or weak),
! but these directives can be used to override that.
!
! A visibility of @code{protected} means that any references to the symbol from
! within the component that defines the symbol must be resolved to the definition
! in that component, even if a definition in another component would normally
! preempt this.
!
! A visibility of @code{hidden} means that the symbol is not visible to other
! components. Such a symbol is always considered to be protected as well.
!
! A visibility of @code{internal} is the same as a visibility of @code{hidden},
! except that some extra, processor specific processing must also be performed
! upon the symbol.
! For ELF targets, the directives are used like this:
! @smallexample
! .internal @var{name}
! .hidden @var{name}
! .protected @var{name}
! @end smallexample
@end ifset
@node Word
--- 5044,5083 ----
@end ifset
@end ifset
! @ifset ELF
! @node Version
! @section @code{.version "@var{string}"}
! @cindex @code{.version}
! This directive creates a @code{.note} section and places into it an ELF
! formatted note of type NT_VERSION. The note's name is set to @code{string}.
! @end ifset
@ifset ELF
! @node VTableEntry
! @section @code{.vtable_entry @var{table}, @var{offset}}
! @cindex @code{.vtable_entry}
! This directive finds or creates a symbol @code{table} and creates a
! @code{VTABLE_ENTRY} relocation for it with an addend of @code{offset}.
!
! @node VTableInherit
! @section @code{.vtable_inherit @var{child}, @var{parent}}
!
! @cindex @code{.vtable_inherit}
! This directive finds the symbol @code{child} and finds or creates the symbol
! @code{parent} and then creates a @code{VTABLE_INHERIT} relocation for the
! parent whoes addend is the value of the child symbol. As a special case the
! parent name of @code{0} is treated as refering the @code{*ABS*} section.
! @end ifset
! @ifset ELF
! @node Weak
! @section @code{.weak @var{names}}
+ @cindex @code{.weak}
+ This directive sets the weak attribute on the comma seperated list of symbol
+ @code{names}. If the symbols do not already exist, they will be created.
@end ifset
@node Word