From patchwork Mon Jan 5 18:30:24 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1279 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=1767637888; bh=TAz4sJdqJQTO4dX6qo4jHJjXCauQ6wDJckrauSYVI0Q=; 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=naAbRKc3RaBzXTt0Dv6Ut+W+cE8WJcIon7AhSx3ipqyGRNdKu6IqX6IE3zmaalUWu KGEW36FOdy5Rj2Gb07eJpWHhkfy8isEymUoJdDYiWMMdifttRYhXfcHxDoZritdnTW WdfliT94fWWt25HCLsoWx5oQhpLT6f/aYZAw2y72RhFMORqGz+eQ4Mp+9rqTJzQKFb /tfDhlcXeIRNltY3SmxWDgIMNYc85zYcFNiYT9W2slrlZEjCwr3qDXO99mP4eCd3ZJ 8WwysvBW8UZ1N+CIb91DgdQRRQr7iXIvzgbc1ewIiscBu/eRTKY9A8fE2ErUc4zDQh Y8MqrFOFk65mA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26EA469118 for ; Mon, 5 Jan 2026 11:31:28 -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 ger-uZC1gK0M for ; Mon, 5 Jan 2026 11:31:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637888; bh=TAz4sJdqJQTO4dX6qo4jHJjXCauQ6wDJckrauSYVI0Q=; 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=naAbRKc3RaBzXTt0Dv6Ut+W+cE8WJcIon7AhSx3ipqyGRNdKu6IqX6IE3zmaalUWu KGEW36FOdy5Rj2Gb07eJpWHhkfy8isEymUoJdDYiWMMdifttRYhXfcHxDoZritdnTW WdfliT94fWWt25HCLsoWx5oQhpLT6f/aYZAw2y72RhFMORqGz+eQ4Mp+9rqTJzQKFb /tfDhlcXeIRNltY3SmxWDgIMNYc85zYcFNiYT9W2slrlZEjCwr3qDXO99mP4eCd3ZJ 8WwysvBW8UZ1N+CIb91DgdQRRQr7iXIvzgbc1ewIiscBu/eRTKY9A8fE2ErUc4zDQh Y8MqrFOFk65mA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 132636911B for ; Mon, 5 Jan 2026 11:31:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637886; bh=ZGg4Q+UPjTm2sCitzqOb/dDetlUan0lmM0auY1rXKfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6B+HSzxMHZ5UTMz/OPTXC5rBc0j2BkhNyjvB7D5jCTUknxERawI7SB0e+CyXke9z vx++F2RSZViFtI51BAfPo156MFlmYWxCLv3AN4Z9U9vjI06LN/0hclEDms7sdIVGNR MVJusjHy8l8VPeYEmfNTCCYK5kXjIaxSLaeuuxDFAQe5fhNIbcgFtSVwJi2eM3x9tb dZgPB3C+nRE6ZJpvE1Sw+828K35iv3Rt0v09Zvo3Jmidb5Z8r/XwzpDdayvPTguc2s wfyYyk2eRxF5POij/MTCNV/29aXnaDqkcZoSrUq5NWf+vfu6CJI9S5DRef7NYa8Z0V r1JLVVW8F1yZw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1620C6911F; Mon, 5 Jan 2026 11:31:26 -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 aTJhz7gXZDRZ; Mon, 5 Jan 2026 11:31:26 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1767637881; bh=j3oafw5rFOMQcHAYyGxovPbXspBw0iqdUlnVeXPoKCA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FdTgLEmmiZXyMFBOCZ2sDlUnLFIjDr7X3AVdNM7UEqtUt99UhYpotYSYoj3+5a2nV vEFIqYQPSDCpm2lS94Z6KjiupQMPvHTNyVLBOqS3MMjYkf20EB/NluepATSRuUUqi3 7B5uBUZzMC8AF8EVQyKIc2MULQ9YcYBPIpfw8/Ds0WobIJpXU4QoW/3t7KUL0qNP/N KPUHuYaZn5JZFVp5ZbudGgBpl7Su8Q7LsdDhYWAX+6bhGl0v5oVLkxKTTojV3bWGeY OQ6EDDDIZ4NgBiuB1PoIaTAubG8ddXfqDw3K4lPhaFephhM8FjKq8LwCk9MFF/BrsC ukBVEE0GdShfQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 3BA3969118; Mon, 5 Jan 2026 11:31:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 5 Jan 2026 11:30:24 -0700 Message-ID: <20260105183030.1487468-10-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260105183030.1487468-1-sjg@u-boot.org> References: <20260105183030.1487468-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: Z5GJARRABZOD6YENBRDBU2VWXQFKI5JE X-Message-ID-Hash: Z5GJARRABZOD6YENBRDBU2VWXQFKI5JE 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 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 09/11] buildman: Extract _process_elf_file() from _write_toolchain_result() 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 Move the ELF file processing logic from the for loop in _write_toolchain_result() into a separate _process_elf_file() method. The new method handles processing a single ELF file: - Running nm to get function sizes - Running objdump to get section headers and rodata size - Running size to get overall sizes - Writing output to appropriate files Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- tools/buildman/builderthread.py | 88 ++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 35 deletions(-) diff --git a/tools/buildman/builderthread.py b/tools/buildman/builderthread.py index 1855e2cc2cb..d5c8c6141eb 100644 --- a/tools/buildman/builderthread.py +++ b/tools/buildman/builderthread.py @@ -684,6 +684,56 @@ class BuilderThread(threading.Thread): result.out_dir = out_dir return result, do_config + def _process_elf_file(self, result, fname, env): + """Process an ELF file to extract size information + + Runs nm, objdump, and size on the ELF file and writes the output + to appropriate files. + + Args: + result (CommandResult): Result containing build information + fname (str): ELF filename to process + env (dict): Environment variables for the commands + + Returns: + str: Size line with rodata size appended, or None if size failed + """ + cmd = [f'{self.toolchain.cross}nm', '--size-sort', fname] + nm_result = command.run_one(*cmd, capture=True, + capture_stderr=True, + cwd=result.out_dir, + raise_on_error=False, env=env) + if nm_result.stdout: + nm_fname = self.builder.get_func_sizes_file( + result.commit_upto, result.brd.target, fname) + with open(nm_fname, 'w', encoding='utf-8') as outf: + print(nm_result.stdout, end=' ', file=outf) + + cmd = [f'{self.toolchain.cross}objdump', '-h', fname] + dump_result = command.run_one(*cmd, capture=True, + capture_stderr=True, + cwd=result.out_dir, + raise_on_error=False, env=env) + rodata_size = '' + if dump_result.stdout: + objdump = self.builder.get_objdump_file(result.commit_upto, + result.brd.target, fname) + with open(objdump, 'w', encoding='utf-8') as outf: + print(dump_result.stdout, end=' ', file=outf) + for line in dump_result.stdout.splitlines(): + fields = line.split() + if len(fields) > 5 and fields[1] == '.rodata': + rodata_size = fields[2] + + cmd = [f'{self.toolchain.cross}size', fname] + size_result = command.run_one(*cmd, capture=True, + capture_stderr=True, + cwd=result.out_dir, + raise_on_error=False, env=env) + if size_result.stdout: + return size_result.stdout.splitlines()[1] + ' ' + rodata_size + return None + def _write_toolchain_result(self, result, done_file, build_dir, maybe_aborted, work_in_output): """Write build result and toolchain information @@ -724,41 +774,9 @@ class BuilderThread(threading.Thread): lines = [] for fname in BASE_ELF_FILENAMES: - cmd = [f'{self.toolchain.cross}nm', '--size-sort', fname] - nm_result = command.run_one(*cmd, capture=True, - capture_stderr=True, - cwd=result.out_dir, - raise_on_error=False, env=env) - if nm_result.stdout: - nm_fname = self.builder.get_func_sizes_file( - result.commit_upto, result.brd.target, fname) - with open(nm_fname, 'w', encoding='utf-8') as outf: - print(nm_result.stdout, end=' ', file=outf) - - cmd = [f'{self.toolchain.cross}objdump', '-h', fname] - dump_result = command.run_one(*cmd, capture=True, - capture_stderr=True, - cwd=result.out_dir, - raise_on_error=False, env=env) - rodata_size = '' - if dump_result.stdout: - objdump = self.builder.get_objdump_file(result.commit_upto, - result.brd.target, fname) - with open(objdump, 'w', encoding='utf-8') as outf: - print(dump_result.stdout, end=' ', file=outf) - for line in dump_result.stdout.splitlines(): - fields = line.split() - if len(fields) > 5 and fields[1] == '.rodata': - rodata_size = fields[2] - - cmd = [f'{self.toolchain.cross}size', fname] - size_result = command.run_one(*cmd, capture=True, - capture_stderr=True, - cwd=result.out_dir, - raise_on_error=False, env=env) - if size_result.stdout: - lines.append(size_result.stdout.splitlines()[1] + ' ' + - rodata_size) + line = self._process_elf_file(result, fname, env) + if line: + lines.append(line) # Extract the environment from U-Boot and dump it out cmd = [f'{self.toolchain.cross}objcopy', '-O', 'binary',