How can I create private labels in assembly functions that can only be used from within the defining function, but cannot be used from other functions as e.g. jump targets?
In the below example, I don't want .private_label
to be reachable from _main
. However, it compiles just fine using clang -S -masm=intel example.s -o example
.
I've previously seen this feature in NASM, but now I've decided to switch to Clang.
Bonus: Where can I look this information up myself? I've already did some research myself.
.intel_syntax noprefix
.globl _main
.text
_f:
push rbp
mov rbp, rsp
.private_label:
mov rsp, rbp
pop rbp
ret
_main:
push rbp
mov rbp, rsp
jmp .private_label
mov rax, 0x5
mov rsp, rbp
pop rbp
ret