[Bug binutils/29189] New: dlltool delaylibs corrupt float/double arguments

2022-05-27 Thread strager.nds at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29189

Bug ID: 29189
   Summary: dlltool delaylibs corrupt float/double arguments
   Product: binutils
   Version: 2.39 (HEAD)
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: strager.nds at gmail dot com
  Target Milestone: ---

Created attachment 14120
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14120&action=edit
semi-tested bug fix

(This report was originally posted on the mailing list:
https://lists.gnu.org/archive/html/bug-binutils/2022-05/msg00099.html)

I am calling a function in another x64 DLL with the
following C signature:

int napi_create_double(void*, double, void*);

The first time I call this function, the 'double' argument
ends up as 1.20305e-307 inside napi_create_double, no matter
what value the caller gives. The 'double' is corrupted.
Calls after the first don't corrupt the 'double'.

The cause is ntdll.dll, eventually called by MinGW's
__delayLoadHelper2, modifying the xmm1 register:

#0  0x7ffd26ce3006 in ntdll!RtlLookupFunctionEntry () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#1  0x7ffd26ce05e8 in ntdll!LdrGetProcedureAddressForCaller () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#2  0x7ffd26ce00a5 in ntdll!LdrGetProcedureAddressForCaller () from
C:\WINDOWS\SYSTEM32\ntdll.dll
#3  0x7ffd245b53dc in KERNELBASE!GetProcAddressForCaller () from
C:\WINDOWS\System32\KernelBase.dll
#4  0x7ffcd7b7ca6f in __delayLoadHelper2 (pidd=0x7ffcd7b8ba70
<__DELAY_IMPORT_DESCRIPTOR_node_napi_lib>,
ppfnIATEntry=0x7ffcd7ecd134 <__imp_napi_create_double>)
at
C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/misc/delayimp.c:209
#5  0x7ffcd7b717c9 in __tailMerge_node_napi_lib ()
   from MYDLL.dll
#6  0x02ad2fe84c50 in ?? ()

   0x7ffd26ce2ffb <+1051>:  movups (%rdx),%xmm0
   0x7ffd26ce2ffe <+1054>:  movups %xmm0,(%rsi)
   0x7ffd26ce3001 <+1057>:  movsd  0x10(%rdx),%xmm1
=> 0x7ffd26ce3006 <+1062>:  movsd  %xmm1,0x10(%rsi)
   0x7ffd26ce300b <+1067>:  mov(%rsi),%rbp
   0x7ffd26ce300e <+1070>:  mov%r11,%rax
   0x7ffd26ce3011 <+1073>:  lock cmpxchg %r12,0x1384d6(%rip)#
0x7ffd26e1b4f0
   0x7ffd26ce301a <+1082>:  jne0x7ffd26ce3102


According to Windows x64 documentation, xmm1 is a volatile
register:
https://docs.microsoft.com/en-us/cpp/build/x64-software-conventions?redirectedfrom=MSDN&view=msvc-170

I think the solution is for dll's delaylib trampoline to
save xmm1 on the stack before calling __delayLoadHelper2.
I made a patch which does this, and it fixes the bug for my
code.

See attached patch. I think my patch has two problems:

1. AVX/vmovupd/ymm might not be usable on the target
   machine, but saving just xmm isn't enough. Should we
   perform a CPUID check?
2. We store unaligned with vmovupd. Storing aligned with
   vmovapd would be better. I haven't looked into how to
   align ymm registers when storing on the stack.

I'd love to get this bug fixed so others don't spend two
days debugging assembly code!

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


[Bug binutils/29189] dlltool delaylibs corrupt float/double arguments

2022-05-27 Thread strager.nds at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29189

--- Comment #1 from strager  ---
My patch saves ymm4 and ymm5, but I think that's unnecessary, since they won't
be used for parameters.

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


[Bug binutils/29189] dlltool delaylibs corrupt float/double arguments

2022-05-27 Thread strager.nds at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29189

--- Comment #2 from strager  ---
Created attachment 14121
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14121&action=edit
minimal repro

Attached is a small program (DLL and EXE) which demonstrates the issue.

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


[Bug binutils/29189] dlltool delaylibs corrupt float/double arguments

2022-05-27 Thread strager.nds at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29189

strager  changed:

   What|Removed |Added

 Target||windows-amd64

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


[Bug binutils/29189] dlltool delaylibs corrupt float/double arguments

