aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@MIT.EDU>2009-05-03 16:02:55 -0400
committerSam Ravnborg <sam@ravnborg.org>2009-05-04 07:05:03 -0400
commit7d875a02864a35532543897195dfea2235815df8 (patch)
tree77949e1c62598f76b0921e593c81837d936869ed /scripts
parentb4348f32dae3cb6eb4bc21c7ed8f76c0b11e9d6a (diff)
kbuild, modpost: fix unexpected non-allocatable section when cross compiling
The missing TO_NATIVE(sechdrs[i].sh_flags) was causing many unexpected non-allocatable section warnings when cross-compiling for an architecture with a different endianness. Fix endianness of all the fields in the ELF header and section headers, not just some of them so we are not hit by this anohter time. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Reported-by: Sean MacLennan <smaclennan@pikatech.com> Tested-by: Sean MacLennan <smaclennan@pikatech.com> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mod/modpost.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 936b6f8e46ff..a5c17db14ee5 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -384,11 +384,19 @@ static int parse_elf(struct elf_info *info, const char *filename)
384 return 0; 384 return 0;
385 } 385 }
386 /* Fix endianness in ELF header */ 386 /* Fix endianness in ELF header */
387 hdr->e_shoff = TO_NATIVE(hdr->e_shoff); 387 hdr->e_type = TO_NATIVE(hdr->e_type);
388 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); 388 hdr->e_machine = TO_NATIVE(hdr->e_machine);
389 hdr->e_shnum = TO_NATIVE(hdr->e_shnum); 389 hdr->e_version = TO_NATIVE(hdr->e_version);
390 hdr->e_machine = TO_NATIVE(hdr->e_machine); 390 hdr->e_entry = TO_NATIVE(hdr->e_entry);
391 hdr->e_type = TO_NATIVE(hdr->e_type); 391 hdr->e_phoff = TO_NATIVE(hdr->e_phoff);
392 hdr->e_shoff = TO_NATIVE(hdr->e_shoff);
393 hdr->e_flags = TO_NATIVE(hdr->e_flags);
394 hdr->e_ehsize = TO_NATIVE(hdr->e_ehsize);
395 hdr->e_phentsize = TO_NATIVE(hdr->e_phentsize);
396 hdr->e_phnum = TO_NATIVE(hdr->e_phnum);
397 hdr->e_shentsize = TO_NATIVE(hdr->e_shentsize);
398 hdr->e_shnum = TO_NATIVE(hdr->e_shnum);
399 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx);
392 sechdrs = (void *)hdr + hdr->e_shoff; 400 sechdrs = (void *)hdr + hdr->e_shoff;
393 info->sechdrs = sechdrs; 401 info->sechdrs = sechdrs;
394 402
@@ -402,13 +410,16 @@ static int parse_elf(struct elf_info *info, const char *filename)
402 410
403 /* Fix endianness in section headers */ 411 /* Fix endianness in section headers */
404 for (i = 0; i < hdr->e_shnum; i++) { 412 for (i = 0; i < hdr->e_shnum; i++) {
405 sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); 413 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name);
406 sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset); 414 sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type);
407 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); 415 sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags);
408 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); 416 sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr);
409 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 417 sechdrs[i].sh_offset = TO_NATIVE(sechdrs[i].sh_offset);
410 sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); 418 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size);
411 sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr); 419 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link);
420 sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info);
421 sechdrs[i].sh_addralign = TO_NATIVE(sechdrs[i].sh_addralign);
422 sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize);
412 } 423 }
413 /* Find symbol table. */ 424 /* Find symbol table. */
414 for (i = 1; i < hdr->e_shnum; i++) { 425 for (i = 1; i < hdr->e_shnum; i++) {