code:
.globl main
main:
mfspr 0, lr
the clang internal assembler thinks lr is a symbol, not a register:
$ clang --target=ppc32 regs.s -c; nm regs.o
U lr
00000000 T main
anyone knows what's going on?
CodePudding user response:
Using %lr results in 7c 08 02 a6 mflr 0 according to llvm-objdump -d, without an unresolved lr symbol.
gcc -mregnames compiling C to PPC asm uses names like %r3: https://godbolt.org/z/7dMnK74vc
Clang doesn't support that option; unless there's a similar option with a different name, clang's asm output always uses instructions like add 3, 3, 4 with just numbers. But I guess clang / LLVM's assembler supports the same "symbolic" register names that GAS does, and those names start with a %, presumably to distinguish them from symbols. (The same way that starting with a digit means they can't be symbols.)
