HomePhabricator

[RISCV] Insert R_RISCV_ALIGN relocation type and Nops for code alignment when…

Authored by shiva0217 on Jan 30 2019, 3:16 AM.

Description

[RISCV] Insert R_RISCV_ALIGN relocation type and Nops for code alignment when linker relaxation enabled

Linker relaxation may change code size. We need to fix up the alignment
of alignment directive in text section by inserting Nops and R_RISCV_ALIGN
relocation type. So then linker could satisfy the alignment by removing Nops.

To do this:

  1. Add shouldInsertExtraNopBytesForCodeAlign target hook to calculate the Nops we need to insert.
  1. Add shouldInsertFixupForCodeAlign target hook to insert R_RISCV_ALIGN fixup type.

Differential Revision: https://reviews.llvm.org/D47755

llvm-svn: 352616