blob: 45d36f4afe0e16399c41238eaa8b4105e50d94c4 [file] [log] [blame]
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00001/*
Peter Stuge45ae92ff2009-04-14 19:48:32 +00002 * cbfs-mkpayload
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00003 *
4 * Copyright (C) 2008 Jordan Crouse <jordan@cosmicpenguin.net>
Patrick Georgib7b56dd82009-09-14 13:29:27 +00005 * 2009 coresystems GmbH
6 * written by Patrick Georgi <patrick.georgi@coresystems.de>
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +00007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000016 */
17
18#include <stdio.h>
19#include <stdlib.h>
20#include <string.h>
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000021
Aaron Durbin54ef3062014-03-05 12:12:09 -060022#include "elfparsing.h"
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000023#include "common.h"
Patrick Georgib7b56dd82009-09-14 13:29:27 +000024#include "cbfs.h"
Stefan Reinauer543a6822013-02-04 15:39:13 -080025#include "fv.h"
26#include "coff.h"
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000027
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080028/* serialize the seg array into the buffer.
29 * The buffer is assumed to be large enough.
30 */
Ronald G. Minnich818f3692014-02-04 08:29:35 -080031void xdr_segs(struct buffer *output,
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080032 struct cbfs_payload_segment *segs, int nseg)
33{
34 struct buffer outheader;
35 int i;
36
37 outheader.data = output->data;
38 outheader.size = 0;
39
40 for(i = 0; i < nseg; i++){
41 xdr_be.put32(&outheader, segs[i].type);
42 xdr_be.put32(&outheader, segs[i].compression);
43 xdr_be.put32(&outheader, segs[i].offset);
44 xdr_be.put64(&outheader, segs[i].load_addr);
45 xdr_be.put32(&outheader, segs[i].len);
46 xdr_be.put32(&outheader, segs[i].mem_len);
47 }
48}
Aaron Durbinca630272014-08-05 10:48:20 -050049
50void xdr_get_seg(struct cbfs_payload_segment *out,
51 struct cbfs_payload_segment *in)
52{
53 struct buffer inheader;
54
55 inheader.data = (void *)in;
56 inheader.size = sizeof(*in);
57
58 out->type = xdr_be.get32(&inheader);
59 out->compression = xdr_be.get32(&inheader);
60 out->offset = xdr_be.get32(&inheader);
61 out->load_addr = xdr_be.get64(&inheader);
62 out->len = xdr_be.get32(&inheader);
63 out->mem_len = xdr_be.get32(&inheader);
64}
65
Sol Boucher0e539312015-03-05 15:38:03 -080066int parse_elf_to_payload(const struct buffer *input, struct buffer *output,
Sol Boucher6310ccc2015-05-07 21:12:28 -070067 enum comp_algo algo)
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000068{
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080069 Elf64_Phdr *phdr;
70 Elf64_Ehdr ehdr;
71 Elf64_Shdr *shdr;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000072 char *header;
73 char *strtab;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000074 int headers;
75 int segments = 1;
76 int isize = 0, osize = 0;
77 int doffset = 0;
Patrick Georgi96990a22014-09-29 10:08:35 +020078 struct cbfs_payload_segment *segs = NULL;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000079 int i;
Patrick Georgi96990a22014-09-29 10:08:35 +020080 int ret = 0;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000081
Patrick Georgib7b56dd82009-09-14 13:29:27 +000082 comp_func_ptr compress = compression_function(algo);
83 if (!compress)
84 return -1;
85
Sol Boucher0e539312015-03-05 15:38:03 -080086 if (elf_headers(input, &ehdr, &phdr, &shdr) < 0)
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080087 return -1;
88
Hung-Te Linc13e4bf2013-01-29 15:22:11 +080089 DEBUG("start: parse_elf_to_payload\n");
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080090 headers = ehdr.e_phnum;
91 header = input->data;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000092
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080093 strtab = &header[shdr[ehdr.e_shstrndx].sh_offset];
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000094
95 /* Count the number of headers - look for the .notes.pinfo
96 * section */
97
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -080098 for (i = 0; i < ehdr.e_shnum; i++) {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +000099 char *name;
100
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800101 if (i == ehdr.e_shstrndx)
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000102 continue;
103
104 if (shdr[i].sh_size == 0)
105 continue;
106
107 name = (char *)(strtab + shdr[i].sh_name);
108
Ronald G. Minnich5a1af7b2009-09-17 15:35:08 +0000109 if (!strcmp(name, ".note.pinfo")) {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000110 segments++;
Ronald G. Minnich5a1af7b2009-09-17 15:35:08 +0000111 isize += (unsigned int)shdr[i].sh_size;
112 }
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000113 }
114
115 /* Now, regular headers - we only care about PT_LOAD headers,
116 * because thats what we're actually going to load
117 */
118
119 for (i = 0; i < headers; i++) {
120 if (phdr[i].p_type != PT_LOAD)
121 continue;
122
123 /* Empty segments are never interesting */
124 if (phdr[i].p_memsz == 0)
125 continue;
126
127 isize += phdr[i].p_filesz;
128
129 segments++;
130 }
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800131 /* allocate the segment header array */
132 segs = calloc(segments, sizeof(*segs));
Patrick Georgi96990a22014-09-29 10:08:35 +0200133 if (segs == NULL) {
134 ret = -1;
135 goto out;
136 }
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000137 /* Allocate a block of memory to store the data in */
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800138 if (buffer_create(output, (segments * sizeof(*segs)) + isize,
Patrick Georgi96990a22014-09-29 10:08:35 +0200139 input->name) != 0) {
140 ret = -1;
141 goto out;
142 }
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800143 memset(output->data, 0, output->size);
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000144
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800145 doffset = (segments * sizeof(*segs));
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000146
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800147 /* set up for output marshaling. This is a bit
148 * tricky as we are marshaling the headers at the front,
149 * and the data starting after the headers. We need to convert
150 * the headers to the right format but the data
151 * passes through unchanged. Unlike most XDR code,
152 * we are doing these two concurrently. The doffset is
153 * used to compute the address for the raw data, and the
154 * outheader is used to marshal the headers. To make it simpler
155 * for The Reader, we set up the headers in a separate array,
156 * then marshal them all at once to the output.
157 */
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000158 segments = 0;
159
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800160 for (i = 0; i < ehdr.e_shnum; i++) {
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000161 char *name;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800162 if (i == ehdr.e_shstrndx)
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000163 continue;
164
165 if (shdr[i].sh_size == 0)
166 continue;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000167 name = (char *)(strtab + shdr[i].sh_name);
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000168 if (!strcmp(name, ".note.pinfo")) {
169 segs[segments].type = PAYLOAD_SEGMENT_PARAMS;
170 segs[segments].load_addr = 0;
171 segs[segments].len = (unsigned int)shdr[i].sh_size;
172 segs[segments].offset = doffset;
173
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800174 memcpy((unsigned long *)(output->data + doffset),
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000175 &header[shdr[i].sh_offset], shdr[i].sh_size);
176
177 doffset += segs[segments].len;
178 osize += segs[segments].len;
179
180 segments++;
181 }
182 }
183
184 for (i = 0; i < headers; i++) {
185 if (phdr[i].p_type != PT_LOAD)
186 continue;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000187 if (phdr[i].p_memsz == 0)
188 continue;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000189 if (phdr[i].p_filesz == 0) {
190 segs[segments].type = PAYLOAD_SEGMENT_BSS;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800191 segs[segments].load_addr = phdr[i].p_paddr;
192 segs[segments].mem_len = phdr[i].p_memsz;
193 segs[segments].offset = doffset;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000194
195 segments++;
196 continue;
197 }
198
Stefan Reinauer51f6a202012-01-11 12:40:14 -0800199 if (phdr[i].p_flags & PF_X)
200 segs[segments].type = PAYLOAD_SEGMENT_CODE;
201 else
202 segs[segments].type = PAYLOAD_SEGMENT_DATA;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800203 segs[segments].load_addr = phdr[i].p_paddr;
204 segs[segments].mem_len = phdr[i].p_memsz;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800205 segs[segments].offset = doffset;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000206
Gabe Black845aa142014-02-21 01:01:06 -0800207 /* If the compression failed or made the section is larger,
208 use the original stuff */
209
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000210 int len;
Gabe Blackdbd006b2014-02-20 23:38:49 -0800211 if (compress((char *)&header[phdr[i].p_offset],
Gabe Black845aa142014-02-21 01:01:06 -0800212 phdr[i].p_filesz, output->data + doffset, &len) ||
213 (unsigned int)len > phdr[i].p_filesz) {
214 WARN("Compression failed or would make the data bigger "
215 "- disabled.\n");
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000216 segs[segments].compression = 0;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800217 segs[segments].len = phdr[i].p_filesz;
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800218 memcpy(output->data + doffset,
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000219 &header[phdr[i].p_offset], phdr[i].p_filesz);
Gabe Black845aa142014-02-21 01:01:06 -0800220 } else {
221 segs[segments].compression = algo;
222 segs[segments].len = len;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000223 }
224
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800225 doffset += segs[segments].len;
226 osize += segs[segments].len;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000227
228 segments++;
229 }
230
231 segs[segments].type = PAYLOAD_SEGMENT_ENTRY;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800232 segs[segments++].load_addr = ehdr.e_entry;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000233
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800234 output->size = (segments * sizeof(*segs)) + osize;
235 xdr_segs(output, segs, segments);
Patrick Georgi96990a22014-09-29 10:08:35 +0200236
237out:
238 if (segs) free(segs);
239 if (shdr) free(shdr);
240 if (phdr) free(phdr);
241 return ret;
Ronald G. Minnich5d01ec02009-03-31 11:57:36 +0000242}
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800243
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800244int parse_flat_binary_to_payload(const struct buffer *input,
245 struct buffer *output,
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800246 uint32_t loadaddress,
247 uint32_t entrypoint,
Sol Boucher6310ccc2015-05-07 21:12:28 -0700248 enum comp_algo algo)
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800249{
250 comp_func_ptr compress;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800251 struct cbfs_payload_segment segs[2];
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800252 int doffset, len = 0;
253
254 compress = compression_function(algo);
255 if (!compress)
256 return -1;
257
258 DEBUG("start: parse_flat_binary_to_payload\n");
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800259 if (buffer_create(output, (sizeof(segs) + input->size),
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800260 input->name) != 0)
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800261 return -1;
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800262 memset(output->data, 0, output->size);
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800263
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800264 doffset = (2 * sizeof(*segs));
265
266 /* Prepare code segment */
267 segs[0].type = PAYLOAD_SEGMENT_CODE;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800268 segs[0].load_addr = loadaddress;
269 segs[0].mem_len = input->size;
270 segs[0].offset = doffset;
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800271
Gabe Black845aa142014-02-21 01:01:06 -0800272 if (!compress(input->data, input->size, output->data + doffset, &len) &&
273 (unsigned int)len < input->size) {
274 segs[0].compression = algo;
275 segs[0].len = len;
276 } else {
277 WARN("Compression failed or would make the data bigger "
278 "- disabled.\n");
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800279 segs[0].compression = 0;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800280 segs[0].len = input->size;
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800281 memcpy(output->data + doffset, input->data, input->size);
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800282 }
283
284 /* prepare entry point segment */
285 segs[1].type = PAYLOAD_SEGMENT_ENTRY;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800286 segs[1].load_addr = entrypoint;
287 output->size = doffset + segs[0].len;
288 xdr_segs(output, segs, 2);
Hung-Te Linc13e4bf2013-01-29 15:22:11 +0800289 return 0;
Hung-Te Lin05dccae2013-01-28 15:04:30 +0800290}
Stefan Reinauer543a6822013-02-04 15:39:13 -0800291
Sol Boucher6310ccc2015-05-07 21:12:28 -0700292int parse_fv_to_payload(const struct buffer *input, struct buffer *output,
293 enum comp_algo algo)
Stefan Reinauer543a6822013-02-04 15:39:13 -0800294{
295 comp_func_ptr compress;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800296 struct cbfs_payload_segment segs[2];
Stefan Reinauer543a6822013-02-04 15:39:13 -0800297 int doffset, len = 0;
298 firmware_volume_header_t *fv;
299 ffs_file_header_t *fh;
300 common_section_header_t *cs;
301 dos_header_t *dh;
302 coff_header_t *ch;
Stefan Reinauer543a6822013-02-04 15:39:13 -0800303 int dh_offset;
304
Stefan Reinauere8764182013-02-05 13:46:49 -0800305 uint32_t loadaddress = 0;
306 uint32_t entrypoint = 0;
Stefan Reinauer543a6822013-02-04 15:39:13 -0800307
308 compress = compression_function(algo);
309 if (!compress)
310 return -1;
311
312 DEBUG("start: parse_fv_to_payload\n");
313
314 fv = (firmware_volume_header_t *)input->data;
315 if (fv->signature != FV_SIGNATURE) {
316 INFO("Not a UEFI firmware volume.\n");
317 return -1;
318 }
319
320 fh = (ffs_file_header_t *)(input->data + fv->header_length);
Patrick Georgi46102472013-02-09 13:26:19 +0100321 while (fh->file_type == FILETYPE_PAD) {
322 unsigned long offset = (fh->size[2] << 16) | (fh->size[1] << 8) | fh->size[0];
Hung-Te Lin7b654a92013-02-18 18:35:00 +0800323 ERROR("skipping %lu bytes of FV padding\n", offset);
Sol Boucher0e539312015-03-05 15:38:03 -0800324 fh = (ffs_file_header_t *)(((uintptr_t)fh) + offset);
Patrick Georgi46102472013-02-09 13:26:19 +0100325 }
Stefan Reinauer543a6822013-02-04 15:39:13 -0800326 if (fh->file_type != FILETYPE_SEC) {
327 ERROR("Not a usable UEFI firmware volume.\n");
Stefan Reinauere8764182013-02-05 13:46:49 -0800328 INFO("First file in first FV not a SEC core.\n");
Stefan Reinauer543a6822013-02-04 15:39:13 -0800329 return -1;
330 }
331
332 cs = (common_section_header_t *)&fh[1];
Patrick Georgi46102472013-02-09 13:26:19 +0100333 while (cs->section_type == SECTION_RAW) {
334 unsigned long offset = (cs->size[2] << 16) | (cs->size[1] << 8) | cs->size[0];
Hung-Te Lin7b654a92013-02-18 18:35:00 +0800335 ERROR("skipping %lu bytes of section padding\n", offset);
Sol Boucher0e539312015-03-05 15:38:03 -0800336 cs = (common_section_header_t *)(((uintptr_t)cs) + offset);
Patrick Georgi46102472013-02-09 13:26:19 +0100337 }
Stefan Reinauer543a6822013-02-04 15:39:13 -0800338 if (cs->section_type != SECTION_PE32) {
339 ERROR("Not a usable UEFI firmware volume.\n");
Stefan Reinauere8764182013-02-05 13:46:49 -0800340 INFO("Section type not PE32.\n");
Stefan Reinauer543a6822013-02-04 15:39:13 -0800341 return -1;
342 }
343
344 dh = (dos_header_t *)&cs[1];
Stefan Reinauere8764182013-02-05 13:46:49 -0800345 if (dh->signature != DOS_MAGIC) {
Stefan Reinauer543a6822013-02-04 15:39:13 -0800346 ERROR("Not a usable UEFI firmware volume.\n");
Stefan Reinauere8764182013-02-05 13:46:49 -0800347 INFO("DOS header signature wrong.\n");
Stefan Reinauer543a6822013-02-04 15:39:13 -0800348 return -1;
349 }
350
351 dh_offset = (unsigned long)dh - (unsigned long)input->data;
352 DEBUG("dos header offset = %x\n", dh_offset);
353
Sol Boucher0e539312015-03-05 15:38:03 -0800354 ch = (coff_header_t *)(((uintptr_t)dh)+dh->e_lfanew);
Stefan Reinauere8764182013-02-05 13:46:49 -0800355
356 if (ch->machine == MACHINE_TYPE_X86) {
357 pe_opt_header_32_t *ph;
358 ph = (pe_opt_header_32_t *)&ch[1];
359 if (ph->signature != PE_HDR_32_MAGIC) {
360 WARN("PE header signature incorrect.\n");
361 return -1;
362 }
363 DEBUG("image base %x\n", ph->image_addr);
364 DEBUG("entry point %x\n", ph->entry_point);
365
366 loadaddress = ph->image_addr - dh_offset;
367 entrypoint = ph->image_addr + ph->entry_point;
368 } else if (ch->machine == MACHINE_TYPE_X64) {
369 pe_opt_header_64_t *ph;
370 ph = (pe_opt_header_64_t *)&ch[1];
371 if (ph->signature != PE_HDR_64_MAGIC) {
372 WARN("PE header signature incorrect.\n");
373 return -1;
374 }
375 DEBUG("image base %lx\n", (unsigned long)ph->image_addr);
376 DEBUG("entry point %x\n", ph->entry_point);
377
378 loadaddress = ph->image_addr - dh_offset;
379 entrypoint = ph->image_addr + ph->entry_point;
380 } else {
381 ERROR("Machine type not x86 or x64.\n");
Stefan Reinauer543a6822013-02-04 15:39:13 -0800382 return -1;
383 }
384
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800385 if (buffer_create(output, (sizeof(segs) + input->size),
Stefan Reinauer543a6822013-02-04 15:39:13 -0800386 input->name) != 0)
387 return -1;
388
389 memset(output->data, 0, output->size);
390
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800391 doffset = (sizeof(segs));
Stefan Reinauer543a6822013-02-04 15:39:13 -0800392
393 /* Prepare code segment */
394 segs[0].type = PAYLOAD_SEGMENT_CODE;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800395 segs[0].load_addr = loadaddress;
396 segs[0].mem_len = input->size;
397 segs[0].offset = doffset;
Stefan Reinauer543a6822013-02-04 15:39:13 -0800398
Gabe Black845aa142014-02-21 01:01:06 -0800399 if (!compress(input->data, input->size, output->data + doffset, &len) &&
400 (unsigned int)len < input->size) {
401 segs[0].compression = algo;
402 segs[0].len = len;
403 } else {
404 WARN("Compression failed or would make the data bigger "
405 "- disabled.\n");
Stefan Reinauer543a6822013-02-04 15:39:13 -0800406 segs[0].compression = 0;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800407 segs[0].len = input->size;
Stefan Reinauer543a6822013-02-04 15:39:13 -0800408 memcpy(output->data + doffset, input->data, input->size);
409 }
410
411 /* prepare entry point segment */
412 segs[1].type = PAYLOAD_SEGMENT_ENTRY;
Ronald G. Minnicha8a133d2013-12-30 13:16:18 -0800413 segs[1].load_addr = entrypoint;
414 output->size = doffset + segs[0].len;
415 xdr_segs(output, segs, 2);
Stefan Reinauer543a6822013-02-04 15:39:13 -0800416 return 0;
417
418}