[Bug libgcc/81218] New: libgcc_s.so.1 call to __get_cpuid does not correctly code around 486 cpus lacking cpuid instruction

2017-06-26 Thread tedheadster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81218

Bug ID: 81218
   Summary: libgcc_s.so.1 call to __get_cpuid does not correctly
code around 486 cpus lacking cpuid instruction
   Product: gcc
   Version: 5.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libgcc
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tedheadster at gmail dot com
  Target Milestone: ---

Programs calling libgcc_s.so.1 are failing with an "illegal instruction" signal
on old i486 processors that do not support the cpuid instruction. Later i486
had the instruction, but earlier ones lacked it. The code looks like it
attempts to detect support for the instruction, but it is not working. 

Below is a backtrace (with only partial symbols available):

(gdb) bt
#0  0xb74b5142 in __get_cpuid (__edx=0xbfe5fd18, __ecx=0xbfe5fd14,
__ebx=0xbfe5fd10, __eax=0xbfe5fd0c, __level=0)
at
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/build/gcc/include/cpuid.h:2\
42

#1  __get_cpuid_output (__level=__level@entry=0, __eax=__eax@entry=0xbfe5fd0c,
__ebx=__ebx@entry=0xbfe5fd10, __ecx=0xbfe5fd14, __edx=0xbfe5fd18)
at
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/gcc-5.4.0/libgcc/config/i38\
6/cpuinfo.c:337

#2  0xb74b51ba in __cpu_indicator_init ()
at
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/gcc-5.4.0/libgcc/config/i38\
6/cpuinfo.c:362

#3  0xb77385b6 in ?? () from /lib/ld-linux.so.2
#4  0xb77386dd in ?? () from /lib/ld-linux.so.2
#5  0xb77289cf in ?? () from /lib/ld-linux.so.2
(gdb)

I can move the hard drive between an i486DX/75 and an x86_64 machine. It fails
on the i486 and succeeds on the x86_64 machine.

[Bug libgcc/81218] libgcc_s.so.1 call to __get_cpuid does not correctly code around 486 cpus lacking cpuid instruction

2017-06-26 Thread tedheadster at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81218

--- Comment #2 from Matthew Whitehead  ---
Here is a better backtrace with more symbols added:

#0  0xb750a142 in __get_cpuid (__edx=0xbf9be478, __ecx=0xbf9be474,
__ebx=0xbf9be470, __eax=0xbf9be46c, __level=0)
at
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/build/gcc/include/cpuid.h:2\
42

#1  __get_cpuid_output (__level=__level@entry=0, __eax=__eax@entry=0xbf9be46c,
__ebx=__ebx@entry=0xbf9be470, __ecx=0xbf9be474, __edx=0xbf9be478)
at
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/gcc-5.4.0/libgcc/config/i38\
6/cpuinfo.c:337

#2  0xb750a1ba in __cpu_indicator_init ()
at
/var/tmp/portage/sys-devel/gcc-5.4.0-r3/work/gcc-5.4.0/libgcc/config/i38\
6/cpuinfo.c:362

#3  0xb778d5b6 in call_init (l=, argc=argc@entry=1,
argv=argv@entry=0xbf9be524, env=0xbf9be52c) at dl-init.c:72

#4  0xb778d6dd in call_init (env=0xbf9be52c, argv=0xbf9be524, argc=1,
l=) at dl-init.c:30

#5  _dl_init (main_map=, argc=1, argv=0xbf9be524,
env=0xbf9be52c) at dl-init.c:120

#6  0xb777d9cf in _dl_start_user () from /lib/ld-linux.so.2

[Bug c++/98667] New: gcc generates endbr32 invalid opcode on -march=i486

2021-01-13 Thread tedheadster at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98667

Bug ID: 98667
   Summary: gcc generates endbr32 invalid opcode on -march=i486
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tedheadster at gmail dot com
  Target Milestone: ---

Compiling the 'eix' program with gcc 9.3.0 and the '-march=i486' generated an
'endbr32' opcode. This is an undefined opcode on an i486.


# /usr/bin/gdb /usr/bin/eix
GNU gdb (Gentoo 10.1 vanilla) 10.1
...
Reading symbols from /usr/bin/eix...
Reading symbols from /usr/lib/debug//usr/bin/eix.debug...
(gdb) run
Starting program: /usr/bin/eix

Program received signal SIGILL, Illegal instruction.
_GLOBAL__sub_I_spaces () at eixTk/stringutils.cc:686
686     }

(gdb) disassemble _GLOBAL__sub_I_spaces
Dump of assembler code for function _GLOBAL__sub_I_spaces():
=> 0x004208e0 <+0>:     endbr32
   0x004208e4 <+4>:     push   %esi
   0x004208e5 <+5>:     push   %ebx
   0x004208e6 <+6>:     sub    $0xc,%esp
   0x004208e9 <+9>:     call   0x420d30 <__x86.get_pc_thunk.bx>
   0x004208ee <+14>:    add    $0x17e712,%ebx
   0x0042091e <+62>:    add    $0x14,%esp
   0x00420921 <+65>:    pop    %ebx
   0x00420922 <+66>:    pop    %esi
   0x00420923 <+67>:    ret    

