Lines 107-157
write_guidnames(FILE *out, const char *listname,
Link Here
|
107 |
gn->symbol, gn->name, gn->description); |
107 |
gn->symbol, gn->name, gn->description); |
108 |
} |
108 |
} |
109 |
fprintf(out, "};\n"); |
109 |
fprintf(out, "};\n"); |
|
|
110 |
fprintf(out, "const struct efivar_guidname\n" |
111 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
112 |
"\t* const %s = %s_;\n", listname, listname); |
113 |
fprintf(out, "const struct efivar_guidname\n" |
114 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
115 |
"\t* const %s_end = %s_\n\t+ %zd;\n", |
116 |
listname, listname, n - 1); |
110 |
} |
117 |
} |
111 |
|
118 |
|
112 |
int |
119 |
int |
113 |
main(int argc, char *argv[]) |
120 |
main(int argc, char *argv[]) |
114 |
{ |
121 |
{ |
115 |
int rc; |
122 |
int rc; |
116 |
int argstart = 0; |
123 |
FILE *symout, *header; |
117 |
FILE *symout, *header, *ldsout; |
|
|
118 |
int dash_t = 0; |
119 |
|
124 |
|
120 |
if (argc < 5) { |
125 |
if (argc < 4) { |
121 |
errx(1, "Not enough arguments.\n"); |
126 |
errx(1, "Not enough arguments.\n"); |
122 |
} else if (argc > 5 && !strcmp(argv[1],"-T")) { |
127 |
} else if (argc > 4) { |
123 |
argstart = 1; |
|
|
124 |
dash_t = 1; |
125 |
} else if (argc > 5) { |
126 |
errx(1, "Too many arguments.\n"); |
128 |
errx(1, "Too many arguments.\n"); |
127 |
} |
129 |
} |
128 |
|
130 |
|
129 |
symout = fopen(argv[argstart + 2], "w"); |
131 |
symout = fopen(argv[2], "w"); |
130 |
if (symout == NULL) |
132 |
if (symout == NULL) |
131 |
err(1, "could not open \"%s\"", argv[argstart + 2]); |
133 |
err(1, "could not open \"%s\"", argv[2]); |
132 |
rc = chmod(argv[argstart + 2], 0644); |
134 |
rc = chmod(argv[2], 0644); |
133 |
if (rc < 0) |
135 |
if (rc < 0) |
134 |
warn("chmod(%s, 0644)", argv[argstart + 2]); |
136 |
warn("chmod(%s, 0644)", argv[2]); |
135 |
|
137 |
|
136 |
header = fopen(argv[argstart + 3], "w"); |
138 |
header = fopen(argv[3], "w"); |
137 |
if (header == NULL) |
139 |
if (header == NULL) |
138 |
err(1, "could not open \"%s\"", argv[argstart + 3]); |
140 |
err(1, "could not open \"%s\"", argv[3]); |
139 |
rc = chmod(argv[argstart + 3], 0644); |
141 |
rc = chmod(argv[3], 0644); |
140 |
if (rc < 0) |
|
|
141 |
warn("chmod(%s, 0644)", argv[argstart + 3]); |
142 |
|
143 |
ldsout = fopen(argv[argstart + 4], "w"); |
144 |
if (ldsout == NULL) |
145 |
err(1, "could not open \"%s\"", argv[argstart + 4]); |
146 |
rc = chmod(argv[argstart + 4], 0644); |
147 |
if (rc < 0) |
142 |
if (rc < 0) |
148 |
warn("chmod(%s, 0644)", argv[argstart + 4]); |
143 |
warn("chmod(%s, 0644)", argv[3]); |
149 |
|
144 |
|
150 |
struct guidname_index *guidnames = NULL; |
145 |
struct guidname_index *guidnames = NULL; |
151 |
|
146 |
|
152 |
rc = read_guids_at(AT_FDCWD, argv[argstart + 1], &guidnames); |
147 |
rc = read_guids_at(AT_FDCWD, argv[1], &guidnames); |
153 |
if (rc < 0) |
148 |
if (rc < 0) |
154 |
err(1, "could not read \"%s\"", argv[argstart + 1]); |
149 |
err(1, "could not read \"%s\"", argv[1]); |
155 |
|
150 |
|
156 |
struct efivar_guidname *outbuf; |
151 |
struct efivar_guidname *outbuf; |
157 |
|
152 |
|
Lines 243-254
struct efivar_guidname {\n\
Link Here
|
243 |
fprintf(header, |
238 |
fprintf(header, |
244 |
"extern const struct efivar_guidname\n" |
239 |
"extern const struct efivar_guidname\n" |
245 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
240 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
246 |
"\tefi_well_known_guids[%d];\n", |
241 |
"\t* const efi_well_known_guids;\n"); |
247 |
i); |
|
|
248 |
fprintf(header, |
242 |
fprintf(header, |
249 |
"extern const struct efivar_guidname\n" |
243 |
"extern const struct efivar_guidname\n" |
250 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
244 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
251 |
"\tefi_well_known_guids_end;\n"); |
245 |
"\t* const efi_well_known_guids_end;\n"); |
252 |
fprintf(header, |
246 |
fprintf(header, |
253 |
"extern const uint64_t\n" |
247 |
"extern const uint64_t\n" |
254 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
248 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
Lines 256-267
struct efivar_guidname {\n\
Link Here
|
256 |
fprintf(header, |
250 |
fprintf(header, |
257 |
"extern const struct efivar_guidname\n" |
251 |
"extern const struct efivar_guidname\n" |
258 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
252 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
259 |
"\tefi_well_known_names[%d];\n", |
253 |
"\t* const efi_well_known_names;\n"); |
260 |
i); |
|
|
261 |
fprintf(header, |
254 |
fprintf(header, |
262 |
"extern const struct efivar_guidname\n" |
255 |
"extern const struct efivar_guidname\n" |
263 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
256 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
264 |
"\tefi_well_known_names_end;\n"); |
257 |
"\t* const efi_well_known_names_end;\n"); |
265 |
fprintf(header, |
258 |
fprintf(header, |
266 |
"extern const uint64_t\n" |
259 |
"extern const uint64_t\n" |
267 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
260 |
"\t__attribute__((__visibility__ (\"default\")))\n" |
Lines 310-332
struct efivar_guidname {\n\
Link Here
|
310 |
|
303 |
|
311 |
fclose(symout); |
304 |
fclose(symout); |
312 |
|
305 |
|
313 |
fprintf(ldsout, |
|
|
314 |
"SECTIONS\n" |
315 |
"{\n" |
316 |
" .data :\n" |
317 |
" {\n" |
318 |
" efi_well_known_guids = efi_well_known_guids_;\n" |
319 |
" efi_well_known_guids_end = efi_well_known_guids_ + %zd;\n" |
320 |
" efi_well_known_names = efi_well_known_names_;\n" |
321 |
" efi_well_known_names_end = efi_well_known_names_ + %zd;\n" |
322 |
" }\n" |
323 |
"}%s;\n", |
324 |
(line - 1) * sizeof(struct efivar_guidname), |
325 |
(line - 1) * sizeof(struct efivar_guidname), |
326 |
dash_t ? " INSERT AFTER .data" : ""); |
327 |
|
328 |
fclose(ldsout); |
329 |
|
330 |
free(guidnames->strtab); |
306 |
free(guidnames->strtab); |
331 |
free(guidnames); |
307 |
free(guidnames); |
332 |
|
308 |
|