Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH i-g-t] scripts/generate_iga64_codes: prevent objcopy from modifying the input file
@ 2024-10-30 18:40 Jeff Dagenais
  2024-10-31 16:51 ` Kamil Konieczny
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Jeff Dagenais @ 2024-10-30 18:40 UTC (permalink / raw)
  To: igt-dev; +Cc: Jeff Dagenais, Jeff Dagenais

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


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-11-05 16:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 18:40 [PATCH i-g-t] scripts/generate_iga64_codes: prevent objcopy from modifying the input file Jeff Dagenais
2024-10-31 16:51 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox