Restore the release binutils tools and linker formats
@@ -46,6 +46,8 @@ MPFR needs a cross-compiler with BID decimal support. On aarch64 the worker used
4646
4747The aarch64 GNU runtime uses inline atomics so its shared libraries resolve against the packaged musl and unwinder. The recipe checks every library for 16 KiB load segments and unresolved outlined atomic helpers. A clean signed installation of `gcc-libs` 14.2.0-2 booted with the released kernel and ran the C++ exception, OpenMP and 128-bit atomic fixtures in `tests/toolchain`. The package digest is `796840770f4e2121e2923e727c5469270625b0e9832cea4504e97ea3149460a0`. See `gnu/arm/logs/runtime-guest-r115/serial.log`, SHA-256 `61e7f5b0b14295d3b2c1a6156388aa67f6ba21fccb1555ca8a484d410e260dcd`.
4848
49+The binutils recipe uses its signed SDK's Zstd and Jansson metadata in subdirectory configuration. Both source builds exercised split DWARF, CTF and Zstd debug-section compression. The x86_64 check linked PE32 and PE32+ fixtures with the generated scripts. On aarch64, BFD and gold linked executables with 16 KiB load segments, and the package installed into the signed GCC SDK. The archive receipts are `gnu/gcc-work/binutils-release-r3/binutils.sha256` and `gnu/arm/build/binutils-release-r3/binutils.sha256`, manifest SHA-256 `b27e492226fdc1987b5973277a3853e0410f488e97da1e1c76605bd50aa2968c` and `73a87a0882a369fc245d3f000791a5047a5917d3f0d573395d223e939899c631`.
50+
4951The desktop metapackage requires musl 1.2.6-4 or later on arm64 and 1.2.6-2 or later on x86_64. The test-signed ARM 1.2.6-3 loader itself had 16 KiB load segments. Its GCC specs let the cross toolchain override that setting for a newly linked shared library. The expected ARM minimum excludes this SDK. The worker checked the architecture-specific version constraints with native vpac metadata in `foundation/release-musl-floor-02`, receipt SHA-256 `2d6886c3bc9fdc7ef38945d303c92cb3b877eba9d67c2fa25b49f46d73019e8a`.
5052
5153Run `python3 tests/exec-linkage.py x86_64 "$client" "$auditor" --proot "$(command -v proot)"` on an x86_64 worker to exercise the installed loader against each dynamic executable in an audited root. For a Vinix guest, use `--fixture "$work/linkage.sh"` and pass that script to the boot harness. Packaged musl 1.2.6 applies relocations before returning from `--list`. It resolved all 109 dynamic executables in the signed 106-package x86_64 root. Renaming the exported `OPENSSL_init_ssl` symbol in an isolated copy of libssl caused the loader to reject `/usr/bin/openssl` with status 127. See `foundation/exec-linkage-01`, receipt SHA-256 `cb2fdec09f4b9e7c873ec82d672af576e9e0c26484f9496744588323a01ed3a0`.
@@ -1,13 +1,28 @@
11; Alpine 3.21 binutils source and patches, producing native Vinix ELF tools.
2+selected := get-environment-variable("VPAC_TARGET_ARCH")
3+host-arch := if memq(string->symbol("aarch64"), features()) { "aarch64" } else { "x86_64" }
4+arch := if string?(selected) { selected } else { host-arch }
5+libc := if string=?(arch, "aarch64") { "musl>=1.2.6-4" } else { "musl" }
6+
7+; Libtool leaves a shell launcher in the build tree for dynamically linked
8+; programs. Invoke the underlying target ELF with its freshly built DSOs.
9+tool := fn(dir, name) {
10+ binary := string-append(dir, "/.libs/", name)
11+ if file-exists?(binary) { binary } else { string-append(dir, "/", name) }
12+}
13+check-tool := fn(dir, name, args) {
14+ apply(run, append(list("vinix-run", "--library-path", "bfd/.libs:opcodes/.libs:libctf/.libs:libsframe/.libs", tool(dir, name)), args))
15+}
16+
217defpkgbuild(binutils,
318 #:pkgname, "binutils",
419 #:pkgver, "2.43.1",
5- #:pkgrel, 2,
20+ #:pkgrel, if string=?(arch, "aarch64") { 4 } else { 3 },
621 #:pkgdesc, "GNU assembler, linker, and binary utilities for Vinix",
722 #:arch, [#:x86-64, #:aarch64],
823 #:url, "https://www.gnu.org/software/binutils/",
924 #:license, ["GPL-2.0-or-later", "LGPL-2.1-or-later", "BSD-3-Clause"],
10- #:depends, ["musl", "zlib"],
25+ #:depends, list(libc, "zlib", "zstd", "jansson", "gcc-libs"),
1126 #:source, ["https://distfiles.alpinelinux.org/distfiles/v3.21/binutils-2.43.1.tar.xz",
1227 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch",
1328 "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/binutils/binutils-ld-fix-static-linking.patch",
@@ -21,6 +36,14 @@ defpkgbuild(binutils,
2136 "395450d49cc0059100d33622bc4e22f4c56f9313fd0c8a81c4facb6514536483",
2237 "ffe8d968ef8bfc682421756d24ad465636a359bb0a10a66943647e726f780640"],
2338 #:prepare, fn() {
39+ if string=?(arch, "aarch64") {
40+ ; The native Vinix AArch64 MMU uses 16 KiB pages. Set both BFD and
41+ ; gold defaults so direct linker users produce loadable segments.
42+ run("sed", "-i", "/^#define ELF_MAXPAGESIZE/s/0x10000/0x4000/; /^#define ELF_COMMONPAGESIZE/s/0x1000/0x4000/",
43+ "binutils-2.43.1/bfd/elfnn-aarch64.c")
44+ run("sed", "-i", "/abi_pagesize (overridable/s/0x10000/0x4000/; /common_pagesize (overridable/s/0x1000/0x4000/",
45+ "binutils-2.43.1/gold/aarch64.cc")
46+ }
2447 for-each(fn(p) { run("patch", "--batch", "--fuzz=1", "-p1", "-d", "binutils-2.43.1", "-i", string-append("../", p)) },
2548 list("0001-Revert-PR25882-.gnu.attributes-are-not-checked-for-s.patch",
2649 "binutils-ld-fix-static-linking.patch", "CVE-2025-0840.patch", "CVE-2025-1153.patch", "CVE-2025-3198.patch"))
@@ -30,21 +53,62 @@ defpkgbuild(binutils,
3053 tools := if string?(prefix) { prefix } else { "" }
3154 ; When --target is omitted GNU configure uses --host, producing a
3255 ; native assembler and linker for the requested Vinix architecture.
33- run("env", string-append("AR=", tools, "ar"), string-append("RANLIB=", tools, "ranlib"), string-append("NM=", tools, "nm"),
56+ formats := if string=?(arch, "x86_64") { list("--enable-targets=x86_64-pep") } else { list() }
57+ apply(run, append(list("env", string-append("AR=", tools, "ar"), string-append("RANLIB=", tools, "ranlib"), string-append("NM=", tools, "nm"),
3458 string-append("AS=", tools, "as"), string-append("LD=", tools, "ld"), "CC_FOR_BUILD=gcc", "CFLAGS=-O2 -std=gnu17",
35- "CXXCPP=vinix-cc -E -x c++", "PKG_CONFIG=false", "vinix-configure", "binutils-2.43.1/configure",
36- "--with-sysroot=/", "--with-system-zlib", "--without-zstd", "--disable-gold",
59+ "CXXCPP=vinix-cc -E -x c++", "vinix-configure", "binutils-2.43.1/configure",
60+ "--with-sysroot=/", "--with-system-zlib", "--with-zstd", "--enable-jansson", "--enable-gold", "--enable-ld=default",
3761 "--disable-gdb", "--disable-gprofng", "--disable-sim", "--disable-nls", "--disable-werror",
38- "--disable-multilib", "--disable-libctf", "--disable-shared", "--enable-deterministic-archives",
39- "--enable-new-dtags", "--enable-relro", "--enable-default-hash-style=gnu")
40- run("make")
62+ "--disable-multilib", "--enable-libctf", "--enable-shared", "--enable-plugins", "--enable-install-libiberty", "--enable-64-bit-bfd",
63+ "--enable-deterministic-archives", "--enable-colored-disassembly", "--enable-default-execstack=no",
64+ "--enable-threads", "--with-pic", "--with-mmap", "--enable-new-dtags", "--enable-relro", "--enable-default-hash-style=gnu"), formats))
65+ ; Binutils configures its subdirectories during make. Use the same SDK
66+ ; pkg-config paths that vinix-configure sets for the top-level script.
67+ root := get-environment-variable("VPAC_MAKEPKG_ROOT")
68+ run("env", string-append("PKG_CONFIG_SYSROOT_DIR=", root),
69+ string-append("PKG_CONFIG_LIBDIR=", root, "/usr/lib/pkgconfig:", root, "/usr/share/pkgconfig"),
70+ "PKG_CONFIG_PATH=", "make")
4171 },
4272 #:check, fn() {
43- for-each(fn(tool) { run("vinix-run", tool, "--version") }, list("gas/as-new", "ld/ld-new", "binutils/objdump"))
73+ call-with-output-file("debug-fixture.c", fn(port) { display("struct record { int number; };\nint twice(struct record r) { return r.number * 2; }\n", port) })
74+ run("vinix-cc", "-gdwarf-4", "-gsplit-dwarf", "-c", "debug-fixture.c", "-o", "fixture.o")
75+ check-tool("gold", "dwp", list("fixture.dwo", "-o", "fixture.dwp"))
76+ check-tool("binutils", "objcopy", list("--dump-section", ".debug_cu_index=fixture.index", "fixture.dwp"))
77+ run("test", "-s", "fixture.index")
78+ run("vinix-cc", "-gctf", "-c", "debug-fixture.c", "-o", "ctf.o")
79+ check-tool("binutils", "objdump", list("--ctf=.ctf", "ctf.o"))
80+ check-tool("binutils", "objcopy", list("--compress-debug-sections=zstd", "fixture.o", "compressed.o"))
81+ if string=?(arch, "x86_64") {
82+ call-with-output-file("pe-start.s", fn(port) { display(".text\n.globl _start\n_start:\n xorl %eax, %eax\n ret\n", port) })
83+ for-each(fn(bits, format, emulation) {
84+ check-tool("gas", "as-new", list(string-append("--", bits), "-o", "pe-start.o", "pe-start.s"))
85+ check-tool("binutils", "objcopy", list("-O", format, "pe-start.o", "pe-start.obj"))
86+ script := string-append("ld/ldscripts/", emulation, ".x")
87+ check-tool("ld", "ld-new", list("-m", emulation, "-T", script, "--entry", "_start", "-o", "pe-start.exe", "pe-start.obj"))
88+ check-tool("binutils", "objdump", list("-f", "pe-start.exe"))
89+ }, list("32", "64"), list("pe-i386", "pe-x86-64"), list("i386pe", "i386pep"))
90+ } else {
91+ call-with-output-file("abi-start.s", fn(port) { display(".text\n.global _start\n_start:\n mov x0, #0\n mov x8, #93\n svc #0\n", port) })
92+ check-tool("gas", "as-new", list("-o", "abi-start.o", "abi-start.s"))
93+ for-each(fn(dir, name) {
94+ check-tool(dir, name, list("-o", "abi-start", "abi-start.o"))
95+ run("vinix-elf-pages", "aarch64", "abi-start")
96+ }, list("ld", "gold"), list("ld-new", "ld-new"))
97+ }
4498 },
4599 #:package, fn() {
46100 run("make", string-append("DESTDIR=", pkgdir()), "install")
47101 run("rm", "-f", string-append(pkgdir(), "/usr/share/info/dir"))
48102 for-each(fn(la) { run("rm", la) }, glob(string-append(pkgdir(), "/usr/lib/*.la")))
103+ for-each(fn(lib) { run("test", "-f", string-append(pkgdir(), "/usr/lib/", lib)) },
104+ list("bfd-plugins/libdep.so", "libbfd-2.43.1.so", "libctf-nobfd.so.0", "libctf-nobfd.so.0.0.0", "libctf.so.0", "libctf.so.0.0.0",
105+ "libopcodes-2.43.1.so", "libsframe.so.1", "libsframe.so.1.0.0"))
106+ run("test", "-x", string-append(pkgdir(), "/usr/bin/dwp"))
107+ if string=?(arch, "x86_64") {
108+ for-each(fn(emulation) {
109+ for-each(fn(suffix) { run("test", "-s", string-append(pkgdir(), "/usr/x86_64-linux-musl/lib/ldscripts/", emulation, suffix)) },
110+ list(".x", ".xa", ".xbn", ".xe", ".xer", ".xn", ".xr", ".xu"))
111+ }, list("i386pe", "i386pep"))
112+ }
49113 run("install", "-Dm644", "binutils-2.43.1/COPYING3", string-append(pkgdir(), "/usr/share/licenses/binutils/COPYING3"))
50114 })