Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dagenais <jeff.dagenais@gmail.com>
To: igt-dev@lists.freedesktop.org
Cc: Jeff Dagenais <jdagenais@tesla.com>,
	Jeff Dagenais <jeff.dagenais@gmail.com>
Subject: [PATCH i-g-t] scripts/generate_iga64_codes: prevent objcopy from modifying the input file
Date: Wed, 30 Oct 2024 11:40:54 -0700	[thread overview]
Message-ID: <20241030184054.73065-1-jdagenais@tesla.com> (raw)

This script uses objcopy in order to dump a section. Objcopy is meant
for copying and expects a second argument. Failing that, it uses the
input file as output. Even though there's no intented change to the
file, this operation still re-writes the file completely.

In most cases, this re-writes the file as it was before. But in
cross-compilation cases, the "objcopy" program in the PATH used here
might be different than the toolchain which generated the ELF file.

In all cases, this causes a racy re-build of the .a, and in the worst
case, the objcopy re-written .o and .a files are actually incompatible
with the cross-linker used downstream in the ninja build causing failure
to find all symbols from the libs passed to this script.

```
../lib/intel_batchbuffer.c:763: undefined reference to
`gen8_gpgpu_fillfunc'
../lib/intel_batchbuffer.c:762: undefined reference to
`xehp_gpgpu_fillfunc'
[...]
```

The intent of the command was just to extract info from the LIBS, not
modify them. Using /dev/null as output file ensures the input files will
not be modified.

Signed-off-by: Jeff Dagenais <jeff.dagenais@gmail.com>
---
 scripts/generate_iga64_codes | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/generate_iga64_codes b/scripts/generate_iga64_codes
index d1e40b600..bbf1f7008 100755
--- a/scripts/generate_iga64_codes
+++ b/scripts/generate_iga64_codes
@@ -37,7 +37,7 @@ ASMS=()
 while  read -d $'\0' asm; do
     test -z "$asm" && continue
     ASMS+=( "$asm" )
-done < <(for f in $LIBS; do objcopy --dump-section .iga64_assembly=/dev/stdout $f.p/*.o; done)
+done < <(for f in $LIBS; do objcopy --dump-section .iga64_assembly=/dev/stdout $f.p/*.o /dev/null; done)
 
 # check if we need to recompile - checksum difference and compiler present
 MD5_ASMS="$(md5sum <<< "${ASMS[@]}" | cut -b1-32)"
-- 
2.43.0


             reply	other threads:[~2024-10-31 15:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 18:40 Jeff Dagenais [this message]
2024-10-31 16:51 ` [PATCH i-g-t] scripts/generate_iga64_codes: prevent objcopy from modifying the input file Kamil Konieczny
2024-11-04  6:29 ` ✓ CI.xeBAT: success for " Patchwork
2024-11-04  6:39 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-11-05 16:32   ` Kamil Konieczny
2024-11-04  8:11 ` ✗ CI.xeFULL: " Patchwork
2024-11-05 16:30   ` Kamil Konieczny
2024-11-04  9:44 ` [PATCH i-g-t] " Hajda, Andrzej

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241030184054.73065-1-jdagenais@tesla.com \
    --to=jeff.dagenais@gmail.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jdagenais@tesla.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox