60 likes | 210 Vues
Using the Clang Integrated Assembler to Compile the Linux Kernel. Bryce Adelstein-Lelbach , Louisiana State University. What is the Integrated Assembler?. The Integrated Assembler (IA) is an assembler built in to the Clang compiler driver N ot a separate binary like the GNU Assembler (GAS)
E N D
Using the Clang Integrated Assembler to Compile the Linux Kernel Bryce Adelstein-Lelbach, Louisiana State University
What is the Integrated Assembler? • The Integrated Assembler (IA) is an assembler built in to the Clang compiler driver • Not a separate binary like the GNU Assembler (GAS) • Supports all platforms that Clang supports • Largely compatible with GAS • Benefits • Clang-style diagnostics for assembly • Faster compile times • No temporary assembly files stellar.cct.lsu.edu
IA Issues • IA rejects ambiguous inline x86 assembly that GAS accepts • IA has no support for 16-bit mode on x86 • IA has no support for switching assembly modes on x86 (e.g. .code16, .code32, .code64) • IA does not support GCC-style explicit register variables (ERVs) • IA uses ARM Unified Assembly Language (UAL), and does not support GAS's ARM assembly extensions stellar.cct.lsu.edu
Ambiguous x86 Inline Assembly • GAS is more lenient about accepting inline x86 assembly that is ambiguous. For example: __asm__("add %al, (%rax)"); __asm__("addw $4, (%rax)"); __asm__("add $4, (%rax)"); • Discussion: how should we fix this? • Can someone give me an example of when the more explicit form would be bad? stellar.cct.lsu.edu
16-bit Mode/Mode Switching • LLVM has no x86-16 backend • Essential for compiling kernel boot code, bootloaders, etc • GAS .code16, .code32, .code64 directives • These directives tell GAS what type of assembly to output • Longer term project • Discussion: Could this be accomplished in a GSoC? stellar.cct.lsu.edu
Explicit Register Variables • Places a variable into a specific hardware register. Example: registeruint64_t sp __asm__("%rsp"); • Compiler must exclude these registers from register allocation while the variable is in scope • Used to access the stack pointer in the kernel • A possible solution for this use case would be to add__builtin_stack_pointer()to Clang and GCC. • Also used in Xen, glibcand most dynamic linkers stellar.cct.lsu.edu