Hardening on x86-64, ppc64le makes a broken executable

Summary

EDIT : Initially reported as affecting PPC64, I now realise its Intel/AMD and ARM as well. Post further down has details.

EDIT : As noted below, this is a two part thing, firstly, on PPC64le, its a definite confirmed bug. But that also exposed a lesser problem on other platforms, hardening does not work with a static binary, maybe its a documentation issue, maybe a new switch is needed that ensures a request for hardening also ensures dynamic linking.

Debian powerpc64el compiling with " -Cg -k-pie -k-znow " makes a non viable binary.

System Information

Debian Bookworm running in a qemu emulator of powerpc64le (note debian says 'el' instead of 'le'). Underlying system x86-64 Linux.

FPC 3.2.2 form a tarball.

Steps to reproduce

Build a powerpc64el vm, install a netinstall of Debian Bookworm -

$> wget http://d-i.debian.org/daily-images/ppc64el/daily/netboot/mini.iso
$> qemu-img create -f qcow ppc64el-base.qcow 15G
$> qemu-system-ppc64le  -machine pseries-2.12  -m 4096 -boot d  -net nic -net user -hda ppc64el-base.qcow -cdrom mini.iso

Last step is seriously slow !

Then install the appropriate FPC tarball and make a minimal helloworld with and without the " -Cg -k-pie -k-znow " options.

Example Project

not needed.

What is the current bug behavior?

When fpc is given the hardening switches, it compiles fine, the resulting binary is shown by the 'file' command as being "pie" but bash cannot even find the executable (??). It does not complain about the executable being wrong, it says its not there !

My application, a medium Lazarus one, the OS tries to run the binary but it segfaults.

What is the expected (correct) behavior?

The same hello world app (and my app) without the hardening commands runs as expected.

Relevant logs and/or screenshots

Possible fixes

Its unclear to me whether the Intel/Arm hardening is even supposed to work with Power but the compiler accepts the switches.

Edited Jan 04, 2022 by dbannon
Assignee Loading
Time tracking Loading