~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to util/grub-pe2elf.c

Tags: upstream-1.99~20101122
ImportĀ upstreamĀ versionĀ 1.99~20101122

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <stdlib.h>
30
30
#include <getopt.h>
31
31
 
 
32
#include "progname.h"
 
33
 
32
34
static struct option options[] = {
33
35
  {"help", no_argument, 0, 'h'},
34
36
  {"version", no_argument, 0, 'V'},
40
42
usage (int status)
41
43
{
42
44
  if (status)
43
 
    fprintf (stderr, "Try ``%s --help'' for more information.\n", program_name);
 
45
    fprintf (stderr, "Try `%s --help' for more information.\n", program_name);
44
46
  else
45
47
    printf ("\
46
48
Usage: %s [OPTIONS] input [output]\n\
182
184
          char name[5 + strlen (pe_shdr->name)];
183
185
 
184
186
          if (num_sections >= MAX_SECTIONS)
185
 
            grub_util_error ("Too many sections");
 
187
            grub_util_error ("too many sections");
186
188
 
187
189
          sprintf (name, ".rel%s", pe_shdr->name);
188
190
 
230
232
 
231
233
          if ((pe_rel->symtab_index >= pe_chdr->num_symbols) ||
232
234
              (symtab_map[pe_rel->symtab_index] == -1))
233
 
            grub_util_error ("Invalid symbol");
 
235
            grub_util_error ("invalid symbol");
234
236
 
235
237
          if (pe_rel->type == GRUB_PE32_REL_I386_DIR32)
236
238
            type = R_386_32;
237
239
          else if (pe_rel->type == GRUB_PE32_REL_I386_REL32)
238
240
            type = R_386_PC32;
239
241
          else
240
 
            grub_util_error ("Unknown pe relocation type %d\n", pe_rel->type);
 
242
            grub_util_error ("unknown pe relocation type %d\n", pe_rel->type);
241
243
 
242
244
          ofs = pe_rel->offset - pe_sec->virtual_address;
243
245
          addr = (grub_uint32_t *)(image + pe_sec->raw_data_offset + ofs);
248
250
              code = image[pe_sec->raw_data_offset + ofs - 1];
249
251
 
250
252
              if (((code != 0xe8) && (code != 0xe9)) || (*addr))
251
 
                grub_util_error ("Invalid relocation (%x %x)", code, *addr);
 
253
                grub_util_error ("invalid relocation (%x %x)", code, *addr);
252
254
 
253
255
              modified = 1;
254
256
              if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx)
255
257
                {
256
258
                  if (symtab[symtab_map[pe_rel->symtab_index]].st_shndx
257
259
                      != shdr[i].sh_info)
258
 
                    grub_util_error ("Cross section call is not allowed");
 
260
                    grub_util_error ("cross section call is not allowed");
259
261
 
260
262
                  *addr = (symtab[symtab_map[pe_rel->symtab_index]].st_value
261
263
                           - ofs - 4);
440
442
 
441
443
  pe_chdr = (struct grub_pe32_coff_header *) image;
442
444
  if (grub_le_to_cpu16 (pe_chdr->machine) != GRUB_PE32_MACHINE_I386)
443
 
    grub_util_error ("Invalid coff image");
 
445
    grub_util_error ("invalid coff image");
444
446
 
445
447
  strtab = xmalloc (STRTAB_BLOCK);
446
448
  strtab_max = STRTAB_BLOCK;