Page MenuHomePhabricator

[LoongArch] Allow writing unaligned nop sequences
ClosedPublic

Authored by wangleiat on Dec 4 2022, 6:24 PM.

Details

Summary

In case of unaligned nop sequences, pad to the nearest 4-byte boundary
with zeros before filling with nop instructions. This is consistent
with gas behavior, and is necessary to compile the Linux kernel with
LLVM IAS.

Replace support::endian::write with OS.write while at it. This is
simpler and correct because we only have little endian.

Diff Detail

Event Timeline

wangleiat created this revision.Dec 4 2022, 6:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2022, 6:24 PM
wangleiat requested review of this revision.Dec 4 2022, 6:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 4 2022, 6:24 PM
xen0n edited the summary of this revision. (Show Details)Dec 4 2022, 6:56 PM
xen0n retitled this revision from [LoongArch] Allow write unaligned nop sequence to [LoongArch] Allow writing unaligned nop sequences.
xen0n accepted this revision.EditedDec 4 2022, 7:00 PM

LGTM.

I've edited the title and summary for you, mainly for correcting one semantic mistake in the summary ("switches the bytes to not be dependent on endianness, even though we have only little endian" -- you most certainly didn't mean that, we definitely want the output to be valid little-endian LoongArch machine code, and the host's endianness shouldn't matter. The semantics could be inadvertently reversed by mistranslation).

This revision is now accepted and ready to land.Dec 4 2022, 7:00 PM

LGTM.

I've edited the title and summary for you, mainly for correcting one semantic mistake in the summary ("switches the bytes to not be dependent on endianness, even though we have only little endian" -- you most certainly didn't mean that, we definitely want the output to be valid little-endian LoongArch machine code, and the host's endianness shouldn't matter. The semantics could be inadvertently reversed by mistranslation).

Thank you very much!

This revision was landed with ongoing or failed builds.Dec 8 2022, 2:44 AM
This revision was automatically updated to reflect the committed changes.