* PR 14444, degenerate SHT_GROUP
@ 2012-08-10 6:23 Alan Modra
0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2012-08-10 6:23 UTC (permalink / raw)
To: binutils
Allowing SHT_GROUP sections that only contain a flag word doesn't seem
to break anything in BFD, so don't reject files that have empty
groups. I don't see anything in the ELF spec that forbids such.
PR binutils/14444
* elf.c (IS_VALID_GROUP_SECTION_HEADER) Add minsize param.
(setup_group): Adjust uses.
(bfd_section_from_shdr): Allow SHT_GROUP sections with just a flag
word.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.568
diff -u -p -r1.568 elf.c
--- bfd/elf.c 24 Jul 2012 21:06:57 -0000 1.568
+++ bfd/elf.c 10 Aug 2012 02:02:31 -0000
@@ -545,9 +545,9 @@ setup_group (bfd *abfd, Elf_Internal_Shd
shnum = elf_numsections (abfd);
num_group = 0;
-#define IS_VALID_GROUP_SECTION_HEADER(shdr) \
+#define IS_VALID_GROUP_SECTION_HEADER(shdr, minsize) \
( (shdr)->sh_type == SHT_GROUP \
- && (shdr)->sh_size >= (2 * GRP_ENTRY_SIZE) \
+ && (shdr)->sh_size >= minsize \
&& (shdr)->sh_entsize == GRP_ENTRY_SIZE \
&& ((shdr)->sh_size % GRP_ENTRY_SIZE) == 0)
@@ -555,7 +555,7 @@ setup_group (bfd *abfd, Elf_Internal_Shd
{
Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
- if (IS_VALID_GROUP_SECTION_HEADER (shdr))
+ if (IS_VALID_GROUP_SECTION_HEADER (shdr, 2 * GRP_ENTRY_SIZE))
num_group += 1;
}
@@ -581,7 +581,7 @@ setup_group (bfd *abfd, Elf_Internal_Shd
{
Elf_Internal_Shdr *shdr = elf_elfsections (abfd)[i];
- if (IS_VALID_GROUP_SECTION_HEADER (shdr))
+ if (IS_VALID_GROUP_SECTION_HEADER (shdr, 2 * GRP_ENTRY_SIZE))
{
unsigned char *src;
Elf_Internal_Group *dest;
@@ -1929,7 +1929,7 @@ bfd_section_from_shdr (bfd *abfd, unsign
return TRUE;
case SHT_GROUP:
- if (! IS_VALID_GROUP_SECTION_HEADER (hdr))
+ if (! IS_VALID_GROUP_SECTION_HEADER (hdr, GRP_ENTRY_SIZE))
return FALSE;
if (!_bfd_elf_make_section_from_shdr (abfd, hdr, name, shindex))
return FALSE;
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-08-10 2:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-10 6:23 PR 14444, degenerate SHT_GROUP 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).