.align N alignment fixed by assembler may be changed when the linker relaxation enabled.
In this case, we have to insert N-2 bytes NOPs and R_RISCV_ALIGN relocation type.
In this way, Linker could detect R_RISCV_ALIGN and fix the alignment by removing
To do this:
- Add parseDirectiveAlign in RISCVAsmParser to parse .align and .p2align directive and then insert PseudoNOPs instruction.
- Add expandNOPs in RISCVMCCodeEmitter to expand PseudoNOPs to NOPs with R_RISCV_ALIGN relocation type.
- Add disableAlignmentPaddingInTextSectiontarget hook in MCAsmBackend to disable generic padding for .align and let PseudoNOPs deal with it.