From nobody Thu May 12 22:56:26 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 490C61AE47A6; Thu, 12 May 2022 22:56:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KznFl0hpbz3Fty; Thu, 12 May 2022 22:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652396187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CFVE5S2euRm2saMnB6yBiiJunKKhU1R3gpf6xdioD+U=; b=gZVr+J5qz3OGqHV/2weyQpbXdqwErNIxpkU7gxFP79dzGi3vT2c+UYeBMmYlR6/NdrCDTk UeOhCOBMuKLVtjH+gTjWiFRzPEbY8S8Q66hETwUdx4GiFIqp8MylyqHme8AeoqWnoLFEuc uj7d4zXUgcYx53JrPH8Fzaiue6VaGNH+3aeSR2Bfuz5xYIZwfRVERdy/Fx82PUBQH2YEVu fOIkVGk759n/obvHu5uxzMHsCFiurLrNhmdYs+fUkDpy8jxY7R6hQCHqaTfZ/XlQdEvgE2 gGSpe2bBJmEi+wp67Tt380n9Kg8woDK9jjQFV1bmegRgbvzWK1jjnoIN7cMO0Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C279917515; Thu, 12 May 2022 22:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 24CMuQ83020487; Thu, 12 May 2022 22:56:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24CMuQUe020486; Thu, 12 May 2022 22:56:26 GMT (envelope-from git) Date: Thu, 12 May 2022 22:56:26 GMT Message-Id: <202205122256.24CMuQUe020486@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: 9fdb30b9167c - stable/13 - Unstaticize parts of coredumping code List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 9fdb30b9167c776fe45e37cb062d6a84bced926d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652396187; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CFVE5S2euRm2saMnB6yBiiJunKKhU1R3gpf6xdioD+U=; b=Go+StjvzqgDg2cbUpA8EQC1+OMO0GAETA4H2dzWL6SUKSkJZjAUhCmK6vN3dxa8hMs6ojQ xIfPiXOel2WjOrnDZQQueZWagHViKbrGHmYbjDu2Z11LBjh9ybEZbc3fyzMvEmDYMyatYR f54JDY6IBCg7cVj9cTfiitRj+lfSe3nXMc12lCk0ysXGo4hVvlTb1+AZz1lWNF0/oUOd5b 94JDoB8IlmBFl9ZEt/cUQyQWZ2M6rtVOOO8is5hxFth9N1s18vdLW4PB+Gw1atQZqvY8cj mmAV3WcfkFKUxnlKRw5FwlqoSo4jauozaRhm1hY07MyZi+djDwLZu5S3zrbRuQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652396187; a=rsa-sha256; cv=none; b=O0ztQ+vBfY/RqPM+fd/zne6Fnj/AzxkaYlUb2v023O1+iCW+7kpFQswACdaAQfAsuO125i fgnOz1TfrRMyZ+ghJNimpbPu+YulqVwOIbQokQv3mQ9AbReRDdzVfHTSTwPbXtfk9Pj/8N cYJsiLXrd1FZhzMDbGDTWpBIf/gxdNwet8G3IUZWsRFj0eitDvbBp7zG7H98hesBJlF60Q AWFYk60uBmQJ3vkpLL/Wu2pStEt8F3NGO7m0Rgvy/H0Yq7eXj9l+lCirkngLHaC9/LUN8/ gJdWluz3ZSgz436RaXyGcGumH//A8dQtrzL9HwW8KNFQ3/b+D76517tzReYkYw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9fdb30b9167c776fe45e37cb062d6a84bced926d commit 9fdb30b9167c776fe45e37cb062d6a84bced926d Author: Edward Tomasz Napierala AuthorDate: 2021-05-26 09:23:37 +0000 Commit: John Baldwin CommitDate: 2022-05-12 22:12:59 +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 (cherry picked from commit 905d192d6f161496c26db29d0d429525166bfff7) --- 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 d2cee91e0531..d189339283a7 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1504,12 +1504,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 { @@ -1533,7 +1527,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 *); @@ -1578,9 +1571,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. @@ -1715,6 +1706,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 @@ -1873,7 +1874,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 5ad26e5c1084..61937642a91a 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); @@ -107,6 +113,8 @@ int __elfN(freebsd_fixup)(uintptr_t *, struct image_params *); 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(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 *);