[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1.1 Symbols

The definition for the symbol structure, symbolS, is located in `struc-symbol.h'.

In general, the fields of this structure may not be referred to directly. Instead, you must use one of the accessor functions defined in `symbol.h'. These accessor functions should work for any GAS version.

Symbol structures contain the following fields:

sy_value
This is an expressionS that describes the value of the symbol. It might refer to one or more other symbols; if so, its true value may not be known until resolve_symbol_value is called with finalize_syms non-zero in write_object_file.

The expression is often simply a constant. Before resolve_symbol_value is called with finalize_syms set, the value is the offset from the frag (see section 1.4 Frags). Afterward, the frag address has been added in.

sy_resolved
This field is non-zero if the symbol's value has been completely resolved. It is used during the final pass over the symbol table.

sy_resolving
This field is used to detect loops while resolving the symbol's value.

sy_used_in_reloc
This field is non-zero if the symbol is used by a relocation entry. If a local symbol is used in a relocation entry, it must be possible to redirect those relocations to other symbols, or this symbol cannot be removed from the final symbol list.

sy_next
sy_previous
These pointers to other symbolS structures describe a doubly linked list. These fields should be accessed with the symbol_next and symbol_previous macros.

sy_frag
This points to the frag (see section 1.4 Frags) that this symbol is attached to.

sy_used
Whether the symbol is used as an operand or in an expression. Note: Not all of the backends keep this information accurate; backends which use this bit are responsible for setting it when a symbol is used in backend routines.

sy_mri_common
Whether the symbol is an MRI common symbol created by the COMMON pseudo-op when assembling in MRI mode.

sy_volatile
Whether the symbol can be re-defined.

sy_forward_ref
Whether the symbol's value must only be evaluated upon use.

sy_weakrefr
Whether the symbol is a weakref alias to another symbol.

sy_weakrefd
Whether the symbol is or was referenced by one or more weakref aliases, and has not had any direct references.

bsym
This points to the BFD asymbol that will be used in writing the object file.

sy_obj
This format-specific data is of type OBJ_SYMFIELD_TYPE. If no macro by that name is defined in `obj-format.h', this field is not defined.

sy_tc
This processor-specific data is of type TC_SYMFIELD_TYPE. If no macro by that name is defined in `targ-cpu.h', this field is not defined.

Here is a description of the accessor functions. These should be used rather than referring to the fields of symbolS directly.

S_SET_VALUE
Set the symbol's value.

S_GET_VALUE
Get the symbol's value. This will cause resolve_symbol_value to be called if necessary.

S_SET_SEGMENT
Set the section of the symbol.

S_GET_SEGMENT
Get the symbol's section.

S_GET_NAME
Get the name of the symbol.

S_SET_NAME
Set the name of the symbol.

S_IS_EXTERNAL
Return non-zero if the symbol is externally visible.

S_IS_EXTERN
A synonym for S_IS_EXTERNAL. Don't use it.

S_IS_WEAK
Return non-zero if the symbol is weak, or if it is a weakref alias or symbol that has not been strongly referenced.

S_IS_WEAKREFR
Return non-zero if the symbol is a weakref alias.

S_IS_WEAKREFD
Return non-zero if the symbol was aliased by a weakref alias and has not had any strong references.

S_IS_VOLATILE
Return non-zero if the symbol may be re-defined. Such symbols get created by the = operator, equ, or set.

S_IS_FORWARD_REF
Return non-zero if the symbol is a forward reference, that is its value must only be determined upon use.

S_IS_COMMON
Return non-zero if this is a common symbol. Common symbols are sometimes represented as undefined symbols with a value, in which case this function will not be reliable.

S_IS_DEFINED
Return non-zero if this symbol is defined. This function is not reliable when called on a common symbol.

S_IS_DEBUG
Return non-zero if this is a debugging symbol.

S_IS_LOCAL
Return non-zero if this is a local assembler symbol which should not be included in the final symbol table. Note that this is not the opposite of S_IS_EXTERNAL. The `-L' assembler option affects the return value of this function.

S_SET_EXTERNAL
Mark the symbol as externally visible.

S_CLEAR_EXTERNAL
Mark the symbol as not externally visible.

S_SET_WEAK
Mark the symbol as weak.

S_SET_WEAKREFR
Mark the symbol as the referrer in a weakref directive. The symbol it aliases must have been set to the value expression before this point. If the alias has already been used, the symbol is marked as used too.

S_CLEAR_WEAKREFR
Clear the weakref alias status of a symbol. This is implicitly called whenever a symbol is defined or set to a new expression.

S_SET_WEAKREFD
Mark the symbol as the referred symbol in a weakref directive. Implicitly marks the symbol as weak, but see below. It should only be called if the referenced symbol has just been added to the symbol table.

S_SET_WEAKREFD
Clear the weakref aliased status of a symbol. This is implicitly called whenever the symbol is looked up, as part of a direct reference or a definition, but not as part of a weakref directive.

S_SET_VOLATILE
Indicate that the symbol may be re-defined.

S_CLEAR_VOLATILE
Indicate that the symbol may no longer be re-defined.

S_SET_FORWARD_REF
Indicate that the symbol is a forward reference, that is its value must only be determined upon use.

S_GET_TYPE
S_GET_DESC
S_GET_OTHER
Get the type, desc, and other fields of the symbol. These are only defined for object file formats for which they make sense (primarily a.out).

S_SET_TYPE
S_SET_DESC
S_SET_OTHER
Set the type, desc, and other fields of the symbol. These are only defined for object file formats for which they make sense (primarily a.out).

S_GET_SIZE
Get the size of a symbol. This is only defined for object file formats for which it makes sense (primarily ELF).

S_SET_SIZE
Set the size of a symbol. This is only defined for object file formats for which it makes sense (primarily ELF).

symbol_get_value_expression
Get a pointer to an expressionS structure which represents the value of the symbol as an expression.

symbol_set_value_expression
Set the value of a symbol to an expression.

symbol_set_frag
Set the frag where a symbol is defined.

symbol_get_frag
Get the frag where a symbol is defined.

symbol_mark_used
Mark a symbol as having been used in an expression.

symbol_clear_used
Clear the mark indicating that a symbol was used in an expression.

symbol_used_p
Return whether a symbol was used in an expression.

symbol_mark_used_in_reloc
Mark a symbol as having been used by a relocation.

symbol_clear_used_in_reloc
Clear the mark indicating that a symbol was used in a relocation.

symbol_used_in_reloc_p
Return whether a symbol was used in a relocation.

symbol_mark_mri_common
Mark a symbol as an MRI common symbol.

symbol_clear_mri_common
Clear the mark indicating that a symbol is an MRI common symbol.

symbol_mri_common_p
Return whether a symbol is an MRI common symbol.

symbol_mark_written
Mark a symbol as having been written.

symbol_clear_written
Clear the mark indicating that a symbol was written.

symbol_written_p
Return whether a symbol was written.

symbol_mark_resolved
Mark a symbol as having been resolved.

symbol_resolved_p
Return whether a symbol has been resolved.

symbol_section_p
Return whether a symbol is a section symbol.

symbol_equated_p
Return whether a symbol is equated to another symbol.

symbol_constant_p
Return whether a symbol has a constant value, including being an offset within some frag.

symbol_get_bfdsym
Return the BFD symbol associated with a symbol.

symbol_set_bfdsym
Set the BFD symbol associated with a symbol.

symbol_get_obj
Return a pointer to the OBJ_SYMFIELD_TYPE field of a symbol.

symbol_set_obj
Set the OBJ_SYMFIELD_TYPE field of a symbol.

symbol_get_tc
Return a pointer to the TC_SYMFIELD_TYPE field of a symbol.

symbol_set_tc
Set the TC_SYMFIELD_TYPE field of a symbol.

GAS attempts to store local symbols--symbols which will not be written to the output file--using a different structure, struct local_symbol. This structure can only represent symbols whose value is an offset within a frag.

Code outside of the symbol handler will always deal with symbolS structures and use the accessor functions. The accessor functions correctly deal with local symbols. struct local_symbol is much smaller than symbolS (which also automatically creates a bfd asymbol structure), so this saves space when assembling large files.

The first field of symbolS is bsym, the pointer to the BFD symbol. The first field of struct local_symbol is a pointer which is always set to NULL. This is how the symbol accessor functions can distinguish local symbols from ordinary symbols. The symbol accessor functions automatically convert a local symbol into an ordinary symbol when necessary.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by system on July, 22 2007 using texi2html