From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id A54EB9DD140; Thu, 14 Mar 2024 14:41:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A54EB9DD140 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1710416471; bh=t/2WENn9jLTHYfdNb3o4bS6RqGmKPmpvXyNaeAaXMb8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ueq54H/+nWzuzooE+ueh/nCuXzM3dwv7KQqlJTOdzARlhH0akEibTc2ZpM8Z2qbtW 0Ao27lWCxjksj91/lw1IUv453NNf79C3FiKibsD9pxg6vhDqNwqNnfzEAyNNkLBrNw zQ2exI+PmZ/kxP+LcwvdzzoN9l9gFZUw1Pej8qfU= Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6838D9DD146 for ; Thu, 14 Mar 2024 14:40:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6838D9DD146 Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d29111272eso11381901fa.0 for ; Thu, 14 Mar 2024 04:40:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710416454; x=1711021254; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UuSK6RHcCxpp1MRzLNaFfuyKwLjB3k3fX1hR1czIUsc=; b=vjYmww1k4kPSwhZEGBE4qfwFSzotxTn7sz9BciFzS5sBx0skxE2pvqyP2HPs55wrZD zYqClfr3OYPrHWFqfqrT4dIvoI+MerOmhCt9tsd8JwZ8f3KYtA+xASFwelXy61JowcQx WKMRDGs+Z6Uf6bJZT2I2SKyDwVlFL1QujoijDhMPjcBgEBqf5by0Kf1HMqUCSVJL+b0i Qmg/8JyzZxHvGKJy3n4XoxoUQ+s3e0pqzLsaCVDuOb+3yGYGxlrVgH0iFf8aVRN49Zhu 61LslBd11dJ6HYfRc3i51HvCxjmRyvm+w0I2zD5D4tYkzdneh+rg3ul2Ku6Z9QS/L7Nm hwhw== X-Gm-Message-State: AOJu0YwRztDFzZk2s0b18HfHd3XD9ATPgRYX5Y1943F8o8/6Uv0LIcpY 2D2cx0hiqFXlp+36WD2c3o797cMBx3fTn/QxZYmisdQCZ7AdjcP5J/L1vvtyovI= X-Google-Smtp-Source: AGHT+IERk4rQlF/cHHEkJU29VYzz+Qf8f6rUZ70rjPs9k4dvJL9EONta/n3xa2xxRkaR8MRUZAvHvg== X-Received: by 2002:a05:651c:204a:b0:2d4:2b9a:e853 with SMTP id t10-20020a05651c204a00b002d42b9ae853mr1009517ljo.8.1710416454268; Thu, 14 Mar 2024 04:40:54 -0700 (PDT) Received: from pony.mail.msk ([2a00:1148:b0ba:16:1896:add6:753b:e168]) by smtp.gmail.com with ESMTPSA id z10-20020a2e9b8a000000b002d250e323edsm100141lji.89.2024.03.14.04.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 04:40:53 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, Sergey Kaplun , Maxim Kokryashkin Date: Thu, 14 Mar 2024 14:39:51 +0300 Message-Id: <1fe5f0ebbd285bd58849be28548bcc8c8c68c2a1.1710416150.git.sergeyb@tarantool.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit 2/2] OSX/iOS/ARM64: Fix bytecode embedding in Mach-O object file. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: sergeyb@tarantool.org Thanks to Carlo Cabrera. (cherry picked from commit b98b37231bd2dcb79e10b0f974cefd91eb0d7b3a) Mach-O FAR object files generated by LuaJIT for arm64 had an incorrect format because FFI structure used for generation was wrong: `mach_fat_obj` instead of `mach_fat_obj_64`. Sergey Bronnikov: * added the description and a test for the problem Part of tarantool/tarantool#9595 --- src/jit/bcsave.lua | 14 +++++++++++++- ...-fix_generation_of_mach-o_object_files.test.lua | 4 +++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/jit/bcsave.lua b/src/jit/bcsave.lua index 7aec1555..069cf1a3 100644 --- a/src/jit/bcsave.lua +++ b/src/jit/bcsave.lua @@ -491,6 +491,18 @@ typedef struct { mach_nlist sym_entry; uint8_t space[4096]; } mach_fat_obj; +typedef struct { + mach_fat_header fat; + mach_fat_arch fat_arch[2]; + struct { + mach_header_64 hdr; + mach_segment_command_64 seg; + mach_section_64 sec; + mach_symtab_command sym; + } arch[2]; + mach_nlist_64 sym_entry; + uint8_t space[4096]; +} mach_fat_obj_64; ]] local symname = '_'..LJBC_PREFIX..ctx.modname local isfat, is64, align, mobj = false, false, 4, "mach_obj" @@ -499,7 +511,7 @@ typedef struct { elseif ctx.arch == "arm" then isfat, mobj = true, "mach_fat_obj" elseif ctx.arch == "arm64" then - is64, align, isfat, mobj = true, 8, true, "mach_fat_obj" + is64, align, isfat, mobj = true, 8, true, "mach_fat_obj_64" else check(ctx.arch == "x86", "unsupported architecture for OSX") end diff --git a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua index 0519e134..0a11f163 100644 --- a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua +++ b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua @@ -7,7 +7,7 @@ local test = tap.test('lj-865-fix_generation_of_mach-o_object_files'):skipcond({ ['Test uses exotic type of loaders (see #9671)'] = _TARANTOOL, }) -test:plan(4) +test:plan(8) -- Test creates an object file in Mach-O format with LuaJIT bytecode -- and checks validness of the object file fields. @@ -267,5 +267,7 @@ end -- ARM build_and_check_mach_o(false) +-- ARM64 +build_and_check_mach_o(true) test:done(true) -- 2.34.1