X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=bfd%2Fcoffcode.h;h=dc101b511a7268d26c0163c8a23df3bdfb034944;hb=95830fd17d6ae253d8f6c2595188cadd59058799;hp=ff69704558fe2749376477f3fcd440b1ee9ec759;hpb=72e4db75e816964c7533b8522a59ec05b7439691;p=deliverable%2Fbinutils-gdb.git diff --git a/bfd/coffcode.h b/bfd/coffcode.h index ff69704558..dc101b511a 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -1,6 +1,6 @@ /* Support for the generic parts of most COFF variants, for BFD. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Written by Cygnus Support. @@ -372,7 +372,9 @@ CODE_FRAGMENT #define STRING_SIZE_SIZE 4 #define DOT_DEBUG ".debug" +#define DOT_ZDEBUG ".zdebug" #define GNU_LINKONCE_WI ".gnu.linkonce.wi." +#define GNU_LINKONCE_WT ".gnu.linkonce.wt." #define DOT_RELOC ".reloc" #if defined (COFF_LONG_SECTION_NAMES) @@ -544,7 +546,8 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) styp_flags = STYP_LIT; #endif /* _LIT */ } - else if (CONST_STRNEQ (sec_name, DOT_DEBUG)) + else if (CONST_STRNEQ (sec_name, DOT_DEBUG) + || CONST_STRNEQ (sec_name, DOT_ZDEBUG)) { /* Handle the XCOFF debug section and DWARF2 debug sections. */ if (!sec_name[6]) @@ -557,7 +560,8 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) styp_flags = STYP_DEBUG_INFO; } #ifdef COFF_LONG_SECTION_NAMES - else if (CONST_STRNEQ (sec_name, GNU_LINKONCE_WI)) + else if (CONST_STRNEQ (sec_name, GNU_LINKONCE_WI) + || CONST_STRNEQ (sec_name, GNU_LINKONCE_WT)) { styp_flags = STYP_DEBUG_INFO; } @@ -579,6 +583,17 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) { styp_flags = STYP_TYPCHK; } + else if (sec_flags & SEC_DEBUGGING) + { + int i; + + for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) + if (!strcmp (sec_name, xcoff_dwsect_names[i].name)) + { + styp_flags = STYP_DWARF | xcoff_dwsect_names[i].flag; + break; + } + } #endif /* Try and figure out what it should be */ else if (sec_flags & SEC_CODE) @@ -639,8 +654,10 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) bfd_boolean is_dbg = FALSE; if (CONST_STRNEQ (sec_name, DOT_DEBUG) + || CONST_STRNEQ (sec_name, DOT_ZDEBUG) #ifdef COFF_LONG_SECTION_NAMES || CONST_STRNEQ (sec_name, GNU_LINKONCE_WI) + || CONST_STRNEQ (sec_name, GNU_LINKONCE_WT) #endif || CONST_STRNEQ (sec_name, ".stab")) is_dbg = TRUE; @@ -655,7 +672,12 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) /* FIXME: There is no gas syntax to specify the debug section flag. */ if (is_dbg) - sec_flags = SEC_DEBUGGING | SEC_READONLY; + { + sec_flags &= (SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD + | SEC_LINK_DUPLICATES_SAME_CONTENTS + | SEC_LINK_DUPLICATES_SAME_SIZE); + sec_flags |= SEC_DEBUGGING | SEC_READONLY; + } /* skip LOAD */ /* READONLY later */ @@ -681,7 +703,11 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags) /* skip SORT */ if (sec_flags & SEC_LINK_ONCE) styp_flags |= IMAGE_SCN_LNK_COMDAT; - /* skip LINK_DUPLICATES */ + if ((sec_flags + & (SEC_LINK_DUPLICATES_DISCARD | SEC_LINK_DUPLICATES_SAME_CONTENTS + | SEC_LINK_DUPLICATES_SAME_SIZE)) != 0) + styp_flags |= IMAGE_SCN_LNK_COMDAT; + /* skip LINKER_CREATED */ if ((sec_flags & SEC_COFF_NOREAD) == 0) @@ -770,6 +796,10 @@ styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED, } else if (styp_flags & STYP_PAD) sec_flags = 0; +#ifdef RS6000COFF_C + else if (styp_flags & STYP_DWARF) + sec_flags |= SEC_DEBUGGING; +#endif else if (strcmp (name, _TEXT) == 0) { if (sec_flags & SEC_NEVER_LOAD) @@ -794,11 +824,13 @@ styp_to_sec_flags (bfd *abfd ATTRIBUTE_UNUSED, sec_flags |= SEC_ALLOC; } else if (CONST_STRNEQ (name, DOT_DEBUG) + || CONST_STRNEQ (name, DOT_ZDEBUG) #ifdef _COMMENT || strcmp (name, _COMMENT) == 0 #endif #ifdef COFF_LONG_SECTION_NAMES || CONST_STRNEQ (name, GNU_LINKONCE_WI) + || CONST_STRNEQ (name, GNU_LINKONCE_WT) #endif || CONST_STRNEQ (name, ".stab")) { @@ -956,7 +988,7 @@ handle_COMDAT (bfd * abfd, if (! ((isym.n_sclass == C_STAT || isym.n_sclass == C_EXT) - && isym.n_type == T_NULL + && BTYPE (isym.n_type) == T_NULL && isym.n_value == 0)) abort (); @@ -1130,8 +1162,10 @@ styp_to_sec_flags (bfd *abfd, bfd_boolean is_dbg = FALSE; if (CONST_STRNEQ (name, DOT_DEBUG) + || CONST_STRNEQ (name, DOT_ZDEBUG) #ifdef COFF_LONG_SECTION_NAMES || CONST_STRNEQ (name, GNU_LINKONCE_WI) + || CONST_STRNEQ (name, GNU_LINKONCE_WT) #endif || CONST_STRNEQ (name, ".stab")) is_dbg = TRUE; @@ -1709,6 +1743,7 @@ coff_new_section_hook (bfd * abfd, asection * section) { combined_entry_type *native; bfd_size_type amt; + unsigned char sclass = C_STAT; section->alignment_power = COFF_DEFAULT_SECTION_ALIGNMENT_POWER; @@ -1716,9 +1751,22 @@ coff_new_section_hook (bfd * abfd, asection * section) if (bfd_xcoff_text_align_power (abfd) != 0 && strcmp (bfd_get_section_name (abfd, section), ".text") == 0) section->alignment_power = bfd_xcoff_text_align_power (abfd); - if (bfd_xcoff_data_align_power (abfd) != 0 + else if (bfd_xcoff_data_align_power (abfd) != 0 && strcmp (bfd_get_section_name (abfd, section), ".data") == 0) section->alignment_power = bfd_xcoff_data_align_power (abfd); + else + { + int i; + + for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++) + if (strcmp (bfd_get_section_name (abfd, section), + xcoff_dwsect_names[i].name) == 0) + { + section->alignment_power = 0; + sclass = C_DWARF; + break; + } + } #endif /* Set up the section symbol. */ @@ -1742,7 +1790,7 @@ coff_new_section_hook (bfd * abfd, asection * section) for n_numaux is already correct. */ native->u.syment.n_type = T_NULL; - native->u.syment.n_sclass = C_STAT; + native->u.syment.n_sclass = sclass; coffsymbol (section->symbol)->native = native; @@ -1855,12 +1903,14 @@ coff_set_alignment_hook (bfd * abfd ATTRIBUTE_UNUSED, file_ptr oldpos = bfd_tell (abfd); bfd_size_type relsz = bfd_coff_relsz (abfd); - bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0); + if (bfd_seek (abfd, (file_ptr) hdr->s_relptr, 0) != 0) + return; if (bfd_bread (& dst, relsz, abfd) != relsz) return; coff_swap_reloc_in (abfd, &dst, &n); - bfd_seek (abfd, oldpos, 0); + if (bfd_seek (abfd, oldpos, 0) != 0) + return; section->reloc_count = hdr->s_nreloc = n.r_vaddr - 1; section->rel_filepos += relsz; } @@ -3290,6 +3340,8 @@ coff_compute_section_file_positions (bfd * abfd) if (!(current->flags & SEC_HAS_CONTENTS)) continue; + current->rawsize = current->size; + #ifdef COFF_IMAGE_WITH_PE /* Make sure we skip empty sections in a PE image. */ if (current->size == 0) @@ -3356,7 +3408,7 @@ coff_compute_section_file_positions (bfd * abfd) #ifdef COFF_IMAGE_WITH_PE /* Set the padded size. */ - current->size = (current->size + page_size -1) & -page_size; + current->size = (current->size + page_size - 1) & -page_size; #endif sofar += current->size; @@ -4742,6 +4794,10 @@ coff_slurp_symbol_table (bfd * abfd) case C_THUMBSTAT: /* Thumb static. */ case C_THUMBLABEL: /* Thumb label. */ case C_THUMBSTATFUNC:/* Thumb static function. */ +#endif +#ifdef RS6000COFF_C + case C_DWARF: /* A label in a dwarf section. */ + case C_INFO: /* A label in a comment section. */ #endif case C_LABEL: /* Label. */ if (src->u.syment.n_scnum == N_DEBUG) @@ -4847,7 +4903,7 @@ coff_slurp_symbol_table (bfd * abfd) to the symbol instead of the index. FIXME: This should use a union. */ src->u.syment.n_value = - (long) (native_symbols + src->u.syment.n_value); + (long) (intptr_t) (native_symbols + src->u.syment.n_value); dst->symbol.value = src->u.syment.n_value; src->fix_value = 1; break; @@ -4889,6 +4945,11 @@ coff_slurp_symbol_table (bfd * abfd) && src->u.syment.n_value == 0 && src->u.syment.n_scnum == 0) break; +#ifdef RS6000COFF_C + /* XCOFF specific: deleted entry. */ + if (src->u.syment.n_value == C_NULL_VALUE) + break; +#endif /* Fall through. */ case C_EXTDEF: /* External definition. */ case C_ULABEL: /* Undefined label. */ @@ -5602,6 +5663,10 @@ static bfd_coff_backend_data ticoff1_swap_table = #define coff_bfd_gc_sections bfd_generic_gc_sections #endif +#ifndef coff_bfd_lookup_section_flags +#define coff_bfd_lookup_section_flags bfd_generic_lookup_section_flags +#endif + #ifndef coff_bfd_merge_sections #define coff_bfd_merge_sections bfd_generic_merge_sections #endif @@ -5616,7 +5681,7 @@ static bfd_coff_backend_data ticoff1_swap_table = #ifndef coff_section_already_linked #define coff_section_already_linked \ - _bfd_generic_section_already_linked + _bfd_coff_section_already_linked #endif #ifndef coff_bfd_define_common_symbol @@ -5638,6 +5703,7 @@ const bfd_target VAR = \ UNDER, /* Leading symbol underscore. */ \ '/', /* AR_pad_char. */ \ 15, /* AR_max_namelen. */ \ + 0, /* match priority. */ \ \ /* Data conversion functions. */ \ bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ @@ -5688,6 +5754,7 @@ const bfd_target VAR = \ UNDER, /* Leading symbol underscore. */ \ '/', /* AR_pad_char. */ \ 15, /* AR_max_namelen. */ \ + 0, /* match priority. */ \ \ /* Data conversion functions. */ \ bfd_getb64, bfd_getb_signed_64, bfd_putb64, \ @@ -5738,6 +5805,7 @@ const bfd_target VAR = \ UNDER, /* Leading symbol underscore. */ \ '/', /* AR_pad_char. */ \ 15, /* AR_max_namelen. */ \ + 0, /* match priority. */ \ \ /* Data conversion functions. */ \ bfd_getl64, bfd_getl_signed_64, bfd_putl64, \