Deleted Added
full compact
kern_ctf.c (231949) kern_ctf.c (241896)
1/*-
2 * Copyright (c) 2008 John Birrell <jb@freebsd.org>
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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 *
1/*-
2 * Copyright (c) 2008 John Birrell <jb@freebsd.org>
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

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

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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 * $FreeBSD: head/sys/kern/kern_ctf.c 231949 2012-02-21 01:05:12Z kib $
26 * $FreeBSD: head/sys/kern/kern_ctf.c 241896 2012-10-22 17:50:54Z kib $
27 */
28
29/*
30 * Note this file is included by both link_elf.c and link_elf_obj.c.
31 *
32 * The CTF header structure definition can't be used here because it's
33 * (annoyingly) covered by the CDDL. We will just use a few bytes from
34 * it as an integer array where we 'know' what they mean.

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

64 caddr_t ctftab = NULL;
65 caddr_t raw = NULL;
66 caddr_t shstrtab = NULL;
67 elf_file_t ef = (elf_file_t) lf;
68 int flags;
69 int i;
70 int nbytes;
71 ssize_t resid;
27 */
28
29/*
30 * Note this file is included by both link_elf.c and link_elf_obj.c.
31 *
32 * The CTF header structure definition can't be used here because it's
33 * (annoyingly) covered by the CDDL. We will just use a few bytes from
34 * it as an integer array where we 'know' what they mean.

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

64 caddr_t ctftab = NULL;
65 caddr_t raw = NULL;
66 caddr_t shstrtab = NULL;
67 elf_file_t ef = (elf_file_t) lf;
68 int flags;
69 int i;
70 int nbytes;
71 ssize_t resid;
72 int vfslocked;
73 size_t sz;
74 struct nameidata nd;
75 struct thread *td = curthread;
76 uint8_t ctf_hdr[CTF_HDR_SIZE];
77#endif
78 int error = 0;
79
80 if (lf == NULL || lc == NULL)

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

109
110 /*
111 * We need to try reading the CTF data. Flag no CTF data present
112 * by default and if we actually succeed in reading it, we'll
113 * update ctfcnt to the number of bytes read.
114 */
115 ef->ctfcnt = -1;
116
72 size_t sz;
73 struct nameidata nd;
74 struct thread *td = curthread;
75 uint8_t ctf_hdr[CTF_HDR_SIZE];
76#endif
77 int error = 0;
78
79 if (lf == NULL || lc == NULL)

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

108
109 /*
110 * We need to try reading the CTF data. Flag no CTF data present
111 * by default and if we actually succeed in reading it, we'll
112 * update ctfcnt to the number of bytes read.
113 */
114 ef->ctfcnt = -1;
115
117 NDINIT(&nd, LOOKUP, FOLLOW | MPSAFE, UIO_SYSSPACE, lf->pathname, td);
116 NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, lf->pathname, td);
118 flags = FREAD;
119 error = vn_open(&nd, &flags, 0, NULL);
120 if (error)
121 return (error);
117 flags = FREAD;
118 error = vn_open(&nd, &flags, 0, NULL);
119 if (error)
120 return (error);
122 vfslocked = NDHASGIANT(&nd);
123 NDFREE(&nd, NDF_ONLY_PNBUF);
124
125 /* Allocate memory for the FLF header. */
126 if ((hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK)) == NULL) {
127 error = ENOMEM;
128 goto out;
129 }
130

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

318 lc->nsym = ef->ddbsymcnt;
319 lc->ctfoffp = (uint32_t **) &ef->ctfoff;
320 lc->typoffp = (uint32_t **) &ef->typoff;
321 lc->typlenp = &ef->typlen;
322
323out:
324 VOP_UNLOCK(nd.ni_vp, 0);
325 vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
121 NDFREE(&nd, NDF_ONLY_PNBUF);
122
123 /* Allocate memory for the FLF header. */
124 if ((hdr = malloc(sizeof(*hdr), M_LINKER, M_WAITOK)) == NULL) {
125 error = ENOMEM;
126 goto out;
127 }
128

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

316 lc->nsym = ef->ddbsymcnt;
317 lc->ctfoffp = (uint32_t **) &ef->ctfoff;
318 lc->typoffp = (uint32_t **) &ef->typoff;
319 lc->typlenp = &ef->typlen;
320
321out:
322 VOP_UNLOCK(nd.ni_vp, 0);
323 vn_close(nd.ni_vp, FREAD, td->td_ucred, td);
326 VFS_UNLOCK_GIANT(vfslocked);
327
328 if (hdr != NULL)
329 free(hdr, M_LINKER);
330 if (shdr != NULL)
331 free(shdr, M_LINKER);
332 if (shstrtab != NULL)
333 free(shstrtab, M_LINKER);
334 if (ctftab != NULL)
335 free(ctftab, M_LINKER);
336 if (raw != NULL)
337 free(raw, M_LINKER);
338#else
339 error = EOPNOTSUPP;
340#endif
341
342 return (error);
343}
324
325 if (hdr != NULL)
326 free(hdr, M_LINKER);
327 if (shdr != NULL)
328 free(shdr, M_LINKER);
329 if (shstrtab != NULL)
330 free(shstrtab, M_LINKER);
331 if (ctftab != NULL)
332 free(ctftab, M_LINKER);
333 if (raw != NULL)
334 free(raw, M_LINKER);
335#else
336 error = EOPNOTSUPP;
337#endif
338
339 return (error);
340}