public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] bfd: Discard region regardless of warning flag
@ 2022-12-17 10:28 Torbjörn SVENSSON
  2022-12-17 16:13 ` Christophe Lyon
  0 siblings, 1 reply; 2+ messages in thread
From: Torbjörn SVENSSON @ 2022-12-17 10:28 UTC (permalink / raw)
  To: binutils; +Cc: christophe.lyon, Torbjörn SVENSSON

The discard of the region should be performed regardless if the warning
for the discard is enabled or not.
Without this patch, ld would segfault in bfd_section_removed_from_list,
called in the if-statement right after this block, as the argument
isec->output_section can be NULL.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 bfd/elflink.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index fc3edef9a05..0368256970b 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -11154,12 +11154,12 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
       if (isym->st_shndx != SHN_UNDEF
 	  && isym->st_shndx < SHN_LORESERVE
 	  && isec->output_section == NULL
-	  && flinfo->info->non_contiguous_regions
-	  && flinfo->info->non_contiguous_regions_warnings)
+	  && flinfo->info->non_contiguous_regions)
 	{
-	  _bfd_error_handler (_("warning: --enable-non-contiguous-regions "
-				"discards section `%s' from '%s'\n"),
-			      isec->name, bfd_get_filename (isec->owner));
+	  if (flinfo->info->non_contiguous_regions_warnings)
+	    _bfd_error_handler (_("warning: --enable-non-contiguous-regions "
+				  "discards section `%s' from '%s'\n"),
+				isec->name, bfd_get_filename (isec->owner));
 	  continue;
 	}
 
-- 
2.25.1


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

* Re: [PATCH] bfd: Discard region regardless of warning flag
  2022-12-17 10:28 [PATCH] bfd: Discard region regardless of warning flag Torbjörn SVENSSON
@ 2022-12-17 16:13 ` Christophe Lyon
  0 siblings, 0 replies; 2+ messages in thread
From: Christophe Lyon @ 2022-12-17 16:13 UTC (permalink / raw)
  To: Torbjörn SVENSSON; +Cc: binutils, christophe.lyon

[-- Attachment #1: Type: text/plain, Size: 1852 bytes --]

Hi Torbjörn,

On Sat, Dec 17, 2022 at 11:29 AM Torbjörn SVENSSON via Binutils <
binutils@sourceware.org> wrote:

> The discard of the region should be performed regardless if the warning
> for the discard is enabled or not.
> Without this patch, ld would segfault in bfd_section_removed_from_list,
> called in the if-statement right after this block, as the argument
> isec->output_section can be NULL.
>
> Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
> ---
>  bfd/elflink.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index fc3edef9a05..0368256970b 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -11154,12 +11154,12 @@ elf_link_input_bfd (struct elf_final_link_info
> *flinfo, bfd *input_bfd)
>        if (isym->st_shndx != SHN_UNDEF
>           && isym->st_shndx < SHN_LORESERVE
>           && isec->output_section == NULL
> -         && flinfo->info->non_contiguous_regions
> -         && flinfo->info->non_contiguous_regions_warnings)
> +         && flinfo->info->non_contiguous_regions)
>         {
> -         _bfd_error_handler (_("warning: --enable-non-contiguous-regions "
> -                               "discards section `%s' from '%s'\n"),
> -                             isec->name, bfd_get_filename (isec->owner));
> +         if (flinfo->info->non_contiguous_regions_warnings)
> +           _bfd_error_handler (_("warning:
> --enable-non-contiguous-regions "
> +                                 "discards section `%s' from '%s'\n"),
> +                               isec->name, bfd_get_filename
> (isec->owner));
>           continue;
>         }
>
>
Thanks for catching this, it makes sense indeed.
Any change you can add a testcase?

Best,

Christophe



> --
> 2.25.1
>
>

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

end of thread, other threads:[~2022-12-17 16:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-17 10:28 [PATCH] bfd: Discard region regardless of warning flag Torbjörn SVENSSON
2022-12-17 16:13 ` Christophe Lyon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).