{"push_id":1805750901,"size":1,"distinct_size":1,"ref":"refs/heads/rvc-norvc-align","head":"435e8589e3716b532c9c606ff56ced1399c44316","before":"063e350f28474acf567a455484f8c70ec08a05a5","commits":[{"sha":"435e8589e3716b532c9c606ff56ced1399c44316","author":{"name":"Palmer Dabbelt","email":"da5bafab56f66b7236a8991f0e01aad56ae901eb@dabbelt.com"},"message":"RISC-V: Avoid emitting invalid instructions in mixed RVC/no-RVC code\n\nWhen linking the following code\n\n    .global _prog_start\n    _prog_start:\n            mv x1, x1\n            mv x2, x2\n    .align 2\n    rvc_boundry:\n    .option norvc\n    .align 3\n            mv x3, x3\n\nwe currently emit an invalid two-byte 0 instruction.  The actual output\ncode looks like\n\n    0000000080000000 <_prog_start>:\n        80000000:   8086                    mv      ra,ra\n        80000002:   810a                    mv      sp,sp\n\n    0000000080000004 <rvc_boundry>:\n        80000004:   0000                    unimp\n        80000006:   0001                    nop\n        80000008:   00018193                mv      gp,gp\n\nThis ends up manifesting due to the two-byte compressed NOP that's\npessimisticly emitted by the \".align 2\", which results in \"rvc_boundry\"\nbeing 2-byte aligned.  frag_align_code() then goes and outputs a 2-byte\nNOP (which is invalid in no-RVC mode) to align the code back to a 4-byte\nboundry, which can't be relaxed away by the linker as it's not part of\nthe R_RISCV_RELAX relocation.\n\nThe fix is to just always emit the worst case possible alignment into\nthe output as a R_RISCV_RELAX, which the linker will then fix up.\n\nWith this patch I get the expected code generation\n\n    0000000080000000 <_prog_start>:\n        80000000:   8086                    mv      ra,ra\n        80000002:   810a                    mv      sp,sp\n\n    0000000080000004 <rvc_boundry>:\n        80000004:   00000013                nop\n        80000008:   00018193                mv      gp,gp","distinct":true,"url":"https://api.github.com/repos/riscv/riscv-binutils-gdb/commits/435e8589e3716b532c9c606ff56ced1399c44316"}]}
{"actor":{"display_login":"palmer-dabbelt"}}