Skip to contentSkip to conversation

objtool-do-not-retrieve-data-from-empty-sections.patch removed from -mm tree

merged [email protected] 1 participant 1 message Sep 25, 2017

lore
Share & tools
lore

[email protected]

author tree notice Applied
#0 lore raw

The patch titled
Subject: objtool: do not retrieve data from empty sections
has been removed from the -mm tree. Its filename was
objtool-do-not-retrieve-data-from-empty-sections.patch

This patch was dropped because it was merged into mainline or a subsystem tree

------------------------------------------------------
From: Petr Vandrovec <[email protected]>
Subject: objtool: do not retrieve data from empty sections

Binutils 2.29-9 in Debian returns 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.

---

 tools/objtool/elf.c |   25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
tools/objtool/elf.c renamed from tools/objtool/elf.c~objtool-do-not-retrieve-data-from-empty-sections +12 -10
diff -puN tools/objtool/elf.c~objtool-do-not-retrieve-data-from-empty-sections 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->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;
+			}
 		}
-
-		if (sec->data->d_off != 0 ||
-		    sec->data->d_size != sec->sh.sh_size) {
-			WARN("unexpected data attributes for %s", sec->name);
-			return -1;
-		}