summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_elf.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-03-11 19:38:49 +0000
committerkib <kib@FreeBSD.org>2012-03-11 19:38:49 +0000
commit4e790f9b2bb03f68c3e84c20c4a2c4e9dc912da7 (patch)
treef6565e102b890bbbf49a05aa423208362c42361b /sys/kern/imgact_elf.c
parentf3886e29aff7988ddf148a5f8f016154f15383d4 (diff)
downloadFreeBSD-src-4e790f9b2bb03f68c3e84c20c4a2c4e9dc912da7.zip
FreeBSD-src-4e790f9b2bb03f68c3e84c20c4a2c4e9dc912da7.tar.gz
ELF image can have several PT_NOTE program headers. Look for the ELF
brand note in each header, instead of using only first one. Reviewed by: kan Tested by: andrew (arm), flo (sparc64) MFC after: 3 weeks
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r--sys/kern/imgact_elf.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index bde590c..f907526 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -1549,32 +1549,14 @@ __elfN(putnote)(void *dst, size_t *off, const char *name, int type,
*off += roundup2(note.n_descsz, sizeof(Elf_Size));
}
-/*
- * Try to find the appropriate ABI-note section for checknote,
- * fetch the osreldate for binary from the ELF OSABI-note. Only the
- * first page of the image is searched, the same as for headers.
- */
static boolean_t
-__elfN(check_note)(struct image_params *imgp, Elf_Brandnote *checknote,
- int32_t *osrel)
+__elfN(parse_notes)(struct image_params *imgp, Elf_Brandnote *checknote,
+ int32_t *osrel, const Elf_Phdr *pnote)
{
const Elf_Note *note, *note0, *note_end;
- const Elf_Phdr *phdr, *pnote;
- const Elf_Ehdr *hdr;
const char *note_name;
int i;
- pnote = NULL;
- hdr = (const Elf_Ehdr *)imgp->image_header;
- phdr = (const Elf_Phdr *)(imgp->image_header + hdr->e_phoff);
-
- for (i = 0; i < hdr->e_phnum; i++) {
- if (phdr[i].p_type == PT_NOTE) {
- pnote = &phdr[i];
- break;
- }
- }
-
if (pnote == NULL || pnote->p_offset >= PAGE_SIZE ||
pnote->p_offset + pnote->p_filesz >= PAGE_SIZE)
return (FALSE);
@@ -1613,6 +1595,31 @@ nextnote:
}
/*
+ * Try to find the appropriate ABI-note section for checknote,
+ * fetch the osreldate for binary from the ELF OSABI-note. Only the
+ * first page of the image is searched, the same as for headers.
+ */
+static boolean_t
+__elfN(check_note)(struct image_params *imgp, Elf_Brandnote *checknote,
+ int32_t *osrel)
+{
+ const Elf_Phdr *phdr;
+ const Elf_Ehdr *hdr;
+ int i;
+
+ hdr = (const Elf_Ehdr *)imgp->image_header;
+ phdr = (const Elf_Phdr *)(imgp->image_header + hdr->e_phoff);
+
+ for (i = 0; i < hdr->e_phnum; i++) {
+ if (phdr[i].p_type == PT_NOTE &&
+ __elfN(parse_notes)(imgp, checknote, osrel, &phdr[i]))
+ return (TRUE);
+ }
+ return (FALSE);
+
+}
+
+/*
* Tell kern_execve.c about it, with a little help from the linker.
*/
static struct execsw __elfN(execsw) = {
OpenPOWER on IntegriCloud