)]}'
{
  "commit": "b0c4ddf9196738d9c8a162521b61bcefb7aa4c0a",
  "tree": "9ff82fb0ea0818f98c1e889ca68f0ec1cb90a6a8",
  "parents": [
    "a2466e26c53331511b73258c2c890c61484ae8c8"
  ],
  "author": {
    "name": "Tess Strickland",
    "email": "sstrickl@google.com",
    "time": "Thu Sep 29 08:32:47 2022 +0000"
  },
  "committer": {
    "name": "Commit Queue",
    "email": "dart-scoped@luci-project-accounts.iam.gserviceaccount.com",
    "time": "Thu Sep 29 08:32:47 2022 +0000"
  },
  "message": "[pkg/dart2native] Avoid overwriting section contents in MachO files.\n\nTo create a Dart standalone executable on MacOS, we modify the\ndartaotruntime executable to add the snapshot contents, and the\nVM looks into the executable on disk to find the snapshot to load.\n\nPreviously, we did this by adding a new 64-bit segment load command\nwith a single section, where the section\u0027s file offset and size\ndescribes the inserted snapshot. This meant the Mach-O header size increased by 152 bytes.\n\nOriginally, this wasn\u0027t an issue as there was plenty of padding, but\nlater clang updates removed most of this padding, and so writing the\nnew header actually overwrote the initial contents of the first section\nin the file, which happens to be the __text section. In addition, since\nthe first section\u0027s offset was now declared to be within the header,\nutilities that strictly validated the Mach-O format, like codesign,\nwould report errors.\n\nThis CL changes it so that we actually reserve space in the\ndartaotruntime header using the -add_empty_section flag to the linker.\nIn addition, we change from using a segment load command to using a\n(40 byte) note load command. This is because a segment load command\nspecifies that the contents should be loaded in memory, but we don\u0027t\nuse that loaded version. Instead, the VM reloads it from the executable\non disk so it can appropriately mmap the different parts of the\nsnapshot. A note section instead just declares a section of the\nexecutable as arbitrary data that the owner can read from the file\nand use as desired, which is semantically closer to our current usage.\n\nThis CL also adds a test to pkg/dartdev/test/commands/compile_test to\nensure that corrupting a random part of the snapshot in the executable\ncauses signature verification to fail.\n\nThis CL also reverts CL 256208, thus relanding the clang changes\nstarting from June that originally raised awareness of the issue by\ngreatly reduced the amount of padding after the load commands.\n\nTEST\u003dpkg/dartdev/test/commands/compile_test\n\nBug: https://github.com/dart-lang/sdk/issues/49783\nChange-Id: Iee554d87b0eabaecd7a534ca4e4facfefbce6385\nCq-Include-Trybots: luci.dart.try:analyzer-mac-release-try,dart-sdk-mac-arm64-try,dart-sdk-mac-try,pkg-mac-release-arm64-try,pkg-mac-release-try,vm-kernel-precomp-mac-product-x64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try\nReviewed-on: https://dart-review.googlesource.com/c/sdk/+/260108\nReviewed-by: Ryan Macnak \u003crmacnak@google.com\u003e\nReviewed-by: Daco Harkes \u003cdacoharkes@google.com\u003e\nCommit-Queue: Tess Strickland \u003csstrickl@google.com\u003e\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d6be5ede4b83aea99add7e616a24a60d8278e6e0",
      "old_mode": 33188,
      "old_path": "DEPS",
      "new_id": "ac2c4ce09edec89468623d2ae105969eda629cc8",
      "new_mode": 33188,
      "new_path": "DEPS"
    },
    {
      "type": "modify",
      "old_id": "c2ba3f7ac31903eea1984bc6d8083cf5a14ba39f",
      "old_mode": 33188,
      "old_path": "build/config/clang/clang.gni",
      "new_id": "49cc5097ac068d73b811195ccc97f1f6a7abd048",
      "new_mode": 33188,
      "new_path": "build/config/clang/clang.gni"
    },
    {
      "type": "modify",
      "old_id": "c2b1643d77d87d2f727f09eb1554c4821cdf5d62",
      "old_mode": 33188,
      "old_path": "build/config/compiler/BUILD.gn",
      "new_id": "4e2a79debf4a5b6ff6e7bef6b980d2bcf8484ee2",
      "new_mode": 33188,
      "new_path": "build/config/compiler/BUILD.gn"
    },
    {
      "type": "modify",
      "old_id": "2b9c42608fdd0534e561c8a5e0e5ca68b77c736e",
      "old_mode": 33188,
      "old_path": "build/toolchain/mac/BUILD.gn",
      "new_id": "1dd0cdac08e21ce9b7743f48f857cc132688217d",
      "new_mode": 33188,
      "new_path": "build/toolchain/mac/BUILD.gn"
    },
    {
      "type": "modify",
      "old_id": "701e3c3448c16161eff8343f585a190576b75f12",
      "old_mode": 33188,
      "old_path": "pkg/dart2native/lib/dart2native_macho.dart",
      "new_id": "fe240c352cf460132c278920f8cc9bb11db156e2",
      "new_mode": 33188,
      "new_path": "pkg/dart2native/lib/dart2native_macho.dart"
    },
    {
      "type": "modify",
      "old_id": "3919d92d8081fb24854dbcedde8bdd91fae5bbe7",
      "old_mode": 33188,
      "old_path": "pkg/dart2native/lib/macho.dart",
      "new_id": "f8dac8323fb01f29f28262ebc6b6f8ed4dec558e",
      "new_mode": 33188,
      "new_path": "pkg/dart2native/lib/macho.dart"
    },
    {
      "type": "modify",
      "old_id": "b9ff8360b6c918217244bed38bd05b89997658e1",
      "old_mode": 33188,
      "old_path": "pkg/dart2native/lib/macho_utils.dart",
      "new_id": "e975ecb93ffa350f044f717033d24980f9b7b71d",
      "new_mode": 33188,
      "new_path": "pkg/dart2native/lib/macho_utils.dart"
    },
    {
      "type": "modify",
      "old_id": "e42927acf10f0221b03a5e2de064b17b93a14ba6",
      "old_mode": 33188,
      "old_path": "pkg/dartdev/test/commands/compile_test.dart",
      "new_id": "11deb0ec85ef25b9ca529c4343e267d922ec752c",
      "new_mode": 33188,
      "new_path": "pkg/dartdev/test/commands/compile_test.dart"
    },
    {
      "type": "modify",
      "old_id": "3e6c317b746d515d5905702eabe9308973d16f04",
      "old_mode": 33188,
      "old_path": "runtime/BUILD.gn",
      "new_id": "d894483fe0f2f449ff0ecb62533a140152612330",
      "new_mode": 33188,
      "new_path": "runtime/BUILD.gn"
    },
    {
      "type": "modify",
      "old_id": "fd0d4dc46c42c2819802997453b855b7d6138d24",
      "old_mode": 33188,
      "old_path": "runtime/bin/snapshot_utils.cc",
      "new_id": "dd418817ac0d50dbf24e02db2025190aaa7e92e7",
      "new_mode": 33188,
      "new_path": "runtime/bin/snapshot_utils.cc"
    },
    {
      "type": "modify",
      "old_id": "d5bf913fe60e619f6b32d6e5c1eff25040631d81",
      "old_mode": 33188,
      "old_path": "runtime/platform/mach_o.h",
      "new_id": "377331cf80e1eaed1bfccbf5192775488d2a325d",
      "new_mode": 33188,
      "new_path": "runtime/platform/mach_o.h"
    },
    {
      "type": "modify",
      "old_id": "2b7a3710a79174f58a957697b6f37c565d14eb08",
      "old_mode": 33188,
      "old_path": "runtime/vm/malloc_hooks_ia32.cc",
      "new_id": "0572ac03400f1a00ce68fb7e33e6656e33fd2e30",
      "new_mode": 33188,
      "new_path": "runtime/vm/malloc_hooks_ia32.cc"
    }
  ]
}
