From: Ian Lance Taylor Date: Sat, 11 Sep 1999 22:04:16 +0000 (+0000) Subject: 1999-09-11 Donn Terry X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8add8e30998b29281d95c32d34c96b908ef43496;p=binutils-gdb.git 1999-09-11 Donn Terry * cofflink.c (_bfd_coff_link_input_bfd): When writing out a symbol, switch on the class when determining whether to modify the value. For PE, don't modify the value of a C_FCN symbol not named .bf. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c9aa5e1516c..341fa7f8da2 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -7,6 +7,11 @@ 1999-09-11 Donn Terry + * cofflink.c (_bfd_coff_link_input_bfd): When writing out a + symbol, switch on the class when determining whether to modify the + value. For PE, don't modify the value of a C_FCN symbol not named + .bf. + * libbfd-in.h (_bfd_abort): Declare. (abort): Define. * bfd.c (_bfd_abort): New function. diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 9344a04e440..113158cf1ff 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -1689,31 +1689,76 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; } - if (isym.n_scnum > 0) + switch (isym.n_sclass) { - isym.n_scnum = (*secpp)->output_section->target_index; - isym.n_value += (*secpp)->output_offset; - if (! obj_pe (input_bfd)) - isym.n_value -= (*secpp)->vma; - if (! obj_pe (finfo->output_bfd)) - isym.n_value += (*secpp)->output_section->vma; - } + case C_AUTO: + case C_MOS: + case C_EOS: + case C_MOE: + case C_MOU: + case C_UNTAG: + case C_STRTAG: + case C_ENTAG: + case C_TPDEF: + case C_ARG: + case C_USTATIC: + case C_REG: + case C_REGPARM: + case C_FIELD: + /* The symbol value should not be modified. */ + break; + + case C_FCN: + if (obj_pe (input_bfd) + && strcmp (isym.n_name, ".bf") != 0 + && isym.n_scnum > 0) + { + /* For PE, .lf and .ef get their value left alone, + while .bf gets relocated. However, they all have + "real" section numbers, and need to be moved into + the new section. */ + isym.n_scnum = (*secpp)->output_section->target_index; + break; + } + /* Fall through. */ + default: + case C_LABEL: /* Not completely sure about these 2 */ + case C_EXTDEF: + case C_BLOCK: + case C_EFCN: + case C_NULL: + case C_EXT: + case C_STAT: + case C_SECTION: + case C_NT_WEAK: + /* Compute new symbol location. */ + if (isym.n_scnum > 0) + { + isym.n_scnum = (*secpp)->output_section->target_index; + isym.n_value += (*secpp)->output_offset; + if (! obj_pe (input_bfd)) + isym.n_value -= (*secpp)->vma; + if (! obj_pe (finfo->output_bfd)) + isym.n_value += (*secpp)->output_section->vma; + } + break; + + case C_FILE: + /* The value of a C_FILE symbol is the symbol index of + the next C_FILE symbol. The value of the last C_FILE + symbol is the symbol index to the first external + symbol (actually, coff_renumber_symbols does not get + this right--it just sets the value of the last C_FILE + symbol to zero--and nobody has ever complained about + it). We try to get this right, below, just before we + write the symbols out, but in the general case we may + have to write the symbol out twice. */ - /* The value of a C_FILE symbol is the symbol index of the - next C_FILE symbol. The value of the last C_FILE symbol - is the symbol index to the first external symbol - (actually, coff_renumber_symbols does not get this - right--it just sets the value of the last C_FILE symbol - to zero--and nobody has ever complained about it). We - try to get this right, below, just before we write the - symbols out, but in the general case we may have to write - the symbol out twice. */ - if (isym.n_sclass == C_FILE) - { if (finfo->last_file_index != -1 && finfo->last_file.n_value != (long) output_index) { - /* We must correct the value of the last C_FILE entry. */ + /* We must correct the value of the last C_FILE + entry. */ finfo->last_file.n_value = output_index; if ((bfd_size_type) finfo->last_file_index >= syment_base) { @@ -1745,6 +1790,7 @@ _bfd_coff_link_input_bfd (finfo, input_bfd) finfo->last_file_index = output_index; finfo->last_file = isym; + break; } /* If doing task linking, convert normal global function symbols to