Reputation: 96586
Can somebody explain the difference between these labels in assembly?
Lfoo:
.Lfoo:
foo:
.foo:
There's some documentation but it is a bit unclear. I tried this with an ELF system:
$ cat foo.S
Laaa:
jmp Laaa
.Lbbb:
jmp .Lbbb
aaa:
jmp aaa
.bbb:
jmp .bbb
$ clang -c foo.S -o foo.o
$ objdump -D foo.o
foo.o: file format elf64-x86-64
Disassembly of section .text:
0000000000000000 <Laaa>:
0: eb fe jmp 0 <Laaa>
2: eb fe jmp 2 <Laaa+0x2>
0000000000000004 <aaa>:
4: eb fe jmp 4 <aaa>
0000000000000006 <.bbb>:
6: eb fe jmp 6 <.bbb>
And that seems to confirm that .L
is a local symbol for ELF, however the symbols clearly don't have to start with .
or _
. I know _
is used for name mangling in C, but what is the point of the .
?
Upvotes: 6
Views: 1271
Reputation: 93014
The name mangling scheme and the prefix to make a local symbol (i.e. symbol that does not appear in the symbol table) depend on your platform and assembler. There is no single combination that works everywhere. The following two conventions seem to be common:
On targets following the traditional UNIX conventions (e.g. aout, Mach-O, and COFF targets), C symbols are decorated with a leading underscore _
and local labels begin with an L
.
On ELF targets, C symbols are not decorated and local labels begin with .L
.
Some assemblers (e.g. nasm) deviate from these conventions for local labels. For example, on NASM, local labels begin with a single period .
independently of what target you are on.
I don't know what the convention outside UNIX is (Windows is UNIX-like in that it is a COFF target).
Upvotes: 7