~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to kern/elf.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-01-11 11:12:55 UTC
  • mfrom: (17.3.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100111111255-lr8ebkqw5x41gq6j
Tags: 1.98~20100101-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script: title,
    recovery mode, quiet option, tweak how memtest86+ is displayed, and
    use UUIDs where appropriate.
  - Conflict with grub (<< 0.97-54) as well as grub-legacy.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel= options if kdump and makedumpfile are available.
  - If other operating systems are installed, then automatically unhide
    the menu. Otherwise, if GRUB_HIDDEN_TIMEOUT is 0, then use keystatus
    if available to check whether Shift is pressed. If it is, show the
    menu, otherwise boot immediately. If keystatus is not available, then
    fall back to a short delay interruptible with Escape.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Don't display introductory message about line editing unless we're
    actually offering a shell prompt. Don't clear the screen just before
    booting if we never drew the menu in the first place.
  - Remove some verbose messages printed before reading the configuration
    file.
  - If the environment variable "quiet" is set to something other than 0,
    suppress progress messages as the kernel and initrd load. Set this for
    non-recovery kernel menu entries.
  - Add GRUB_DEFAULT=saved, as well as grub-set-default and grub-reboot
    utilities. Provides functionality essentially equivalent to GRUB
    Legacy's savedefault.
  - Keep the loopback file open so that subsequent changes to the "root"
    environment variable don't affect it.
  - Change prepare_grub_to_access_device to handle filesystems
    loop-mounted on file images.
  - Ignore devices loop-mounted from files in 10_linux.
  - Show the boot menu if the previous boot failed, that is if it failed
    to get to the end of one of the normal runlevels.
  - Handle RAID devices containing virtio components.
* Update savedefault patch from current Bazaar branch, fixing grub-reboot
  to have distinct behaviour from grub-set-default (LP: #497326).
* Fix grub-mkisofs compilation error with FORTIFY_SOURCE.
* Convert recordfail boilerplate in each menu entry to use a function.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
      != sizeof (elf->ehdr))
75
75
    {
76
76
      grub_error_push ();
77
 
      grub_error (GRUB_ERR_READ_ERROR, "Cannot read ELF header.");
 
77
      grub_error (GRUB_ERR_READ_ERROR, "cannot read ELF header");
78
78
      goto fail;
79
79
    }
80
80
 
134
134
      || (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
135
135
    {
136
136
      grub_error_push ();
137
 
      return grub_error (GRUB_ERR_READ_ERROR, "Cannot read program headers");
 
137
      return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers");
138
138
    }
139
139
 
140
140
  return GRUB_ERR_NONE;
181
181
  /* Run through the program headers to calculate the total memory size we
182
182
   * should claim.  */
183
183
  auto int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf, Elf32_Phdr *phdr, void *_arg);
184
 
  int NESTED_FUNC_ATTR calcsize (grub_elf_t UNUSED _elf, Elf32_Phdr *phdr, void UNUSED *_arg)
 
184
  int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf  __attribute__ ((unused)),
 
185
                                 Elf32_Phdr *phdr,
 
186
                                 void *_arg __attribute__ ((unused)))
185
187
    {
186
188
      /* Only consider loadable segments.  */
187
189
      if (phdr->p_type != PT_LOAD)
198
200
 
199
201
  if (nr_phdrs == 0)
200
202
    {
201
 
      grub_error (GRUB_ERR_BAD_OS, "No program headers present");
 
203
      grub_error (GRUB_ERR_BAD_OS, "no program headers present");
202
204
      return 0;
203
205
    }
204
206
 
205
207
  if (segments_end < segments_start)
206
208
    {
207
209
      /* Very bad addresses.  */
208
 
      grub_error (GRUB_ERR_BAD_OS, "Bad program header load addresses");
 
210
      grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses");
209
211
      return 0;
210
212
    }
211
213
 
247
249
      {
248
250
        grub_error_push ();
249
251
        return grub_error (GRUB_ERR_BAD_OS,
250
 
                           "Invalid offset in program header.");
 
252
                           "invalid offset in program header");
251
253
      }
252
254
 
253
255
    if (phdr->p_filesz)
259
261
            /* XXX How can we free memory from `load_hook'? */
260
262
            grub_error_push ();
261
263
            return grub_error (GRUB_ERR_BAD_OS,
262
 
                               "Couldn't read segment from file: "
263
 
                               "wanted 0x%lx bytes; read 0x%lx bytes.",
 
264
                               "couldn't read segment from file: "
 
265
                               "wanted 0x%lx bytes; read 0x%lx bytes",
264
266
                               phdr->p_filesz, read);
265
267
          }
266
268
      }
313
315
      || (grub_file_read (elf->file, elf->phdrs, phdrs_size) != phdrs_size))
314
316
    {
315
317
      grub_error_push ();
316
 
      return grub_error (GRUB_ERR_READ_ERROR, "Cannot read program headers");
 
318
      return grub_error (GRUB_ERR_READ_ERROR, "cannot read program headers");
317
319
    }
318
320
 
319
321
  return GRUB_ERR_NONE;
360
362
  /* Run through the program headers to calculate the total memory size we
361
363
   * should claim.  */
362
364
  auto int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf, Elf64_Phdr *phdr, void *_arg);
363
 
  int NESTED_FUNC_ATTR calcsize (grub_elf_t UNUSED _elf, Elf64_Phdr *phdr, void UNUSED *_arg)
 
365
  int NESTED_FUNC_ATTR calcsize (grub_elf_t _elf __attribute__ ((unused)),
 
366
                                 Elf64_Phdr *phdr,
 
367
                                 void *_arg __attribute__ ((unused)))
364
368
    {
365
369
      /* Only consider loadable segments.  */
366
370
      if (phdr->p_type != PT_LOAD)
377
381
 
378
382
  if (nr_phdrs == 0)
379
383
    {
380
 
      grub_error (GRUB_ERR_BAD_OS, "No program headers present");
 
384
      grub_error (GRUB_ERR_BAD_OS, "no program headers present");
381
385
      return 0;
382
386
    }
383
387
 
384
388
  if (segments_end < segments_start)
385
389
    {
386
390
      /* Very bad addresses.  */
387
 
      grub_error (GRUB_ERR_BAD_OS, "Bad program header load addresses");
 
391
      grub_error (GRUB_ERR_BAD_OS, "bad program header load addresses");
388
392
      return 0;
389
393
    }
390
394
 
427
431
      {
428
432
        grub_error_push ();
429
433
        return grub_error (GRUB_ERR_BAD_OS,
430
 
                           "Invalid offset in program header.");
 
434
                           "invalid offset in program header");
431
435
      }
432
436
 
433
437
    if (phdr->p_filesz)
439
443
            /* XXX How can we free memory from `load_hook'?  */
440
444
            grub_error_push ();
441
445
            return grub_error (GRUB_ERR_BAD_OS,
442
 
                              "Couldn't read segment from file: "
443
 
                              "wanted 0x%lx bytes; read 0x%lx bytes.",
 
446
                              "couldn't read segment from file: "
 
447
                              "wanted 0x%lx bytes; read 0x%lx bytes",
444
448
                              phdr->p_filesz, read);
445
449
          }
446
450
      }