diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-22 12:40:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-22 12:40:53 -0400 |
commit | 02c502566ef505d0469fa27567f48766c1f5f7af (patch) | |
tree | dd29678eb5f15ddfe537418eb83ad2c54074c37b /arch | |
parent | f06fc0c0de0b4f01dbad8ec5552e78192c7abbb8 (diff) | |
parent | a51f4047758d2bcd099ea113b833ed380f4024ba (diff) |
Merge branch 'x86-build-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86/build changes from Ingo Molnar.
* 'x86-build-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
x86, build: Fix portability issues when cross-building
x86, tools: Remove unneeded header files from tools/build.c
USB: ffs-test: Don't duplicate {get,put}_unaligned*() functions
x86, efi: Fix endian issues and unaligned accesses
x86, boot: Restrict CFLAGS for hostprogs
x86, mkpiggy: Don't open code put_unaligned_le32()
x86, relocs: Don't open code put_unaligned_le32()
tools/include: Add byteshift headers for endian access
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/boot/Makefile | 5 | ||||
-rw-r--r-- | arch/x86/boot/compressed/Makefile | 1 | ||||
-rw-r--r-- | arch/x86/boot/compressed/mkpiggy.c | 11 | ||||
-rw-r--r-- | arch/x86/boot/compressed/relocs.c | 6 | ||||
-rw-r--r-- | arch/x86/boot/tools/build.c | 40 |
5 files changed, 27 insertions, 36 deletions
diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile index 95365a82b6a0..3e02148bb774 100644 --- a/arch/x86/boot/Makefile +++ b/arch/x86/boot/Makefile | |||
@@ -37,8 +37,9 @@ setup-y += video-bios.o | |||
37 | targets += $(setup-y) | 37 | targets += $(setup-y) |
38 | hostprogs-y := mkcpustr tools/build | 38 | hostprogs-y := mkcpustr tools/build |
39 | 39 | ||
40 | HOST_EXTRACFLAGS += $(LINUXINCLUDE) | 40 | HOSTCFLAGS_mkcpustr.o := -I$(srctree)/arch/$(SRCARCH)/include |
41 | 41 | HOST_EXTRACFLAGS += -I$(objtree)/include -I$(srctree)/tools/include \ | |
42 | -include $(srctree)/include/linux/kconfig.h | ||
42 | $(obj)/cpu.o: $(obj)/cpustr.h | 43 | $(obj)/cpu.o: $(obj)/cpustr.h |
43 | 44 | ||
44 | quiet_cmd_cpustr = CPUSTR $@ | 45 | quiet_cmd_cpustr = CPUSTR $@ |
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile index b123b9a8f5b3..fd55a2ff3ad8 100644 --- a/arch/x86/boot/compressed/Makefile +++ b/arch/x86/boot/compressed/Makefile | |||
@@ -22,6 +22,7 @@ LDFLAGS := -m elf_$(UTS_MACHINE) | |||
22 | LDFLAGS_vmlinux := -T | 22 | LDFLAGS_vmlinux := -T |
23 | 23 | ||
24 | hostprogs-y := mkpiggy | 24 | hostprogs-y := mkpiggy |
25 | HOST_EXTRACFLAGS += -I$(srctree)/tools/include | ||
25 | 26 | ||
26 | VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ | 27 | VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \ |
27 | $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \ | 28 | $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \ |
diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c index 46a823882437..958a641483dd 100644 --- a/arch/x86/boot/compressed/mkpiggy.c +++ b/arch/x86/boot/compressed/mkpiggy.c | |||
@@ -29,14 +29,7 @@ | |||
29 | #include <stdio.h> | 29 | #include <stdio.h> |
30 | #include <string.h> | 30 | #include <string.h> |
31 | #include <inttypes.h> | 31 | #include <inttypes.h> |
32 | 32 | #include <tools/le_byteshift.h> | |
33 | static uint32_t getle32(const void *p) | ||
34 | { | ||
35 | const uint8_t *cp = p; | ||
36 | |||
37 | return (uint32_t)cp[0] + ((uint32_t)cp[1] << 8) + | ||
38 | ((uint32_t)cp[2] << 16) + ((uint32_t)cp[3] << 24); | ||
39 | } | ||
40 | 33 | ||
41 | int main(int argc, char *argv[]) | 34 | int main(int argc, char *argv[]) |
42 | { | 35 | { |
@@ -69,7 +62,7 @@ int main(int argc, char *argv[]) | |||
69 | } | 62 | } |
70 | 63 | ||
71 | ilen = ftell(f); | 64 | ilen = ftell(f); |
72 | olen = getle32(&olen); | 65 | olen = get_unaligned_le32(&olen); |
73 | fclose(f); | 66 | fclose(f); |
74 | 67 | ||
75 | /* | 68 | /* |
diff --git a/arch/x86/boot/compressed/relocs.c b/arch/x86/boot/compressed/relocs.c index 89bbf4e4d05d..d3c0b0277666 100644 --- a/arch/x86/boot/compressed/relocs.c +++ b/arch/x86/boot/compressed/relocs.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #define USE_BSD | 10 | #define USE_BSD |
11 | #include <endian.h> | 11 | #include <endian.h> |
12 | #include <regex.h> | 12 | #include <regex.h> |
13 | #include <tools/le_byteshift.h> | ||
13 | 14 | ||
14 | static void die(char *fmt, ...); | 15 | static void die(char *fmt, ...); |
15 | 16 | ||
@@ -605,10 +606,7 @@ static void emit_relocs(int as_text) | |||
605 | fwrite("\0\0\0\0", 4, 1, stdout); | 606 | fwrite("\0\0\0\0", 4, 1, stdout); |
606 | /* Now print each relocation */ | 607 | /* Now print each relocation */ |
607 | for (i = 0; i < reloc_count; i++) { | 608 | for (i = 0; i < reloc_count; i++) { |
608 | buf[0] = (relocs[i] >> 0) & 0xff; | 609 | put_unaligned_le32(relocs[i], buf); |
609 | buf[1] = (relocs[i] >> 8) & 0xff; | ||
610 | buf[2] = (relocs[i] >> 16) & 0xff; | ||
611 | buf[3] = (relocs[i] >> 24) & 0xff; | ||
612 | fwrite(buf, 4, 1, stdout); | 610 | fwrite(buf, 4, 1, stdout); |
613 | } | 611 | } |
614 | } | 612 | } |
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 4e9bd6bcafa6..ed549767a231 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c | |||
@@ -29,18 +29,18 @@ | |||
29 | #include <stdarg.h> | 29 | #include <stdarg.h> |
30 | #include <sys/types.h> | 30 | #include <sys/types.h> |
31 | #include <sys/stat.h> | 31 | #include <sys/stat.h> |
32 | #include <sys/sysmacros.h> | ||
33 | #include <unistd.h> | 32 | #include <unistd.h> |
34 | #include <fcntl.h> | 33 | #include <fcntl.h> |
35 | #include <sys/mman.h> | 34 | #include <sys/mman.h> |
36 | #include <asm/boot.h> | 35 | #include <tools/le_byteshift.h> |
37 | 36 | ||
38 | typedef unsigned char u8; | 37 | typedef unsigned char u8; |
39 | typedef unsigned short u16; | 38 | typedef unsigned short u16; |
40 | typedef unsigned long u32; | 39 | typedef unsigned int u32; |
41 | 40 | ||
42 | #define DEFAULT_MAJOR_ROOT 0 | 41 | #define DEFAULT_MAJOR_ROOT 0 |
43 | #define DEFAULT_MINOR_ROOT 0 | 42 | #define DEFAULT_MINOR_ROOT 0 |
43 | #define DEFAULT_ROOT_DEV (DEFAULT_MAJOR_ROOT << 8 | DEFAULT_MINOR_ROOT) | ||
44 | 44 | ||
45 | /* Minimal number of setup sectors */ | 45 | /* Minimal number of setup sectors */ |
46 | #define SETUP_SECT_MIN 5 | 46 | #define SETUP_SECT_MIN 5 |
@@ -159,7 +159,7 @@ int main(int argc, char ** argv) | |||
159 | die("read-error on `setup'"); | 159 | die("read-error on `setup'"); |
160 | if (c < 1024) | 160 | if (c < 1024) |
161 | die("The setup must be at least 1024 bytes"); | 161 | die("The setup must be at least 1024 bytes"); |
162 | if (buf[510] != 0x55 || buf[511] != 0xaa) | 162 | if (get_unaligned_le16(&buf[510]) != 0xAA55) |
163 | die("Boot block hasn't got boot flag (0xAA55)"); | 163 | die("Boot block hasn't got boot flag (0xAA55)"); |
164 | fclose(file); | 164 | fclose(file); |
165 | 165 | ||
@@ -171,8 +171,7 @@ int main(int argc, char ** argv) | |||
171 | memset(buf+c, 0, i-c); | 171 | memset(buf+c, 0, i-c); |
172 | 172 | ||
173 | /* Set the default root device */ | 173 | /* Set the default root device */ |
174 | buf[508] = DEFAULT_MINOR_ROOT; | 174 | put_unaligned_le16(DEFAULT_ROOT_DEV, &buf[508]); |
175 | buf[509] = DEFAULT_MAJOR_ROOT; | ||
176 | 175 | ||
177 | fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i); | 176 | fprintf(stderr, "Setup is %d bytes (padded to %d bytes).\n", c, i); |
178 | 177 | ||
@@ -192,44 +191,42 @@ int main(int argc, char ** argv) | |||
192 | 191 | ||
193 | /* Patch the setup code with the appropriate size parameters */ | 192 | /* Patch the setup code with the appropriate size parameters */ |
194 | buf[0x1f1] = setup_sectors-1; | 193 | buf[0x1f1] = setup_sectors-1; |
195 | buf[0x1f4] = sys_size; | 194 | put_unaligned_le32(sys_size, &buf[0x1f4]); |
196 | buf[0x1f5] = sys_size >> 8; | ||
197 | buf[0x1f6] = sys_size >> 16; | ||
198 | buf[0x1f7] = sys_size >> 24; | ||
199 | 195 | ||
200 | #ifdef CONFIG_EFI_STUB | 196 | #ifdef CONFIG_EFI_STUB |
201 | file_sz = sz + i + ((sys_size * 16) - sz); | 197 | file_sz = sz + i + ((sys_size * 16) - sz); |
202 | 198 | ||
203 | pe_header = *(unsigned int *)&buf[0x3c]; | 199 | pe_header = get_unaligned_le32(&buf[0x3c]); |
204 | 200 | ||
205 | /* Size of code */ | 201 | /* Size of code */ |
206 | *(unsigned int *)&buf[pe_header + 0x1c] = file_sz; | 202 | put_unaligned_le32(file_sz, &buf[pe_header + 0x1c]); |
207 | 203 | ||
208 | /* Size of image */ | 204 | /* Size of image */ |
209 | *(unsigned int *)&buf[pe_header + 0x50] = file_sz; | 205 | put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); |
210 | 206 | ||
211 | #ifdef CONFIG_X86_32 | 207 | #ifdef CONFIG_X86_32 |
212 | /* Address of entry point */ | 208 | /* Address of entry point */ |
213 | *(unsigned int *)&buf[pe_header + 0x28] = i; | 209 | put_unaligned_le32(i, &buf[pe_header + 0x28]); |
214 | 210 | ||
215 | /* .text size */ | 211 | /* .text size */ |
216 | *(unsigned int *)&buf[pe_header + 0xb0] = file_sz; | 212 | put_unaligned_le32(file_sz, &buf[pe_header + 0xb0]); |
217 | 213 | ||
218 | /* .text size of initialised data */ | 214 | /* .text size of initialised data */ |
219 | *(unsigned int *)&buf[pe_header + 0xb8] = file_sz; | 215 | put_unaligned_le32(file_sz, &buf[pe_header + 0xb8]); |
220 | #else | 216 | #else |
221 | /* | 217 | /* |
222 | * Address of entry point. startup_32 is at the beginning and | 218 | * Address of entry point. startup_32 is at the beginning and |
223 | * the 64-bit entry point (startup_64) is always 512 bytes | 219 | * the 64-bit entry point (startup_64) is always 512 bytes |
224 | * after. | 220 | * after. |
225 | */ | 221 | */ |
226 | *(unsigned int *)&buf[pe_header + 0x28] = i + 512; | 222 | put_unaligned_le32(i + 512, &buf[pe_header + 0x28]); |
227 | 223 | ||
228 | /* .text size */ | 224 | /* .text size */ |
229 | *(unsigned int *)&buf[pe_header + 0xc0] = file_sz; | 225 | put_unaligned_le32(file_sz, &buf[pe_header + 0xc0]); |
230 | 226 | ||
231 | /* .text size of initialised data */ | 227 | /* .text size of initialised data */ |
232 | *(unsigned int *)&buf[pe_header + 0xc8] = file_sz; | 228 | put_unaligned_le32(file_sz, &buf[pe_header + 0xc8]); |
229 | |||
233 | #endif /* CONFIG_X86_32 */ | 230 | #endif /* CONFIG_X86_32 */ |
234 | #endif /* CONFIG_EFI_STUB */ | 231 | #endif /* CONFIG_EFI_STUB */ |
235 | 232 | ||
@@ -250,8 +247,9 @@ int main(int argc, char ** argv) | |||
250 | } | 247 | } |
251 | 248 | ||
252 | /* Write the CRC */ | 249 | /* Write the CRC */ |
253 | fprintf(stderr, "CRC %lx\n", crc); | 250 | fprintf(stderr, "CRC %x\n", crc); |
254 | if (fwrite(&crc, 1, 4, stdout) != 4) | 251 | put_unaligned_le32(crc, buf); |
252 | if (fwrite(buf, 1, 4, stdout) != 4) | ||
255 | die("Writing CRC failed"); | 253 | die("Writing CRC failed"); |
256 | 254 | ||
257 | close(fd); | 255 | close(fd); |