Граф коммитов

30 Коммитов

Автор SHA1 Сообщение Дата
KJ Tsanaktsidis 86c2724e75 Don't emit ELF notes on non-ELF platforms
These apparently break compilation on old MacOS toolchains, because the
MachO section name is capped to 16 chars (although, on my MacOS, at
least, the section name just gets truncated). Nevertheless, these serve
no purpose on non-ELF platforms (they're part of the LSB Linux ABI).

[Bug #20677]
2024-08-22 17:35:43 +10:00
KJ Tsanaktsidis ff0a181852 Fix typo in ELF note generation
This wasn't looking at the right macro name for pac-ret support, so if
Ruby was compiled with pac-ret but NOT BTI, then the ELF note would not
be emitted.
2024-08-22 17:35:43 +10:00
KJ Tsanaktsidis b940de83de Revert autoconf macros defining RUBY_AARCH64_{BTI|PAC}_ENABLED
This partially reverts https://github.com/ruby/ruby/pull/10944; now that
we decided to pass CFLAGS to $(CC) when assembling .S files, we don't
need these autoconf macros that capture the state of
__ARM_FEATURE{PAC|BTI}_DEFAULT.

[Bug #20601]
2024-07-07 20:14:44 +10:00
KJ Tsanaktsidis 0ccb80d6bf Extract hardening CFLAGS to a special $hardenflags variable
This changes the automatic detection of -fstack-protector,
-D_FORTIFY_SOURCE, and -mbranch-protection to write to $hardenflags
instead of $XCFLAGS. The definition of $cflags is changed to
"$hardenflags $orig_cflags $optflags $debugflags $warnflags" to match.

Furthermore, these flags are _prepended_ to $hardenflags, rather than
appended.

The implications of doing this are as follows:

* If a CRuby builder specifies cflags="-mbranch-protection=foobar" at
  the ./configure script, and the configure script detects that
  -mbranch-protection=pac-ret is accepted, then GCC will be invoked as
  "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar". Since
  the last flags take precedence, that means that user-supplied values
  of these flags in $cflags will take priority.
* Likewise, if a CRuby builder explicitly specifies
  "hardenflags=-mbranch-protection=foobar", because we _prepend_ to
  $hardenflags in our autoconf script, we will still invoke GCC as
  "gcc -mbranch-protection=pac-ret -mbranch-protection=foobar".
* If a CRuby builder specifies CFLAGS="..." at the configure line,
  automatic detection of hardening flags is ignored as before.
* C extensions will _also_ be built with hardening flags now as well
  (this was not the case by default before because the detected flags
  went into $XCFLAGS).

Additionally, as part of this work, I changed how the detection of
PAC/BTI in Context.S works. Rather than appending the autodetected
option to ASFLAGS, we simply compile a set of test programs with the
actual CFLAGS in use to determine what PAC/BTI settings were actually
chosen by the builder. Context.S is made aware of these choices through
some custom macros.

The result of this work is that:

* Ruby will continue to choose some sensible defaults for hardening
  options for the C compiler
* Distributors are able to specify CFLAGS that are consistent with their
  distribution and override these defaults
* Context.S will react to whatever -mbranch-protection is actually in
  use, not what was autodetected
* Extensions get built with hardening flags too.

[Bug #20154]
[Bug #20520]
2024-06-11 20:48:55 +10:00
cui fliter 226a889dc7
[DOC] fix some comments
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-03-05 18:50:47 +09:00
Nobuyoshi Nakada 4f6b827e98
Use `__asm` instead of `asm`
With `--std=c99` option coroutine/arm64/Context.h errs:

```
In file included from cont.c:26:
coroutine/arm64/Context.h:59:5: error: call to undeclared function 'asm'; ISO C99 and later do not support
      implicit function declarations [-Wimplicit-function-declaration]
   59 |     asm ("hint #8;" : "+r"(r17) : "r"(r16));
      |     ^
```

Also move the common function header.
2024-02-06 12:19:56 +09:00
Yuta Saito fa0f7522c4 coroutine/arm64: Skip saving/restoring x30 twice and use `autiasp`
We don't need to save/restore x30 twice, and we can just use `ret`,
which uses x30 as return address register instead of explicit `ret <reg>`
instruction. This also allows us to use `autiasp` instead of `autia1716`
and we can skip setting SP/LR to x16/x17.

Also the size of register save area is shrunk by 16 bytes due to the
removal of extra x30 save/restore.
2023-12-22 11:30:00 +09:00
Yuta Saito 2d004decde coroutine/arm64/Context.S: Append PAC/BTI note section if needed
Fixes https://bugs.ruby-lang.org/issues/20029
2023-12-22 11:30:00 +09:00
Yuta Saito 35587150e2 coroutine/arm64/Context.S: Insert `bti c` as BTI landing pad 2023-12-22 11:30:00 +09:00
Yuta Saito d9e5564ccd coroutine/arm64: Sign return address if PAC enabled 2023-12-22 11:30:00 +09:00
Samuel Williams 901525b107 Add support for address sanitizer for amd64 and arm64. 2022-05-25 15:24:24 +12:00
Samuel Williams 42130a64f0
Replace copy coroutine with pthread implementation. 2021-07-01 11:23:03 +12:00
David CARLIER 68a8f611e0 coroutine: Darwin on ARM64 needs alignment of 2^2 2021-04-01 23:51:06 +13:00
David CARLIER 816a1d97fd coroutine mac m1 update.
using proper link register and frame pointer which equal x30/x29.
2021-03-22 23:32:07 +09:00
David Carlier c230ccdba6 coroutine arm64 generating note.GNU-stack section for linux. 2021-03-05 14:26:00 +13:00
Nobuyoshi Nakada f1c36f2e6b
Added include guards to coroutine headers 2021-01-22 23:21:25 +09:00
Nobuyoshi Nakada 41168f69fb
Prefix export symbol prefix to coroutine_transfer 2020-07-05 17:27:12 +09:00
Nobuyoshi Nakada 04c704c5c9
Removed trailing spaces [ci skip] 2020-07-05 17:12:20 +09:00
Samuel Williams f96216df8d
Remove "All Rights Reserved." from Copyright statement. 2019-12-28 12:41:47 +13:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
Samuel Williams 6c6bf9ffcb Add `ucontext` coroutine implementation for generic fallback. 2019-06-26 20:19:53 +12:00
Nobuyoshi Nakada a160b2f567
Make COROUTINE_REGISTERS compile-time only not to be a global symbol 2019-05-16 15:52:09 +09:00
samuel e64f71f812 Change Makefile rule for assembly to use .S rather than .s
It is more conventional to use compiler to pre-process and
assemble the `.S` file rather than forcing Makefile to use `.s`.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65952 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-24 11:35:29 +00:00
samuel 26adef94fa Fix indentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 20:09:38 +00:00
samuel ae3c8c2085 Prefer "static inline" to avoid duplicate symbols.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 10:17:17 +00:00
samuel 83c84182ad Formatting changes.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 10:17:00 +00:00
samuel 9481461cc3 Ensure start function has correct declaration.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 10:16:54 +00:00
samuel 99346f74a4 Mark COROUTINE as noreturn.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 10:16:41 +00:00
samuel 3710dedc12 Tidy up comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 10:16:29 +00:00
samuel 07a324a0f6 Native implementation of coroutines to improve performance of fibers
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-20 09:59:10 +00:00