| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_ksyms.c,v 1.91 2021/06/01 21:11:07 riastradh Exp $ */ | | 1 | /* $NetBSD: kern_ksyms.c,v 1.92 2021/06/01 21:11:52 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software developed for The NetBSD Foundation | | 7 | * This code is derived from software developed for The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -63,27 +63,27 @@ | | | @@ -63,27 +63,27 @@ |
63 | * struct, placed in a circular list. The first entry is the kernel | | 63 | * struct, placed in a circular list. The first entry is the kernel |
64 | * symbol table. | | 64 | * symbol table. |
65 | */ | | 65 | */ |
66 | | | 66 | |
67 | /* | | 67 | /* |
68 | * TODO: | | 68 | * TODO: |
69 | * | | 69 | * |
70 | * Add support for mmap, poll. | | 70 | * Add support for mmap, poll. |
71 | * Constify tables. | | 71 | * Constify tables. |
72 | * Constify db_symtab and move it to .rodata. | | 72 | * Constify db_symtab and move it to .rodata. |
73 | */ | | 73 | */ |
74 | | | 74 | |
75 | #include <sys/cdefs.h> | | 75 | #include <sys/cdefs.h> |
76 | __KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.91 2021/06/01 21:11:07 riastradh Exp $"); | | 76 | __KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.92 2021/06/01 21:11:52 riastradh Exp $"); |
77 | | | 77 | |
78 | #if defined(_KERNEL) && defined(_KERNEL_OPT) | | 78 | #if defined(_KERNEL) && defined(_KERNEL_OPT) |
79 | #include "opt_copy_symtab.h" | | 79 | #include "opt_copy_symtab.h" |
80 | #include "opt_ddb.h" | | 80 | #include "opt_ddb.h" |
81 | #include "opt_dtrace.h" | | 81 | #include "opt_dtrace.h" |
82 | #endif | | 82 | #endif |
83 | | | 83 | |
84 | #define _KSYMS_PRIVATE | | 84 | #define _KSYMS_PRIVATE |
85 | | | 85 | |
86 | #include <sys/param.h> | | 86 | #include <sys/param.h> |
87 | #include <sys/queue.h> | | 87 | #include <sys/queue.h> |
88 | #include <sys/exec.h> | | 88 | #include <sys/exec.h> |
89 | #include <sys/systm.h> | | 89 | #include <sys/systm.h> |
| @@ -1079,50 +1079,46 @@ ksymsread(dev_t dev, struct uio *uio, in | | | @@ -1079,50 +1079,46 @@ ksymsread(dev_t dev, struct uio *uio, in |
1079 | error = uiomove((char *)&ksyms_hdr + off, | | 1079 | error = uiomove((char *)&ksyms_hdr + off, |
1080 | sizeof(struct ksyms_hdr) - off, uio); | | 1080 | sizeof(struct ksyms_hdr) - off, uio); |
1081 | if (error != 0) | | 1081 | if (error != 0) |
1082 | return error; | | 1082 | return error; |
1083 | } | | 1083 | } |
1084 | | | 1084 | |
1085 | /* | | 1085 | /* |
1086 | * Copy out the symbol table. | | 1086 | * Copy out the symbol table. |
1087 | */ | | 1087 | */ |
1088 | filepos = sizeof(struct ksyms_hdr); | | 1088 | filepos = sizeof(struct ksyms_hdr); |
1089 | for (st = TAILQ_FIRST(&ksyms_symtabs); | | 1089 | for (st = TAILQ_FIRST(&ksyms_symtabs); |
1090 | st != ksyms_last_snapshot; | | 1090 | st != ksyms_last_snapshot; |
1091 | st = TAILQ_NEXT(st, sd_queue)) { | | 1091 | st = TAILQ_NEXT(st, sd_queue)) { |
1092 | if (__predict_false(st->sd_gone)) | | | |
1093 | continue; | | | |
1094 | if (uio->uio_resid == 0) | | 1092 | if (uio->uio_resid == 0) |
1095 | return 0; | | 1093 | return 0; |
1096 | if (uio->uio_offset <= st->sd_symsize + filepos) { | | 1094 | if (uio->uio_offset <= st->sd_symsize + filepos) { |
1097 | inpos = uio->uio_offset - filepos; | | 1095 | inpos = uio->uio_offset - filepos; |
1098 | error = uiomove((char *)st->sd_symstart + inpos, | | 1096 | error = uiomove((char *)st->sd_symstart + inpos, |
1099 | st->sd_symsize - inpos, uio); | | 1097 | st->sd_symsize - inpos, uio); |
1100 | if (error != 0) | | 1098 | if (error != 0) |
1101 | return error; | | 1099 | return error; |
1102 | } | | 1100 | } |
1103 | filepos += st->sd_symsize; | | 1101 | filepos += st->sd_symsize; |
1104 | } | | 1102 | } |
1105 | | | 1103 | |
1106 | /* | | 1104 | /* |
1107 | * Copy out the string table | | 1105 | * Copy out the string table |
1108 | */ | | 1106 | */ |
1109 | KASSERT(filepos <= sizeof(struct ksyms_hdr) + | | 1107 | KASSERT(filepos == sizeof(struct ksyms_hdr) + |
1110 | ksyms_hdr.kh_shdr[SYMTAB].sh_size); | | 1108 | ksyms_hdr.kh_shdr[SYMTAB].sh_size); |
1111 | for (st = TAILQ_FIRST(&ksyms_symtabs); | | 1109 | for (st = TAILQ_FIRST(&ksyms_symtabs); |
1112 | st != ksyms_last_snapshot; | | 1110 | st != ksyms_last_snapshot; |
1113 | st = TAILQ_NEXT(st, sd_queue)) { | | 1111 | st = TAILQ_NEXT(st, sd_queue)) { |
1114 | if (__predict_false(st->sd_gone)) | | | |
1115 | continue; | | | |
1116 | if (uio->uio_resid == 0) | | 1112 | if (uio->uio_resid == 0) |
1117 | return 0; | | 1113 | return 0; |
1118 | if (uio->uio_offset <= st->sd_strsize + filepos) { | | 1114 | if (uio->uio_offset <= st->sd_strsize + filepos) { |
1119 | inpos = uio->uio_offset - filepos; | | 1115 | inpos = uio->uio_offset - filepos; |
1120 | error = uiomove((char *)st->sd_strstart + inpos, | | 1116 | error = uiomove((char *)st->sd_strstart + inpos, |
1121 | st->sd_strsize - inpos, uio); | | 1117 | st->sd_strsize - inpos, uio); |
1122 | if (error != 0) | | 1118 | if (error != 0) |
1123 | return error; | | 1119 | return error; |
1124 | } | | 1120 | } |
1125 | filepos += st->sd_strsize; | | 1121 | filepos += st->sd_strsize; |
1126 | } | | 1122 | } |
1127 | | | 1123 | |
1128 | /* | | 1124 | /* |