From 86c0be5b675c90717b3a3704e6d53202fc458cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20S=C3=A1nchez=20Mu=C3=B1oz?= Date: Fri, 14 Apr 2023 18:59:25 +0200 Subject: [PATCH] Fix tcc crash when building lwext4 in chroot/bwrap Fixes https://github.com/fosslinux/live-bootstrap/issues/281. This is adding a null pointer check to `fill_local_got_entries` in tcc 0.9.27. This is rather a workaround because I am not sure if it is legit for that pointer to be null. --- sysa/tcc-0.9.27/simple-patches/check-reloc-null.after | 6 ++++++ sysa/tcc-0.9.27/simple-patches/check-reloc-null.before | 4 ++++ sysa/tcc-0.9.27/tcc-0.9.27.checksums | 2 +- sysa/tcc-0.9.27/tcc-0.9.27.kaem | 3 +++ 4 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 sysa/tcc-0.9.27/simple-patches/check-reloc-null.after create mode 100644 sysa/tcc-0.9.27/simple-patches/check-reloc-null.before diff --git a/sysa/tcc-0.9.27/simple-patches/check-reloc-null.after b/sysa/tcc-0.9.27/simple-patches/check-reloc-null.after new file mode 100644 index 0000000..86d63cf --- /dev/null +++ b/sysa/tcc-0.9.27/simple-patches/check-reloc-null.after @@ -0,0 +1,6 @@ +static void fill_local_got_entries(TCCState *s1) +{ + ElfW_Rel *rel; + if (!s1->got->reloc) + return; + for_each_elem(s1->got->reloc, 0, rel, ElfW_Rel) { diff --git a/sysa/tcc-0.9.27/simple-patches/check-reloc-null.before b/sysa/tcc-0.9.27/simple-patches/check-reloc-null.before new file mode 100644 index 0000000..af9bb3f --- /dev/null +++ b/sysa/tcc-0.9.27/simple-patches/check-reloc-null.before @@ -0,0 +1,4 @@ +static void fill_local_got_entries(TCCState *s1) +{ + ElfW_Rel *rel; + for_each_elem(s1->got->reloc, 0, rel, ElfW_Rel) { diff --git a/sysa/tcc-0.9.27/tcc-0.9.27.checksums b/sysa/tcc-0.9.27/tcc-0.9.27.checksums index c19c5a0..e9ed11d 100644 --- a/sysa/tcc-0.9.27/tcc-0.9.27.checksums +++ b/sysa/tcc-0.9.27/tcc-0.9.27.checksums @@ -1 +1 @@ -5cd0428fdcb9dc579cdf496a4fd974c4d2a941f76f2ce2049a1c2ff477f64002 /usr/bin/tcc +e5f00ef66c5796f436089d3f6e67af001182e6fbb439d13bb65eef8cf82f5973 /usr/bin/tcc diff --git a/sysa/tcc-0.9.27/tcc-0.9.27.kaem b/sysa/tcc-0.9.27/tcc-0.9.27.kaem index c857591..cb41d4e 100755 --- a/sysa/tcc-0.9.27/tcc-0.9.27.kaem +++ b/sysa/tcc-0.9.27/tcc-0.9.27.kaem @@ -26,6 +26,9 @@ untar --file ../src/${pkg}.tar /sysa/tcc-0.9.27/simple-patches/addback-fileopen.before /sysa/tcc-0.9.27/simple-patches/addback-fileopen.after /x86/bin/simple-patch /sysa/tcc-0.9.27/build/tcc-0.9.27/tccelf.c \ /sysa/tcc-0.9.27/simple-patches/fiwix-paddr.before /sysa/tcc-0.9.27/simple-patches/fiwix-paddr.after +# Fix SIGSEGV while building lwext4 +/x86/bin/simple-patch /sysa/tcc-0.9.27/build/tcc-0.9.27/tccelf.c \ + /sysa/tcc-0.9.27/simple-patches/check-reloc-null.before /sysa/tcc-0.9.27/simple-patches/check-reloc-null.after untar --non-strict --file ../src/${MES_PKG}.tar cd ${pkg}