public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4
@ 2020-05-13  8:42 ro at gcc dot gnu.org
  2020-05-13  8:43 ` [Bug build/25981] " ro at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: ro at gcc dot gnu.org @ 2020-05-13  8:42 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

            Bug ID: 25981
           Summary: Use of short i386 register names breaks compilation on
                    recent Solaris 11.4
           Product: gdb
           Version: HEAD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: build
          Assignee: unassigned at sourceware dot org
          Reporter: ro at gcc dot gnu.org
  Target Milestone: 10.1
              Host: amd64-pc-solaris2.11, i386-pc-solaris2.11
            Target: amd64-pc-solaris2.11, i386-pc-solaris2.11
             Build: amd64-pc-solaris2.11, i386-pc-solaris2.11

A future Solaris 11.4 SRU will soon remove the short i386 register names (like
UESP, GS, ...) from <sys/regset.h>.  They can unexpectedly leak into user code
in some circumstances and pollute the user's namespace.

They will only remain in <ucontext.h> since the are prescribed by the i386
psABI
to be present when that header is included.

This change breaks gdb compilation on both 64 and 32-bit Solaris/x86:

* On both amd64 and i386, procfs.c doesn't compile:

/vol/src/gnu/gdb/hg/master/git/gdb/procfs.c: In function 'ssd*
procfs_find_LDT_entry(ptid_t)':
/vol/src/gnu/gdb/hg/master/git/gdb/procfs.c:1643:18: error: 'GS' was not
declared in this scope
 1643 |   key = (*gregs)[GS] & 0xffff;
      |                  ^~
make[2]: *** [Makefile:1607: procfs.o] Error 1

* On i386 only, i386-sol2-nat.c doesn't compile:

/vol/src/gnu/gdb/hg/master/git/gdb/i386-sol2-nat.c:181:3: error: 'EAX' was not
declared in this scope
  181 |   EAX, ECX, EDX, EBX,
      |   ^~~

  and many more.

Both can be easily fixed: procfs_find_LDT_entry has long been obsolete and can
simply go, and i386-sol2-nat.c can just hardcode the register numbers as the
64-bit counterpart already does.

Patches forthcoming; I'm just filing this PR since the changes should also go
into the gdb-9 branch which needs the PR to go forward.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
@ 2020-05-13  8:43 ` ro at gcc dot gnu.org
  2020-05-18 14:13 ` brobecker at gnat dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu.org @ 2020-05-13  8:43 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at sourceware dot org   |ro at gcc dot gnu.org

--- Comment #1 from Rainer Orth <ro at gcc dot gnu.org> ---
Mine.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
  2020-05-13  8:43 ` [Bug build/25981] " ro at gcc dot gnu.org
@ 2020-05-18 14:13 ` brobecker at gnat dot com
  2020-05-18 15:57 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: brobecker at gnat dot com @ 2020-05-18 14:13 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

Joel Brobecker <brobecker at gnat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |brobecker at gnat dot com
   Target Milestone|10.1                        |9.2

--- Comment #2 from Joel Brobecker <brobecker at gnat dot com> ---
OK to backport to 9.2 (simple, can only affect Solaris)

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
  2020-05-13  8:43 ` [Bug build/25981] " ro at gcc dot gnu.org
  2020-05-18 14:13 ` brobecker at gnat dot com
@ 2020-05-18 15:57 ` cvs-commit at gcc dot gnu.org
  2020-05-18 16:01 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-18 15:57 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <ro@sourceware.org>:

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

commit 7f2043399809c0ba5c4819172214371ed820e8c6
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Mon May 18 17:56:00 2020 +0200

    Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981]

    As reported in PR build/25981, a future Solaris 11.4 update will soon
    remove the short i386 register names like SS etc. from <sys/regset.h>.
    They could leak into user code (e.g. via <signal.h> -> <sys/signal.h> ->
    <sys/ucontext.h>) and pollute the user namespace.  Affected code would
    have a hard time avoiding the issue: LLVM is one of those.

    While the short names are required to be present by the i386 psABI, that
    document only demands that they exist in <ucontext.h>, which is what the
    upcoming update assures.

    With this change, in a 64-bit-default configuration, procfs.c fails to
    compile on Solaris/x86:

    /vol/src/gnu/gdb/hg/master/git/gdb/procfs.c: In function 'ssd*
procfs_find_LDT_entry(ptid_t)':
    /vol/src/gnu/gdb/hg/master/git/gdb/procfs.c:1643:18: error: 'GS' was not
