Hi Mark,

On Thu, Apr 9, 2026 at 8:48 AM Mark Wielaard <[email protected]> wrote:
>
> .debug dwo sections can include the SHF_EXCLUDE flag to indicate that
> the linker shouldn't process them. Also a .debug_str.dwo section is
> like a normal .debug_str section. There is no .debug_line_str.dwo
> section, so that doesn't need special casing..

Extra "." at the end of this sentence. Otherwise LGTM.

Aaron

>
> Add some dwo files to run-elflint-test.sh to make sure debug files
> with .dwo sections aren't flagged by eu-elflint with --gnu --debug.
>
>         * src/elflint.c (special_sections): Add .debug_str.dwo.
>         (IS_DEBUG_DWO): New macro.
>         (check_sections): For IS_DEBUG_DWO files allow SHF_EXCLUDE.
>         * tests/run-elflint-test.sh: Add .dwo testfiles.
>
> Signed-off-by: Mark Wielaard <[email protected]>
> ---
>  src/elflint.c             | 17 +++++++++++++----
>  tests/run-elflint-test.sh |  8 ++++++++
>  2 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/src/elflint.c b/src/elflint.c
> index a05f37d166ea..9e1180af67ce 100644
> --- a/src/elflint.c
> +++ b/src/elflint.c
> @@ -3686,6 +3686,7 @@ static const struct
>      { ".data", 6, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE, 0 },
>      { ".data1", 7, SHT_PROGBITS, exact, SHF_ALLOC | SHF_WRITE, 0 },
>      { ".debug_str", 11, SHT_PROGBITS, exact_or_gnuld, SHF_MERGE | 
> SHF_STRINGS, 0 },
> +    { ".debug_str.dwo", 15, SHT_PROGBITS, exact_or_gnuld, SHF_MERGE | 
> SHF_STRINGS, 0 },
>      { ".debug_line_str", 16, SHT_PROGBITS, exact_or_gnuld, SHF_MERGE | 
> SHF_STRINGS, 0 },
>      { ".debug", 6, SHT_PROGBITS, exact, 0, 0 },
>      { ".dynamic", 9, SHT_DYNAMIC, atleast, SHF_ALLOC, SHF_WRITE },
> @@ -3734,6 +3735,10 @@ static const struct
>     && !memcmp (special_sections[idx].name, string, \
>                sizeof string - (prefix ? 1 : 0)))
>
> +#define IS_DEBUG_DWO(name) \
> +  (startswith (name, ".debug_") \
> +   && strcmp (name + strlen (name) - 4, ".dwo") == 0)
> +
>  /* Extra section flags that might or might not be added to the section
>     and have to be ignored.  */
>  #define EXTRA_SHFLAGS (SHF_LINK_ORDER \
> @@ -3856,10 +3861,14 @@ section [%2d] '%s' has wrong type: expected %s, is 
> %s\n"),
>                 if (special_sections[s].attrflag == exact
>                     || special_sections[s].attrflag == exact_or_gnuld)
>                   {
> -                   /* Except for the link order, retain, group bit and
> -                      compression flag all the other bits should
> -                      match exactly.  */
> -                   if ((shdr->sh_flags & ~EXTRA_SHFLAGS)
> +                   /* Except for the link order, retain, group bit
> +                      and compression flag all the other bits should
> +                      match exactly.  .debug.dwo sections can also be
> +                      SHF_EXCLUDE. */
> +                   GElf_Word extra_shflags = EXTRA_SHFLAGS;
> +                   if (IS_DEBUG_DWO (scnname))
> +                       extra_shflags |= SHF_EXCLUDE;
> +                   if ((shdr->sh_flags & ~extra_shflags)
>                         != special_sections[s].attr
>                         && (special_sections[s].attrflag == exact || !gnuld))
>                       ERROR (_("\
> diff --git a/tests/run-elflint-test.sh b/tests/run-elflint-test.sh
> index caf172a61631..41b531ee3c91 100755
> --- a/tests/run-elflint-test.sh
> +++ b/tests/run-elflint-test.sh
> @@ -57,4 +57,12 @@ tempfiles testfile-s390x-hash-bothz
>  testrun ${abs_top_builddir}/src/elfcompress -f -q --name='.s??tab' -o 
> testfile-s390x-hash-bothz testfile-s390x-hash-both
>  testrun ${abs_top_builddir}/src/elflint -q --gnu-ld testfile-s390x-hash-bothz
>
> +# Recognize debug dwo sections
> +testfiles testfile-hello4.dwo testfile-world4.dwo
> +testfiles testfile-hello5.dwo testfile-world5.dwo
> +testrun ${abs_top_builddir}/src/elflint -q --gnu --debug \
> +       testfile-hello4.dwo testfile-world4.dwo
> +testrun ${abs_top_builddir}/src/elflint -q --gnu --debug \
> +       testfile-hello5.dwo testfile-world5.dwo
> +
>  exit 0
> --
> 2.53.0
>

Reply via email to