Procházet zdrojové kódy

Limit -ENOEXEC to mean "this is not in my format".

tags/v0.9.3
Michael Brown před 18 roky
rodič
revize
819cd3f41c
2 změnil soubory, kde provedl 11 přidání a 3 odebrání
  1. 3
    3
      src/image/elf.c
  2. 8
    0
      src/include/gpxe/image.h

+ 3
- 3
src/image/elf.c Zobrazit soubor

@@ -53,7 +53,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr ) {
53 53
 	/* Check segment lies within image */
54 54
 	if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
55 55
 		DBG ( "ELF segment outside ELF file\n" );
56
-		return -ENOEXEC;
56
+		return -ERANGE;
57 57
 	}
58 58
 
59 59
 	/* Find start address: use physical address for preference,
@@ -65,7 +65,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr ) {
65 65
 		dest = phdr->p_vaddr;
66 66
 	if ( ! dest ) {
67 67
 		DBG ( "ELF segment loads to physical address 0\n" );
68
-		return -ENOEXEC;
68
+		return -ERANGE;
69 69
 	}
70 70
 	buffer = phys_to_user ( dest );
71 71
 
@@ -113,7 +113,7 @@ int elf_load ( struct image *image ) {
113 113
 		if ( phoff > image->len ) {
114 114
 			DBG ( "ELF program header %d outside ELF image\n",
115 115
 			      phnum );
116
-			return -ENOEXEC;
116
+			return -ERANGE;
117 117
 		}
118 118
 		copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
119 119
 		if ( ( rc = elf_load_segment ( image, &phdr ) ) != 0 )

+ 8
- 0
src/include/gpxe/image.h Zobrazit soubor

@@ -40,6 +40,14 @@ struct image_type {
40 40
 	 * discarded after this call; the method must preserve any
41 41
 	 * information it may require later (e.g. the execution
42 42
 	 * address) within the @c image structure.
43
+	 *
44
+	 * The method should return -ENOEXEC if and only if the image
45
+	 * is not in the correct format.  Other errors will be
46
+	 * interpreted as "I claim this image format, but there's
47
+	 * something wrong with it that makes it unloadable".  In
48
+	 * particular, returning -ENOEXEC will cause the image probing
49
+	 * code to try the next available image type, while returning
50
+	 * any other error will terminate image probing.
43 51
 	 */
44 52
 	int ( * load ) ( struct image *image );
45 53
 };

Načítá se…
Zrušit
Uložit