This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ELF64 note sections
On Thu, Sep 18, 2003 at 08:20:51AM -0400, Daniel Jacobowitz wrote:
> That struct is bogus. BFD code assumes that sizeof (Elf_External_Note)
> is 13, but I've encountered at least one ABI which pads it up to 16
> bytes.
A grep over the source says that the overall size is used in just
one place, elf.c:elfcore_write_note. So the following ought to fix
this problem. What's more worrying though, is that we use the same
idiom elsewhere to declare variable sized arrays. How many of them
are broken?
* elf.c (elfcore_write_note): Don't use sizeof(Elf_External_note)
since some ABIs round up the size of the struct.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.198
diff -u -p -r1.198 elf.c
--- bfd/elf.c 7 Aug 2003 08:38:07 -0000 1.198
+++ bfd/elf.c 19 Sep 2003 00:13:55 -0000
@@ -7066,7 +7066,7 @@ elfcore_write_note (bfd *abfd,
pad = -namesz & ((1 << bed->s->log_file_align) - 1);
}
- newspace = sizeof (Elf_External_Note) - 1 + namesz + pad + size;
+ newspace = 12 + namesz + pad + size;
p = realloc (buf, *bufsiz + newspace);
dest = p + *bufsiz;
--
Alan Modra
IBM OzLabs - Linux Technology Centre