+ kbuild-check-sht_rel-sections.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     kbuild: check SHT_REL sections

has been added to the -mm tree.  Its filename is

     kbuild-check-sht_rel-sections.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this


From: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>

I found that modpost can not detect section mismatch on mips and i386.  On
mips64, the modpost (with r_info layout fix) can detect it.  The current
modpst only checks SHT_RELA section but I suppose SHT_REL section should be
checked also.  This patch does not contain r_info layout fix.  I'll post an
updated r_info layout fix on next mail.

Check SHT_REL sections as like as SHT_RELA sections to detect section
mismatch.

Signed-off-by: Atsushi Nemoto <anemo@xxxxxxxxxxxxx>
Cc: Sam Ravnborg <sam@xxxxxxxxxxxx>
Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 scripts/mod/modpost.c |   65 ++++++++++++++++++++++++++++------------
 scripts/mod/modpost.h |    2 +
 2 files changed, 48 insertions(+), 19 deletions(-)

diff -puN scripts/mod/modpost.c~kbuild-check-sht_rel-sections scripts/mod/modpost.c
--- devel/scripts/mod/modpost.c~kbuild-check-sht_rel-sections	2006-05-18 00:47:32.000000000 -0700
+++ devel-akpm/scripts/mod/modpost.c	2006-05-18 00:47:32.000000000 -0700
@@ -728,29 +728,56 @@ static void check_sec_ref(struct module 
 
 	/* Walk through all sections */
 	for (i = 0; i < hdr->e_shnum; i++) {
-		Elf_Rela *rela;
-		Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
-		Elf_Rela *stop  = (void*)start + sechdrs[i].sh_size;
-		const char *name = secstrings + sechdrs[i].sh_name +
-						strlen(".rela");
+		const char *name = secstrings + sechdrs[i].sh_name;
+		const char *secname;
+		Elf_Rela r;
 		/* We want to process only relocation sections and not .init */
-		if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA))
-			continue;
+		if (sechdrs[i].sh_type == SHT_RELA) {
+			Elf_Rela *rela;
+			Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
+			Elf_Rela *stop  = (void*)start + sechdrs[i].sh_size;
+			name += strlen(".rela");
+			if (section_ref_ok(name))
+				continue;
 
-		for (rela = start; rela < stop; rela++) {
-			Elf_Rela r;
-			const char *secname;
-			r.r_offset = TO_NATIVE(rela->r_offset);
-			r.r_info   = TO_NATIVE(rela->r_info);
-			r.r_addend = TO_NATIVE(rela->r_addend);
-			sym = elf->symtab_start + ELF_R_SYM(r.r_info);
-			/* Skip special sections */
-			if (sym->st_shndx >= SHN_LORESERVE)
+			for (rela = start; rela < stop; rela++) {
+				r.r_offset = TO_NATIVE(rela->r_offset);
+				r.r_info   = TO_NATIVE(rela->r_info);
+				r.r_addend = TO_NATIVE(rela->r_addend);
+				sym = elf->symtab_start + ELF_R_SYM(r.r_info);
+				/* Skip special sections */
+				if (sym->st_shndx >= SHN_LORESERVE)
+					continue;
+
+				secname = secstrings +
+					sechdrs[sym->st_shndx].sh_name;
+				if (section(secname))
+					warn_sec_mismatch(modname, name,
+							  elf, sym, r);
+			}
+		} else if (sechdrs[i].sh_type == SHT_REL) {
+			Elf_Rel *rel;
+			Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset;
+			Elf_Rel *stop  = (void*)start + sechdrs[i].sh_size;
+			name += strlen(".rel");
+			if (section_ref_ok(name))
 				continue;
 
-			secname = secstrings + sechdrs[sym->st_shndx].sh_name;
-			if (section(secname))
-				warn_sec_mismatch(modname, name, elf, sym, r);
+			for (rel = start; rel < stop; rel++) {
+				r.r_offset = TO_NATIVE(rel->r_offset);
+				r.r_info   = TO_NATIVE(rel->r_info);
+				r.r_addend = 0;
+				sym = elf->symtab_start + ELF_R_SYM(r.r_info);
+				/* Skip special sections */
+				if (sym->st_shndx >= SHN_LORESERVE)
+					continue;
+
+				secname = secstrings +
+					sechdrs[sym->st_shndx].sh_name;
+				if (section(secname))
+					warn_sec_mismatch(modname, name,
+							  elf, sym, r);
+			}
 		}
 	}
 }
diff -puN scripts/mod/modpost.h~kbuild-check-sht_rel-sections scripts/mod/modpost.h
--- devel/scripts/mod/modpost.h~kbuild-check-sht_rel-sections	2006-05-18 00:47:32.000000000 -0700
+++ devel-akpm/scripts/mod/modpost.h	2006-05-18 00:47:32.000000000 -0700
@@ -21,6 +21,7 @@
 #define ELF_ST_BIND ELF32_ST_BIND
 #define ELF_ST_TYPE ELF32_ST_TYPE
 
+#define Elf_Rel     Elf32_Rel
 #define Elf_Rela    Elf32_Rela
 #define ELF_R_SYM   ELF32_R_SYM
 #define ELF_R_TYPE  ELF32_R_TYPE
@@ -34,6 +35,7 @@
 #define ELF_ST_BIND ELF64_ST_BIND
 #define ELF_ST_TYPE ELF64_ST_TYPE
 
+#define Elf_Rel     Elf64_Rel
 #define Elf_Rela    Elf64_Rela
 #define ELF_R_SYM   ELF64_R_SYM
 #define ELF_R_TYPE  ELF64_R_TYPE
_

Patches currently in -mm which might be from anemo@xxxxxxxxxxxxx are

kbuild-check-sht_rel-sections.patch
kbuild-fix-modpost-segfault-for-64bit-mipsel-kernel.patch
git-cryptodev.patch
rtc-rtc-dev-uie-emulation.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux