Date: Wed, 26 May 2021 10:52:02 GMT From: Edward Tomasz Napierala <trasz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 905d192d6f16 - main - Unstaticize parts of coredumping code Message-ID: <202105261052.14QAq285070431@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by trasz: URL: https://cgit.FreeBSD.org/src/commit/?id=905d192d6f161496c26db29d0d429525166bfff7 commit 905d192d6f161496c26db29d0d429525166bfff7 Author: Edward Tomasz Napierala <trasz@FreeBSD.org> AuthorDate: 2021-05-26 09:23:37 +0000 Commit: Edward Tomasz Napierala <trasz@FreeBSD.org> CommitDate: 2021-05-26 10:51:57 +0000 Unstaticize parts of coredumping code This makes it possible to call __elfN(size_segments) and __elfN(puthdr) from Linux coredump code. Reviewed By: kib Sponsored By: EPSRC Differential Revision: https://reviews.freebsd.org/D30455 --- sys/kern/imgact_elf.c | 23 ++++++++++++----------- sys/sys/imgact_elf.h | 8 ++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 15976d143988..57e9ac18e63b 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1434,12 +1434,6 @@ struct phdr_closure { Elf_Off offset; /* Offset of segment in core file */ }; -/* Closure for cb_size_segment(). */ -struct sseg_closure { - int count; /* Count of writable segments. */ - size_t size; /* Total size of all writable segments. */ -}; - typedef void (*outfunc_t)(void *, struct sbuf *, size_t *); struct note_info { @@ -1463,7 +1457,6 @@ 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(puthdr)(struct thread *, void *, size_t, int, size_t, int); static void __elfN(putnote)(struct note_info *, struct sbuf *); static size_t register_note(struct note_info_list *, int, outfunc_t, void *); @@ -1508,9 +1501,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags) TAILQ_INIT(¬elst); /* Size the program segments. */ - seginfo.count = 0; - seginfo.size = 0; - each_dumpable_segment(td, cb_size_segment, &seginfo, flags); + __elfN(size_segments)(td, &seginfo, flags); /* * Collect info about the core file header area. @@ -1645,6 +1636,16 @@ cb_size_segment(vm_map_entry_t entry, void *closure) ssc->size += entry->end - entry->start; } +void +__elfN(size_segments)(struct thread *td, struct sseg_closure *seginfo, + int flags) +{ + seginfo->count = 0; + seginfo->size = 0; + + each_dumpable_segment(td, cb_size_segment, seginfo, flags); +} + /* * For each writable segment in the process's memory map, call the given * function with a pointer to the map entry and some arbitrary @@ -1803,7 +1804,7 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list, *sizep = size; } -static void +void __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs, size_t notesz, int flags) { diff --git a/sys/sys/imgact_elf.h b/sys/sys/imgact_elf.h index ca95798c7288..f0c112b2bcdc 100644 --- a/sys/sys/imgact_elf.h +++ b/sys/sys/imgact_elf.h @@ -100,6 +100,12 @@ __ElfType(Brandinfo); #define MAX_BRANDS 8 +/* Closure for __elfN(size_segments)(). */ +struct sseg_closure { + int count; /* Count of writable segments. */ + size_t size; /* Total size of all writable segments. */ +}; + int __elfN(brand_inuse)(Elf_Brandinfo *entry); int __elfN(insert_brand_entry)(Elf_Brandinfo *entry); int __elfN(remove_brand_entry)(Elf_Brandinfo *entry); @@ -108,6 +114,8 @@ int __elfN(coredump)(struct thread *, struct vnode *, off_t, int); size_t __elfN(populate_note)(int, void *, void *, size_t, void **); void __elfN(stackgap)(struct image_params *, uintptr_t *); int __elfN(freebsd_copyout_auxargs)(struct image_params *, uintptr_t); +void __elfN(puthdr)(struct thread *, void *, size_t, int, size_t, int); +void __elfN(size_segments)(struct thread *, struct sseg_closure *, int); /* Machine specific function to dump per-thread information. */ void __elfN(dump_thread)(struct thread *, void *, size_t *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105261052.14QAq285070431>