Commit graph

38 commits

Author SHA1 Message Date
Alex Rønne Petersen
31f353cd92 musl: Fix typo in m68k clone() assembly. 2025-02-22 08:13:44 +01:00
Alex Rønne Petersen
8a3aebaee0 musl: Apply Rich Felker's CVE-2025-26519 mitigation patches.
https://www.openwall.com/lists/oss-security/2025/02/13/2

Closes #22883.
2025-02-14 06:42:57 +01:00
Alex Rønne Petersen
975cd9fc4f
musl: Align the stack pointer given to clone() on riscv. 2025-02-08 05:31:56 +01:00
Alex Rønne Petersen
b3d9b0e3f6 musl: Manually inline __tls_get_addr into s390x __tls_get_offset.
See these mailing list threads:

* https://www.openwall.com/lists/musl/2024/11/23/3
* https://www.openwall.com/lists/musl/2025/01/24/1

This supplants cc73d7ad74.
2025-01-24 20:02:30 +01:00
Andrew Kelley
b31a2c9555
Merge pull request #22541 from ziglang/pipeline
Compilation pipeline: spawn Jobs earlier that produce linker inputs
2025-01-21 14:27:05 -05:00
Alex Rønne Petersen
f1f269c6ee libc: Remove a bunch of code for architectures we don't actually support.
Namely:

* alpha
* hppa
* ia64
* microblaze
* nios2
* or1k
* s390
* sh
2025-01-21 09:30:16 +01:00
Andrew Kelley
f5485a52bc reject crti.o/crtn.o, embrace the future
crti.o/crtn.o is a legacy strategy for calling constructor functions
upon object loading that has been superseded by the
init_array/fini_array mechanism.

Zig code depends on neither, since the language intentionally has no way
to initialize data at runtime, but alas the Zig linker still must
support this feature since popular languages depend on it.

Anyway, the way it works is that crti.o has the machine code prelude of
two functions called _init and _fini, each in their own section with the
respective name. crtn.o has the machine code instructions comprising the
exitlude for each function. In between, objects use the .init and .fini
link section to populate the function body.

This function is then expected to be called upon object initialization
and deinitialization.

This mechanism is depended on by libc, for example musl and glibc, but
only for older ISAs. By the time the libcs gained support for newer
ISAs, they had moved on to the init_array/fini_array mechanism instead.

For the Zig linker, we are trying to move the linker towards
order-independent objects which is incompatible with the legacy
crti/crtn mechanism.

Therefore, this commit drops support entirely for crti/crtn mechanism,
which is necessary since the other commits in this branch make it
nondeterministic in which order the libc objects and the other link
inputs are sent to the linker.

The linker is still expected to produce a deterministic output, however,
by ignoring object input order for the purposes of symbol resolution.
2025-01-20 20:59:52 -08:00
Andrew Kelley
e6dc85f1b4 remove memcpy and memmove from bundled libcs
These are provided instead by compiler_rt.

Part of #2879
2025-01-17 12:34:15 -08:00
Alex Rønne Petersen
c666ebb1f8
musl: Add unwinding protection in clone() implementations.
Whatever was in the frame pointer register prior to clone() will no longer be
valid in the child process, so zero it to protect FP-based unwinders. This is
just an extension of what was already done for i386 and x86_64. Only applied
to architectures where the _start() code also zeroes the frame pointer.
2024-12-11 00:10:17 +01:00
Alex Rønne Petersen
67e524da54
musl: Update libc.S against musl 1.2.5.
All supported architectures included except for x32 (currently broken).
2024-11-23 03:10:58 +01:00
Alex Rønne Petersen
cc73d7ad74
musl: Mark __tls_get_addr as hidden before invoking it on s390x.
https://www.openwall.com/lists/musl/2024/11/23/3
2024-11-23 03:10:54 +01:00
Alex Rønne Petersen
4972a871c5
musl: Mark __restore(_rt) functions hidden on riscv.
https://www.openwall.com/lists/musl/2024/11/23/2
2024-11-23 01:24:35 +01:00
Alex Rønne Petersen
ea26af0b9d
musl: Set symbol type for the START function on i386 and x86_64.
https://www.openwall.com/lists/musl/2024/11/23/1
2024-11-23 01:23:02 +01:00
Alex Rønne Petersen
ec0e6440b1
musl: Update sources from musl 1.2.5.
Adds mipsn32 and x32 sources.

