1/*-
2 * Copyright (c) 2000 David O'Brien
3 * Copyright (c) 1995-1996 S�ren Schmidt
4 * Copyright (c) 1996 Peter Wemm
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
--- 15 unchanged lines hidden (view full) ---
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 190708 2009-04-05 09:27:19Z dchagin $");
33
34#include "opt_compat.h"
35
36#include <sys/param.h>
37#include <sys/exec.h>
38#include <sys/fcntl.h>
39#include <sys/imgact.h>
40#include <sys/imgact_elf.h>
--- 40 unchanged lines hidden (view full) ---
81static Elf_Brandinfo *__elfN(get_brandinfo)(struct image_params *imgp,
82 const char *interp, int32_t *osrel);
83static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
84 u_long *entry, size_t pagesize);
85static int __elfN(load_section)(struct vmspace *vmspace, vm_object_t object,
86 vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz,
87 vm_prot_t prot, size_t pagesize);
88static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp);
89static boolean_t __elfN(check_note)(struct image_params *imgp,
90 Elf_Brandnote *checknote, int32_t *osrel);
91
92SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW, 0,
93 "");
94
95int __elfN(fallback_brand) = -1;
96SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
--- 14 unchanged lines hidden (view full) ---
111
112static const char FREEBSD_ABI_VENDOR[] = "FreeBSD";
113
114Elf_Brandnote __elfN(freebsd_brandnote) = {
115 .hdr.n_namesz = sizeof(FREEBSD_ABI_VENDOR),
116 .hdr.n_descsz = sizeof(int32_t),
117 .hdr.n_type = 1,
118 .vendor = FREEBSD_ABI_VENDOR,
119 .flags = BN_CAN_FETCH_OSREL
120};
121
122int
123__elfN(insert_brand_entry)(Elf_Brandinfo *entry)
124{
125 int i;
126
127 for (i = 0; i < MAX_BRANDS; i++) {
128 if (elf_brand_list[i] == NULL) {
129 elf_brand_list[i] = entry;
--- 1236 unchanged lines hidden (view full) ---
1366 if (strncmp(checknote->vendor, note_name,
1367 checknote->hdr.n_namesz) != 0)
1368 goto nextnote;
1369
1370 /*
1371 * Fetch the osreldate for binary
1372 * from the ELF OSABI-note if necessary.
1373 */
1374 if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 &&
1375 osrel != NULL)
1376 *osrel = *(const int32_t *) (note_name +
1377 roundup2(checknote->hdr.n_namesz,
1378 sizeof(Elf32_Addr)));
1379 return (TRUE);
1380
1381nextnote:
1382 note = (const Elf_Note *)((const char *)(note + 1) +
1383 roundup2(note->n_namesz, sizeof(Elf32_Addr)) +
1384 roundup2(note->n_descsz, sizeof(Elf32_Addr)));
1385 }
1386
1387 return (FALSE);
1388}
1389
1390/*
1391 * Tell kern_execve.c about it, with a little help from the linker.
1392 */
1393static struct execsw __elfN(execsw) = {
1394 __CONCAT(exec_, __elfN(imgact)),
1395 __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE))
1396};
1397EXEC_SET(__CONCAT(elf, __ELF_WORD_SIZE), __elfN(execsw));
2 * Copyright (c) 2000 David O'Brien
3 * Copyright (c) 1995-1996 S�ren Schmidt
4 * Copyright (c) 1996 Peter Wemm
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
--- 15 unchanged lines hidden (view full) ---
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <sys/cdefs.h>
32__FBSDID("$FreeBSD: head/sys/kern/imgact_elf.c 190708 2009-04-05 09:27:19Z dchagin $");
33
34#include "opt_compat.h"
35
36#include <sys/param.h>
37#include <sys/exec.h>
38#include <sys/fcntl.h>
39#include <sys/imgact.h>
40#include <sys/imgact_elf.h>
--- 40 unchanged lines hidden (view full) ---
81static Elf_Brandinfo *__elfN(get_brandinfo)(struct image_params *imgp,
82 const char *interp, int32_t *osrel);
83static int __elfN(load_file)(struct proc *p, const char *file, u_long *addr,
84 u_long *entry, size_t pagesize);
85static int __elfN(load_section)(struct vmspace *vmspace, vm_object_t object,
86 vm_offset_t offset, caddr_t vmaddr, size_t memsz, size_t filsz,
87 vm_prot_t prot, size_t pagesize);
88static int __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp);
89static boolean_t __elfN(check_note)(struct image_params *imgp,
90 Elf_Brandnote *checknote, int32_t *osrel);
91
92SYSCTL_NODE(_kern, OID_AUTO, __CONCAT(elf, __ELF_WORD_SIZE), CTLFLAG_RW, 0,
93 "");
94
95int __elfN(fallback_brand) = -1;
96SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO,
--- 14 unchanged lines hidden (view full) ---
111
112static const char FREEBSD_ABI_VENDOR[] = "FreeBSD";
113
114Elf_Brandnote __elfN(freebsd_brandnote) = {
115 .hdr.n_namesz = sizeof(FREEBSD_ABI_VENDOR),
116 .hdr.n_descsz = sizeof(int32_t),
117 .hdr.n_type = 1,
118 .vendor = FREEBSD_ABI_VENDOR,
119 .flags = BN_CAN_FETCH_OSREL
120};
121
122int
123__elfN(insert_brand_entry)(Elf_Brandinfo *entry)
124{
125 int i;
126
127 for (i = 0; i < MAX_BRANDS; i++) {
128 if (elf_brand_list[i] == NULL) {
129 elf_brand_list[i] = entry;
--- 1236 unchanged lines hidden (view full) ---
1366 if (strncmp(checknote->vendor, note_name,
1367 checknote->hdr.n_namesz) != 0)
1368 goto nextnote;
1369
1370 /*
1371 * Fetch the osreldate for binary
1372 * from the ELF OSABI-note if necessary.
1373 */
1374 if ((checknote->flags & BN_CAN_FETCH_OSREL) != 0 &&
1375 osrel != NULL)
1376 *osrel = *(const int32_t *) (note_name +
1377 roundup2(checknote->hdr.n_namesz,
1378 sizeof(Elf32_Addr)));
1379 return (TRUE);
1380
1381nextnote:
1382 note = (const Elf_Note *)((const char *)(note + 1) +
1383 roundup2(note->n_namesz, sizeof(Elf32_Addr)) +
1384 roundup2(note->n_descsz, sizeof(Elf32_Addr)));
1385 }
1386
1387 return (FALSE);
1388}
1389
1390/*
1391 * Tell kern_execve.c about it, with a little help from the linker.
1392 */
1393static struct execsw __elfN(execsw) = {
1394 __CONCAT(exec_, __elfN(imgact)),
1395 __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE))
1396};
1397EXEC_SET(__CONCAT(elf, __ELF_WORD_SIZE), __elfN(execsw));