[PATCH i-g-t] scripts/generate_iga64_codes: prevent objcopy from modifying the input file

Hajda, Andrzej andrzej.hajda at intel.com
Mon Nov 4 09:44:52 UTC 2024


W dniu 30.10.2024 o 19:40, Jeff Dagenais pisze:
> 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 at gmail.com>

Thx for the fix.

Reviewed-by: Andrzej Hajda <andrzej.hajda at intel.com>

Regards
Andrzej

> ---
>   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)"



More information about the igt-dev mailing list