Go to file
LIU Hao 19fb46e9e8 headers/intrin-impl: Fix segment accessors
First, these intrins read from and write to thread-local memory. The TEB
contains a pointer to itself in the DS segment, known as the `Self` field of
`struct _NT_TIB`, which means the TEB is semantically in the same address
space as other objects, so these asm statements must clobber "memory". If an
asm statement writes to memory that is not passed with "m" constraints, then
the compiler shall be noted that it has unknown side effects, by adding a
`volatile` qualifier.

Second, for Intel syntax, this commit removes superfluous prefixes in front of
segment register names.

Third, previously `Offset` was cast to a pointer and dereferenced, and then
passed to inline assembly as a memory operand using the `m` constraint. This
was a pure hack. GCC assumes that a memory operand should belong in the DS
segment, so it appeared to reference unknown memory, and caused warnings like

  intrin-impl.h:849:1: warning: array subscript 0 is outside array bounds of
  'long long unsigned int[0]' [-Warray-bounds=]
  849 | __buildreadseg(__readgsqword, unsigned __int64, "gs", "q")
      | ^~~~~~~~~~~~~~

This commit passes the address by register instead. For Intel syntax, there is
no way to print the `DWORD PTR` thing, so unfortunately the value also has to
be passed by register. It's suboptimal, but should be safe.

For x86-64, the use of a 32-bit address requires an address size override
prefix. However, it's deliberate, as zero-extending a 32-bit register (like
`mov edi, edi`) would require two additional bytes.

Signed-off-by: LIU Hao <lh_mouse@126.com>
2024-11-12 17:03:45 +08:00
build-aux Regenerate configure with autoconf 2.72 2024-01-09 22:26:23 +08:00
COPYING.MinGW-w64 Remove Fixme about csq.h 2010-02-23 15:17:58 +00:00
COPYING.MinGW-w64-runtime Add 2011-2013 to copyright years 2013-02-26 20:28:23 +00:00
mingw-w64-crt crt: Regenerate Makefile.in 2024-11-08 14:41:01 +02:00
mingw-w64-doc doc: ucrt-vs-msvcrt.txt: Update information about CRT options and links how to obtain UCRT 2024-09-02 23:17:51 +03:00
mingw-w64-headers headers/intrin-impl: Fix segment accessors 2024-11-12 17:03:45 +08:00
mingw-w64-libraries winpthreads: also use SetThreadDescription to set thread name 2024-10-29 22:39:01 +08:00
mingw-w64-tools widl: Import Wine version wine-9.20. 2024-10-18 23:16:01 +02:00
.gitignore winpthreads: Ignore MSVC object files and Autotools generated files 2023-12-19 15:25:13 +02:00
aclocal.m4 Regenerate configure with autoconf 2.72 2024-01-09 22:26:23 +08:00
AUTHORS Merge commit '954b97bcfc515152cb5e666411d3ca0b256d589b' 2019-06-03 10:37:03 +02:00
config.h.in Add top level configury system 2010-02-24 17:55:02 +00:00
configure Regenerate configure with autoconf 2.72 2024-01-09 22:26:23 +08:00
configure.ac build: enable specific tools and libraries 2017-11-06 23:05:00 +00:00
COPYING Add 2013 as copyright year. 2013-02-26 20:29:09 +00:00
DISCLAIMER removed svn:executable property. 2010-01-15 20:22:39 +00:00
DISCLAIMER.PD Replace 'w64 mingw-runtime' by 'mingw-w64 runtime' 2012-06-28 15:40:59 +00:00
Makefile.am build: autoconf: support winpthreads library 2017-10-07 23:36:26 +00:00
Makefile.in Regenerate autotools scripts with automake 1.16.5 2023-11-17 13:14:02 +08:00