Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 517160 - sys-libs/uclibc: PIEs on ppc crash
Summary: sys-libs/uclibc: PIEs on ppc crash
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: uclibc-porting
  Show dependency tree
 
Reported: 2014-07-15 14:32 UTC by Anthony Basile
Modified: 2022-01-02 10:25 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Full build.log for completeness (build.log,20.38 KB, text/plain)
2014-07-15 14:34 UTC, Anthony Basile
Details
config log (config.log,643.00 KB, text/plain)
2014-11-28 21:21 UTC, Anthony Basile
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Anthony Basile gentoo-dev 2014-07-15 14:32:52 UTC
For reasons I have not yet figured out, openssh's configure script fails to find the the openssl headers.  This happens only on uclibc and only on ppc.  Here's the last lines of the configure log:

checking for utmpxname... yes
checking for getlastlogxbyname... no
checking for daemon... yes
checking for getpagesize... yes
checking whether snprintf correctly terminates long strings... no
configure: WARNING: ****** Your snprintf() function is broken, complain to your vendor
checking whether snprintf can declare const char *fmt... yes
checking whether system supports SO_PEERCRED getsockopt... yes
checking for (overly) strict mkstemp... yes
checking if openpty correctly handles controlling tty... no
checking whether getpgrp requires zero arguments... yes
checking OpenSSL header version... not found
configure: error: OpenSSL version header not found.



Reproducible: Always
Comment 1 Anthony Basile gentoo-dev 2014-07-15 14:34:33 UTC
Created attachment 380750 [details]
Full build.log for completeness
Comment 2 SpanKY gentoo-dev 2014-08-03 14:23:59 UTC
really we need the config.log.  that error message is weird.
Comment 3 Anthony Basile gentoo-dev 2014-11-28 21:21:21 UTC
Created attachment 390514 [details]
config log

It looks like two errors but its really just one:

1) configure: WARNING: ****** Your snprintf() function is broken, complain to your vendor.

This is due to pie:

timberdoodle openssh-6.6p1 # cat conftest.c 
#include <stdio.h>
#include <stdlib.h>
int
main ()
{

      char b[5];
      snprintf(b,5,"123456789");
      exit(b[4]!='\0');

  ;
  return 0;
}
timberdoodle openssh-6.6p1 # gcc  -o conftest conftest.c 
timberdoodle openssh-6.6p1 # ./conftest 
timberdoodle openssh-6.6p1 # gcc -fPIE -pie  -o conftest conftest.c 
timberdoodle openssh-6.6p1 # ./conftest 
Segmentation fault
timberdoodle openssh-6.6p1 # gcc -fPIE -pie  -o conftest conftest.c -ggdb
timberdoodle openssh-6.6p1 # gdb ./conftest
GNU gdb (Gentoo 7.7.1 p1) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "powerpc-gentoo-linux-uclibc".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./conftest...done.
(gdb) run
Starting program: /var/tmp/portage/net-misc/openssh-6.6_p1-r1/work/openssh-6.6p1/conftest 

Program received signal SIGSEGV, Segmentation fault.
0x207288e0 in 00000000.plt_pic32.__uClibc_main ()
(gdb) bt
#0  0x207288e0 in 00000000.plt_pic32.__uClibc_main ()
#1  0x00000000 in ?? ()


2) configure: error: OpenSSL version header not found.

