public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: Achim Gratz <Stromeko@nexgo.de>, binutils@sourceware.org
Subject: Re: [Bug] DWARF-5 section names in PE/PEP and weak symbols
Date: Wed, 15 Dec 2021 13:12:32 +0000	[thread overview]
Message-ID: <b51431d6-eaf3-552c-3ceb-e8ee3fe1540f@redhat.com> (raw)
In-Reply-To: <878rwvrlz9.fsf@Rainer.invalid>

Hi Achim,

   Please could you file a bug report for this problem here:

https://sourceware.org/bugzilla/enter_bug.cgi?product=binutils


> changed the behaviour of weak symbols in Cygwin.  The following test
> from gnulib that should fail.  In other words fputs should have a symbol
> value of 0x0 and the resulting executable should not be able to run
> since the Windows loader does not resolve weak symbols):
> 
> --8<--weak.c-------cut here---------------start------------->8---
> #include <stdio.h>
> #pragma weak fputs
> int main ()
> {
>    return (fputs == NULL);
> }
> --8<---------------cut here---------------end--------------->8---
> 
> $ gcc -o weak weak.c # w/ binutils 2.36.1
> $ ./weak ; echo $?
> ./weak: ./weak: cannot execute binary file
> 126
> 
> Instead, starting with the above commit, the test succeeds since fputs
> has the (expected) value from cygwin1.dll.  

So you are saying that because the linker script now includes specific
references to DWARF-5 debug sections, the fputs symbol is being pulled
in to the link from the cygwin1.dll and hence it is no longer undefined ?
That seems to be most strange.


> I've narrowed it down to just one of the new DWARF5 sections and
> removing them from the linker scripts restores the correct behaviour of
> weak symbols in Cygwin (I have no idea if that triggers problems
> elsewhere):

> +/* ===
>     .debug_loclists ${RELOCATING+BLOCK(__section_alignment__)} ${RELOCATING+(NOLOAD)} :
>     {
>       *(.debug_loclists)
>     }
> +=== */

Hmm, I suppose that the location lists will refer to real locations in
the code space, and so including the debug information could also pull
in the code itself.  But really you would only want to have the debug
information for code that is already part of the final link.  So maybe
the underlying problem is that the debug information has not been pruned
to match discarded code.

Quick question - if instead of deleting the references to the .debug_loclists
section you move them into the /DISCARD/ section earlier in the pe.se file,
does this also solve the problem.  (The point being that if the script
explitcitly discards this information we also have room to add a comment
explaining why.  Plus it will prevent future changes to the pe.sc file
from adding the section back in).  (Also the change would be needed in
the pep.sc file as well, obviously.  Plus the .zdebug_loclists section
would need similar treatment).

Cheers
   Nick


  reply	other threads:[~2021-12-15 13:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08 18:27 Achim Gratz
2021-12-15 13:12 ` Nick Clifton [this message]
2021-12-20 19:45   ` Achim Gratz
2022-01-23  8:10     ` Achim Gratz
2022-01-29  7:57   ` Achim Gratz
2022-02-13 20:17   ` Achim Gratz
2022-02-14 11:02     ` ASSI
2022-02-15 17:58       ` Achim Gratz
2022-02-15 19:08         ` Achim Gratz
2022-02-15 20:19         ` Achim Gratz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b51431d6-eaf3-552c-3ceb-e8ee3fe1540f@redhat.com \
    --to=nickc@redhat.com \
    --cc=Stromeko@nexgo.de \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).