{"id":31789,"date":"2021-03-04T20:41:13","date_gmt":"2021-03-05T01:41:13","guid":{"rendered":"https:\/\/mjtsai.com\/blog\/?p=31789"},"modified":"2022-11-29T15:54:35","modified_gmt":"2022-11-29T20:54:35","slug":"reverse-engineering-rosetta-2","status":"publish","type":"post","link":"https:\/\/mjtsai.com\/blog\/2021\/03\/04\/reverse-engineering-rosetta-2\/","title":{"rendered":"Reverse-Engineering Rosetta 2"},"content":{"rendered":"<p><a href=\"https:\/\/ffri.github.io\/ProjectChampollion\/part1\/\">Koh M. Nakagawa<\/a> (via <a href=\"https:\/\/news.ycombinator.com\/item?id=26346980\">Hacker News<\/a>):<\/p>\n<blockquote cite=\"https:\/\/ffri.github.io\/ProjectChampollion\/part1\/\"><p>I mentioned earlier that a proprietary ABI is used in AOT files. Specifically, the System V AMD64 ABI is used, with the x86_64 registers converted to arm64 registers according to the following table.<\/p>\n<p>[&#8230;]<\/p>\n<p>The Rosetta 2 <code>runtime<\/code> is the binary that initializes the emulation process, maps the AOT file onto the memory, and performs JIT translation.\nWhen an x86_64 emulation process starts, <code>runtime<\/code> is mapped onto the memory, and the program counter is set to the entry point of <code>runtime<\/code>.<\/p>\n<p>One interesting point is that <code>runtime<\/code> is <strong>not<\/strong> a dynamic link library.\nThis is in contrast to the x86 emulation engine <code>xtajit.dll<\/code> in Windows 10 on Arm.<\/p>\n<p>[&#8230;]<\/p>\n<p>The logic for JIT translation is also needed is to support the execution of x86_64 applications that generate x86_64 code at runtime (e.g., JavaScript engine uses a JIT compiler).<\/p>\n<\/blockquote>","protected":false},"excerpt":{"rendered":"<p>Koh M. Nakagawa (via Hacker News): I mentioned earlier that a proprietary ABI is used in AOT files. Specifically, the System V AMD64 ABI is used, with the x86_64 registers converted to arm64 registers according to the following table. [&#8230;] The Rosetta 2 runtime is the binary that initializes the emulation process, maps the AOT [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"apple_news_api_created_at":"2021-03-05T01:41:17Z","apple_news_api_id":"b2c0e903-82df-4c44-9fca-69e88ceddc41","apple_news_api_modified_at":"2022-11-29T20:54:38Z","apple_news_api_revision":"AAAAAAAAAAAAAAAAAAAAAQ==","apple_news_api_share_url":"https:\/\/apple.news\/AssDpA4LfTESfymnojO3cQQ","apple_news_coverimage":0,"apple_news_coverimage_caption":"","apple_news_is_hidden":false,"apple_news_is_paid":false,"apple_news_is_preview":false,"apple_news_is_sponsored":false,"apple_news_maturity_rating":"","apple_news_metadata":"\"\"","apple_news_pullquote":"","apple_news_pullquote_position":"","apple_news_slug":"","apple_news_sections":"\"\"","apple_news_suppress_video_url":false,"apple_news_use_image_component":false,"footnotes":""},"categories":[4],"tags":[2014,770,205,817,30,1891,71,1025],"class_list":["post-31789","post","type-post","status-publish","format-standard","hentry","category-programming-category","tag-apple-m1","tag-assembly-language","tag-dyld","tag-just-in-time-compilation-jit","tag-mac","tag-macos-11-0","tag-programming","tag-rosetta"],"apple_news_notices":[],"_links":{"self":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/comments?post=31789"}],"version-history":[{"count":2,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31789\/revisions"}],"predecessor-version":[{"id":37746,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/posts\/31789\/revisions\/37746"}],"wp:attachment":[{"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/media?parent=31789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/categories?post=31789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mjtsai.com\/blog\/wp-json\/wp\/v2\/tags?post=31789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}