LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What does the .globl directive do in assembly, and what happens to a symbol without it?

.globl name exports a symbol so the linker can resolve references to it from other object files; without it the symbol is local to its own file.

Two object files feeding a central linker: one exports main via .globl so the linker matches it to another file's reference, while a symbol without .globl stays file-local.

* The .globl directive exports a symbol for the linker to match across files; a symbol without it stays file-local like C static. *

When you compile multiple .c/.s files separately, each becomes an object file. The linker then stitches them together by matching up symbol names. A symbol only participates in that matching if it's marked global — otherwise it's invisible outside its own file.

.globl main      # main is visible to the linker (and to the C runtime)
main:
    ...

This is the assembly equivalent of external linkage in C. A C function is global by default; marking it static makes it file-local — exactly the difference between having .globl and omitting it.

Common gotcha: If main is missing .globl, the C startup code can't find your entry point and the linker reports an undefined-reference error for main.

Go deeper:

From Quiz: REVE1 / Translation of C to Assembly | Updated: Jul 10, 2026