GNU ld supports . and $ in symbol names while LLD doesn't support them in
readPrimary expressions. Using . can result in such an error:
https://github.com/ClangBuiltLinux/linux/issues/1318 ld.lld: error: ./arch/powerpc/kernel/vmlinux.lds:255: malformed number: .TOC. >>> __toc_ptr = (DEFINED (.TOC.) ? .TOC. : ADDR (.got)) + 0x8000;
Allow . (ppc64 special symbol .TOC.) and $ (RISC-V special symbol __global_pointer$).
Change diag[3-5].test to use an invalid character ^.
Note: GNU ld allows ~ in non-leading positions of a symbol name. ~
is not used in practice, conflicts with the unary operator, and can
cause some parsing difficulty, so this patch does not add it.
Looks like ld will also accept a '~' at least in some places, for example:
Unlikely this will come up in practice but maybe worth matching it as well.