Skip to content

Commit

Permalink
syslinux: apply patches to fix pointer mismatch (NixOS#368469)
Browse files Browse the repository at this point in the history
  • Loading branch information
K900 authored Dec 27, 2024
2 parents 26b95a4 + 3008b70 commit e6bc4f7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 74 deletions.
22 changes: 22 additions & 0 deletions pkgs/by-name/sy/syslinux/fix-longjmp-calls.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/efi/main.c b/efi/main.c
index 6a748412..a914e31a 100644
--- a/efi/main.c
+++ b/efi/main.c
@@ -187,7 +187,7 @@ __export void local_boot(uint16_t ax)
* Inform the firmware that we failed to execute correctly, which
* will trigger the next entry in the EFI Boot Manager list.
*/
- longjmp(&load_error_buf, 1);
+ longjmp(load_error_buf, 1);
}

void bios_timer_cleanup(void)
@@ -1385,7 +1385,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table)
status = uefi_call_wrapper(in->ReadKeyStroke, 2, in, &key);
} while (status == EFI_SUCCESS);

- if (!setjmp(&load_error_buf))
+ if (!setjmp(load_error_buf))
load_env32(NULL);

/* load_env32() failed.. cancel timer and bailout */
33 changes: 0 additions & 33 deletions pkgs/by-name/sy/syslinux/gcc10.patch

This file was deleted.

61 changes: 20 additions & 41 deletions pkgs/by-name/sy/syslinux/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
stdenv,
fetchFromRepoOrCz,
gnu-efi,
fetchurl,
fetchpatch,
libuuid,
makeWrapper,
Expand All @@ -28,51 +27,34 @@ stdenv.mkDerivation {

patches =
let
fetchDebianPatch =
name: commit: hash:
fetchurl {
url = "https://salsa.debian.org/images-team/syslinux/raw/" + commit + "/debian/patches/" + name;
inherit name hash;
};
archlinuxCommit = "db7884ec80642781edeead3e3bbd883a15b9b3ce";
fetchArchlinuxPatch =
name: commit: hash:
fetchurl {
url = "https://raw.githubusercontent.com/archlinux/svntogit-packages/" + commit + "/trunk/" + name;
name: hash:
fetchpatch {
url = "https://gitlab.archlinux.org/archlinux/packaging/packages/syslinux/-/raw/${archlinuxCommit}/${name}";
inherit name hash;
};
in
[
./gcc10.patch
(fetchDebianPatch "0002-gfxboot-menu-label.patch" "fa1349f1"
"sha256-0f6QhM4lJmGflLige4n7AZTodL7vnyAvi5dIedd/Lho="
)
(fetchArchlinuxPatch "0005-gnu-efi-version-compatibility.patch"
"821c3da473d1399d930d5b4a086e46a4179eaa45"
"sha256-hhCVnfbAFWj/R4yh60qsMB87ofW9RznarsByhl6L4tc="
)
(fetchArchlinuxPatch "0025-reproducible-build.patch" "821c3da473d1399d930d5b4a086e46a4179eaa45"
"sha256-mnb291pCSFvDNxY7o4BosJ94ib3BpOGRQIiY8Q3jZmI="
)
(fetchDebianPatch
# mbr.bin: too big (452 > 440)
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=906414
"0016-strip-gnu-property.patch"
"7468ef0e38c43"
"sha256-lW+E6THuXlTGvhly0f/D9NwYHhkiKHot2l+bz9Eaxp4="
)
(fetchDebianPatch
# mbr.bin: too big (452 > 440)
"0017-single-load-segment.patch"
"012e1dd312eb"
"sha256-C6VmdlTs1blMGUHH3OfOlFBZsfpwRn9vWodwqVn8+Cs="
)
(fetchDebianPatch "0018-prevent-pow-optimization.patch" "26f0e7b2"
"sha256-dVzXBi/oSV9vYgU85mRFHBKuZdup+1x1BipJX74ED7E="
)
(fetchArchlinuxPatch "0002-gfxboot-menu-label.patch" "sha256-eoId3jn4eRxItil5naoGMBGOJM/p5FG74ePwxiJ0w/8=")
(fetchArchlinuxPatch "0005-gnu-efi-version-compatibility.patch" "sha256-5oZ/24emWNPHx621v/9i2xU6rodpVCM0R18hCU35eDk=")
(fetchArchlinuxPatch "0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch" "sha256-aq2vKqGonhMI2gRrAYNe+VRD8Vwijn7kOOv5wqAncx8=")
# mbr.bin: too big (452 > 440)
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=906414
(fetchArchlinuxPatch "0016-strip-gnu-property.patch" "sha256-gn69YHbObqg6uTLPTtu8otNBFuCSyazwxLW3FbTNLX4=")
# mbr.bin: too big (452 > 440)
(fetchArchlinuxPatch "0017-single-load-segment.patch" "sha256-pGDcP62k50YkGgP0pFp5NSe7X0sojfLCzTmJtba2Yww=")
# Fixes build with "modern" gnu-efi
(fetchArchlinuxPatch "0018-prevent-pow-optimization.patch" "sha256-1+u8Kb6bxRbTPm0QCCt4yViLozzD/+/yspkJasOFM+g=")
(fetchArchlinuxPatch "0025-reproducible-build.patch" "sha256-vhth9CFHqChPQPgGhUWVpYwMFnnjoMVIGr7Wfu1jcDY=")
(fetchArchlinuxPatch "0027-use-correct-type-for-size.patch" "sha256-5nlKwIbXpZEyBrBSq9Zg0D+PRF7/kzEG13WzpwzDpPA=")

./import-efisetjmp.patch
# Upstream patch: https://www.syslinux.org/archives/2024-February/026903.html
./define-wchar_t.patch
# gnu-efi changed their definition to already be a 1-elem array, don't double-ref it.
# https://github.com/ncroxon/gnu-efi/commit/5b74db0e154ffd2fba4bcc254069844f21913988
./fix-longjmp-calls.patch
];

postPatch = ''
Expand Down Expand Up @@ -115,10 +97,7 @@ stdenv.mkDerivation {
# gcc-10. Otherwise build fails as:
# ld: acpi/xsdt.o:/build/syslinux-b404870/com32/gpllib/../gplinclude/memory.h:40: multiple definition of
# `e820_types'; memory.o:/build/syslinux-b404870/com32/gpllib/../gplinclude/memory.h:40: first defined here
# and with gcc14+ also:
# /build/source/com32/chain/chain.c:517:44:
# error: passing argument 3 of 'loadfile' from incompatible pointer type
env.NIX_CFLAGS_COMPILE = "-fcommon -Wno-error=incompatible-pointer-types";
env.NIX_CFLAGS_COMPILE = "-fcommon";

makeFlags =
[
Expand Down

0 comments on commit e6bc4f7

Please sign in to comment.