* PIC/PIE issue on Nios2
@ 2021-05-27 22:21 Romain Naour
2021-05-28 8:01 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Romain Naour @ 2021-05-27 22:21 UTC (permalink / raw)
To: GNU C Library
Hello,
The Buildroot project now generate Position-Independent Code (PIC) and link
Position-Independent Executables (PIE) by default.
This add -fPIE or -pie flag at compile/link time while building the toolchain
and the rootfs.
On Nios2 architecture this produce non working executable crashing the system
while starting the init process.
Run /init as init process
with arguments:
/init
with environment:
HOME=/
TERM=linux
Failed to execute /init (error -12)
See: Buildroot build log and Qemu runtime test log in build artifacts:
https://gitlab.com/buildroot.org/buildroot/-/jobs/1285145889
Analyzing one of the binary with strace show that the problem occur
very early when starting the new process:
# strace ./busybox
execve("./busybox", ["./busybox"], 0x7f91ce90 /* 10 vars */) = -1 ENOMEM
(Cannot allocate memory)
+++ killed by SIGSEGV +++
I tried with several binutils/glibc/gcc version without any success.
Is PIE is really supported for Nios2 architecture ?
Best regards,
Romain
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PIC/PIE issue on Nios2
2021-05-27 22:21 PIC/PIE issue on Nios2 Romain Naour
@ 2021-05-28 8:01 ` Florian Weimer
2021-06-06 9:56 ` Romain Naour
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2021-05-28 8:01 UTC (permalink / raw)
To: Romain Naour via Libc-alpha
* Romain Naour via Libc-alpha:
> Analyzing one of the binary with strace show that the problem occur
> very early when starting the new process:
>
> # strace ./busybox
> execve("./busybox", ["./busybox"], 0x7f91ce90 /* 10 vars */) = -1 ENOMEM
> (Cannot allocate memory)
> +++ killed by SIGSEGV +++
>
> I tried with several binutils/glibc/gcc version without any success.
>
> Is PIE is really supported for Nios2 architecture ?
If the kernel cannot execve the executable at all, that looks more like
a linker problem. It could also be a kernel bug, of course. (Address
space layout is architecture-specific.)
There is PIE and statically linked PIE. The latter should be supported
on all targets. Statically linked PIE requires toolchain changes and a
little bit of architecture-specific code in glibc.
Thanks,
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PIC/PIE issue on Nios2
2021-05-28 8:01 ` Florian Weimer
@ 2021-06-06 9:56 ` Romain Naour
0 siblings, 0 replies; 3+ messages in thread
From: Romain Naour @ 2021-06-06 9:56 UTC (permalink / raw)
To: Florian Weimer, Romain Naour via Libc-alpha
Hello,
Le 28/05/2021 à 10:01, Florian Weimer a écrit :
> * Romain Naour via Libc-alpha:
>
>> Analyzing one of the binary with strace show that the problem occur
>> very early when starting the new process:
>>
>> # strace ./busybox
>> execve("./busybox", ["./busybox"], 0x7f91ce90 /* 10 vars */) = -1 ENOMEM
>> (Cannot allocate memory)
>> +++ killed by SIGSEGV +++
>>
>> I tried with several binutils/glibc/gcc version without any success.
>>
>> Is PIE is really supported for Nios2 architecture ?
>
> If the kernel cannot execve the executable at all, that looks more like
> a linker problem. It could also be a kernel bug, of course. (Address
> space layout is architecture-specific.)
>
> There is PIE and statically linked PIE. The latter should be supported
> on all targets. Statically linked PIE requires toolchain changes and a
> little bit of architecture-specific code in glibc.
I don't know about the status of required toolchain changes for statically
linked PIE for NiosII. The statically linked PIE option (--enable-static-pie) is
not used to build the toolchain so (as you said) it look like a linker problem
or kernel bug.
I tried with the latest kernel version without success.
For now, the PIC/PIE Buildroot option has been disabled for NiosII.
Best regards,
Romain
>
> Thanks,
> Florian
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-06 9:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 22:21 PIC/PIE issue on Nios2 Romain Naour
2021-05-28 8:01 ` Florian Weimer
2021-06-06 9:56 ` Romain Naour
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).