declared in this scope
     1643 |   key = (*gregs)[GS] & 0xffff;
          |                  ^~
    make[2]: *** [Makefile:1607: procfs.o] Error 1

    Initially I meant to provide a definition using the planned replacement
    macro, but closer inspection revealed a better way.  procfs_find_LDT_entry
    and its helper proc_get_LDT_entry are only used to implement ps_lgetLDT,
    one of the callback functions required by libthread_db.so.1
    (cf. <proc_service.h>).  While that function is still documented as being
    required even in Solaris 11.4, I found that calls to it had been removed
    long ago in Solaris 9, so just removing the three functions above is the
    easiest fix.

    The following patch does just that.  It compiled successfully on
    amd64-pc-solaris2.11, however, as reported in PR gdb/25939, master is
    completely broken on Solaris since the multi-target patch.  The patch
    applies cleanly to the gdb-9 branch and there I could test it
    successfully.

            PR build/25981
            * procfs.c [(__i386__ || __x86_64__) && sun] (proc_get_LDT_entry,
            procfs_find_LDT_entry): Remove.
            * procfs.h [(__i386__ || __x86_64__) && sun] (struct ssd,
            procfs_find_LDT_entry): Remove.
            * sol-thread.c [(__i386__ || __x86_64__) && sun] (ps_lgetLDT):
            Remove.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2020-05-18 15:57 ` cvs-commit at gcc dot gnu.org
@ 2020-05-18 16:01 ` cvs-commit at gcc dot gnu.org
  2020-05-19  8:04 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-18 16:01 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <ro@sourceware.org>:

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

commit e52a0f1bd949e1b6b6bcadc284c8f84464d46f2c
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Mon May 18 17:59:43 2020 +0200

    Avoid short i386 register names on Solaris/x86 [PR25981]

    This is the 32-bit companion to

            Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981]
            https://sourceware.org/pipermail/gdb-patches/2020-May/168713.html

    A 32-bit-default gdb fails to compile with the updated <sys/regset.h>.
    While it is also affected by the lack of a GS definition, which the
    compantion patch above fixes, it also fails to compile i386-sol2-nat.c like
    this

    /vol/src/gnu/gdb/hg/master/git/gdb/i386-sol2-nat.c:181:3: error: 'EAX' was
not declared in this scope
      181 |   EAX, ECX, EDX, EBX,
          |   ^~~

    and several more.

    While this could be fixed by either including <ucontext.h> here or
    provding fallback definitions of the register macros, I chose to do what
    the 64-bit-default code in the same file
    (amd64_sol2_gregset32_reg_offset[]) does, namely just hardcode the
    numeric values instead.  They are part of the ABI and thus guaranteed
    not to change.

    With this patch, a i386-pc-solaris2.11 configuration on master compiles
    again, however, it doesn't work.  However, I could successfully test it
    on the gdb-9 branch.

    Compiling and testing proved to be messy, unfortunately:

    * For one, Solaris <sys/procfs.h> and largefile support used to be
      mutually exclusive (fixed in Solaris 11.4 and Illumos), which was
      exacerbated by the fact that g++ predefines _FILE_OFFSET_BITS=64 since
      GCC 9.1.0.  For now I've worked around this by adding
      -U_FILE_OFFSET_BITS to CXXFLAGS and configuring with
      --disable-largefile.  I hope to clean this up in a future patch.

    * gdb still defaults to startup-with-shell on.  However, /bin/bash is a
      64-bit executable which cannot be debugged by a 32-bit gdb.  I hacked
      around that part by pointing $SHELL at a 32-bit bash before running
      make check.

            PR build/25981
            * i386-sol2-nat.c [PR_MODEL_NATIVE != PR_MODEL_LP64] (regmap):
            Hardcode register numbers.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2020-05-18 16:01 ` cvs-commit at gcc dot gnu.org
@ 2020-05-19  8:04 ` cvs-commit at gcc dot gnu.org
  2020-05-19  8:07 ` cvs-commit at gcc dot gnu.org
  2020-05-19  8:15 ` ro at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-19  8:04 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-9-branch branch has been updated by Rainer Orth <ro@sourceware.org>:

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

commit ff6da943781d65f7ebc8e2e5ab52fb85590ea60b
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue May 19 10:03:14 2020 +0200

    Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981]

    As reported in PR build/25981, a future Solaris 11.4 update will soon
    remove the short i386 register names like SS etc. from <sys/regset.h>.
    They could leak into user code (e.g. via <signal.h> -> <sys/signal.h> ->
    <sys/ucontext.h>) and pollute the user namespace.  Affected code would
    have a hard time avoiding the issue: LLVM is one of those.

    While the short names are required to be present by the i386 psABI, that
    document only demands that they exist in <ucontext.h>, which is what the
    upcoming update assures.

    With this change, in a 64-bit-default configuration, procfs.c fails to
    compile on Solaris/x86:

    /vol/src/gnu/gdb/hg/master/git/gdb/procfs.c: In function 'ssd*
procfs_find_LDT_entry(ptid_t)':
    /vol/src/gnu/gdb/hg/master/git/gdb/procfs.c:1643:18: error: 'GS' was not
