aboutsummaryrefslogtreecommitdiff
path: root/tools/objtool
diff options
context:
space:
mode:
authorPetr Vandrovec <petr@vandrovec.name>2017-09-15 02:15:05 -0500
committerIngo Molnar <mingo@kernel.org>2017-09-15 11:31:50 +0200
commitdf968c9329f6e5cf3596a0a54adb6f749747a746 (patch)
tree6e7c2dde58d95c1effacb54ecfbaa72bf8843f2f /tools/objtool
parent0998b7a0befdf6e734032895ee639a5e6f88cc3f (diff)
downloadlinux-stericsson-df968c9329f6e5cf3596a0a54adb6f749747a746.tar.gz
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> 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>
Diffstat (limited to 'tools/objtool')
-rw-r--r--tools/objtool/elf.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 1e89a5f8bfc9..b4cd8bc62521 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 */