mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] ptxd_make_xpkg_pkg.sh: Prevent incomplete comp variable and build break
@ 2024-12-10  8:15 Carsten Schlote
  2024-12-10 11:42 ` Alexander Dahl
  2024-12-10 14:02 ` Michael Olbrich
  0 siblings, 2 replies; 3+ messages in thread
From: Carsten Schlote @ 2024-12-10  8:15 UTC (permalink / raw)
  To: ptxdist

Changed code to detect broken detection of debug compression type. This
prevents an invalid comp variable ('='), which in turn causes some
abort, when objcopy is called with incomplete arguments.

If the compression can't be set and the comp variable is just "=", it
will be set to an empty string. The target objcopy tool will use its
internal default for compression in this case.

Signed-off-by: Carsten Schlote <schlote@vahanus.net>
---
  scripts/lib/ptxd_make_xpkg_pkg.sh | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh
b/scripts/lib/ptxd_make_xpkg_pkg.sh
index 08a0ab593..36bb3a564 100644
--- a/scripts/lib/ptxd_make_xpkg_pkg.sh
+++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
@@ -390,11 +390,15 @@ ptxd_install_compression_format() {

      libc="$(ptxd_cross_cc -print-file-name=libc.so.6 2> /dev/null)"
      if [ -n "${libc}" ]; then
-    comp="=$(readelf -t "${libc}" | sed -n -e
'/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"
+        comp="=$(readelf -t "${libc}" | sed -n -e
'/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"
+    fi
+    if [ "${comp}" == "=" ]; then
+        comp=""
      fi
      export ptxd_install_file_objcopy_args="--only-keep-debug
--compress-debug-sections${comp}"
  }

+
  ptxd_install_compression_format

  ptxd_install_file_extract_debug() {




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

* Re: [ptxdist] [PATCH] ptxd_make_xpkg_pkg.sh: Prevent incomplete comp variable and build break
  2024-12-10  8:15 [ptxdist] [PATCH] ptxd_make_xpkg_pkg.sh: Prevent incomplete comp variable and build break Carsten Schlote
@ 2024-12-10 11:42 ` Alexander Dahl
  2024-12-10 14:02 ` Michael Olbrich
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander Dahl @ 2024-12-10 11:42 UTC (permalink / raw)
  To: Carsten Schlote; +Cc: ptxdist

Hello Carsten,

Am Tue, Dec 10, 2024 at 09:15:51AM +0100 schrieb Carsten Schlote:
> Changed code to detect broken detection of debug compression type. This
> prevents an invalid comp variable ('='), which in turn causes some
> abort, when objcopy is called with incomplete arguments.
> 
> If the compression can't be set and the comp variable is just "=", it
> will be set to an empty string. The target objcopy tool will use its
> internal default for compression in this case.
> 
> Signed-off-by: Carsten Schlote <schlote@vahanus.net>
> ---
>  scripts/lib/ptxd_make_xpkg_pkg.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh
> b/scripts/lib/ptxd_make_xpkg_pkg.sh
> index 08a0ab593..36bb3a564 100644
> --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> @@ -390,11 +390,15 @@ ptxd_install_compression_format() {
> 
>      libc="$(ptxd_cross_cc -print-file-name=libc.so.6 2> /dev/null)"
>      if [ -n "${libc}" ]; then
> -    comp="=$(readelf -t "${libc}" | sed -n -e
> '/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"
> +        comp="=$(readelf -t "${libc}" | sed -n -e
> '/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"

Please don't change indentation.

> +    fi
> +    if [ "${comp}" == "=" ]; then
> +        comp=""

Instead of fixing a failed subshell call afterwards, it would probably
be better to call it separately and evaluate the result before
assinging to 'comp' here?  shellcheck warns about this (when called
with `-o all`) like this:

In scripts/lib/ptxd_make_xpkg_pkg.sh line 393:
        comp="=$(readelf -t "${libc}" | sed -n -e '/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"
                 ^------------------^ SC2312 (info): Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).
                                        ^-- SC2312 (info): Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).

See https://www.shellcheck.net/wiki/SC2312 for details.

>      fi
>      export ptxd_install_file_objcopy_args="--only-keep-debug
> --compress-debug-sections${comp}"
>  }
> 
> +

No need to add an empty line here.

Greets
Alex

>  ptxd_install_compression_format
> 
>  ptxd_install_file_extract_debug() {
> 
> 



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

* Re: [ptxdist] [PATCH] ptxd_make_xpkg_pkg.sh: Prevent incomplete comp variable and build break
  2024-12-10  8:15 [ptxdist] [PATCH] ptxd_make_xpkg_pkg.sh: Prevent incomplete comp variable and build break Carsten Schlote
  2024-12-10 11:42 ` Alexander Dahl
@ 2024-12-10 14:02 ` Michael Olbrich
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Olbrich @ 2024-12-10 14:02 UTC (permalink / raw)
  To: Carsten Schlote; +Cc: ptxdist

On Tue, Dec 10, 2024 at 09:15:51AM +0100, Carsten Schlote wrote:
> Changed code to detect broken detection of debug compression type. This
> prevents an invalid comp variable ('='), which in turn causes some
> abort, when objcopy is called with incomplete arguments.
> 
> If the compression can't be set and the comp variable is just "=", it
> will be set to an empty string. The target objcopy tool will use its
> internal default for compression in this case.
> 
> Signed-off-by: Carsten Schlote <schlote@vahanus.net>
> ---
>  scripts/lib/ptxd_make_xpkg_pkg.sh | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/scripts/lib/ptxd_make_xpkg_pkg.sh
> b/scripts/lib/ptxd_make_xpkg_pkg.sh
> index 08a0ab593..36bb3a564 100644
> --- a/scripts/lib/ptxd_make_xpkg_pkg.sh
> +++ b/scripts/lib/ptxd_make_xpkg_pkg.sh
> @@ -390,11 +390,15 @@ ptxd_install_compression_format() {
> 
>      libc="$(ptxd_cross_cc -print-file-name=libc.so.6 2> /dev/null)"
>      if [ -n "${libc}" ]; then
> -    comp="=$(readelf -t "${libc}" | sed -n -e
> '/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"
> +        comp="=$(readelf -t "${libc}" | sed -n -e
> '/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/\1/p;q}' | tr '[:upper:]' '[:lower:]')"

I think, if you do this (only add the '=' if s/// finds a match):

        comp="$(readelf -t "${libc}" | sed -n -e '/COMPRESSED/{N;s/.*\(ZLIB\|ZSTD\).*/=\1/p;q}' | tr '[:upper:]' '[:lower:]')"

> +    fi
> +    if [ "${comp}" == "=" ]; then
> +        comp=""

Then you don't need tis.

>      fi
>      export ptxd_install_file_objcopy_args="--only-keep-debug
> --compress-debug-sections${comp}"

Something (Thunderbird?) added extra new-lines that broke the patch.
Please send again. If you cannot use 'git send-email' then sending as
attachment should work as well.

>  }
> 
> +

Unrelated whitespace change.

Michael

>  ptxd_install_compression_format
> 
>  ptxd_install_file_extract_debug() {
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2024-12-10 14:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-10  8:15 [ptxdist] [PATCH] ptxd_make_xpkg_pkg.sh: Prevent incomplete comp variable and build break Carsten Schlote
2024-12-10 11:42 ` Alexander Dahl
2024-12-10 14:02 ` Michael Olbrich

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