declared in this scope
     1643 |   key = (*gregs)[GS] & 0xffff;
          |                  ^~
    make[2]: *** [Makefile:1607: procfs.o] Error 1

    Initially I meant to provide a definition using the planned replacement
    macro, but closer inspection revealed a better way.  procfs_find_LDT_entry
    and its helper proc_get_LDT_entry are only used to implement ps_lgetLDT,
    one of the callback functions required by libthread_db.so.1
    (cf. <proc_service.h>).  While that function is still documented as being
    required even in Solaris 11.4, I found that calls to it had been removed
    long ago in Solaris 9, so just removing the three functions above is the
    easiest fix.

    The following patch does just that.  It compiled successfully on
    amd64-pc-solaris2.11, however, as reported in PR gdb/25939, master is
    completely broken on Solaris since the multi-target patch.  The patch
    applies cleanly to the gdb-9 branch and there I could test it
    successfully.

            PR build/25981
            * procfs.c [(__i386__ || __x86_64__) && sun] (proc_get_LDT_entry,
            procfs_find_LDT_entry): Remove.
            * procfs.h [(__i386__ || __x86_64__) && sun] (struct ssd,
            procfs_find_LDT_entry): Remove.
            * sol-thread.c [(__i386__ || __x86_64__) && sun] (ps_lgetLDT):
            Remove.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2020-05-19  8:04 ` cvs-commit at gcc dot gnu.org
@ 2020-05-19  8:07 ` cvs-commit at gcc dot gnu.org
  2020-05-19  8:15 ` ro at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-05-19  8:07 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

--- Comment #6 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-9-branch branch has been updated by Rainer Orth <ro@sourceware.org>:

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

commit 3bfcbaaa2b23824b1584d2782be64820e4a35acb
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Tue May 19 10:06:00 2020 +0200

    Avoid short i386 register names on Solaris/x86 [PR25981]

    This is the 32-bit companion to

            Remove unused ps_lgetLDT etc. on Solaris/x86 [PR25981]
            https://sourceware.org/pipermail/gdb-patches/2020-May/168713.html

    A 32-bit-default gdb fails to compile with the updated <sys/regset.h>.
    While it is also affected by the lack of a GS definition, which the
    compantion patch above fixes, it also fails to compile i386-sol2-nat.c like
    this

    /vol/src/gnu/gdb/hg/master/git/gdb/i386-sol2-nat.c:181:3: error: 'EAX' was
not declared in this scope
      181 |   EAX, ECX, EDX, EBX,
          |   ^~~

    and several more.

    While this could be fixed by either including <ucontext.h> here or
    provding fallback definitions of the register macros, I chose to do what
    the 64-bit-default code in the same file
    (amd64_sol2_gregset32_reg_offset[]) does, namely just hardcode the
    numeric values instead.  They are part of the ABI and thus guaranteed
    not to change.

    With this patch, a i386-pc-solaris2.11 configuration on master compiles
    again, however, it doesn't work.  However, I could successfully test it
    on the gdb-9 branch.

    Compiling and testing proved to be messy, unfortunately:

    * For one, Solaris <sys/procfs.h> and largefile support used to be
      mutually exclusive (fixed in Solaris 11.4 and Illumos), which was
      exacerbated by the fact that g++ predefines _FILE_OFFSET_BITS=64 since
      GCC 9.1.0.  For now I've worked around this by adding
      -U_FILE_OFFSET_BITS to CXXFLAGS and configuring with
      --disable-largefile.  I hope to clean this up in a future patch.

    * gdb still defaults to startup-with-shell on.  However, /bin/bash is a
      64-bit executable which cannot be debugged by a 32-bit gdb.  I hacked
      around that part by pointing $SHELL at a 32-bit bash before running
      make check.

            PR build/25981
            * i386-sol2-nat.c [PR_MODEL_NATIVE != PR_MODEL_LP64] (regmap):
            Hardcode register numbers.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug build/25981] Use of short i386 register names breaks compilation on recent Solaris 11.4
  2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2020-05-19  8:07 ` cvs-commit at gcc dot gnu.org
@ 2020-05-19  8:15 ` ro at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: ro at gcc dot gnu.org @ 2020-05-19  8:15 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=25981

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                URL|                            |https://sourceware.org/pipe
                   |                            |rmail/gdb-patches/2020-May/
                   |                            |168713.html,
                   |                            |https://sourceware.org/pipe
                   |                            |rmail/gdb-patches/2020-May/
                   |                            |168714.html
         Resolution|---                         |FIXED

--- Comment #7 from Rainer Orth <ro at gcc dot gnu.org> ---
Fixed for GDB 9.2 and 10.1.

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-05-19  8:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13  8:42 [Bug build/25981] New: Use of short i386 register names breaks compilation on recent Solaris 11.4 ro at gcc dot gnu.org
2020-05-13  8:43 ` [Bug build/25981] " ro at gcc dot gnu.org
2020-05-18 14:13 ` brobecker at gnat dot com
2020-05-18 15:57 ` cvs-commit at gcc dot gnu.org
2020-05-18 16:01 ` cvs-commit at gcc dot gnu.org
2020-05-19  8:04 ` cvs-commit at gcc dot gnu.org
2020-05-19  8:07 ` cvs-commit at gcc dot gnu.org
2020-05-19  8:15 ` ro at gcc dot gnu.org

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).