2022-05-27 Thread dushistov at mail dot ru
https://sourceware.org/bugzilla/show_bug.cgi?id=29189

Evgeniy Dushistov  changed:

   What|Removed |Added

 CC||dushistov at mail dot ru

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


[Bug binutils/29189] dlltool delaylibs corrupt float/double arguments

2022-05-27 Thread egor.pugin at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29189

Egor Pugin  changed:

   What|Removed |Added

 CC||egor.pugin at gmail dot com

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


[Bug gprofng/29191] New: gprofng ignores --sysconfdir configuration option

2022-05-27 Thread doko at debian dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=29191

Bug ID: 29191
   Summary: gprofng ignores --sysconfdir configuration option
   Product: binutils
   Version: 2.39 (HEAD)
Status: NEW
  Severity: normal
  Priority: P2
 Component: gprofng
  Assignee: vladimir.mezentsev at oracle dot com
  Reporter: doko at debian dot org
  Target Milestone: ---

gprofng.rc is installed into 

  dbe_DATA = $(srcdir)/gprofng.rc

while it probably should be installed into the sysconfdir, which can be
specified by the --sysconfdir option.

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


[Bug gprofng/29191] gprofng ignores --sysconfdir configuration option

2022-05-27 Thread doko at debian dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=29191

--- Comment #1 from Matthias Klose  ---
i.e. it ends up in /usr/etc, but should be /etc when configured with
--sysconfdir=/etc

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


[Bug binutils/29192] New: addr2line suspected incompatibility with DWARF5

2022-05-27 Thread ofekshilon at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29192

Bug ID: 29192
   Summary: addr2line suspected incompatibility with DWARF5
   Product: binutils
   Version: 2.38
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: ofekshilon at gmail dot com
  Target Milestone: ---

==Example:
$ cat toy.cpp
#include 
int main() {
std::cout << "hello world";
return 0;
}
$ clang-14 -g -stdlib=libc++ -lc++ -I/usr/lib/llvm-14/include/c++/v1 toy.cpp -o
toy14
$ addr2line -fe ./toy 0x1234
addr2line: DWARF error: invalid or unhandled FORM value: 0x25
main
??:?
=end example

