Deleted Added
full compact
subr_module.c (302408) subr_module.c (337262)
1/*-
2 * Copyright (c) 1998 Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998 Michael Smith
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/11/sys/kern/subr_module.c 287000 2015-08-21 15:57:57Z royger $");
28__FBSDID("$FreeBSD: stable/11/sys/kern/subr_module.c 337262 2018-08-03 15:42:39Z markj $");
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/linker.h>
33
29
30#include <sys/param.h>
31#include <sys/systm.h>
32#include <sys/linker.h>
33
34#include <vm/vm.h>
35#include <vm/vm_extern.h>
36
34/*
35 * Preloaded module support
36 */
37
38vm_offset_t preload_addr_relocate = 0;
39caddr_t preload_metadata;
40
41/*

--- 155 unchanged lines hidden (view full) ---

197}
198
199/*
200 * Delete a preload record by name.
201 */
202void
203preload_delete_name(const char *name)
204{
37/*
38 * Preloaded module support
39 */
40
41vm_offset_t preload_addr_relocate = 0;
42caddr_t preload_metadata;
43
44/*

--- 155 unchanged lines hidden (view full) ---

200}
201
202/*
203 * Delete a preload record by name.
204 */
205void
206preload_delete_name(const char *name)
207{
205 caddr_t curp;
206 uint32_t *hdr;
208 caddr_t addr, curp;
209 uint32_t *hdr, sz;
207 int next;
208 int clearing;
210 int next;
211 int clearing;
212
213 addr = 0;
214 sz = 0;
209
210 if (preload_metadata != NULL) {
215
216 if (preload_metadata != NULL) {
211
217
212 clearing = 0;
213 curp = preload_metadata;
214 for (;;) {
215 hdr = (uint32_t *)curp;
218 clearing = 0;
219 curp = preload_metadata;
220 for (;;) {
221 hdr = (uint32_t *)curp;
216 if (hdr[0] == 0 && hdr[1] == 0)
217 break;
222 if (hdr[0] == MODINFO_NAME || (hdr[0] == 0 && hdr[1] == 0)) {
223 /* Free memory used to store the file. */
224 if (addr != 0 && sz != 0)
225 kmem_bootstrap_free((vm_offset_t)addr, sz);
226 addr = 0;
227 sz = 0;
218
228
219 /* Search for a MODINFO_NAME field */
220 if (hdr[0] == MODINFO_NAME) {
229 if (hdr[0] == 0)
230 break;
221 if (!strcmp(name, curp + sizeof(uint32_t) * 2))
222 clearing = 1; /* got it, start clearing */
231 if (!strcmp(name, curp + sizeof(uint32_t) * 2))
232 clearing = 1; /* got it, start clearing */
223 else if (clearing)
233 else if (clearing) {
224 clearing = 0; /* at next one now.. better stop */
234 clearing = 0; /* at next one now.. better stop */
235 }
225 }
236 }
226 if (clearing)
237 if (clearing) {
238 if (hdr[0] == MODINFO_ADDR)
239 addr = *(caddr_t *)(curp + sizeof(uint32_t) * 2);
240 else if (hdr[0] == MODINFO_SIZE)
241 sz = *(uint32_t *)(curp + sizeof(uint32_t) * 2);
227 hdr[0] = MODINFO_EMPTY;
242 hdr[0] = MODINFO_EMPTY;
243 }
228
229 /* skip to next field */
230 next = sizeof(uint32_t) * 2 + hdr[1];
231 next = roundup(next, sizeof(u_long));
232 curp += next;
233 }
234 }
235}

--- 58 unchanged lines hidden ---
244
245 /* skip to next field */
246 next = sizeof(uint32_t) * 2 + hdr[1];
247 next = roundup(next, sizeof(u_long));
248 curp += next;
249 }
250 }
251}

--- 58 unchanged lines hidden ---