* coffcode.h (coff_slurp_symbol_table): If COFF_WITH_PE or
authorIan Lance Taylor <ian@airs.com>
Wed, 21 May 1997 21:42:38 +0000 (21:42 +0000)
committerIan Lance Taylor <ian@airs.com>
Wed, 21 May 1997 21:42:38 +0000 (21:42 +0000)
COFF_IMAGE_WITH_PE, don't subtract the section VMA from the symbol
value.
* coffgen.c (fixup_symbol_value): Add abfd parameter.  Change all
callers.  If PE file, don't add section VMA.
(coff_write_alien_symbol): If PE file, don't add section VMA.
* cofflink.c (_bfd_coff_link_input_bfd): Likewise.
(_bfd_coff_write_global_sym): Likewise.
(_bfd_coff_generic_relocate_section): Likewise.

bfd/ChangeLog
bfd/coffcode.h
bfd/cofflink.c

index ba16b40122cd952f16c88c71d7c8ab44d7ed5f5d..e708a1968b7902ce345d0a4a5718d9cd1e638c23 100644 (file)
@@ -1,5 +1,15 @@
 Wed May 21 17:15:50 1997  Ian Lance Taylor  <ian@cygnus.com>
 
+       * coffcode.h (coff_slurp_symbol_table): If COFF_WITH_PE or
+       COFF_IMAGE_WITH_PE, don't subtract the section VMA from the symbol
+       value.
+       * coffgen.c (fixup_symbol_value): Add abfd parameter.  Change all
+       callers.  If PE file, don't add section VMA.
+       (coff_write_alien_symbol): If PE file, don't add section VMA.
+       * cofflink.c (_bfd_coff_link_input_bfd): Likewise.
+       (_bfd_coff_write_global_sym): Likewise.
+       (_bfd_coff_generic_relocate_section): Likewise.
+
        * peicode.h: Add & 0xffffffff when using ImageBase in case bfd_vma
        is 64 bits.
 
index 941be95cff17a51878d427a62bbda944b095bcf1..633d31f959a49fbf925e08c8e500e9cf5292c1cf 100644 (file)
@@ -3408,8 +3408,15 @@ coff_slurp_symbol_table (abfd)
                     section */
 
                  dst->symbol.flags = BSF_EXPORT | BSF_GLOBAL;
+
+#if defined (COFF_WITH_PE) || defined (COFF_IMAGE_WITH_PE)
+                 /* PE sets the symbol to a value relative to the
+                     start of the section.  */
+                 dst->symbol.value = src->u.syment.n_value;
+#else
                  dst->symbol.value = (src->u.syment.n_value
                                       - dst->symbol.section->vma);
+#endif
 
                  if (ISFCN ((src->u.syment.n_type)))
                    {
@@ -3448,8 +3455,16 @@ coff_slurp_symbol_table (abfd)
              /* Base the value as an index from the base of the
                 section, if there is one.  */
              if (dst->symbol.section)
-               dst->symbol.value = (src->u.syment.n_value
-                                    - dst->symbol.section->vma);
+               {
+#if defined (COFF_WITH_PE) || defined (COFF_IMAGE_WITH_PE)
+                 /* PE sets the symbol to a value relative to the
+                     start of the section.  */
+                 dst->symbol.value = src->u.syment.n_value;
+#else
+                 dst->symbol.value = (src->u.syment.n_value
+                                      - dst->symbol.section->vma);
+#endif
+               }
              else
                dst->symbol.value = src->u.syment.n_value;
              break;
@@ -3545,10 +3560,16 @@ coff_slurp_symbol_table (abfd)
            case C_FCN:         /* ".bf" or ".ef"                */
            case C_EFCN:        /* physical end of function      */
              dst->symbol.flags = BSF_LOCAL;
+#if defined (COFF_WITH_PE) || defined (COFF_IMAGE_WITH_PE)
+             /* PE sets the symbol to a value relative to the start
+                of the section.  */
+             dst->symbol.value = src->u.syment.n_value;
+#else
              /* Base the value as an index from the base of the
                 section.  */
              dst->symbol.value = (src->u.syment.n_value
                                   - dst->symbol.section->vma);
+#endif
              break;
 
            case C_NULL:
index 7d1d5051835d403e76392fe1a497729bbc2e602f..c721bdf9de1fa75588eea9f1ee5e0baf0bedd939 100644 (file)
@@ -1550,9 +1550,10 @@ _bfd_coff_link_input_bfd (finfo, input_bfd)
          if (isym.n_scnum > 0)
            {
              isym.n_scnum = (*secpp)->output_section->target_index;
-             isym.n_value += ((*secpp)->output_section->vma
-                              + (*secpp)->output_offset
-                              - (*secpp)->vma);
+             isym.n_value += (*secpp)->output_offset;
+             if (! obj_pe (finfo->output_bfd))
+               isym.n_value += ((*secpp)->output_section->vma
+                                - (*secpp)->vma);
            }
 
          /* The value of a C_FILE symbol is the symbol index of the
@@ -2245,8 +2246,9 @@ _bfd_coff_write_global_sym (h, data)
        else
          isym.n_scnum = sec->target_index;
        isym.n_value = (h->root.u.def.value
-                       + sec->vma
                        + h->root.u.def.section->output_offset);
+       if (! obj_pe (finfo->output_bfd))
+         isym.n_value += sec->vma;
       }
       break;
 
@@ -2544,8 +2546,9 @@ _bfd_coff_generic_relocate_section (output_bfd, info, input_bfd,
              sec = sections[symndx];
               val = (sec->output_section->vma
                     + sec->output_offset
-                    + sym->n_value
-                    - sec->vma);
+                    + sym->n_value);
+             if (! obj_pe (output_bfd))
+               val -= sec->vma;
            }
        }
       else