mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add infrastructure required for Linux coredump support
This adds `sv_elf_core_osabi`, `sv_elf_core_abi_vendor`,
and `sv_elf_core_prepare_notes` fields to `struct sysentvec`,
and modifies imgact_elf.c to make use of them instead
of hardcoding FreeBSD-specific values. It also updates all
of the ABI definitions to preserve current behaviour.
This makes it possible to implement non-native ELF coredump
support without unnecessary code duplication. It will be used
for Linux coredumps.
Reviewed By: kib
Sponsored By: EPSRC
Differential Revision: https://reviews.freebsd.org/D30921
(cherry picked from commit 435754a59e)
This commit is contained in:
parent
f44a8039fe
commit
f707a6cf1a
23 changed files with 113 additions and 34 deletions
|
|
@ -66,6 +66,9 @@ struct sysentvec elf64_freebsd_sysvec_la48 = {
|
|||
.sv_sigcodeoff = VDSO_SIGCODE_OFFSET,
|
||||
.sv_name = "FreeBSD ELF64",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
@ -104,6 +107,9 @@ struct sysentvec elf64_freebsd_sysvec_la57 = {
|
|||
.sv_sigcodeoff = VDSO_SIGCODE_OFFSET,
|
||||
.sv_name = "FreeBSD ELF64",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -209,6 +209,9 @@ static struct sysentvec cloudabi32_elf_sysvec = {
|
|||
.sv_fixup = cloudabi32_fixup_tcb,
|
||||
.sv_name = "CloudABI ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_minuser = FREEBSD32_MINUSER,
|
||||
.sv_maxuser = FREEBSD32_MAXUSER,
|
||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
||||
|
|
|
|||
|
|
@ -197,6 +197,9 @@ static struct sysentvec cloudabi64_elf_sysvec = {
|
|||
.sv_fixup = cloudabi64_fixup_tcb,
|
||||
.sv_name = "CloudABI ELF64",
|
||||
.sv_coredump = elf64_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf64_prepare_notes,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
/* Keep top page reserved to work around AMD Ryzen stability issues. */
|
||||
.sv_maxuser = VM_MAXUSER_ADDRESS - PAGE_SIZE,
|
||||
|
|
|
|||
|
|
@ -734,6 +734,9 @@ struct sysentvec elf_linux_sysvec = {
|
|||
.sv_szsigcode = &linux_szsigcode,
|
||||
.sv_name = "Linux ELF64",
|
||||
.sv_coredump = elf64_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_NONE,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf64_prepare_notes,
|
||||
.sv_imgact_try = linux_exec_imgact_try,
|
||||
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -898,6 +898,9 @@ struct sysentvec elf_linux_sysvec = {
|
|||
.sv_szsigcode = &linux_szsigcode,
|
||||
.sv_name = "Linux ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_imgact_try = linux_exec_imgact_try,
|
||||
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||
.sv_szsigcode = &szsigcode,
|
||||
.sv_name = "FreeBSD ELF32",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -173,6 +173,9 @@ static struct sysentvec cloudabi32_elf_sysvec = {
|
|||
.sv_fixup = cloudabi32_fixup,
|
||||
.sv_name = "CloudABI ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
.sv_maxuser = VM_MAXUSER_ADDRESS,
|
||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ static struct sysentvec elf32_freebsd_sysvec = {
|
|||
.sv_szsigcode = &sz_aarch32_sigcode,
|
||||
.sv_name = "FreeBSD ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = FREEBSD32_MINUSER,
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ static struct sysentvec elf64_freebsd_sysvec = {
|
|||
.sv_szsigcode = &szsigcode,
|
||||
.sv_name = "FreeBSD ELF64",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -181,6 +181,9 @@ static struct sysentvec cloudabi32_elf_sysvec = {
|
|||
.sv_fixup = cloudabi32_fixup,
|
||||
.sv_name = "CloudABI ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
.sv_maxuser = (uintmax_t)1 << 32,
|
||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
||||
|
|
|
|||
|
|
@ -165,6 +165,9 @@ static struct sysentvec cloudabi64_elf_sysvec = {
|
|||
.sv_fixup = cloudabi64_fixup,
|
||||
.sv_name = "CloudABI ELF64",
|
||||
.sv_coredump = elf64_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf64_prepare_notes,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
.sv_maxuser = VM_MAXUSER_ADDRESS,
|
||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
||||
|
|
|
|||
|
|
@ -404,6 +404,9 @@ struct sysentvec elf_linux_sysvec = {
|
|||
.sv_szsigcode = &linux_szsigcode,
|
||||
.sv_name = "Linux ELF64",
|
||||
.sv_coredump = elf64_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_NONE,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf64_prepare_notes,
|
||||
.sv_imgact_try = linux_exec_imgact_try,
|
||||
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -112,6 +112,9 @@ struct sysentvec ia32_freebsd_sysvec = {
|
|||
.sv_sigcodeoff = VDSO_IA32_SIGCODE_OFFSET,
|
||||
.sv_name = "FreeBSD ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = FREEBSD32_MINUSER,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||
.sv_szsigcode = &szsigcode,
|
||||
.sv_name = "FreeBSD ELF32",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -883,6 +883,9 @@ struct sysentvec elf_linux_sysvec = {
|
|||
.sv_szsigcode = &linux_szsigcode,
|
||||
.sv_name = "Linux ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = elf32_prepare_notes,
|
||||
.sv_imgact_try = linux_exec_imgact_try,
|
||||
.sv_minsigstksz = LINUX_MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -206,8 +206,6 @@ static Elf_Brandinfo *elf_brand_list[MAX_BRANDS];
|
|||
|
||||
#define aligned(a, t) (rounddown2((u_long)(a), sizeof(t)) == (u_long)(a))
|
||||
|
||||
static const char FREEBSD_ABI_VENDOR[] = "FreeBSD";
|
||||
|
||||
Elf_Brandnote __elfN(freebsd_brandnote) = {
|
||||
.hdr.n_namesz = sizeof(FREEBSD_ABI_VENDOR),
|
||||
.hdr.n_descsz = sizeof(int32_t),
|
||||
|
|
@ -1504,8 +1502,6 @@ struct phdr_closure {
|
|||
Elf_Off offset; /* Offset of segment in core file */
|
||||
};
|
||||
|
||||
typedef void (*outfunc_t)(void *, struct sbuf *, size_t *);
|
||||
|
||||
struct note_info {
|
||||
int type; /* Note type. */
|
||||
outfunc_t outfunc; /* Output function. */
|
||||
|
|
@ -1525,10 +1521,7 @@ static void each_dumpable_segment(struct thread *, segment_callback, void *,
|
|||
int);
|
||||
static int __elfN(corehdr)(struct coredump_params *, int, void *, size_t,
|
||||
struct note_info_list *, size_t, int);
|
||||
static void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
|
||||
size_t *);
|
||||
static void __elfN(putnote)(struct note_info *, struct sbuf *);
|
||||
static size_t register_note(struct note_info_list *, int, outfunc_t, void *);
|
||||
static void __elfN(putnote)(struct thread *td, struct note_info *, struct sbuf *);
|
||||
|
||||
static void __elfN(note_fpregset)(void *, struct sbuf *, size_t *);
|
||||
static void __elfN(note_prpsinfo)(void *, struct sbuf *, size_t *);
|
||||
|
|
@ -1579,7 +1572,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
|
|||
hdrsize = sizeof(Elf_Ehdr) + sizeof(Elf_Phdr) * (1 + seginfo.count);
|
||||
if (seginfo.count + 1 >= PN_XNUM)
|
||||
hdrsize += sizeof(Elf_Shdr);
|
||||
__elfN(prepare_notes)(td, ¬elst, ¬esz);
|
||||
td->td_proc->p_sysent->sv_elf_core_prepare_notes(td, ¬elst, ¬esz);
|
||||
coresize = round_page(hdrsize + notesz) + seginfo.size;
|
||||
|
||||
/* Set up core dump parameters. */
|
||||
|
|
@ -1805,7 +1798,7 @@ __elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr,
|
|||
sbuf_start_section(sb, NULL);
|
||||
sbuf_bcat(sb, hdr, hdrsize);
|
||||
TAILQ_FOREACH(ninfo, notelst, link)
|
||||
__elfN(putnote)(ninfo, sb);
|
||||
__elfN(putnote)(p->td, ninfo, sb);
|
||||
/* Align up to a page boundary for the program segments. */
|
||||
sbuf_end_section(sb, -1, PAGE_SIZE, 0);
|
||||
error = sbuf_finish(sb);
|
||||
|
|
@ -1814,7 +1807,7 @@ __elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr,
|
|||
return (error);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
__elfN(prepare_notes)(struct thread *td, struct note_info_list *list,
|
||||
size_t *sizep)
|
||||
{
|
||||
|
|
@ -1825,7 +1818,7 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list,
|
|||
p = td->td_proc;
|
||||
size = 0;
|
||||
|
||||
size += register_note(list, NT_PRPSINFO, __elfN(note_prpsinfo), p);
|
||||
size += __elfN(register_note)(td, list, NT_PRPSINFO, __elfN(note_prpsinfo), p);
|
||||
|
||||
/*
|
||||
* To have the debugger select the right thread (LWP) as the initial
|
||||
|
|
@ -1835,15 +1828,15 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list,
|
|||
*/
|
||||
thr = td;
|
||||
while (thr != NULL) {
|
||||
size += register_note(list, NT_PRSTATUS,
|
||||
size += __elfN(register_note)(td, list, NT_PRSTATUS,
|
||||
__elfN(note_prstatus), thr);
|
||||
size += register_note(list, NT_FPREGSET,
|
||||
size += __elfN(register_note)(td, list, NT_FPREGSET,
|
||||
__elfN(note_fpregset), thr);
|
||||
size += register_note(list, NT_THRMISC,
|
||||
size += __elfN(register_note)(td, list, NT_THRMISC,
|
||||
__elfN(note_thrmisc), thr);
|
||||
size += register_note(list, NT_PTLWPINFO,
|
||||
size += __elfN(register_note)(td, list, NT_PTLWPINFO,
|
||||
__elfN(note_ptlwpinfo), thr);
|
||||
size += register_note(list, -1,
|
||||
size += __elfN(register_note)(td, list, -1,
|
||||
__elfN(note_threadmd), thr);
|
||||
|
||||
thr = thr == td ? TAILQ_FIRST(&p->p_threads) :
|
||||
|
|
@ -1852,23 +1845,23 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list,
|
|||
thr = TAILQ_NEXT(thr, td_plist);
|
||||
}
|
||||
|
||||
size += register_note(list, NT_PROCSTAT_PROC,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_PROC,
|
||||
__elfN(note_procstat_proc), p);
|
||||
size += register_note(list, NT_PROCSTAT_FILES,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_FILES,
|
||||
note_procstat_files, p);
|
||||
size += register_note(list, NT_PROCSTAT_VMMAP,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_VMMAP,
|
||||
note_procstat_vmmap, p);
|
||||
size += register_note(list, NT_PROCSTAT_GROUPS,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_GROUPS,
|
||||
note_procstat_groups, p);
|
||||
size += register_note(list, NT_PROCSTAT_UMASK,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_UMASK,
|
||||
note_procstat_umask, p);
|
||||
size += register_note(list, NT_PROCSTAT_RLIMIT,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_RLIMIT,
|
||||
note_procstat_rlimit, p);
|
||||
size += register_note(list, NT_PROCSTAT_OSREL,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_OSREL,
|
||||
note_procstat_osrel, p);
|
||||
size += register_note(list, NT_PROCSTAT_PSSTRINGS,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_PSSTRINGS,
|
||||
__elfN(note_procstat_psstrings), p);
|
||||
size += register_note(list, NT_PROCSTAT_AUXV,
|
||||
size += __elfN(register_note)(td, list, NT_PROCSTAT_AUXV,
|
||||
__elfN(note_procstat_auxv), p);
|
||||
|
||||
*sizep = size;
|
||||
|
|
@ -1892,7 +1885,7 @@ __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
|
|||
ehdr->e_ident[EI_CLASS] = ELF_CLASS;
|
||||
ehdr->e_ident[EI_DATA] = ELF_DATA;
|
||||
ehdr->e_ident[EI_VERSION] = EV_CURRENT;
|
||||
ehdr->e_ident[EI_OSABI] = ELFOSABI_FREEBSD;
|
||||
ehdr->e_ident[EI_OSABI] = td->td_proc->p_sysent->sv_elf_core_osabi;
|
||||
ehdr->e_ident[EI_ABIVERSION] = 0;
|
||||
ehdr->e_ident[EI_PAD] = 0;
|
||||
ehdr->e_type = ET_CORE;
|
||||
|
|
@ -1958,12 +1951,15 @@ __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
|
|||
each_dumpable_segment(td, cb_put_phdr, &phc, flags);
|
||||
}
|
||||
|
||||
static size_t
|
||||
register_note(struct note_info_list *list, int type, outfunc_t out, void *arg)
|
||||
size_t
|
||||
__elfN(register_note)(struct thread *td, struct note_info_list *list,
|
||||
int type, outfunc_t out, void *arg)
|
||||
{
|
||||
const struct sysentvec *sv;
|
||||
struct note_info *ninfo;
|
||||
size_t size, notesize;
|
||||
|
||||
sv = td->td_proc->p_sysent;
|
||||
size = 0;
|
||||
out(arg, NULL, &size);
|
||||
ninfo = malloc(sizeof(*ninfo), M_TEMP, M_ZERO | M_WAITOK);
|
||||
|
|
@ -1977,7 +1973,7 @@ register_note(struct note_info_list *list, int type, outfunc_t out, void *arg)
|
|||
return (size);
|
||||
|
||||
notesize = sizeof(Elf_Note) + /* note header */
|
||||
roundup2(sizeof(FREEBSD_ABI_VENDOR), ELF_NOTE_ROUNDSIZE) +
|
||||
roundup2(strlen(sv->sv_elf_core_abi_vendor) + 1, ELF_NOTE_ROUNDSIZE) +
|
||||
/* note name */
|
||||
roundup2(size, ELF_NOTE_ROUNDSIZE); /* note description */
|
||||
|
||||
|
|
@ -2027,9 +2023,10 @@ __elfN(populate_note)(int type, void *src, void *dst, size_t size, void **descp)
|
|||
}
|
||||
|
||||
static void
|
||||
__elfN(putnote)(struct note_info *ninfo, struct sbuf *sb)
|
||||
__elfN(putnote)(struct thread *td, struct note_info *ninfo, struct sbuf *sb)
|
||||
{
|
||||
Elf_Note note;
|
||||
const struct sysentvec *sv;
|
||||
ssize_t old_len, sect_len;
|
||||
size_t new_len, descsz, i;
|
||||
|
||||
|
|
@ -2038,13 +2035,16 @@ __elfN(putnote)(struct note_info *ninfo, struct sbuf *sb)
|
|||
return;
|
||||
}
|
||||
|
||||
note.n_namesz = sizeof(FREEBSD_ABI_VENDOR);
|
||||
sv = td->td_proc->p_sysent;
|
||||
|
||||
note.n_namesz = strlen(sv->sv_elf_core_abi_vendor) + 1;
|
||||
note.n_descsz = ninfo->outsize;
|
||||
note.n_type = ninfo->type;
|
||||
|
||||
sbuf_bcat(sb, ¬e, sizeof(note));
|
||||
sbuf_start_section(sb, &old_len);
|
||||
sbuf_bcat(sb, FREEBSD_ABI_VENDOR, sizeof(FREEBSD_ABI_VENDOR));
|
||||
sbuf_bcat(sb, sv->sv_elf_core_abi_vendor,
|
||||
strlen(sv->sv_elf_core_abi_vendor) + 1);
|
||||
sbuf_end_section(sb, old_len, ELF_NOTE_ROUNDSIZE, 0);
|
||||
if (note.n_descsz == 0)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,8 @@ static struct sysentvec elf_freebsd_sysvec = {
|
|||
.sv_name = "FreeBSD ELF32",
|
||||
#endif
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -85,6 +85,9 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||
.sv_szsigcode = &szsigcode32,
|
||||
.sv_name = "FreeBSD ELF32",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ struct sysentvec elf32_freebsd_sysvec = {
|
|||
.sv_szsigcode = &szsigcode32,
|
||||
.sv_name = "FreeBSD ELF32",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -69,6 +69,9 @@ struct sysentvec elf64_freebsd_sysvec_v1 = {
|
|||
.sv_szsigcode = &szsigcode64,
|
||||
.sv_name = "FreeBSD ELF64",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
@ -108,6 +111,9 @@ struct sysentvec elf64_freebsd_sysvec_v2 = {
|
|||
.sv_szsigcode = &szsigcode64,
|
||||
.sv_name = "FreeBSD ELF64 V2",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -72,6 +72,9 @@ static struct sysentvec elf64_freebsd_sysvec = {
|
|||
.sv_szsigcode = &szsigcode,
|
||||
.sv_name = "FreeBSD ELF64",
|
||||
.sv_coredump = __elfN(coredump),
|
||||
.sv_elf_core_osabi = ELFOSABI_FREEBSD,
|
||||
.sv_elf_core_abi_vendor = FREEBSD_ABI_VENDOR,
|
||||
.sv_elf_core_prepare_notes = __elfN(prepare_notes),
|
||||
.sv_imgact_try = NULL,
|
||||
.sv_minsigstksz = MINSIGSTKSZ,
|
||||
.sv_minuser = VM_MIN_ADDRESS,
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@
|
|||
struct image_params;
|
||||
struct thread;
|
||||
struct vnode;
|
||||
struct note_info_list;
|
||||
struct sbuf;
|
||||
|
||||
/*
|
||||
* Structure used to pass information from the loader to the
|
||||
|
|
@ -98,7 +100,10 @@ typedef struct {
|
|||
__ElfType(Auxargs);
|
||||
__ElfType(Brandinfo);
|
||||
|
||||
#define MAX_BRANDS 8
|
||||
#define MAX_BRANDS 8
|
||||
#define FREEBSD_ABI_VENDOR "FreeBSD"
|
||||
|
||||
typedef void (*outfunc_t)(void *, struct sbuf *, size_t *);
|
||||
|
||||
/* Closure for __elfN(size_segments)(). */
|
||||
struct sseg_closure {
|
||||
|
|
@ -114,7 +119,11 @@ int __elfN(coredump)(struct thread *, struct vnode *, off_t, int);
|
|||
size_t __elfN(populate_note)(int, void *, void *, size_t, void **);
|
||||
int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t);
|
||||
void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int);
|
||||
void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
|
||||
size_t *);
|
||||
void __elfN(size_segments)(struct thread *, struct sseg_closure *, int);
|
||||
size_t __elfN(register_note)(struct thread *, struct note_info_list *,
|
||||
int, outfunc_t, void *);
|
||||
|
||||
/* Machine specific function to dump per-thread information. */
|
||||
void __elfN(dump_thread)(struct thread *, void *, size_t *);
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ struct proc;
|
|||
struct __sigset;
|
||||
struct trapframe;
|
||||
struct vnode;
|
||||
struct note_info_list;
|
||||
|
||||
struct sysentvec {
|
||||
int sv_size; /* number of entries */
|
||||
|
|
@ -114,6 +115,10 @@ struct sysentvec {
|
|||
char *sv_name; /* name of binary type */
|
||||
int (*sv_coredump)(struct thread *, struct vnode *, off_t, int);
|
||||
/* function to dump core, or NULL */
|
||||
int sv_elf_core_osabi;
|
||||
const char *sv_elf_core_abi_vendor;
|
||||
void (*sv_elf_core_prepare_notes)(struct thread *,
|
||||
struct note_info_list *, size_t *);
|
||||
int (*sv_imgact_try)(struct image_params *);
|
||||
int (*sv_copyout_auxargs)(struct image_params *,
|
||||
uintptr_t);
|
||||
|
|
|
|||
Loading…
Reference in a new issue