From 61ea8541b7ceb1782636bcaf5fab175846569bf9 Mon Sep 17 00:00:00 2001 From: Simon Horman Date: Tue, 2 Feb 2010 14:42:02 +1100 Subject: ia64: move_loaded_segments: handle no matching region Apparently this never happens, but the current code seems excessively loose. 1) die if it does happen 2) initialise offset to make gcc happy. # ia64-unknown-linux-gnu-gcc --version ia64-unknown-linux-gnu-gcc (GCC) 3.4.5 Copyright (C) 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # make kexec/arch/ia64/kexec-elf-ia64.c: In function `move_loaded_segments': kexec/arch/ia64/kexec-elf-ia64.c:102: warning: 'offset' might be used uninitialized in this function Signed-off-by: Simon Horman --- kexec/arch/ia64/kexec-elf-ia64.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kexec/arch/ia64/kexec-elf-ia64.c b/kexec/arch/ia64/kexec-elf-ia64.c index f5273b7..3bb5a4d 100644 --- a/kexec/arch/ia64/kexec-elf-ia64.c +++ b/kexec/arch/ia64/kexec-elf-ia64.c @@ -99,15 +99,19 @@ void elf_ia64_usage(void) void move_loaded_segments(struct mem_ehdr *ehdr, unsigned long addr) { unsigned i; - long offset; + long offset = 0; + int found = 0; struct mem_phdr *phdr; for(i = 0; i < ehdr->e_phnum; i++) { phdr = &ehdr->e_phdr[i]; if (phdr->p_type == PT_LOAD) { offset = addr - phdr->p_paddr; + found++; break; } } + if (!found) + die("move_loaded_segments: no PT_LOAD region 0x%016x\n", addr); ehdr->e_entry += offset; for(i = 0; i < ehdr->e_phnum; i++) { phdr = &ehdr->e_phdr[i]; -- cgit