as: Symbol Names
1
1 5.3 Symbol Names
1 ================
1
1 Symbol names begin with a letter or with one of '._'. On most machines,
11 you can also use '$' in symbol names; exceptions are noted in ⇒
Machine Dependencies. That character may be followed by any string of
1 digits, letters, dollar signs (unless otherwise noted for a particular
1 target machine), and underscores.
1
1 Case of letters is significant: 'foo' is a different symbol name than
1 'Foo'.
1
1 Symbol names do not start with a digit. An exception to this rule is
1 made for Local Labels. See below.
1
1 Multibyte characters are supported. To generate a symbol name
1 containing multibyte characters enclose it within double quotes and use
1 escape codes. cf ⇒Strings. Generating a multibyte symbol name
1 from a label is not currently supported.
1
1 Each symbol has exactly one name. Each name in an assembly language
1 program refers to exactly one symbol. You may use that symbol name any
1 number of times in a program.
1
1 Local Symbol Names
1 ------------------
1
1 A local symbol is any symbol beginning with certain local label
1 prefixes. By default, the local label prefix is '.L' for ELF systems or
1 'L' for traditional a.out systems, but each target may have its own set
1 of local label prefixes. On the HPPA local symbols begin with 'L$'.
1
1 Local symbols are defined and used within the assembler, but they are
1 normally not saved in object files. Thus, they are not visible when
11 debugging. You may use the '-L' option (⇒Include Local Symbols
L.) to retain the local symbols in the object files.
1
1 Local Labels
1 ------------
1
1 Local labels are different from local symbols. Local labels help
1 compilers and programmers use names temporarily. They create symbols
1 which are guaranteed to be unique over the entire scope of the input
1 source code and which can be referred to by a simple notation. To
1 define a local label, write a label of the form 'N:' (where N represents
1 any non-negative integer). To refer to the most recent previous
1 definition of that label write 'Nb', using the same number as when you
1 defined the label. To refer to the next definition of a local label,
1 write 'Nf'. The 'b' stands for "backwards" and the 'f' stands for
1 "forwards".
1
1 There is no restriction on how you can use these labels, and you can
1 reuse them too. So that it is possible to repeatedly define the same
1 local label (using the same number 'N'), although you can only refer to
1 the most recently defined local label of that number (for a backwards
1 reference) or the next definition of a specific local label for a
1 forward reference. It is also worth noting that the first 10 local
1 labels ('0:'...'9:') are implemented in a slightly more efficient manner
1 than the others.
1
1 Here is an example:
1
1 1: branch 1f
1 2: branch 1b
1 1: branch 2f
1 2: branch 1b
1
1 Which is the equivalent of:
1
1 label_1: branch label_3
1 label_2: branch label_1
1 label_3: branch label_4
1 label_4: branch label_3
1
1 Local label names are only a notational device. They are immediately
1 transformed into more conventional symbol names before the assembler
1 uses them. The symbol names are stored in the symbol table, appear in
1 error messages, and are optionally emitted to the object file. The
1 names are constructed using these parts:
1
1 '_local label prefix_'
1 All local symbols begin with the system-specific local label
1 prefix. Normally both 'as' and 'ld' forget symbols that start with
1 the local label prefix. These labels are used for symbols you are
1 never intended to see. If you use the '-L' option then 'as'
1 retains these symbols in the object file. If you also instruct
1 'ld' to retain these symbols, you may use them in debugging.
1
1 'NUMBER'
1 This is the number that was used in the local label definition. So
1 if the label is written '55:' then the number is '55'.
1
1 'C-B'
1 This unusual character is included so you do not accidentally
1 invent a symbol of the same name. The character has ASCII value of
1 '\002' (control-B).
1
1 '_ordinal number_'
1 This is a serial number to keep the labels distinct. The first
1 definition of '0:' gets the number '1'. The 15th definition of
1 '0:' gets the number '15', and so on. Likewise the first
1 definition of '1:' gets the number '1' and its 15th definition gets
1 '15' as well.
1
1 So for example, the first '1:' may be named '.L1C-B1', and the 44th
1 '3:' may be named '.L3C-B44'.
1
1 Dollar Local Labels
1 -------------------
1
1 On some targets 'as' also supports an even more local form of local
1 labels called dollar labels. These labels go out of scope (i.e., they
1 become undefined) as soon as a non-local label is defined. Thus they
1 remain valid for only a small region of the input source code. Normal
1 local labels, by contrast, remain in scope for the entire file, or until
1 they are redefined by another occurrence of the same local label.
1
1 Dollar labels are defined in exactly the same way as ordinary local
1 labels, except that they have a dollar sign suffix to their numeric
1 value, e.g., '55$:'.
1
1 They can also be distinguished from ordinary local labels by their
1 transformed names which use ASCII character '\001' (control-A) as the
1 magic character to distinguish them from ordinary labels. For example,
1 the fifth definition of '6$' may be named '.L6'C-A'5'.
1