The conftest.c setfaults as above and configure thinks a header is missing.
Comment 4 SpanKY gentoo-dev 2015-03-22 05:37:36 UTC
looks like PIE is broken on ppc/uclibc.  openssh respects the USE=pie flag, so it could be masked in the uclibc profile to unblock this.  either way, not an openssh bug.
Comment 5 Anthony Basile gentoo-dev 2015-03-22 10:44:02 UTC
(In reply to SpanKY from comment #4)
> looks like PIE is broken on ppc/uclibc.  openssh respects the USE=pie flag,
> so it could be masked in the uclibc profile to unblock this.  either way,
> not an openssh bug.

Yes of course.  I should have changed the title to reflect that.  Looks like the problem is in the plt, probably some bad address due to a problem in linking.
Comment 6 Joakim Tjernlund 2015-08-12 04:06:25 UTC
(In reply to Anthony Basile from comment #5)
> (In reply to SpanKY from comment #4)
> > looks like PIE is broken on ppc/uclibc.  openssh respects the USE=pie flag,
> > so it could be masked in the uclibc profile to unblock this.  either way,
> > not an openssh bug.
> 
> Yes of course.  I should have changed the title to reflect that.  Looks like
> the problem is in the plt, probably some bad address due to a problem in
> linking.

Stumbled over this bug from your blog :)

As I have hacked alot uclibc ldso/crt1.S for ppc32 many years ago I could not
resist having a look :)

From just browsing the uClibc crt1.S I suspect that ppc32 can only do
-fpie, not -fPIE. Could you test?

Also, ppc32 generally works well with -fpic(smaller and faster code).
Comment 7 Anthony Basile gentoo-dev 2015-08-12 20:38:13 UTC
(In reply to Joakim Tjernlund from comment #6)
> (In reply to Anthony Basile from comment #5)
> > (In reply to SpanKY from comment #4)
> > > looks like PIE is broken on ppc/uclibc.  openssh respects the USE=pie flag,
> > > so it could be masked in the uclibc profile to unblock this.  either way,
> > > not an openssh bug.
> > 
> > Yes of course.  I should have changed the title to reflect that.  Looks like
> > the problem is in the plt, probably some bad address due to a problem in
> > linking.
> 
> Stumbled over this bug from your blog :)
> 
> As I have hacked alot uclibc ldso/crt1.S for ppc32 many years ago I could not
> resist having a look :)
> 
> From just browsing the uClibc crt1.S I suspect that ppc32 can only do
> -fpie, not -fPIE. Could you test?
> 
> Also, ppc32 generally works well with -fpic(smaller and faster code).

Any combination  of -fpie or -fPIE or -fpic or -fPIE with -pie fails in the same way:

# gcc -fpie -pie -o conftest conftest.c
# ./conftest 
Segmentation fault

If it makes a difference, I'm building uclibc-0.9.33.2 with the following config file:

https://gitweb.gentoo.org/proj/releng.git/tree/tools-uclibc/portage.ppc.vanilla/savedconfig/sys-libs/uclibc
Comment 8 Joakim Tjernlund 2015-08-13 07:12:27 UTC
(In reply to Anthony Basile from comment #7)
> (In reply to Joakim Tjernlund from comment #6)
> > (In reply to Anthony Basile from comment #5)
> > > (In reply to SpanKY from comment #4)
> > > > looks like PIE is broken on ppc/uclibc.  openssh respects the USE=pie flag,
> > > > so it could be masked in the uclibc profile to unblock this.  either way,
> > > > not an openssh bug.
> > > 
> > > Yes of course.  I should have changed the title to reflect that.  Looks like
> > > the problem is in the plt, probably some bad address due to a problem in
> > > linking.
> > 
> > Stumbled over this bug from your blog :)
> > 
> > As I have hacked alot uclibc ldso/crt1.S for ppc32 many years ago I could not
> > resist having a look :)
> > 
> > From just browsing the uClibc crt1.S I suspect that ppc32 can only do
> > -fpie, not -fPIE. Could you test?
> > 
> > Also, ppc32 generally works well with -fpic(smaller and faster code).
> 
> Any combination  of -fpie or -fPIE or -fpic or -fPIE with -pie fails in the
> same way:
> 
> # gcc -fpie -pie -o conftest conftest.c
> # ./conftest 
> Segmentation fault
> 
> If it makes a difference, I'm building uclibc-0.9.33.2 with the following
> config file:
> 
> https://gitweb.gentoo.org/proj/releng.git/tree/tools-uclibc/portage.ppc.
> vanilla/savedconfig/sys-libs/uclibc

Bugger , I was hoping for something simple.

Could you just check if HAVE_ASM_PPC_REL16 is still defined when compling crt1.S
in http://git.uclibc.org/uClibc/tree/libc/sysdeps/linux/powerpc/crt1.S?h=0.9.33

If still so set a breakpoint on __uClibc_main to see if the app makes it that far before SEGV.
Comment 9 David Seifert gentoo-dev 2022-01-02 10:25:30 UTC
uclibc support in Gentoo has been removed.