[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2022-08-03 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

Alan Modra  changed:

   What|Removed |Added

   Severity|critical|normal
 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #13 from Alan Modra  ---
Looks to be fixed.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-08 Thread yselkowitz at cygwin dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

Cygwin/X maintainer  changed:

   What|Removed |Added

 CC||yselkowitz at cygwin dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-09 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

Nick Clifton  changed:

   What|Removed |Added

 CC||nickc at redhat dot com

--- Comment #1 from Nick Clifton  ---
Created attachment 7543
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7543&action=edit
Partial patch

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-09 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

Nick Clifton  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED

--- Comment #2 from Nick Clifton  ---
Hi Corinna,

  DJ has found the cause of the problem: the PE and PE32+ file formats store
the value of symbols in a 32-bit field.  For section relative symbols this
amount is usually enough, as section addresses can be 64-bit.  But for absolute
symbols any value needing more than 32-bits is silently truncated by the
linker.

  I have uploaded a patch which is a partial fix for the problem.  It detects
out-of-range absolute values and tries to convert them into section relative
values.  This works for most cases, but it fails for the __image_base__ and
__ImageBase__ symbols, and possibly some others that I have not yet
encountered.  The problem is that these symbols have a value which is less than
the lowest addressed section, but higher than 1^32.  (Note the value of
ImageBase in the PE header is not affected by this problem.  It is only the
*symbols* __image_base__ and __ImageBase__ that are affected).

  One thing that patch does not do at the moment is issue an error message when
it knows that the truncation is taking place and it has not found a way around
it.  I omitted the warning because I know that it will be triggered for every
x86_64 cygwin binary that gets built, and most, if not all of them, do not care
about the value of __image_base__.

  Any suggestions as to how to handle __image_base__ will be greatfully
received.

Cheers
  Nick

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-09 Thread corinna at vinschen dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #3 from Corinna Vinschen  ---
Hi Nick,

thanks for the patch.

(In reply to Nick Clifton from comment #2)
>   I have uploaded a patch which is a partial fix for the problem.  It
> detects out-of-range absolute values and tries to convert them into section
> relative values.  This works for most cases, but it fails for the
> __image_base__ and __ImageBase__ symbols, and possibly some others that I
> have not yet encountered.  The problem is that these symbols have a value
> which is less than the lowest addressed section, but higher than 1^32. 
> (Note the value of ImageBase in the PE header is not affected by this
> problem.  It is only the *symbols* __image_base__ and __ImageBase__ that are
> affected).

Well, I'm wondering if ld couldn't utilize the fact that executables
are never bigger than 2 Gigs.  I'm not entirely sure, but afaik the
relocation information is signed.  Couldn't __image_base__ be defined
with a negative offset relative to the first section?

>   One thing that patch does not do at the moment is issue an error message
> when it knows that the truncation is taking place and it has not found a way
> around it.  I omitted the warning because I know that it will be triggered
> for every x86_64 cygwin binary that gets built, and most, if not all of
> them, do not care about the value of __image_base__.

That sonds right to me, at least as long as there's no solution for the
__image_base__ problem.


Thanks,
Corinna

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-11 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #4 from Nick Clifton  ---
Hi Corinna,

> Well, I'm wondering if ld couldn't utilize the fact that executables
> are never bigger than 2 Gigs.  I'm not entirely sure, but afaik the
> relocation information is signed.  Couldn't __image_base__ be defined
> with a negative offset relative to the first section?

Well, at the moment, __image_base__ is not a relocated value.  It is an
absolute symbol.  I suppose that it might be possible to use a base relocation
to adjust the value at run-time although that seems like a horrible hack too.

I did try another version of my original patch which created a new section at
ImageBase.  That way all absolute values could be converted to section-relative
values based upon this section.  Unfortunately that does not work because
section addresses are stored in the PE header as offsets from ImageBase, but an
offset of 0 is special.  It means that the section address is exacly 0, not
ImageBase+0.  You cannot put this new section before ImageBase as the section
addresses are all stored as positive offsets from ImageBase.  Plus if you put
the new section above ImageBase then you have no way of converting symbols
whose value is exacly ImageBase.  (eg __image_base__).

*sigh*

Cheers
  Nick

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-11 Thread corinna at vinschen dot de
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

Corinna Vinschen  changed:

   What|Removed |Added

 CC||ktietz at redhat dot com

--- Comment #5 from Corinna Vinschen  ---
(In reply to Nick Clifton from comment #4)
> Hi Corinna,
> 
> > Well, I'm wondering if ld couldn't utilize the fact that executables
> > are never bigger than 2 Gigs.  I'm not entirely sure, but afaik the
> > relocation information is signed.  Couldn't __image_base__ be defined
> > with a negative offset relative to the first section?
> 
> Well, at the moment, __image_base__ is not a relocated value.  It is an
> absolute symbol.  I suppose that it might be possible to use a base
> relocation to adjust the value at run-time although that seems like a
> horrible hack too.
> 
> I did try another version of my original patch which created a new section
> at ImageBase.  That way all absolute values could be converted to
> section-relative values based upon this section.  Unfortunately that does
> not work because section addresses are stored in the PE header as offsets
> from ImageBase, but an offset of 0 is special.  It means that the section
> address is exacly 0, not ImageBase+0.  You cannot put this new section
> before ImageBase as the section addresses are all stored as positive offsets
> from ImageBase.  Plus if you put the new section above ImageBase then you
> have no way of converting symbols whose value is exacly ImageBase.  (eg
> __image_base__).
> 
> *sigh*

Yeah, that sounds bad.  Also, you have to be quite careful with the section
layout because the Windows loader is pretty dumb and needs a rather standarized
layout, otherwise it refuses to load the executable.  There isn't much wiggle
room :(

I'm CCing ktietz, maybe he has some idea how to fix the __image_base__ value.


Corinna

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-11 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #6 from cvs-commit at gcc dot gnu.org  ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
   via  32ae0d80cd430150ad9536aa160f34f504e129bc (commit)
  from  58a84dcf29b735ee776536b4c51ba90b51612b71 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=32ae0d80cd430150ad9536aa160f34f504e129bc

commit 32ae0d80cd430150ad9536aa160f34f504e129bc
Author: Nick Clifton 
Date:   Fri Apr 11 16:02:52 2014 +0100

PE32+ binaries that use addresses > 1^32 have a problem in that the linker
converts some address expressions into absolute values, but the PE format
only stores absolutes as 32-bits.  This is a partial solution which
attempts
to convert such absolute values back to section relative ones instead.  It
fails for symbols like __image_base and ImageBase__, but it is unclear as
to
whether these values are ever actually used by applications.

PR ld/16821
* peXXigen.c (abs_finder): New function.
(_bfd_XXi_swap_sym_out): For absolute symbols with values larger
than 1^32 try to convert them into section relative values
instead.

---

Summary of changes:
 bfd/ChangeLog  |8 
 bfd/peXXigen.c |   31 +++
 2 files changed, 39 insertions(+), 0 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-12 Thread ebotcazou at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=16821



Eric Botcazou  changed:



   What|Removed |Added



 CC||ebotcazou at gcc dot gnu.o
rg



--- Comment #7 from Eric Botcazou  ---

This doesn't compile on 32-bit hosts:



peigen.c: In function ‘abs_finder’:

peigen.c:215:3: error: left shift count >= width of type [-Werror]



-- 

You are receiving this mail because:

You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-14 Thread asmwarrior at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821



asmwarrior  changed:



   What|Removed |Added



 CC||asmwarrior at gmail dot com



--- Comment #8 from asmwarrior  ---

(In reply to Eric Botcazou from comment #7)

> This doesn't compile on 32-bit hosts:

> 

> peigen.c: In function ‘abs_finder’:

> peigen.c:215:3: error: left shift count >= width of type [-Werror]



I got the same build error on MinGW 32-bit hosts, the patch below fixes the

build failure.



Yuanhui Zhang





 bfd/peXXigen.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)



diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c

index 36d90cc..6d80f96 100644

--- a/bfd/peXXigen.c

+++ b/bfd/peXXigen.c

@@ -212,7 +212,7 @@ abs_finder (bfd * abfd ATTRIBUTE_UNUSED, asection * sec,

void * data)

 {

   bfd_vma abs_val = * (bfd_vma *) data;



-  return (sec->vma <= abs_val) && ((sec->vma + (1L << 32)) > abs_val);

+  return (sec->vma <= abs_val) && ((sec->vma + (1LL << 32)) > abs_val);

 }



 unsigned int



-- 

You are receiving this mail because:

You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-22 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #9 from cvs-commit at gcc dot gnu.org  ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
   via  285fc9d8f8ed30b8a9d680fbf37e8f1843b95bc0 (commit)
  from  5d3b02f0036dbf39863fd24414e28f28a53ea1fd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=285fc9d8f8ed30b8a9d680fbf37e8f1843b95bc0

commit 285fc9d8f8ed30b8a9d680fbf37e8f1843b95bc0
Author: Yuanhui Zhang 
Date:   Tue Apr 22 11:00:39 2014 +0100

Fix build problem on 32-bit hosts with the recent patch for PR 16821.

PR ld/16821
* peXXigen.c (abs_finder): Fix for 32-bit host builds.

---

Summary of changes:
 bfd/ChangeLog  |5 +
 bfd/peXXigen.c |   10 +-
 2 files changed, 14 insertions(+), 1 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-22 Thread nickc at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #10 from Nick Clifton  ---
Thanks Yuanhui - patch applied.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-22 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #11 from cvs-commit at gcc dot gnu.org  ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
   via  d5f59c10fc37e325d3fbad4ae7970c7cf0857b46 (commit)
  from  73589c9dbddc7906fa6a150f2a2a0ff6b746e8ba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d5f59c10fc37e325d3fbad4ae7970c7cf0857b46

commit d5f59c10fc37e325d3fbad4ae7970c7cf0857b46
Author: Nick Clifton 
Date:   Tue Apr 22 16:57:34 2014 +0100

Another fix for building on a 32-bit host.

PR ld/16821
* peXXigen.c (_bfd_XXi_swap_sym_out): Fix for 32-bit hosts.

---

Summary of changes:
 bfd/ChangeLog  |5 +
 bfd/peXXigen.c |2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/16821] x86_64 PE/COFF: ld truncates addresses of symbols from linker scripts to 32 bit

2014-04-28 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=16821

--- Comment #12 from cvs-commit at gcc dot gnu.org  ---
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
   via  40af4a3636504a0e7e0223b34ed1e7b15c4fa5da (commit)
  from  e3e163dbb0c50aa94af5416aca86d9ef9c225205 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=40af4a3636504a0e7e0223b34ed1e7b15c4fa5da

commit 40af4a3636504a0e7e0223b34ed1e7b15c4fa5da
Author: Nick Clifton 
Date:   Mon Apr 28 09:34:02 2014 +0100

This patch reworks the fix to avoid a compile time warning so that it will
work
with later versions of gcc.

PR ld/16821
* peXXigen.c (_bfd_XXi_swap_sym_out): Rework fix to avoid compile
time warning.

---

Summary of changes:
 bfd/ChangeLog  |6 ++
 bfd/peXXigen.c |   15 ++-
 2 files changed, 12 insertions(+), 9 deletions(-)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils