comparison src/unexelfsgi.c @ 288:e11d67e05968 r21-0b42

Import from CVS: tag r21-0b42
author cvs
date Mon, 13 Aug 2007 10:35:54 +0200
parents 90d73dddcdc4
children 8e84bee8ddd0
comparison
equal deleted inserted replaced
287:13a0bd77a29d 288:e11d67e05968
867 NEW_SECTION_H (nn).sh_offset += new_offsets_shift; 867 NEW_SECTION_H (nn).sh_offset += new_offsets_shift;
868 NEW_SECTION_H (nn).sh_addr = new_bss_addr; 868 NEW_SECTION_H (nn).sh_addr = new_bss_addr;
869 /* Let the new bss section address alignment be the same as the 869 /* Let the new bss section address alignment be the same as the
870 section address alignment followed the old bss section, so 870 section address alignment followed the old bss section, so
871 this section will be placed in exactly the same place. */ 871 this section will be placed in exactly the same place. */
872 NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (nn).sh_addralign; 872 NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (n).sh_addralign;
873 NEW_SECTION_H (nn).sh_size = 0; 873 NEW_SECTION_H (nn).sh_size = 0;
874 } 874 }
875 else /* n > old_bss_index */ 875 else /* n > old_bss_index */
876 memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n), 876 memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n),
877 old_file_h->e_shentsize); 877 old_file_h->e_shentsize);
892 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB 892 if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB
893 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM) 893 && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM)
894 PATCH_INDEX (NEW_SECTION_H (nn).sh_info); 894 PATCH_INDEX (NEW_SECTION_H (nn).sh_info);
895 895
896 /* Fix the type and alignment for the .sbss section */ 896 /* Fix the type and alignment for the .sbss section */
897 if ((old_sbss_index != -1) && !strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".sbss")) 897 if ((old_sbss_index != -1) && !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".sbss"))
898 { 898 {
899 NEW_SECTION_H (nn).sh_type = SHT_PROGBITS; 899 NEW_SECTION_H (nn).sh_type = SHT_PROGBITS;
900 NEW_SECTION_H (nn).sh_offset = round_up (NEW_SECTION_H (nn).sh_offset, 900 NEW_SECTION_H (nn).sh_offset = round_up (NEW_SECTION_H (nn).sh_offset,
901 NEW_SECTION_H (nn).sh_addralign); 901 NEW_SECTION_H (nn).sh_addralign);
902 } 902 }
907 continue; 907 continue;
908 908
909 /* Write out the sections. .data, .data1 and .sbss (and data2, called 909 /* Write out the sections. .data, .data1 and .sbss (and data2, called
910 ".data" in the strings table) get copied from the current process 910 ".data" in the strings table) get copied from the current process
911 instead of the old file. */ 911 instead of the old file. */
912 if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data") 912 if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
913 || !strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data1") 913 || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data1")
914 || !strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".got") 914 || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".got")
915 || !strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".sbss")) 915 || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".sbss"))
916 src = (caddr_t) OLD_SECTION_H (n).sh_addr; 916 src = (caddr_t) OLD_SECTION_H (n).sh_addr;
917 else 917 else
918 src = old_base + OLD_SECTION_H (n).sh_offset; 918 src = old_base + OLD_SECTION_H (n).sh_offset;
919 919
920 memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src, 920 memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src,
991 PATCH_INDEX (sym->st_shndx); 991 PATCH_INDEX (sym->st_shndx);
992 } 992 }
993 } 993 }
994 } 994 }
995 995
996 /* Kludge around the stupid 5.3 run time loader which always
997 zero-fills the .sbss section no matter what. */
998
999 if (old_sbss_index != -1)
1000 strcpy (new_base
1001 + NEW_SECTION_H (new_file_h->e_shstrndx).sh_offset
1002 + NEW_SECTION_H (old_sbss_index).sh_name,
1003 ".zbzz");
1004
1005 /* Close the files and make the new file executable. */ 996 /* Close the files and make the new file executable. */
1006 997
1007 if (close (old_file)) 998 if (close (old_file))
1008 fatal ("Can't close (%s): errno %d\n", old_name, errno); 999 fatal ("Can't close (%s): errno %d\n", old_name, errno);
1009 1000