Table of Contents

Symbol visibility (ivss)

Symbol visibility determines whether another object can resolve a symbol by name. A definition exported from data.s can satisfy a reference in main.s:

# data.s
.global answer
.section my_data
answer:
    .word 42
.end
# main.s
.extern answer
.section my_code
    ld answer, %r1
    halt
.end

Assemble each file separately, then link both objects. The load refers to answer without knowing where the data section will be placed. Symbol resolution supplies that location, and execution loads forty-two into %r1.

.global exports a definition; .extern conventionally declares a definition supplied elsewhere. In this implementation both directives mark their symbols with global binding. The label's presence distinguishes a section-defined symbol from an undefined reference.

A plain label is local by default, so its name is not automatically a cross-file interface. Exporting a symbol also does not allocate storage: the label and .word supply the definition and data in this example.

Source: asembler.c.