From patchwork Sat Feb 14 02:12:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1862 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035228; bh=+Fk/KC9nx6ogjP6bkWTwrCwWAwARXzSzwiEbmrFKQ84=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Lo4oNVBK6qROVSWpflCqYBXwA9ZAuOTCFPiOe2G3I692utly8e3m2U67/wgrOa/T9 UTkpYcT5MYpvkl8ZWv/aLuVfFjRIkD7TgMHlGS99LhSQvWmuhZ2P1M8zOGs5OMHz1J 9chPVI5ILNWsn2NoMAeguTlcpdDKu4oD2l7BwdG4pIHTWKd0BzV3pcNj7P7x5XfUT0 5+dPJa1LNcRj/SW/2hLE8iWUxTY7Gy7mJjqHaH3gM5bG7mShRGWhBiEXC8DW7/Je4l FZOWQ66OGooMb+nIzeWLzP+88i2VDqa2jVnClgBIHvF69Uz//OA1sF47lbo21IDvjC jsJzGiUGWFXRw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 460A369B56 for ; Fri, 13 Feb 2026 19:13:48 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Xw5Sf9BJVx2o for ; Fri, 13 Feb 2026 19:13:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035228; bh=+Fk/KC9nx6ogjP6bkWTwrCwWAwARXzSzwiEbmrFKQ84=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Lo4oNVBK6qROVSWpflCqYBXwA9ZAuOTCFPiOe2G3I692utly8e3m2U67/wgrOa/T9 UTkpYcT5MYpvkl8ZWv/aLuVfFjRIkD7TgMHlGS99LhSQvWmuhZ2P1M8zOGs5OMHz1J 9chPVI5ILNWsn2NoMAeguTlcpdDKu4oD2l7BwdG4pIHTWKd0BzV3pcNj7P7x5XfUT0 5+dPJa1LNcRj/SW/2hLE8iWUxTY7Gy7mJjqHaH3gM5bG7mShRGWhBiEXC8DW7/Je4l FZOWQ66OGooMb+nIzeWLzP+88i2VDqa2jVnClgBIHvF69Uz//OA1sF47lbo21IDvjC jsJzGiUGWFXRw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 35E3469B58 for ; Fri, 13 Feb 2026 19:13:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035225; bh=75YLyuavqFizbws5fdv0RNpduMTBZGibe5Fh9ScJorI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tdsmB7W1gFLkLh+TbrnWl+NjaRnUuS6VbUMcsewNUzq6kAVBwXh13Mtx/3OnLXrzB E0sY/BN/TQKkhzkC6D1A027qZGwEjrkmqJxTkpEnwBW38Yf44wqNVn90ZvO7hyeHWn oO7M2ar8duPuBDLb7wD1l5PvQQGN6m7nugmL2X1ZfOFMXSV8EwY+lI6r7wNM4OuB4b PzHYMc54u+f9Yg5qDLCVyL9gksuSFL48ZlfvwM7ykdH7sd6PqZMKvsjkDwLCQUC7eL YvT92Pz5P2RnElqzbZJiNduqnz7nWnpFSq24P4uxHrbxyulk2xtALM5B5sNC60Gltx lvMWjE9EAWemA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AD65569B56; Fri, 13 Feb 2026 19:13:45 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id cZRWhcM_JgVU; Fri, 13 Feb 2026 19:13:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771035221; bh=X/1gMwJJUTVzAC5dXiJPM/9gtZyB6kqVTNiKPKl+hEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2C9VRRZ+lW4Lk2M82x41/x90Fyy7rQ9eTibbMkNg0wX8MkiqDLz1NDhgEu/iGT4f u/PHRB4QeOffpF1lJkBsKgrdIDGkIThSlZ41YjWBumK5oGq0p+rUTZRLYphZ1kGxHZ k9A7WLDZK6LrMKuqDLJY5LzTtqaYA91TQbO7raJ08anR3/5PwLp/WqGOu0zQnIXmQP R+qjm06VJr7TPoyCVI2W348gkESwenQePZSO87T36uxotBXaEcL2FU2i6MT/CjmT/m NOniyMw8PgXclk+LzGD9uQKYb+0pvYI7wgokJq8wY4yxR/xpBbJqIG1GhqxR6+NEjd 0GKIlwtdzwm6Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3814869A69; Fri, 13 Feb 2026 19:13:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 13 Feb 2026 19:12:56 -0700 Message-ID: <20260214021317.816170-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260214021317.816170-1-sjg@u-boot.org> References: <20260214021317.816170-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5SQNJ7ZGJXOT6B6C5GZHS23FX6PEDIRU X-Message-ID-Hash: 5SQNJ7ZGJXOT6B6C5GZHS23FX6PEDIRU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 02/13] ulib: Use cross-toolchain objcopy for symbol redefinition List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass build_api.py hardcodes the host 'objcopy' for symbol redefinition, which fails for cross-compiled targets (e.g. qemu_arm64) since the host objcopy cannot handle foreign ELF formats. Add an --objcopy argument to build_api.py and pass $(OBJCOPY) from the Makefile so the correct cross-toolchain binary is used. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- Makefile | 1 + scripts/build_api.py | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e22c12da712..263914b3757 100644 --- a/Makefile +++ b/Makefile @@ -1891,6 +1891,7 @@ quiet_cmd_ulib-objs = OBJS $@ $(PYTHON3) $(srctree)/scripts/build_api.py \ $(srctree)/lib/ulib/rename.syms \ --redefine $$(cat $@.objlist) --output-dir $@.objdir \ + --objcopy $(OBJCOPY) \ $(if $(filter -j%,$(MAKEFLAGS)),--jobs $(patsubst -j%,%,$(filter -j%,$(MAKEFLAGS)))) \ > $@; \ rm -f $@.tmp $@.objlist diff --git a/scripts/build_api.py b/scripts/build_api.py index 7adc6c978a3..aa8b4f16a1a 100755 --- a/scripts/build_api.py +++ b/scripts/build_api.py @@ -310,7 +310,7 @@ class SymbolRedefiner: """ def __init__(self, syms: List[Symbol], outdir: str, max_workers, - verbose=False): + verbose=False, objcopy='objcopy'): """Initialize with symbols and output settings Args: @@ -318,11 +318,13 @@ class SymbolRedefiner: outdir (str): Directory to write modified object files max_workers (int): Number of parallel workers verbose (bool): Whether to show verbose output + objcopy (str): Path to objcopy binary """ self.syms = syms self.outdir = outdir self.verbose = verbose self.max_workers = max_workers + self.objcopy = objcopy self.redefine_args = [] self.symbol_names = set() @@ -339,7 +341,7 @@ class SymbolRedefiner: infile (str): Input object file path outfile (str): Output object file path """ - cmd = ['objcopy'] + self.redefine_args + [infile, outfile] + cmd = [self.objcopy] + self.redefine_args + [infile, outfile] subprocess.run(cmd, check=True, capture_output=True, text=True) if self.verbose: print(f'Copied and modified {infile} -> {outfile}') @@ -397,7 +399,8 @@ class SymbolRedefiner: return outfiles, modified @staticmethod - def apply_renames(obj_files, syms, outdir: str, max_workers, verbose=False): + def apply_renames(obj_files, syms, outdir: str, max_workers, + verbose=False, objcopy='objcopy'): """Apply symbol redefinitions to object files using objcopy Args: @@ -406,6 +409,7 @@ class SymbolRedefiner: outdir (str): Directory to write modified object files max_workers (int): Number of parallel workers verbose (bool): Whether to show verbose output + objcopy (str): Path to objcopy binary Returns: tuple[List[str], int]: List of output object file paths and @@ -414,7 +418,8 @@ class SymbolRedefiner: if not syms: return obj_files, 0 - redefiner = SymbolRedefiner(syms, outdir, max_workers, verbose) + redefiner = SymbolRedefiner(syms, outdir, max_workers, verbose, + objcopy) # Setup: create output directory and prepare work items os.makedirs(outdir, exist_ok=True) @@ -618,6 +623,8 @@ def parse_args(argv): help='Show verbose output') parser.add_argument('-j', '--jobs', type=int, metavar='N', help='Number of parallel jobs for symbol processing') + parser.add_argument('--objcopy', default='objcopy', + help='Path to objcopy binary (default: objcopy)') parser.add_argument('-P', '--processes', type=int, help='set number of processes to use for running tests') parser.add_argument('-t', '--test', action='store_true', dest='test', @@ -692,7 +699,8 @@ def main(argv=None): jobs = args.jobs if args.jobs else min(os.cpu_count() or 4, 8) start_time = time.time() outfiles, modified = SymbolRedefiner.apply_renames( - args.redefine, syms, args.output_dir, jobs, args.verbose) + args.redefine, syms, args.output_dir, jobs, args.verbose, + args.objcopy) # Print the list of output files for the build system to use if args.output_dir: print('\n'.join(outfiles))