According to the dwarf5 spec (https://dwarfstd.org/doc/DWARF5.pdf), section
7.5.6 page 221, 0x25 is a valid DW_FORM value:

  DW_FORM_strx1 ‡ 0x25 string.


In other cases (not yet reduced to a small repro) we see:
  addr2line: Dwarf Error: Could not find abbrev number 127

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


[Bug binutils/29192] addr2line suspected incompatibility with DWARF5

2022-05-27 Thread ofekshilon at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29192

--- Comment #1 from Ofek Shilon  ---
(1) Sorry, typo in the example -
instead of
$ addr2line -fe ./toy 0x1234
should be -
$ addr2line -fe ./toy14 0x1234

Also, just verified that if I build with `-fdebug-default-version=4` the error
disappears and lines are displayed properly.

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


[Bug gprofng/29143] gprofng fails to build on x86_64-linux-gnux32

2022-05-27 Thread doko at debian dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=29143

--- Comment #3 from Matthias Klose  ---
trunk 20220527 still fails to build, this time with:

../../../gprofng/src/Experiment.cc: In member function ‘void
Experiment::write_header()’:
../../../gprofng/src/Experiment.cc:4139:33: error: cannot convert ‘long int*’
to ‘const time_t*’
 {aka ‘const long long int*’}

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


[Bug gprofng/28984] Bad __collector_getpc implementation

2022-05-27 Thread vladimir.mezentsev at oracle dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=28984

Vladimir Mezentsev  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Vladimir Mezentsev  
---
 I fixed this along with fixes for 28983 gprofng: Don't build with -mx32

The master branch has been updated by Vladimir Mezentsev
:

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

commit 2a2cb7cf2c7f0d380ee9cb9ef361223b8770c508
Author: Vladimir Mezentsev 
Date:   Thu May 26 12:59:19 2022 -0700

gprofng: fix build with -mx32

gprofng/ChangeLog
2022-05-26  Vladimir Mezentsev  

PR gprofng/28983
* libcollector/libcol_util.h (__collector_getsp, __collector_getfp,
__collector_getpc): Adapt for build with -mx32
* libcollector/heaptrace.c: Fix -Wpointer-to-int-cast warnings.
* libcollector/hwprofile.h: Likewise.
* libcollector/mmaptrace.c: Likewise.
* libcollector/synctrace.c: Likewise.
* libcollector/unwind.c: Likewise.

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


[Bug binutils/29194] New: bfd/doc/chew.c error: ISO C forbids conversion of function pointer to object pointer type

2022-05-27 Thread dc at genunix dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29194

Bug ID: 29194
   Summary: bfd/doc/chew.c error: ISO C forbids conversion of
function pointer to object pointer type
   Product: binutils
   Version: 2.38
Status: UNCONFIRMED
  Severity: normal
  Priority: P2
 Component: binutils
  Assignee: unassigned at sourceware dot org
  Reporter: dc at genunix dot com
  Target Milestone: ---

Not entirely sure if this is a bug or perhaps the binutils sources are
not C99 clean. Also not sure if this is a Big Flipping Deal[1] or maybe
I can give up on C99? 

Regardless I have CFLAGS set for strict compliance : 

mimas$ echo $CC
/opt/gcc/imed/gcc12/bin/gcc

mimas$ echo $CFLAGS
-std=iso9899:1999 -pedantic -pedantic-errors -fno-builtin -g -O0 -m64 -march=k8
-mtune=k8 -malign-double -mpc80 -mno-mmx
-Wl,-rpath=/opt/bw/lib,--enable-new-dtags

mimas$ echo $CPPFLAGS
-I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE
mimas$ 

This is on an old Red Hat Enterprise Linux 6 machine wherein I did a
bootstrap of GCC 9.4.0 and then used that result to bootstrap GCC 12.1.0
with great success. So I figure the compiler is reasonable. 

Configure was trivial : 


mimas$ ../binutils-2.38/configure --prefix=/opt/bw --enable-ld 
--with-gmp=/opt/bw --with-mpfr=/opt/bw --with-mpc=/opt/bw 
--with-isl=/opt/bw
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /bin/sed
checking for gawk... gawk
checking for gcc... /opt/gcc/imed/gcc12/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /opt/gcc/imed/gcc12/bin/gcc accepts -g... yes
checking for /opt/gcc/imed/gcc12/bin/gcc option to accept ISO C89... none
needed
checking for /opt/gcc/imed/gcc12/bin/gcc option to accept ISO C99... none
needed
checking whether we are using the GNU C++ compiler... yes
checking whether /opt/gcc/imed/gcc12/bin/g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1
$$f2
checking for objdir... .libs
checking for isl 0.15 or later... yes
checking for default BUILD_CONFIG... 
checking for --enable-vtable-verify... no
checking for bison... bison -y
checking for bison... bison
checking for gm4... /opt/bw/bin/m4
checking for flex... flex
checking for flex... flex
checking for makeinfo... makeinfo
checking for expect... no
checking for runtest... no
checking for ar... (cached) /opt/bw/bin/gar
checking for as... (cached) /opt/bw/bin/gas
checking for dlltool... no
checking for ld... (cached) /opt/bw/bin/gld
checking for lipo... no
checking for nm... (cached) /opt/bw/bin/gnm
checking for ranlib... (cached) /opt/bw/bin/granlib
checking for strip... (cached) /opt/bw/bin/gstrip
checking for windres... no
checking for windmc... no
checking for objcopy... (cached) /opt/bw/bin/gobjcopy
checking for objdump... (cached) /opt/bw/bin/gobjdump
checking for readelf... (cached) /opt/bw/bin/greadelf
checking for -plugin option... --plugin
/opt/gcc/imed/gcc12/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/liblto_plugin.so
checking for cc... cc
checking for c++... c++
checking for gcc... gcc
checking for gfortran... gfortran
checking for gccgo... no
checking for ar... ar
checking for as... as
checking for dlltool... no
checking for ld... ld
checking for lipo... no
checking for nm... nm
checking for objcopy... objcopy
checking for objdump... objdump
checking for ranlib... ranlib
checking for readelf... readelf
checking for strip... strip
checking for windres... no
checking for windmc... no
checking where to find the target ar... just compiled
checking where to find the target as... just compiled
checking where to find the target cc... host tool
checking where to find the target c++... host tool
checking where to find the target c++ for libstdc++... host tool
checking where to find the target dlltool... just compiled
checking where to find the target gcc... host tool
checking where to find the target gfortran... host tool
checking where to find the target gccgo... host tool
checking where to find the target ld... just compiled
checking where to find the target lipo... host tool
checking where to find the target nm... just compiled
checking where to find the target objcopy... just compiled
checking where to find the target objdump... j

[Bug binutils/29194] bfd/doc/chew.c error: ISO C forbids conversion of function pointer to object pointer type

2022-05-27 Thread dc at genunix dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29194

--- Comment #1 from Dennis Clarke  ---

As a further comment where I did also try C90 but that gets me
only a little further : 

.
.
.
/opt/gcc/imed/gcc12/bin/gcc -c -DHAVE_CONFIG_H -std=iso9899:1990 -pedantic
-pedantic-errors -fno-builtin -g -O0 -m64 -march=k8 -mtune=k8 -malign-double
-mpc80 -mno-mmx -Wl,-rpath=/opt/bw/lib,--enable-new-dtags -I/opt/bw/include
-D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE -I.
-I../../binutils-2.38/libiberty/../include  -W -Wall -Wwrite-strings
-Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic  -D_GNU_SOURCE
-fcf-protection ../../binutils-2.38/libiberty/cp-demangle.c -o cp-demangle.o
../../binutils-2.38/libiberty/cp-demangle.c: In function 'is_designated_init':
../../binutils-2.38/libiberty/cp-demangle.c:4763:3: error: ISO C90 forbids
mixed declarations and code [-Wdeclaration-after-statement]
 4763 |   struct demangle_component *op = d_left (dc);
  |   ^~
../../binutils-2.38/libiberty/cp-demangle.c: In function
'd_maybe_print_designated_init':
../../binutils-2.38/libiberty/cp-demangle.c:4779:3: error: ISO C90 forbids
mixed declarations and code [-Wdeclaration-after-statement]
 4779 |   const char *code = d_left (dc)->u.s_operator.op->code;
  |   ^
make[2]: *** [cp-demangle.o] Error 1
make[2]: Leaving directory
`/opt/bw/build/binutils-2.38_rhel6_amd64.003/libiberty'
make[1]: *** [all-libiberty] Error 2
make[1]: Leaving directory `/opt/bw/build/binutils-2.38_rhel6_amd64.003'
make: *** [all] Error 2


So I am not sure what C standard the binutils comply with. If at all.

Dennis

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


[Bug gprofng/28983] gprofng: Don't build with -mx32

2022-05-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=28983

--- Comment #2 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Vladimir Mezentsev
:

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

commit 6094a48ec821a52731172f3471dce4923a482cd1
Author: Vladimir Mezentsev 
Date:   Fri May 27 19:54:26 2022 -0700

gprofng: fix build with -mx32

gprofng/ChangeLog
2022-05-27  Vladimir Mezentsev  

PR gprofng/28983
PR gprofng/29143
* src/Experiment.cc (write_header): Fix argument for ctime.
Fix -Wformat= warnings.
* src/Dbe.cc: Likewise.
* src/DwarfLib.h: Fix [-Wsign-compare] warnings.
* src/Experiment.h: Likewise.
* src/ipc.cc: Fix -Wformat= warnings.

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


[Bug gprofng/29143] gprofng fails to build on x86_64-linux-gnux32

2022-05-27 Thread cvs-commit at gcc dot gnu.org
https://sourceware.org/bugzilla/show_bug.cgi?id=29143

--- Comment #4 from cvs-commit at gcc dot gnu.org  ---
The master branch has been updated by Vladimir Mezentsev
:

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

commit 6094a48ec821a52731172f3471dce4923a482cd1
Author: Vladimir Mezentsev 
Date:   Fri May 27 19:54:26 2022 -0700

gprofng: fix build with -mx32

gprofng/ChangeLog
2022-05-27  Vladimir Mezentsev  

PR gprofng/28983
PR gprofng/29143
* src/Experiment.cc (write_header): Fix argument for ctime.
Fix -Wformat= warnings.
* src/Dbe.cc: Likewise.
* src/DwarfLib.h: Fix [-Wsign-compare] warnings.
* src/Experiment.h: Likewise.
* src/ipc.cc: Fix -Wformat= warnings.

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


[Bug binutils/29194] bfd/doc/chew.c error: ISO C forbids conversion of function pointer to object pointer type

2022-05-27 Thread amodra at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=29194

Alan Modra  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #2 from Alan Modra  ---
If -Wpedantic warnings in part of the binutils that is used by developers (and
others building from git source) to regenerate sources is of concern to you, I
suggest posting patches to fix those warnings to binut...@sourceware.org.

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