From: tip-bot for Petr Vandrovec <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dzickus@redhat.com, petr@vandrovec.name, tglx@linutronix.de,
jpoimboe@redhat.com, mingo@kernel.org, hpa@zytor.com,
peterz@infradead.org, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org
Subject: [tip:core/urgent] objtool: Do not retrieve data from empty sections
Date: Fri, 15 Sep 2017 01:43:58 -0700 [thread overview]
Message-ID: <tip-7156b7141a037420a3cd99dbc1559e0235f57c07@git.kernel.org> (raw)
In-Reply-To: <2ce30a44349065b70d0f00e71e286dc0cbe745e6.1505459652.git.jpoimboe@redhat.com>
Commit-ID: 7156b7141a037420a3cd99dbc1559e0235f57c07
Gitweb: http://git.kernel.org/tip/7156b7141a037420a3cd99dbc1559e0235f57c07
Author: Petr Vandrovec <petr@vandrovec.name>
AuthorDate: Fri, 15 Sep 2017 02:15:05 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 15 Sep 2017 10:30:31 +0200
objtool: Do not retrieve data from empty sections
Binutils 2.29-9 in Debian return an error when elf_getdata is invoked
on empty section (.note.GNU-stack in all kernel files), causing
immediate failure of kernel build with:
elf_getdata: can't manipulate null section
As nothing is done with sections that have zero size, just do not
retrieve their data at all.
Signed-off-by: Petr Vandrovec <petr@vandrovec.name>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Reviewed-by: Don Zickus <dzickus@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/2ce30a44349065b70d0f00e71e286dc0cbe745e6.1505459652.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/elf.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 1e89a5f..b4cd8bc 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -175,19 +175,20 @@ static int read_sections(struct elf *elf)
return -1;
}
- sec->data = elf_getdata(s, NULL);
- if (!sec->data) {
- WARN_ELF("elf_getdata");
- return -1;
- }
-
- if (sec->data->d_off != 0 ||
- sec->data->d_size != sec->sh.sh_size) {
- WARN("unexpected data attributes for %s", sec->name);
- return -1;
+ if (sec->sh.sh_size != 0) {
+ sec->data = elf_getdata(s, NULL);
+ if (!sec->data) {
+ WARN_ELF("elf_getdata");
+ return -1;
+ }
+ if (sec->data->d_off != 0 ||
+ sec->data->d_size != sec->sh.sh_size) {
+ WARN("unexpected data attributes for %s",
+ sec->name);
+ return -1;
+ }
}
-
- sec->len = sec->data->d_size;
+ sec->len = sec->sh.sh_size;
}
/* sanity check, one more call to elf_nextscn() should return NULL */
next prev parent reply other threads:[~2017-09-15 8:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-15 7:15 [PATCH] " Josh Poimboeuf
2017-09-15 8:43 ` tip-bot for Petr Vandrovec [this message]
2017-09-15 9:37 ` [tip:core/urgent] " tip-bot for Petr Vandrovec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-7156b7141a037420a3cd99dbc1559e0235f57c07@git.kernel.org \
--to=tipbot@zytor.com \
--cc=dzickus@redhat.com \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=petr@vandrovec.name \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®