(gdb) list
681                     if(likely(isutf8firstgyte(t[i]))) {
682                             ++len;
683                     }
684             }
685             return len;
686     }

[Bug c++/98667] gcc generates endbr32 invalid opcode on -march=i486

2021-01-13 Thread tedheadster at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98667

--- Comment #1 from Matthew Whitehead  ---
Here is the full set of compiler flags used.

readelf --string-dump='.GCC.command.line' /usr/lib/debug/$( which eix ).debug  

String dump of section '.GCC.command.line':
  [ 0]  -I .
  [ 5]  -I ..
  [ b]  -D_GNU_SOURCE
  [19]  -D HAVE_CONFIG_H
  [2a]  -D SYSCONFDIR="/etc"
  [3f]  -D LOCALEDIR="/usr/share/locale"
  [60]  -D _FORTIFY_SOURCE=2
  [75]  various/drop_permissions.cc
  [91]  -march=i486
  [9d]  -auxbase-strip various/drop_permissions.o
  [c7]  -g
  [ca]  -ggdb
  [d0]  -O2
  [d4]  -fdata-sections
  [e4]  -ffunction-sections
  [f8]  -fcf-protection=full
  [   10d]  -fstack-clash-protection
  [   126]  -frecord-gcc-switches
  [   13c]  eixTk/compare.cc
  [   14d]  -auxbase-strip eixTk/compare.o
  [   16c]  eixTk/formated.cc
  [   17e]  -auxbase-strip eixTk/formated.o
  [   19e]  eixTk/stringutils.cc
  [   1b3]  -auxbase-strip eixTk/stringutils.o
  [   1d6]  eixTk/ansicolor.cc
  [   1e9]  -auxbase-strip eixTk/ansicolor.o
  [   20a]  eixTk/argsreader.cc
  [   21e]  -auxbase-strip eixTk/argsreader.o
  [   240]  eixTk/parseerror.cc
  [   254]  -auxbase-strip eixTk/parseerror.o
  [   276]  eixTk/regexp.cc
  [   286]  -auxbase-strip eixTk/regexp.o
  [   2a4]  eixTk/sysutils.cc
  [   2b6]  -auxbase-strip eixTk/sysutils.o
  [   2d6]  eixTk/filenames.cc
  [   2e9]  -auxbase-strip eixTk/filenames.o
  [   30a]  eixTk/utils.cc
  [   319]  -auxbase-strip eixTk/utils.o
  [   336]  eixTk/varsreader.cc
  [   34a]  -auxbase-strip eixTk/varsreader.o
  [   36c]  database/io.cc
  [   37b]  -auxbase-strip database/io.o
  [   398]  database/io_header.cc
  [   3ae]  -auxbase-strip database/io_header.o
  [   3d2]  database/header.cc
  [   3e5]  -auxbase-strip database/header.o
  [   406]  database/header_portage.cc
  [   421]  -auxbase-strip database/header_portage.o
  [   44a]  database/io_portage.cc
  [   461]  -auxbase-strip database/io_portage.o
  [   486]  database/package_reader.cc
  [   4a1]  -auxbase-strip database/package_reader.o
  [   4ca]  portage/conf/portagesettings.cc
  [   4ea]  -auxbase-strip portage/conf/portagesettings.o
  [   518]  portage/conf/cascadingprofile.cc
  [   539]  -auxbase-strip portage/conf/cascadingprofile.o
  [   568]  eixTk/stringlist.cc
  [   57c]  -auxbase-strip eixTk/stringlist.o
  [   59e]  portage/mask.cc
  [   5ae]  -auxbase-strip portage/mask.o
  [   5cc]  portage/mask_list.cc
  [   5e1]  -auxbase-strip portage/mask_list.o
  [   604]  portage/depend.cc
  [   616]  -auxbase-strip portage/depend.o
  [   636]  portage/basicversion.cc
  [   64e]  -auxbase-strip portage/basicversion.o
  [   674]  portage/eapi.cc
  [   684]  -auxbase-strip portage/eapi.o
  [   6a2]  portage/extendedversion.cc
  [   6bd]  -auxbase-strip portage/extendedversion.o
  [   6e6]  portage/extendedversion_bin.cc
  [   705]  -auxbase-strip portage/extendedversion_bin.o
  [   732]  portage/instversion.cc
  [   749]  -auxbase-strip portage/instversion.o
  [   76e]  portage/package.cc
  [   781]  -auxbase-strip portage/package.o
  [   7a2]  portage/package_best.cc
  [   7ba]  -auxbase-strip portage/package_best.o
  [   7e0]  portage/packagesets.cc
  [   7f7]  -auxbase-strip portage/packagesets.o
  [   81c]  portage/vardbpkg.cc
  [   830]  -auxbase-strip portage/vardbpkg.o
  [   852]  portage/packagetree.cc
  [   869]  -auxbase-strip portage/packagetree.o
  [   88e]  portage/keywords.cc
  [   8a2]  -auxbase-strip portage/keywords.o
  [   8c4]  portage/overlay_bin.cc
  [   8db]  -auxbase-strip portage/overlay_bin.o
  [   900]  portage/overlay.cc
  [   913]  -auxbase-strip portage/overlay.o
  [   934]  portage/set_stability.cc
  [   94d]  -auxbase-strip portage/set_stability.o
  [   974]  portage/version.cc
  [   987]  -auxbase-strip portage/version.o
  [   9a8]  eixrc/eixrc.cc
  [   9b7]  -auxbase-strip eixrc/eixrc.o
  [   9d4]  eixrc/global.cc
  [   9e4]  -auxbase-strip eixrc/global.o
  [   a02]  eixrc/globals.cc
  [   a13]  -auxbase-strip eixrc/globals.o
  [   a32]  eixrc/eixrc_portage.cc
  [   a49]  -auxbase-strip eixrc/eixrc_portage.o
  [   a6e]  eixTk/outputstring.cc
  [   a84]  -auxbase-strip eixTk/outputstring.o
  [   aa8]  eixTk/stringlist_output.cc
  [   ac3]  -auxbase-strip eixTk/stringlist_output.o
  [   aec]  portage/version_output.cc
  [   b06]  -auxbase-strip portage/version_output.o
  [   b2e]  output/formatstring.cc
  [   b45]  -auxbase-strip output/formatstring.o
  [   b6a]  output/formatstring-print.cc
  [   b87]  -auxbase-strip output/formatstring-print.o
  [   bb2]  eix.cc
  [   bb9]  -auxbase-strip eix.o
  [   bce]  various/cli.cc
  [   bdd]  -auxbase-strip various/cli.o
  [   bfa]  output/print-proto.cc
  [   c10]  -auxbase-strip output/print-proto.o
  [   c34]  output/print-xml.cc
  [   c48]  -auxbase-strip output/print-xml.o
  [   c6a]  search/levenshtein.cc
  [   c80]  -auxbase-strip search/levenshtein.o
  [   ca4]  search/algorithms.cc

