This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [patch] more PE fixes


On Fri, Jun 23, 2000 at 12:25:20PM -0400, DJ Delorie wrote:
> 
> With this patch, I can build cygwin stuff.  I expect Donn to put this
> back when he gets the rest of the Interix patches ready, but for now
> I've reverted some of his patches to get PE working again.  OK to
> apply?
> 
> 2000-06-23  DJ Delorie  <dj@cygnus.com>
> 
> 	* config/tc-i386.c (md_estimate_size_before_relax): Revert
> 	more changes from Sept 1999
> 	(md_apply_fix3): ditto
> 
> Index: tc-i386.c
> ===================================================================
> RCS file: /cvs/src/src/gas/config/tc-i386.c,v
> retrieving revision 1.56
> diff -p -3 -r1.56 tc-i386.c
> *** tc-i386.c	2000/06/22 10:49:13	1.56
> --- tc-i386.c	2000/06/23 16:05:08
> *************** int
> *** 1023,1029 ****
>   tc_i386_fix_adjustable (fixP)
>        fixS * fixP;
>   {
> ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined (TE_PE)
>     /* Prevent all adjustments to global symbols, or else dynamic
>        linking will not work correctly.  */
>     if (S_IS_EXTERNAL (fixP->fx_addsy)
> --- 1023,1029 ----
>   tc_i386_fix_adjustable (fixP)
>        fixS * fixP;
>   {
> ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
>     /* Prevent all adjustments to global symbols, or else dynamic
>        linking will not work correctly.  */
>     if (S_IS_EXTERNAL (fixP->fx_addsy)
> *************** md_estimate_size_before_relax (fragP, se
> *** 3776,3782 ****
>        an externally visible symbol, because it may be overridden by a
>        shared library.  */
>     if (S_GET_SEGMENT (fragP->fr_symbol) != segment
> ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined (TE_PE)
>         || S_IS_EXTERNAL (fragP->fr_symbol)
>         || S_IS_WEAK (fragP->fr_symbol)
>   #endif
> --- 3776,3782 ----
>        an externally visible symbol, because it may be overridden by a
>        shared library.  */
>     if (S_GET_SEGMENT (fragP->fr_symbol) != segment
> ! #if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF)
>         || S_IS_EXTERNAL (fragP->fr_symbol)
>         || S_IS_WEAK (fragP->fr_symbol)
>   #endif
> *************** md_apply_fix3 (fixP, valp, seg)
> *** 4038,4071 ****
>   	 address offset for a PC relative symbol.  */
>         if (S_GET_SEGMENT (fixP->fx_addsy) != seg)
>   	value += md_pcrel_from (fixP);
> -       else if (S_IS_EXTERNAL (fixP->fx_addsy)
> - 	       || S_IS_WEAK (fixP->fx_addsy))
> - 	{
> - 	  /* We are generating an external relocation for this defined
> -              symbol.  We add the address, because
> -              bfd_install_relocation will subtract it.  VALUE already
> -              holds the symbol value, because fixup_segment added it
> -              in.  We subtract it out, and then we subtract it out
> -              again because bfd_install_relocation will add it in
> -              again.  */
> - 	  value += md_pcrel_from (fixP);
> - 	  value -= 2 * S_GET_VALUE (fixP->fx_addsy);
> - 	}
>   #endif
>       }
> - #ifdef TE_PE
> -   else if (fixP->fx_addsy != NULL
> - 	   && S_IS_DEFINED (fixP->fx_addsy)
> - 	   && (S_IS_EXTERNAL (fixP->fx_addsy)
> - 	       || S_IS_WEAK (fixP->fx_addsy)))
> -     {
> -       /* We are generating an external relocation for this defined
> -          symbol.  VALUE already holds the symbol value, and
> -          bfd_install_relocation will add it in again.  We don't want
> -          either addition.  */
> -       value -= 2 * S_GET_VALUE (fixP->fx_addsy);
> -     }
> - #endif
>   
>     /* Fix a few things - the dynamic linker expects certain values here,
>        and we must not dissappoint it. */

I believe the PE assembler is ok. The problem may be the PE linker. I
say that because the PE assembler seems to generate the same output as
the Microsoft assembler. I learned that while working on linking the PE
relocatable object files generated by the Microsoft assembler under
ia32/ELF. Please see my change:

2000-06-18  H.J. Lu  <hjl@gnu.org>

        * coff-i386.c (coff_i386_reloc): Don't return in case of 
        output_bfd == (bfd *) NULL if COFF_WITH_PE is defined.
        Compensate PE relocations when linking with non-PE object
        files to generate a non-PE executable.

You may need the similar changes in the native PE linker.


H.J.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]