This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: Discrepancy with .reloc section between PE and PE+ emulations when linking -r.


[ Nick C added, we need your advice please! :) ]

Kai Tietz wrote:
> 2009/2/13 Dave Korn <dave.korn.cygwin@googlemail.com>:
>> Dave Korn wrote:
>>  So, it starts to look like pe.em shouldn't be doing this for a relocatable
>> link, rather than that pep.em should, and like I need to adjust the
>> troublesome long section name tests mentioned in my other recent post to
>> remove the check for the presence of a .reloc section, yesnomaybe?
> 
> Yes, this I fixed for pep.em some time ago. I wasn't aware that PE has
> the same problem and didn't wanted to break something working. I had
> an user request for PE+ that relocatable linkt was broken for it, and
> I found that in this case no .reloc has to be emitted as spec says in
> 6.6
> 
> Cheers,
> Kai

  It looks like the older code in pe.em (r1.77 on) matched the structure that
is still in pep.em:

#if ! (defined (TARGET_IS_i386pe) || defined (TARGET_IS_armpe))
  if (link_info.shared)
#else
  if (!link_info.relocateable)
#endif
    pe_dll_build_sections (output_bfd, &link_info);

#ifndef TARGET_IS_i386pe
#ifndef TARGET_IS_armpe
  else
    pe_exe_build_sections (output_bfd, &link_info);
#endif
#endif

and then it got changed to the current shape in r1.119, which left it looking
like this:

#if defined (TARGET_IS_i386pe) \
    || defined (TARGET_IS_armpe) \
    || defined (TARGET_IS_arm_epoc_pe) \
    || defined (TARGET_IS_arm_wince_pe)
  if (!link_info.relocatable)
    pe_dll_build_sections (output_bfd, &link_info);
  else
    pe_exe_build_sections (output_bfd, &link_info);
#else
  if (link_info.shared)
    pe_dll_build_sections (output_bfd, &link_info);
#endif
#endif /* DLL_SUPPORT */

  That was the point at which i386pe targets began calling
pe_exe_build_sections for the first time.  The purpose of the patch was to add
ARM support, so the changed behaviour of i386 targets is most likely inadvertent.

  Nick, it looks like you were trying a hairy bit of refactoring which
involved negating the sense of some preprocessor conditionals and reordering
if...else clauses.  Could you cast your mind back to that patch for us, and
take a second look at this hunk and see if it really says what you meant for
it to say?

@@ -997,22 +1003,21 @@

   pe_find_data_imports ();

-#if ! (defined (TARGET_IS_i386pe) || defined (TARGET_IS_armpe))
-  if (link_info.shared)
-#else
+#if defined (TARGET_IS_i386pe) \
+    || defined (TARGET_IS_armpe) \
+    || defined (TARGET_IS_arm_epoc_pe) \
+    || defined (TARGET_IS_arm_wince_pe)
   if (!link_info.relocatable)
-#endif
     pe_dll_build_sections (output_bfd, &link_info);
-
-#ifndef TARGET_IS_i386pe
-#ifndef TARGET_IS_armpe
   else
     pe_exe_build_sections (output_bfd, &link_info);
+#else
+  if (link_info.shared)
+    pe_dll_build_sections (output_bfd, &link_info);
 #endif
-#endif
-#endif
+#endif /* DLL_SUPPORT */

    cheers,
      DaveK


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