[Bug target/98667] gcc generates endbr32 invalid opcode on -march=i486

2021-01-14 Thread tedheadster at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98667

--- Comment #3 from Matthew Whitehead  ---
This is on an actual first generation i486DX 40MHz system I use to test for
code issues exactly like this case.

[Bug target/98667] gcc generates endbr32 invalid opcode on -march=i486

2021-01-14 Thread tedheadster at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98667

--- Comment #4 from Matthew Whitehead  ---
It looks like /usr/bin/gdb 10.1 also has this opcode in it:

objdump -D /usr/bin/gdb | grep -B6 -A6 endbr32 

  60d7b5:   3f  aas
  60d7b6:   1a 3b   sbb(%ebx),%bh
  60d7b8:   2a 32   sub(%edx),%dh
  60d7ba:   24 22   and$0x22,%al
  60d7bc:   00 00   add%al,(%eax)
  60d7be:   00 00   add%al,(%eax)
  60d7c0:   f3 0f 1e fb endbr32 
  60d7c4:   ff a3 00 00 00 00   jmp*0x0(%ebx)
  60d7ca:   66 0f 1f 44 00 00   nopw   0x0(%eax,%eax,1)
  60d7d0:   f3 0f 1e fb endbr32 
  60d7d4:   ff 25 00 00 00 00   jmp*0x0
  60d7da:   66 0f 1f 44 00 00   nopw   0x0(%eax,%eax,1)
  60d7e0:   ff b3 04 00 00 00   pushl  0x4(%ebx)
  60d7e6:   ff a3 08 00 00 00   jmp*0x8(%ebx)
  60d7ec:   0f 1f 40 00 nopl   0x0(%eax)
  60d7f0:   f3 0f 1e fb endbr32 
  60d7f4:   68 00 00 00 00  push   $0x0
  60d7f9:   e9 00 00 00 00  jmp60d7fe
<_IO_stdin_used@@Base+0xd77fa>
  60d7fe:   66 90   xchg   %ax,%ax
  60d800:   ff 35 00 00 00 00   pushl  0x0
  60d806:   ff 25 00 00 00 00   jmp*0x0
  60d80c:   0f 1f 40 00 nopl   0x0(%eax)

i686-pentium4-mpentium4-lenovo /usr/lib/debug/usr/bin # /usr/bin/gdb --version 
GNU gdb (Gentoo 10.1 vanilla) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

I will provide the gcc compile switches if asked, but it is long: 2156 items.

[Bug target/98667] gcc generates endbr32 invalid opcode on -march=i486

2021-01-15 Thread tedheadster at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98667

--- Comment #11 from Matthew Whitehead  ---
A patch has been proposed to remove the -fcf-protection=full from the ebuild
script:

https://bugs.gentoo.org/765442