Also remove some useless .in files.
2024-11-02 10:42:53 +01:00
Alex Rønne Petersen
92ae5818d2 musl: Align _init/_fini symbols correctly on arm.
See upstream patch: https://www.openwall.com/lists/musl/2024/10/10/4
2024-10-11 03:20:39 +02:00
Alex Rønne Petersen
c1cc63e5ff libc: Work around LLVM's misassembly of j <reg> on mips r6.
See: https://github.com/ziglang/zig/issues/21315
2024-09-23 17:26:30 -07:00
Andrew Kelley
46b2f67905 update musl libc.S to v1.2.5
adds loongarch64 and riscv32
2024-06-04 22:37:28 -07:00
Andrew Kelley
0098e650fb update musl source files to v1.2.5
adds loongarch64 and riscv32
2024-06-04 16:54:14 -07:00
Andrew Kelley
09c7f1bd7c musl: update libc.S to v1.2.4 2023-06-20 12:55:38 -04:00
Andrew Kelley
a5d8c310ee musl: update src files to v1.2.4 2023-06-20 12:55:38 -04:00
Isaac Freund
2477a95d29
tools/gen_stubs: sort output by section/symbol name
This will make future diffs smaller and easier to review.
2022-05-04 18:38:45 +02:00
Isaac Freund
f4131cf8a6
musl: update to 1.2.3
This was a bit trickier than it should be due to symbol conflicts with
zig's compiler-rt implementation. We attempt to use weak linkage in
our compiler-rt, but this does not seem to be working in all cases. I
manually disabled export of the problematic compiler-rt math functions
in order to cross compile musl's libc.so for all targets as input to
`tools/gen_stubs.zig`.

Other than that, this update went fairly smoothly. Quite a few
additional symbols were added to the blacklist in `tools/gen_stubs.zig`
due to recent reorganization of zig's compiler-rt.
2022-05-04 01:00:57 +02:00
Andrew Kelley
f69f55c807 stage2: upgrade musl libc stub file
This is the result of the work on tools/gen_stubs.zig. It now uses the
preprocessor to emit different symbols and sizes depending on the
architecture. The data is collected directly from multiple libc.so files
on disk built with upstream musl.

Closes #8178
Addresses #8896 for musl

There is still room for further improvement to this, which is to
put `.ds` directives after symbols that are not followed by aliases, to
avoid the potential problem of a linker believing that all symbols are
aliases of each other.
2021-12-09 01:39:07 -07:00
Andrew Kelley
808b9239a3 improve musl dynamic stubs file libc.s
tools/gen_stubs.zig now cuts out the middle man and operates directly on
the libc.so ELF file. it outputs accurate .size directives for objects.

std.elf gains an STV enum.
2021-12-08 22:32:31 -07:00
Isaac Freund
6dc2236054 musl: update to 1.2.2 2021-02-10 11:50:55 -08:00
Julian Maingot
384ccaa27a stage2: use %type not @type for libc stubs
Missed a couple places last time so just doing the rest.
2021-01-18 11:04:33 -08:00
Isaac Freund
343249efd8 stage2: use %type not @type for libc stubs
Apparently ARM uses @ for comments. Everything seems to accept % here
though.
2020-12-13 23:19:23 -05:00
Isaac Freund
307d98dc35
stage2: support dynamically linking musl libc 2020-12-13 00:40:35 +01:00
Andrew Kelley
abc717f203 modernize the PIE patch for the latest master branch
This is the part of #3960 that has to be rewritten to apply to latest
master branch code.
2020-11-22 17:28:11 -07:00
Andrew Kelley
e5fab3ba68 update musl sources to 1.2.1 2020-11-06 14:13:57 -07:00
Andrew Kelley
edd6643a26
update musl src files to v1.2.0 2020-03-12 17:17:57 -04:00
Andrew Kelley
55202a021a
add missing license files 2019-12-02 16:02:03 -05:00
Andrew Kelley
88b9579488
update musl src to v1.1.24 2019-10-17 11:55:43 -04:00
LemonBoy
a220648198 Backport patch for Musl libc
Allows musl to compile for mipsel targets.

https://www.openwall.com/lists/musl/2019/09/27/1/2
2019-09-27 18:20:00 +02:00
Andrew Kelley
40e77dad83
musl [PATCH] arm: fix setjmp and longjmp asm for armv8-a
From: Szabolcs Nagy <szabolcs.nagy@arm.com>

armv8 removed the coprocessor instructions other than cp14, so
on an armv8 system the related hwcaps should never be set.

new llvm complains about the use of coprocessor instructions in
armv8-a mode (even though they are never executed at runtime),
so ifdef them out when musl is built for armv8.

<dalias> i think the patch looks ok
2019-09-25 15:15:52 -04:00
Andrew Kelley
04ce5376a8
carry some upstream patches to musl to fix riscv inline asm
Upstream commits:
 * 8eb49e0485fc547eead9e47200bbee6d81f391c1
 * 2dcbeabd917e404a0dde0195388da401b849b9a4
 * f0eb2e77b2132a88e2f00d8e06ffa7638c40b4bc

These will be in the next version of musl, so no harm carrying them
here.
2019-07-18 11:43:39 -04:00
Andrew Kelley
d994379173
update bundled musl source to 1.1.23 2019-07-16 19:54:14 -04:00
Andrew Kelley
49d1a4c562 move lib dirs to lib subdir
also start prefering NtDll API. so far:
 * NtQueryInformationFile
 * NtClose

adds a performance workaround for windows unicode conversion. but that
should probably be removed before merging
2019-07-15 17:54:50 -04:00