-
Notifications
You must be signed in to change notification settings - Fork 23
Description
Dump some content from my offlist discussion with @ved-rivos :P
Introduce one more function in asm syntax: %lpad_label("<signature-string>").
e.g. lpad %lpad_label("v(i,i)"), lui t2, %lpad_label("v(i,i)") for void foo(int, int)
The signature string sytax:
SIGNATURE-STRING := RETURN-TYPE '(' ARGS ')'
| RETURN-TYPE '(' ')'
RETURN-TYPE := TYPE-NAME
ARGS := ARGS ',' ARG
| ARG
ARG := TYPE-NAME
TYPE-NAME is using the mangling name in itanium c++ abi[1] and RISC-V psABI[2].
[1] https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin
[2] https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#c-name-mangling
The value is the hash result of the signature string, we may start from md5.
void foo(int, int) = %lpad_label("v(i,i)") = low20(md5("v(i,i)")) = low20(3a7a68c073dcdbd6ee282a598c2dc44e) = 0xdc44e
Why md5: no strong reason for using md5, but one reason is it's available on binutils and llvm already.
Why using mangling name defined in itanium c++ abi: Prevent us to define complicate rule for mangling name.
More example:
void bar(): v()
void *memset(void *, int, size_t): Pv(Pv,i,m)