1
1
mirror of https://github.com/rui314/mold.git synced 2024-10-04 16:48:04 +03:00

[Mach-O] Do not write x86-64 NOPs if ARM64

This commit is contained in:
Rui Ueyama 2022-06-28 15:49:29 +08:00
parent b0c6aa9a0f
commit 73074389ed

View File

@ -539,7 +539,11 @@ static void copy_sections_to_output_file(Context<E> &ctx) {
[&](std::unique_ptr<OutputSegment<E>> &seg) {
Timer t2(ctx, std::string(seg->cmd.get_segname()), &t);
// Fill text segment paddings with NOPs
// Fill text segment paddings with single-byte NOP instructions so
// that otool wouldn't out-of-sync when disassembling an output file.
// Do this only for x86-64 because ARM64 instructions are always 4
// bytes long.
if constexpr (std::is_same_v<E, X86_64>)
if (seg->cmd.get_segname() == "__TEXT")
memset(ctx.buf + seg->cmd.fileoff, 0x90, seg->cmd.filesize);