fwupd / fwupd-efi

EFI Application used by uefi-capsule plugin in fwupd
GNU Lesser General Public License v2.1
41 stars 20 forks source link

aarch64 build of 1.5 FTBFS #56

Closed superm1 closed 7 months ago

superm1 commented 7 months ago

Hoping for some insight on this build failure.
This is 1.5 compiled against gnu-efi 3.0.18 in Debian. All the other architectures work. It also "worked" to compile against 3.0.15, it's just the upgrade to 3.0.18 that causes an issue.

Found ninja-1.11.1 at /usr/bin/ninja
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
   dh_auto_build -a
dh_auto_build: warning: Use of debian/compat is deprecated and will be removed in debhelper (>= 14~).
    cd obj-aarch64-linux-gnu && LC_ALL=C.UTF-8 ninja -j4 -v
[1/7] /usr/bin/cc -c ../efi/fwup-efi.c -o efi/fwup-efi.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fpic -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[2/7] /usr/bin/cc -c ../efi/fwup-debug.c -o efi/fwup-debug.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fpic -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[3/7] /usr/bin/cc -c ../efi/fwup-common.c -o efi/fwup-common.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fpic -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[4/7] /usr/bin/cc -c ../efi/fwupdate.c -o efi/fwupdate.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fpic -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[5/7] /<<PKGBUILDDIR>>/efi/generate_sbat.py efi/fwup-sbat.o --cc cc --cflags '-Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fpic -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches -DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug" -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants' --objcopy /usr/bin/objcopy --project-name fwupd-efi --project-version 1.5 --sbat-version 1 --sbat-generation 1 --sbat-distro-id debian --sbat-distro-generation 0 --sbat-distro-summary Debian --sbat-distro-pkgname fwupd --sbat-distro-version 1:1.5-2 --sbat-distro-url https://tracker.debian.org/pkg/fwupd
[6/7] /usr/bin/cc -nostdlib -o efi/fwup.so -Wl,-T -Wl,/<<PKGBUILDDIR>>/efi/lds/elf_aarch64_efi.lds -Wl,-shared -Wl,-Bsymbolic -Wl,-nostdlib -Wl,-znocombreloc -Wl,-L -Wl,/usr/lib/../lib -Wl,-L -Wl,/usr/lib/../lib -Wl,/usr/lib/../lib/crt0-efi-aarch64.o -Wl,-z -Wl,common-page-size=4096 -Wl,-z -Wl,max-page-size=4096 efi/fwupdate.o efi/fwup-debug.o efi/fwup-efi.o efi/fwup-common.o efi/fwup-sbat.o -lefi -lgnuefi /usr/lib/gcc/aarch64-linux-gnu/13/libgcc.a
FAILED: efi/fwup.so 
/usr/bin/cc -nostdlib -o efi/fwup.so -Wl,-T -Wl,/<<PKGBUILDDIR>>/efi/lds/elf_aarch64_efi.lds -Wl,-shared -Wl,-Bsymbolic -Wl,-nostdlib -Wl,-znocombreloc -Wl,-L -Wl,/usr/lib/../lib -Wl,-L -Wl,/usr/lib/../lib -Wl,/usr/lib/../lib/crt0-efi-aarch64.o -Wl,-z -Wl,common-page-size=4096 -Wl,-z -Wl,max-page-size=4096 efi/fwupdate.o efi/fwup-debug.o efi/fwup-efi.o efi/fwup-common.o efi/fwup-sbat.o -lefi -lgnuefi /usr/lib/gcc/aarch64-linux-gnu/13/libgcc.a
/usr/bin/ld: /usr/lib/../lib/crt0-efi-aarch64.o: relocation R_AARCH64_ADR_PREL_LO21 against symbol `ImageBase' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/lib/../lib/crt0-efi-aarch64.o: in function `_start':
./aarch64/gnuefi/.//gnuefi/crt0-efi-aarch64.S:31:(.text+0x14): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status

https://buildd.debian.org/status/fetch.php?pkg=fwupd-efi&arch=arm64&ver=1%3A1.5-2&stamp=1711577011&raw=0

Does Fedora or OpenSUSE compile gnu-efi differently?

superm1 commented 7 months ago

I guess it worked on 3.0.15 but fails on 3.0.18 because of https://sourceforge.net/p/gnu-efi/code/ci/368cdf1265372d46c6f66900419432059f93c125/ @vathpela how is this not splodey in Fedora aarch64?

superm1 commented 7 months ago

Also I noticed that we use -fpic in fwupd-efi. Should we be consistent with twhat gnu-efi used? https://github.com/fwupd/fwupd-efi/blob/main/efi/meson.build#L171`

vathpela commented 7 months ago

No idea. It must have worked at the time, but so many things were broken on that platform before the objcopy target change that I considered it completely broken.

hughsie commented 7 months ago

how is this not splodey in Fedora aarch64?

The new gnu-efi update isn't stable, so it's not in the buildroot yet. I suspect we'll have the same problem...

superm1 commented 7 months ago

I did experiment with switching fwupd-efi over to use -fPIE and it still fails.

    cd obj-aarch64-linux-gnu && LC_ALL=C.UTF-8 ninja -j12 -v
