This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] elf: Properly compute offsets of desc and next note
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Simon Marchi <simon dot marchi at ericsson dot com>
- Cc: Nick Clifton <nickc at redhat dot com>, Binutils <binutils at sourceware dot org>, Pedro Alves <palves at redhat dot com>
- Date: Fri, 24 Nov 2017 14:20:42 -0800
- Subject: Re: [PATCH] elf: Properly compute offsets of desc and next note
- Authentication-results: sourceware.org; auth=none
- References: <5028c35a-6bbd-0e14-a428-5a87e5ed7c61@ericsson.com>
On Fri, Nov 24, 2017 at 12:53 PM, Simon Marchi
<simon.marchi@ericsson.com> wrote:
> Hi,
>
> Pedro found that this patch caused the GDB test "gdb.base/auxv.exp" to
> consume memory until the machine becomes unresponsive. I was able to
> reproduce it too, so I chose to revert the patch, to reduce the risk
> of it happening on other developer's machines and buildbot builders.
>
> The test can be ran with:
>
> gdb/$ make check TESTS="gdb.base/auxv.exp"
>
> (It's a good idea to ctrl-C quickly enough :))
>
> After running the test once, I was able to reproduce the issue by starting
> GDB manually like this:
>
> gdb/$ ./gdb -ex "core /home/emaisin/build/binutils-gdb/gdb/testsuite/outputs/gdb.base/auxv/auxv.corefile"
>
> There is an infinite loop in elf_parse_notes, the pointer "p" never
> gets advanced.
>
This patch fixes the problem for me. Please give it a try.
Thanks.
--
H.J.
From 6dc36e23ddb349a90fb471cee5300812b4603451 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 24 Nov 2017 14:17:54 -0800
Subject: [PATCH] Make 4 byte minimum alignment for PT_NOTE segments
CORE PT_NOTE segments may have p_align values of 0 or 1. gABI specifies
that PT_NOTE alignment should be aligned to 4 bytes for 32-bit objects
and to 8 bytes for 64-bit objects. If segment alignment is less than 4,
we use 4 byte alignment.
* elf.c (elf_parse_notes): Make 4 byte minimum alignment for
PT_NOTE segments.
---
bfd/elf.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/bfd/elf.c b/bfd/elf.c
index d42c949407..8f6aa53b5c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10978,6 +10978,13 @@ elf_parse_notes (bfd *abfd, char *buf, size_t size, file_ptr offset,
{
char *p;
+ /* NB: CORE PT_NOTE segments may have p_align values of 0 or 1.
+ gABI specifies that PT_NOTE alignment should be aligned to 4
+ bytes for 32-bit objects and to 8 bytes for 64-bit objects. If
+ align is less than 4, we use 4 byte alignment. */
+ if (align < 4)
+ align = 4;
+
p = buf;
while (p < buf + size)
{
--
2.14.3