* Don't attempt to compress bss sections
@ 2022-09-23 2:26 Alan Modra
2022-09-23 6:33 ` Jan Beulich
0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2022-09-23 2:26 UTC (permalink / raw)
To: binutils
It doesn't make sense to try to compress a section without contents
since those sections take no space on disk. Compression can only
increase the disk image size.
* coffgen.c (make_a_section_from_file): Exclude !SEC_HAS_CONTENTS
sections from compression and decompression.
* elf.c (_bfd_elf_make_section_from_shdr): Likewise.
diff --git a/bfd/coffgen.c b/bfd/coffgen.c
index 90fba3b8554..8eb69af2ce2 100644
--- a/bfd/coffgen.c
+++ b/bfd/coffgen.c
@@ -146,7 +146,8 @@ make_a_section_from_file (bfd *abfd,
/* Compress/decompress DWARF debug sections with names: .debug_* and
.zdebug_*, after the section flags is set. */
- if ((flags & SEC_DEBUGGING)
+ if ((flags & SEC_DEBUGGING) != 0
+ && (flags & SEC_HAS_CONTENTS) != 0
&& strlen (name) > 7
&& ((name[1] == 'd' && name[6] == '_')
|| (strlen (name) > 8 && name[1] == 'z' && name[7] == '_')))
diff --git a/bfd/elf.c b/bfd/elf.c
index bc433cf516c..16cea4f8aeb 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1201,7 +1201,8 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
/* Compress/decompress DWARF debug sections with names: .debug_* and
.zdebug_*, after the section flags is set. */
- if ((newsect->flags & SEC_DEBUGGING)
+ if ((newsect->flags & SEC_DEBUGGING) != 0
+ && (newsect->flags & SEC_HAS_CONTENTS) != 0
&& ((name[1] == 'd' && name[6] == '_')
|| (name[1] == 'z' && name[7] == '_')))
{
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Don't attempt to compress bss sections
2022-09-23 2:26 Don't attempt to compress bss sections Alan Modra
@ 2022-09-23 6:33 ` Jan Beulich
2022-09-23 6:49 ` Alan Modra
0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2022-09-23 6:33 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
On 23.09.2022 04:26, Alan Modra via Binutils wrote:
> It doesn't make sense to try to compress a section without contents
> since those sections take no space on disk. Compression can only
> increase the disk image size.
>
> * coffgen.c (make_a_section_from_file): Exclude !SEC_HAS_CONTENTS
> sections from compression and decompression.
> * elf.c (_bfd_elf_make_section_from_shdr): Likewise.
So I'm curious - are there debugging sections without contents? Or
is the change more for the sake of documentation?
Jan
> --- a/bfd/coffgen.c
> +++ b/bfd/coffgen.c
> @@ -146,7 +146,8 @@ make_a_section_from_file (bfd *abfd,
>
> /* Compress/decompress DWARF debug sections with names: .debug_* and
> .zdebug_*, after the section flags is set. */
> - if ((flags & SEC_DEBUGGING)
> + if ((flags & SEC_DEBUGGING) != 0
> + && (flags & SEC_HAS_CONTENTS) != 0
> && strlen (name) > 7
> && ((name[1] == 'd' && name[6] == '_')
> || (strlen (name) > 8 && name[1] == 'z' && name[7] == '_')))
> diff --git a/bfd/elf.c b/bfd/elf.c
> index bc433cf516c..16cea4f8aeb 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -1201,7 +1201,8 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
>
> /* Compress/decompress DWARF debug sections with names: .debug_* and
> .zdebug_*, after the section flags is set. */
> - if ((newsect->flags & SEC_DEBUGGING)
> + if ((newsect->flags & SEC_DEBUGGING) != 0
> + && (newsect->flags & SEC_HAS_CONTENTS) != 0
> && ((name[1] == 'd' && name[6] == '_')
> || (name[1] == 'z' && name[7] == '_')))
> {
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Don't attempt to compress bss sections
2022-09-23 6:33 ` Jan Beulich
@ 2022-09-23 6:49 ` Alan Modra
0 siblings, 0 replies; 3+ messages in thread
From: Alan Modra @ 2022-09-23 6:49 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Fri, Sep 23, 2022 at 08:33:05AM +0200, Jan Beulich wrote:
> On 23.09.2022 04:26, Alan Modra via Binutils wrote:
> > It doesn't make sense to try to compress a section without contents
> > since those sections take no space on disk. Compression can only
> > increase the disk image size.
> >
> > * coffgen.c (make_a_section_from_file): Exclude !SEC_HAS_CONTENTS
> > sections from compression and decompression.
> > * elf.c (_bfd_elf_make_section_from_shdr): Likewise.
>
> So I'm curious - are there debugging sections without contents? Or
> is the change more for the sake of documentation?
There are fuzzers that try any mad thing.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-23 6:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 2:26 Don't attempt to compress bss sections Alan Modra
2022-09-23 6:33 ` Jan Beulich
2022-09-23 6:49 ` Alan Modra
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).