[1/7] /usr/bin/cc -c ../efi/fwup-efi.c -o efi/fwup-efi.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fPIE -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[2/7] /usr/bin/cc -c ../efi/fwup-debug.c -o efi/fwup-debug.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fPIE -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[3/7] /usr/bin/cc -c ../efi/fwup-common.c -o efi/fwup-common.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fPIE -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[4/7] /usr/bin/cc -c ../efi/fwupdate.c -o efi/fwupdate.o -Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fPIE -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches '-DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug"' -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants
[5/7] /fwupd-efi/efi/generate_sbat.py efi/fwup-sbat.o --cc cc --cflags '-Og -g3 --param=ssp-buffer-size=4 -fexceptions -Wall -Wextra -Wvla -std=gnu11 -fPIE -funsigned-char -fshort-wchar -ffreestanding -fno-strict-aliasing -fno-stack-protector -fno-stack-check -fno-merge-all-constants -Wsign-compare -Wno-missing-field-initializers -Wno-address-of-packed-member -grecord-gcc-switches -DDEBUGDIR="/usr/lib/aarch64-linux-gnu/debug" -I. -isystem /usr/include/efi -isystem /usr/include/efi/aarch64 -fno-merge-constants' --objcopy /usr/bin/objcopy --project-name fwupd-efi --project-version 1.5 --sbat-version 1 --sbat-generation 1 --sbat-distro-id debian --sbat-distro-generation 0 --sbat-distro-summary Debian --sbat-distro-pkgname fwupd --sbat-distro-version 1:1.5-2 --sbat-distro-url https://tracker.debian.org/pkg/fwupd
[6/7] /usr/bin/cc -nostdlib -o efi/fwup.so -Wl,-T -Wl,/fwupd-efi/efi/lds/elf_aarch64_efi.lds -Wl,-shared -Wl,-Bsymbolic -Wl,-nostdlib -Wl,-znocombreloc -Wl,-L -Wl,/usr/lib/../lib -Wl,-L -Wl,/usr/lib/../lib -Wl,/usr/lib/../lib/crt0-efi-aarch64.o -Wl,-z -Wl,common-page-size=4096 -Wl,-z -Wl,max-page-size=4096 efi/fwupdate.o efi/fwup-debug.o efi/fwup-efi.o efi/fwup-common.o efi/fwup-sbat.o -lefi -lgnuefi /usr/lib/gcc/aarch64-linux-gnu/13/libgcc.a
FAILED: efi/fwup.so 
/usr/bin/cc -nostdlib -o efi/fwup.so -Wl,-T -Wl,/fwupd-efi/efi/lds/elf_aarch64_efi.lds -Wl,-shared -Wl,-Bsymbolic -Wl,-nostdlib -Wl,-znocombreloc -Wl,-L -Wl,/usr/lib/../lib -Wl,-L -Wl,/usr/lib/../lib -Wl,/usr/lib/../lib/crt0-efi-aarch64.o -Wl,-z -Wl,common-page-size=4096 -Wl,-z -Wl,max-page-size=4096 efi/fwupdate.o efi/fwup-debug.o efi/fwup-efi.o efi/fwup-common.o efi/fwup-sbat.o -lefi -lgnuefi /usr/lib/gcc/aarch64-linux-gnu/13/libgcc.a
/usr/bin/ld: /usr/lib/../lib/crt0-efi-aarch64.o: relocation R_AARCH64_ADR_PREL_LO21 against symbol `ImageBase' which may bind externally can not be used when making a shared object; recompile with -fPIC
/usr/lib/../lib/crt0-efi-aarch64.o: in function `_start':
./aarch64/gnuefi/.//gnuefi/crt0-efi-aarch64.S:31:(.text+0x14): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
dh_auto_build: error: cd obj-aarch64-linux-gnu && LC_ALL=C.UTF-8 ninja -j12 -v returned exit code 1
make: *** [debian/rules:36: build] Error 255

So I guess the only real option is to recompile gnu-efi with -fpic instead of -fPIE.

superm1 commented 7 months ago

Nope; that doesn't work either.

superm1 commented 7 months ago

CC @gmbr3

gmbr3 commented 7 months ago

It looks like system crt0 with local lds which will not work (intended for local crt0) ImageBase will move hence the relocation in text

It may be detected better after the changes, which I guess is what's going on

hughsie commented 7 months ago

IIUC we only need the local crt0 for sbat and sbom. I'm trying to move the SBAT upstream but ran out out of time before easter. I'll continue after the break -- but in the meantime maybe we should just ship the lds in fwupd-efi too.

superm1 commented 7 months ago

IIUC we only need the local crt0 for sbat and sbom.

I guess we really should rely on local CRT0 for now then and only pair system CRT0 with system LDS and local with local?

gmbr3 commented 7 months ago

IIUC we only need the local crt0 for sbat and sbom.

I guess we really should rely on local CRT0 for now then and only pair system CRT0 with system LDS and local with local?

Yep makes the most sense Having a project CRT0, seperate from gnu-efi is an intended use case as users of gnu-efi have different requirements, and empty sections used to be bugged as I mentioned on gnu-efi mailing list (maybe fixed?)

superm1 commented 7 months ago

As of https://github.com/fwupd/fwupd-efi/commit/a00ec01df79e1ccae1a01d34660e0397c75d65f4 it's working now.