imgact_elf: consistently pass flags from coredump down to helper functions
Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29955
This commit is contained in:
parent
3b57d80c7a
commit
5bc3c61780
@ -1471,12 +1471,13 @@ static void cb_put_phdr(vm_map_entry_t, void *);
|
|||||||
static void cb_size_segment(vm_map_entry_t, void *);
|
static void cb_size_segment(vm_map_entry_t, void *);
|
||||||
static int core_write(struct coredump_params *, const void *, size_t, off_t,
|
static int core_write(struct coredump_params *, const void *, size_t, off_t,
|
||||||
enum uio_seg, size_t *);
|
enum uio_seg, size_t *);
|
||||||
static void each_dumpable_segment(struct thread *, segment_callback, void *);
|
static void each_dumpable_segment(struct thread *, segment_callback, void *,
|
||||||
|
int);
|
||||||
static int __elfN(corehdr)(struct coredump_params *, int, void *, size_t,
|
static int __elfN(corehdr)(struct coredump_params *, int, void *, size_t,
|
||||||
struct note_info_list *, size_t);
|
struct note_info_list *, size_t, int);
|
||||||
static void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
|
static void __elfN(prepare_notes)(struct thread *, struct note_info_list *,
|
||||||
size_t *);
|
size_t *);
|
||||||
static void __elfN(puthdr)(struct thread *, void *, size_t, int, 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 void __elfN(putnote)(struct note_info *, struct sbuf *);
|
||||||
static size_t register_note(struct note_info_list *, int, outfunc_t, void *);
|
static size_t register_note(struct note_info_list *, int, outfunc_t, void *);
|
||||||
static int sbuf_drain_core_output(void *, const char *, int);
|
static int sbuf_drain_core_output(void *, const char *, int);
|
||||||
@ -1669,7 +1670,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
|
|||||||
/* Size the program segments. */
|
/* Size the program segments. */
|
||||||
seginfo.count = 0;
|
seginfo.count = 0;
|
||||||
seginfo.size = 0;
|
seginfo.size = 0;
|
||||||
each_dumpable_segment(td, cb_size_segment, &seginfo);
|
each_dumpable_segment(td, cb_size_segment, &seginfo, flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Collect info about the core file header area.
|
* Collect info about the core file header area.
|
||||||
@ -1722,7 +1723,7 @@ __elfN(coredump)(struct thread *td, struct vnode *vp, off_t limit, int flags)
|
|||||||
*/
|
*/
|
||||||
hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
|
hdr = malloc(hdrsize, M_TEMP, M_WAITOK);
|
||||||
error = __elfN(corehdr)(¶ms, seginfo.count, hdr, hdrsize, ¬elst,
|
error = __elfN(corehdr)(¶ms, seginfo.count, hdr, hdrsize, ¬elst,
|
||||||
notesz);
|
notesz, flags);
|
||||||
|
|
||||||
/* Write the contents of all of the writable segments. */
|
/* Write the contents of all of the writable segments. */
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
@ -1806,7 +1807,8 @@ cb_size_segment(vm_map_entry_t entry, void *closure)
|
|||||||
* caller-supplied data.
|
* caller-supplied data.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
each_dumpable_segment(struct thread *td, segment_callback func, void *closure)
|
each_dumpable_segment(struct thread *td, segment_callback func, void *closure,
|
||||||
|
int flags)
|
||||||
{
|
{
|
||||||
struct proc *p = td->td_proc;
|
struct proc *p = td->td_proc;
|
||||||
vm_map_t map = &p->p_vmspace->vm_map;
|
vm_map_t map = &p->p_vmspace->vm_map;
|
||||||
@ -1867,7 +1869,8 @@ each_dumpable_segment(struct thread *td, segment_callback func, void *closure)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
__elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr,
|
__elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr,
|
||||||
size_t hdrsize, struct note_info_list *notelst, size_t notesz)
|
size_t hdrsize, struct note_info_list *notelst, size_t notesz,
|
||||||
|
int flags)
|
||||||
{
|
{
|
||||||
struct note_info *ninfo;
|
struct note_info *ninfo;
|
||||||
struct sbuf *sb;
|
struct sbuf *sb;
|
||||||
@ -1875,7 +1878,7 @@ __elfN(corehdr)(struct coredump_params *p, int numsegs, void *hdr,
|
|||||||
|
|
||||||
/* Fill in the header. */
|
/* Fill in the header. */
|
||||||
bzero(hdr, hdrsize);
|
bzero(hdr, hdrsize);
|
||||||
__elfN(puthdr)(p->td, hdr, hdrsize, numsegs, notesz);
|
__elfN(puthdr)(p->td, hdr, hdrsize, numsegs, notesz, flags);
|
||||||
|
|
||||||
sb = sbuf_new(NULL, NULL, CORE_BUF_SIZE, SBUF_FIXEDLEN);
|
sb = sbuf_new(NULL, NULL, CORE_BUF_SIZE, SBUF_FIXEDLEN);
|
||||||
sbuf_set_drain(sb, sbuf_drain_core_output, p);
|
sbuf_set_drain(sb, sbuf_drain_core_output, p);
|
||||||
@ -1953,7 +1956,7 @@ __elfN(prepare_notes)(struct thread *td, struct note_info_list *list,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
__elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
|
__elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
|
||||||
size_t notesz)
|
size_t notesz, int flags)
|
||||||
{
|
{
|
||||||
Elf_Ehdr *ehdr;
|
Elf_Ehdr *ehdr;
|
||||||
Elf_Phdr *phdr;
|
Elf_Phdr *phdr;
|
||||||
@ -2032,7 +2035,7 @@ __elfN(puthdr)(struct thread *td, void *hdr, size_t hdrsize, int numsegs,
|
|||||||
/* All the writable segments from the program. */
|
/* All the writable segments from the program. */
|
||||||
phc.phdr = phdr;
|
phc.phdr = phdr;
|
||||||
phc.offset = round_page(hdrsize + notesz);
|
phc.offset = round_page(hdrsize + notesz);
|
||||||
each_dumpable_segment(td, cb_put_phdr, &phc);
|
each_dumpable_segment(td, cb_put_phdr, &phc, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
|
Loading…
Reference in New Issue
Block a user