[PATCH 12/16] elfops: hide get_section() and rename its parameters

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

 



load_section() has replaced get_section() outside elfops.

The new parameter names match the fields in struct elf_file.

Signed-off-by: Andreas Robinson <andr345@xxxxxxxxx>
---
 elfops.c      |   16 ----------------
 elfops.h      |    6 ------
 elfops_core.c |   26 +++++++++++++-------------
 3 files changed, 13 insertions(+), 35 deletions(-)

diff --git a/elfops.c b/elfops.c
index ac33c96..3872bf8 100644
--- a/elfops.c
+++ b/elfops.c
@@ -45,21 +45,6 @@ int elf_ident(void *file, unsigned long fsize, int *conv)
 	return ident[EI_CLASS];
 }
 
-void *get_section(void *file, unsigned long filesize,
-		  const char *secname, unsigned long *secsize)
-{
-	int conv;
-
-	switch (elf_ident(file, filesize, &conv)) {
-	case ELFCLASS32:
-		return get_section32(file, filesize, secname, secsize, conv);
-	case ELFCLASS64:
-		return get_section64(file, filesize, secname, secsize, conv);
-	default:
-		return NULL;
-	}
-}
-
 /*
  * grab_elf_file - read ELF file into memory
  * @pathame: file to load
@@ -141,4 +126,3 @@ void release_elf_file(struct elf_file *file)
 
 	errno = err;
 }
-
diff --git a/elfops.h b/elfops.h
index dffd9f5..c30a7ae 100644
--- a/elfops.h
+++ b/elfops.h
@@ -70,12 +70,6 @@ struct module_ops
 extern struct module_ops mod_ops32, mod_ops64;
 
 int elf_ident(void *file, unsigned long fsize, int *conv);
-void *get_section(void *file, unsigned long filesize,
-	const char *secname, unsigned long *secsize);
-void *get_section32(void *file, unsigned long filesize,
-	const char *secname, unsigned long *secsize, int conv);
-void *get_section64(void *file, unsigned long filesize,
-	const char *secname, unsigned long *secsize, int conv);
 
 struct elf_file *grab_elf_file(const char *pathname);
 struct elf_file *grab_elf_file_fd(const char *pathname, int fd);
diff --git a/elfops_core.c b/elfops_core.c
index ec314df..8968593 100644
--- a/elfops_core.c
+++ b/elfops_core.c
@@ -14,11 +14,11 @@
 #  error "Undefined ELF word length"
 #endif
 
-void *PERBIT(get_section)(void *file,
-			  unsigned long fsize,
-			  const char *secname,
-			  unsigned long *secsize,
-			  int conv)
+static void *PERBIT(get_section)(void *data,
+				 unsigned long len,
+				 const char *secname,
+				 unsigned long *secsize,
+				 int conv)
 {
 	ElfPERBIT(Ehdr) *hdr;
 	ElfPERBIT(Shdr) *sechdrs;
@@ -29,32 +29,32 @@ void *PERBIT(get_section)(void *file,
 	const char *secnames;
 	unsigned int i;
 
-	if (fsize <= 0 || fsize < sizeof(*hdr))
+	if (len <= 0 || len < sizeof(*hdr))
 		return NULL;
 
-	hdr = file;
+	hdr = data;
 	e_shoff = END(hdr->e_shoff, conv);
 	e_shnum = END(hdr->e_shnum, conv);
 	e_shstrndx = END(hdr->e_shstrndx, conv);
 
-	if (fsize < e_shoff + e_shnum * sizeof(sechdrs[0]))
+	if (len < e_shoff + e_shnum * sizeof(sechdrs[0]))
 		return NULL;
 
-	sechdrs = file + e_shoff;
+	sechdrs = data + e_shoff;
 
-	if (fsize < END(sechdrs[e_shstrndx].sh_offset, conv))
+	if (len < END(sechdrs[e_shstrndx].sh_offset, conv))
 		return NULL;
 
 	/* Find section by name, return pointer and size. */
 
-	secnames = file + END(sechdrs[e_shstrndx].sh_offset, conv);
+	secnames = data + END(sechdrs[e_shstrndx].sh_offset, conv);
 	for (i = 1; i < e_shnum; i++) {
 		if (streq(secnames + END(sechdrs[i].sh_name, conv), secname)) {
 			*secsize = END(sechdrs[i].sh_size, conv);
 			secoffset = END(sechdrs[i].sh_offset, conv);
-			if (fsize < secoffset + *secsize)
+			if (len < secoffset + *secsize)
 				return NULL;
-			return file + secoffset;
+			return data + secoffset;
 		}
 	}
 	*secsize = 0;
-- 
1.6.0.4

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

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux