* bogus "ignoring changed section type" warning
@ 2009-08-06 14:36 Jan Beulich
2009-08-07 0:51 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2009-08-06 14:36 UTC (permalink / raw)
To: binutils
Isn't this warning rather odd for code like this:
.section .init.rodata,"a"
.section .init.rodata,"a",@progbits
especially since with just the first directive, the section ends up being
progbits anyway (due to elf_fake_sections() deriving the type from the
section flags)? Wouldn't it hence make sense to guess an unspecified
section type from the flags right away, or alternatively allow modifying
SHT_NULL (in obj_elf_change_section()) by a later, more explicit
directive?
Thanks, Jan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bogus "ignoring changed section type" warning
2009-08-06 14:36 bogus "ignoring changed section type" warning Jan Beulich
@ 2009-08-07 0:51 ` Alan Modra
2009-08-28 16:13 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2009-08-07 0:51 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Thu, Aug 06, 2009 at 03:35:58PM +0100, Jan Beulich wrote:
> Isn't this warning rather odd for code like this:
>
> .section .init.rodata,"a"
> .section .init.rodata,"a",@progbits
>
> especially since with just the first directive, the section ends up being
> progbits anyway (due to elf_fake_sections() deriving the type from the
> section flags)?
Yes, there ought to be a warning on the first directive rather than on
the second one.
> Wouldn't it hence make sense to guess an unspecified
> section type from the flags right away,
Probably.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bogus "ignoring changed section type" warning
2009-08-07 0:51 ` Alan Modra
@ 2009-08-28 16:13 ` Jan Beulich
2009-08-30 18:32 ` Alan Modra
0 siblings, 1 reply; 5+ messages in thread
From: Jan Beulich @ 2009-08-28 16:13 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
>>> Alan Modra <amodra@bigpond.net.au> 07.08.09 02:51 >>>
>On Thu, Aug 06, 2009 at 03:35:58PM +0100, Jan Beulich wrote:
>> Isn't this warning rather odd for code like this:
>>
>> .section .init.rodata,"a"
>> .section .init.rodata,"a",@progbits
>>
>> especially since with just the first directive, the section ends up being
>> progbits anyway (due to elf_fake_sections() deriving the type from the
>> section flags)?
>
>Yes, there ought to be a warning on the first directive rather than on
>the second one.
I'm afraid this wouldn't be welcome to users: Just looking at the Linux
sources, there are quite a few uses without type, expecting it to default
to @progbits.
>> Wouldn't it hence make sense to guess an unspecified
>> section type from the flags right away,
>
>Probably.
Like this (2.19.1 based; I'd move it to mainline and formally submit if it seems
right)?
Jan
--- binutils-2.19.1/bfd/elf-bfd.h 2008-08-21 01:28:58.000000000 +0200
+++ 2.19.1/bfd/elf-bfd.h 2009-08-28 16:24:09.000000000 +0200
@@ -2128,6 +2128,8 @@ extern bfd_boolean _bfd_elf_map_sections
extern bfd_boolean _bfd_elf_is_function_type (unsigned int);
+extern int bfd_elf_get_default_section_type (flagword);
+
extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
(bfd * abfd, asection * section);
--- binutils-2.19.1/bfd/elf.c 2008-12-23 14:54:48.000000000 +0100
+++ 2.19.1/bfd/elf.c 2009-08-28 16:28:43.000000000 +0200
@@ -2485,6 +2485,18 @@ _bfd_elf_init_reloc_shdr (bfd *abfd,
return TRUE;
}
+/* Return the default section type based on the passed in section flags. */
+
+int
+bfd_elf_get_default_section_type (flagword flags)
+{
+ if ((flags & SEC_ALLOC) != 0
+ && ((flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0
+ || (flags & SEC_NEVER_LOAD) != 0))
+ return SHT_NOBITS;
+ return SHT_PROGBITS;
+}
+
/* Set up an ELF internal section header for a section. */
static void
@@ -2534,12 +2546,8 @@ elf_fake_sections (bfd *abfd, asection *
asect->flags. */
if ((asect->flags & SEC_GROUP) != 0)
sh_type = SHT_GROUP;
- else if ((asect->flags & SEC_ALLOC) != 0
- && (((asect->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- || (asect->flags & SEC_NEVER_LOAD) != 0))
- sh_type = SHT_NOBITS;
else
- sh_type = SHT_PROGBITS;
+ sh_type = bfd_elf_get_default_section_type (asect->flags);
if (this_hdr->sh_type == SHT_NULL)
this_hdr->sh_type = sh_type;
--- binutils-2.19.1/gas/config/obj-elf.c 2008-04-23 15:54:56.000000000 +0200
+++ 2.19.1/gas/config/obj-elf.c 2009-08-28 16:18:10.000000000 +0200
@@ -674,6 +685,8 @@ obj_elf_change_section (const char *name
{
symbolS *secsym;
+ if (type == SHT_NULL)
+ type = bfd_elf_get_default_section_type (flags);
elf_section_type (sec) = type;
elf_section_flags (sec) = attr;
--- binutils-2.19.1/gas/testsuite/gas/elf/section5.l 2004-12-21 14:09:55.000000000 +0100
+++ 2.19.1/gas/testsuite/gas/elf/section5.l 2009-08-28 16:37:15.000000000 +0200
@@ -2,7 +2,6 @@
.*:7: Warning: .*
.*:7: Warning: .*
.*:10: Warning: .*
-.*:13: Warning: .*
.*:16: Warning: .*
.*:18: Warning: .*
.*:20: Warning: .*
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bogus "ignoring changed section type" warning
2009-08-28 16:13 ` Jan Beulich
@ 2009-08-30 18:32 ` Alan Modra
2009-08-31 14:14 ` Jan Beulich
0 siblings, 1 reply; 5+ messages in thread
From: Alan Modra @ 2009-08-30 18:32 UTC (permalink / raw)
To: Jan Beulich; +Cc: binutils
On Fri, Aug 28, 2009 at 04:06:47PM +0100, Jan Beulich wrote:
> Like this (2.19.1 based; I'd move it to mainline and formally submit if it seems
> right)?
Yes, preapproved.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: bogus "ignoring changed section type" warning
2009-08-30 18:32 ` Alan Modra
@ 2009-08-31 14:14 ` Jan Beulich
0 siblings, 0 replies; 5+ messages in thread
From: Jan Beulich @ 2009-08-31 14:14 UTC (permalink / raw)
To: Alan Modra; +Cc: binutils
>>> Alan Modra <amodra@bigpond.net.au> 30.08.09 07:54 >>>
>On Fri, Aug 28, 2009 at 04:06:47PM +0100, Jan Beulich wrote:
>> Like this (2.19.1 based; I'd move it to mainline and formally submit if it seems
>> right)?
>
>Yes, preapproved.
Just for the record, this is the patch I'm about to commit.
Jan
bfd/
2009-08-31 Jan Beulich <jbeulich@novell.com>
* elf-bfd.h (bfd_elf_get_default_section_type): Declare.
* elf.c (bfd_elf_get_default_section_type): New.
(elf_fake_sections): Use bfd_elf_get_default_section_type.
gas/
2009-08-31 Jan Beulich <jbeulich@novell.com>
* config/obj-elf.c (obj_elf_change_section): Set default type
by calling bfd_elf_get_default_section_type.
gas/testsuite/
2009-08-31 Jan Beulich <jbeulich@novell.com>
* gas/elf/section5.l: Remove no longer issued warning pattern.
--- 2009-08-31/bfd/elf-bfd.h 2009-07-23 15:06:29.000000000 +0200
+++ 2009-08-31/bfd/elf-bfd.h 2009-08-31 10:07:16.000000000 +0200
@@ -2108,6 +2108,8 @@ extern bfd_boolean _bfd_elf_map_sections
extern bfd_boolean _bfd_elf_is_function_type (unsigned int);
+extern int bfd_elf_get_default_section_type (flagword);
+
extern Elf_Internal_Phdr * _bfd_elf_find_segment_containing_section
(bfd * abfd, asection * section);
--- 2009-08-31/bfd/elf.c 2009-08-31 09:54:15.000000000 +0200
+++ 2009-08-31/bfd/elf.c 2009-08-31 10:07:16.000000000 +0200
@@ -2422,6 +2422,18 @@ _bfd_elf_init_reloc_shdr (bfd *abfd,
return TRUE;
}
+/* Return the default section type based on the passed in section flags. */
+
+int
+bfd_elf_get_default_section_type (flagword flags)
+{
+ if ((flags & SEC_ALLOC) != 0
+ && ((flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0
+ || (flags & SEC_NEVER_LOAD) != 0))
+ return SHT_NOBITS;
+ return SHT_PROGBITS;
+}
+
/* Set up an ELF internal section header for a section. */
static void
@@ -2471,12 +2483,8 @@ elf_fake_sections (bfd *abfd, asection *
asect->flags. */
if ((asect->flags & SEC_GROUP) != 0)
sh_type = SHT_GROUP;
- else if ((asect->flags & SEC_ALLOC) != 0
- && (((asect->flags & (SEC_LOAD | SEC_HAS_CONTENTS)) == 0)
- || (asect->flags & SEC_NEVER_LOAD) != 0))
- sh_type = SHT_NOBITS;
else
- sh_type = SHT_PROGBITS;
+ sh_type = bfd_elf_get_default_section_type (asect->flags);
if (this_hdr->sh_type == SHT_NULL)
this_hdr->sh_type = sh_type;
--- 2009-08-31/gas/config/obj-elf.c 2009-08-31 09:54:18.000000000 +0200
+++ 2009-08-31/gas/config/obj-elf.c 2009-08-31 10:07:16.000000000 +0200
@@ -685,6 +685,8 @@ obj_elf_change_section (const char *name
{
symbolS *secsym;
+ if (type == SHT_NULL)
+ type = bfd_elf_get_default_section_type (flags);
elf_section_type (sec) = type;
elf_section_flags (sec) = attr;
--- 2009-08-31/gas/testsuite/gas/elf/section5.l 2005-01-18 10:43:34.000000000 +0100
+++ 2009-08-31/gas/testsuite/gas/elf/section5.l 2009-08-31 10:07:16.000000000 +0200
@@ -2,7 +2,6 @@
.*:7: Warning: .*
.*:7: Warning: .*
.*:10: Warning: .*
-.*:13: Warning: .*
.*:16: Warning: .*
.*:18: Warning: .*
.*:20: Warning: .*
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-08-31 12:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-06 14:36 bogus "ignoring changed section type" warning Jan Beulich
2009-08-07 0:51 ` Alan Modra
2009-08-28 16:13 ` Jan Beulich
2009-08-30 18:32 ` Alan Modra
2009-08-31 14:14 ` Jan Beulich
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).