GNU Binutils with patches for OS216
Revision | 4e22f78d855c28e90d785d10a5449263df88148f (tree) |
---|---|
Zeit | 2006-07-25 01:51:26 |
Autor | Nick Clifton <nickc@redh...> |
Commiter | Nick Clifton |
PR ld/2729
* peXXigen.c (_bfd_XXi_final_link_postscript): Check for the existance of
@@ -1,3 +1,10 @@ | ||
1 | +2006-07-24 Nick Clifton <nickc@redhat.com> | |
2 | + | |
3 | + PR ld/2729 | |
4 | + * peXXigen.c (_bfd_XXi_final_link_postscript): Check for the | |
5 | + existance of output sections before putting their entries into the | |
6 | + DataDictionary. | |
7 | + | |
1 | 8 | 2006-07-20 Thiemo Seufer <ths@mips.com> |
2 | 9 | |
3 | 10 | * elf32-mips.c (mips16_jump_reloc): Remove function. |
@@ -1950,6 +1950,7 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) | ||
1950 | 1950 | { |
1951 | 1951 | struct coff_link_hash_entry *h1; |
1952 | 1952 | struct bfd_link_info *info = pfinfo->info; |
1953 | + bfd_boolean result = TRUE; | |
1953 | 1954 | |
1954 | 1955 | /* There are a few fields that need to be filled in now while we |
1955 | 1956 | have symbol table access. |
@@ -1963,49 +1964,103 @@ _bfd_XXi_final_link_postscript (bfd * abfd, struct coff_final_link_info *pfinfo) | ||
1963 | 1964 | ".idata$2", FALSE, FALSE, TRUE); |
1964 | 1965 | if (h1 != NULL) |
1965 | 1966 | { |
1966 | - pe_data (abfd)->pe_opthdr.DataDirectory[1].VirtualAddress = | |
1967 | - (h1->root.u.def.value | |
1968 | - + h1->root.u.def.section->output_section->vma | |
1969 | - + h1->root.u.def.section->output_offset); | |
1967 | + /* PR ld/2729: We cannot rely upon all the output sections having been | |
1968 | + created properly, so check before referencing them. Issue a warning | |
1969 | + message for any sections tht could not be found. */ | |
1970 | + if (h1->root.u.def.section != NULL | |
1971 | + && h1->root.u.def.section->output_section != NULL) | |
1972 | + pe_data (abfd)->pe_opthdr.DataDirectory[1].VirtualAddress = | |
1973 | + (h1->root.u.def.value | |
1974 | + + h1->root.u.def.section->output_section->vma | |
1975 | + + h1->root.u.def.section->output_offset); | |
1976 | + else | |
1977 | + { | |
1978 | + _bfd_error_handler | |
1979 | + (_("%B: unable to fill in DataDictionary[1] because .idata$2 is missing"), | |
1980 | + abfd); | |
1981 | + result = FALSE; | |
1982 | + } | |
1983 | + | |
1970 | 1984 | h1 = coff_link_hash_lookup (coff_hash_table (info), |
1971 | 1985 | ".idata$4", FALSE, FALSE, TRUE); |
1972 | - pe_data (abfd)->pe_opthdr.DataDirectory[1].Size = | |
1973 | - ((h1->root.u.def.value | |
1974 | - + h1->root.u.def.section->output_section->vma | |
1975 | - + h1->root.u.def.section->output_offset) | |
1976 | - - pe_data (abfd)->pe_opthdr.DataDirectory[1].VirtualAddress); | |
1986 | + if (h1 != NULL | |
1987 | + && h1->root.u.def.section != NULL | |
1988 | + && h1->root.u.def.section->output_section != NULL) | |
1989 | + pe_data (abfd)->pe_opthdr.DataDirectory[1].Size = | |
1990 | + ((h1->root.u.def.value | |
1991 | + + h1->root.u.def.section->output_section->vma | |
1992 | + + h1->root.u.def.section->output_offset) | |
1993 | + - pe_data (abfd)->pe_opthdr.DataDirectory[1].VirtualAddress); | |
1994 | + else | |
1995 | + { | |
1996 | + _bfd_error_handler | |
1997 | + (_("%B: unable to fill in DataDictionary[1] because .idata$4 is missing"), | |
1998 | + abfd); | |
1999 | + result = FALSE; | |
2000 | + } | |
1977 | 2001 | |
1978 | 2002 | /* The import address table. This is the size/address of |
1979 | 2003 | .idata$5. */ |
1980 | 2004 | h1 = coff_link_hash_lookup (coff_hash_table (info), |
1981 | 2005 | ".idata$5", FALSE, FALSE, TRUE); |
1982 | - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress = | |
1983 | - (h1->root.u.def.value | |
1984 | - + h1->root.u.def.section->output_section->vma | |
1985 | - + h1->root.u.def.section->output_offset); | |
2006 | + if (h1 != NULL | |
2007 | + && h1->root.u.def.section != NULL | |
2008 | + && h1->root.u.def.section->output_section != NULL) | |
2009 | + pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress = | |
2010 | + (h1->root.u.def.value | |
2011 | + + h1->root.u.def.section->output_section->vma | |
2012 | + + h1->root.u.def.section->output_offset); | |
2013 | + else | |
2014 | + { | |
2015 | + _bfd_error_handler | |
2016 | + (_("%B: unable to fill in DataDictionary[12] because .idata$5 is missing"), | |
2017 | + abfd); | |
2018 | + result = FALSE; | |
2019 | + } | |
2020 | + | |
1986 | 2021 | h1 = coff_link_hash_lookup (coff_hash_table (info), |
1987 | 2022 | ".idata$6", FALSE, FALSE, TRUE); |
1988 | - pe_data (abfd)->pe_opthdr.DataDirectory[12].Size = | |
1989 | - ((h1->root.u.def.value | |
1990 | - + h1->root.u.def.section->output_section->vma | |
1991 | - + h1->root.u.def.section->output_offset) | |
1992 | - - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress); | |
2023 | + if (h1 != NULL | |
2024 | + && h1->root.u.def.section != NULL | |
2025 | + && h1->root.u.def.section->output_section != NULL) | |
2026 | + pe_data (abfd)->pe_opthdr.DataDirectory[12].Size = | |
2027 | + ((h1->root.u.def.value | |
2028 | + + h1->root.u.def.section->output_section->vma | |
2029 | + + h1->root.u.def.section->output_offset) | |
2030 | + - pe_data (abfd)->pe_opthdr.DataDirectory[12].VirtualAddress); | |
2031 | + else | |
2032 | + { | |
2033 | + _bfd_error_handler | |
2034 | + (_("%B: unable to fill in DataDictionary[12] because .idata$6 is missing"), | |
2035 | + abfd); | |
2036 | + result = FALSE; | |
2037 | + } | |
1993 | 2038 | } |
1994 | 2039 | |
1995 | 2040 | h1 = coff_link_hash_lookup (coff_hash_table (info), |
1996 | 2041 | "__tls_used", FALSE, FALSE, TRUE); |
1997 | 2042 | if (h1 != NULL) |
1998 | 2043 | { |
1999 | - pe_data (abfd)->pe_opthdr.DataDirectory[9].VirtualAddress = | |
2000 | - (h1->root.u.def.value | |
2001 | - + h1->root.u.def.section->output_section->vma | |
2002 | - + h1->root.u.def.section->output_offset | |
2003 | - - pe_data (abfd)->pe_opthdr.ImageBase); | |
2044 | + if (h1->root.u.def.section != NULL | |
2045 | + && h1->root.u.def.section->output_section != NULL) | |
2046 | + pe_data (abfd)->pe_opthdr.DataDirectory[9].VirtualAddress = | |
2047 | + (h1->root.u.def.value | |
2048 | + + h1->root.u.def.section->output_section->vma | |
2049 | + + h1->root.u.def.section->output_offset | |
2050 | + - pe_data (abfd)->pe_opthdr.ImageBase); | |
2051 | + else | |
2052 | + { | |
2053 | + _bfd_error_handler | |
2054 | + (_("%B: unable to fill in DataDictionary[9] because __tls_used is missing"), | |
2055 | + abfd); | |
2056 | + result = FALSE; | |
2057 | + } | |
2058 | + | |
2004 | 2059 | pe_data (abfd)->pe_opthdr.DataDirectory[9].Size = 0x18; |
2005 | 2060 | } |
2006 | 2061 | |
2007 | 2062 | /* If we couldn't find idata$2, we either have an excessively |
2008 | 2063 | trivial program or are in DEEP trouble; we have to assume trivial |
2009 | 2064 | program.... */ |
2010 | - return TRUE; | |
2065 | + return result; | |
2011 | 2066 | } |