Bug 9251

Summary: Shared C++ libraries for Microblaze results in Segmentation Fault
Product: buildroot Reporter: scotttimothye
Component: OtherAssignee: unassigned
Status: RESOLVED WORKSFORME    
Severity: major CC: buildroot
Priority: P5    
Version: 2016.08   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target:
Build:

Description scotttimothye 2016-09-14 18:56:31 UTC
It appears that enabling C++ and shared libraries does not work for Microblaze targets.  When a simple Hello World C++ application is executed, it results in a Segmentation Fault.  This occurs before any code in the app is executed (presumably the fault is occurring in the libstdc++ startup code.)

Host environment: Linux Mint 15, 32-bit x86 platform.  wbx has also replicated it on an x86_64 system with similar results.

Steps to reproduce using buildroot git hash ed5604ed9e378c3f8814d7f92ec66fd855b8245c:

1) make qemu_microblazeel_mmu_defconfig
2) make menuconfig
- Toolchain: enable C++ support
3) make
4) cat > hello.cpp
int main(void){}
5) output/host/usr/bin/microblazeel-linux-g++ hello.cpp -o output/target/root/hello
6) make
7) Running qemu 2.5.1.1:
qemu-system-microblazeel -M petalogix-s3adsp1800 -serial stdio -kernel output/images/linux.bin
8) Let the system boot.  Login w/password "root"
9) ./hello
-> Segmentation Fault.
Comment 1 scotttimothye 2016-09-14 19:07:22 UTC
If you follow up the previous steps by defining "static-only" libraries, then the C++ app works:

1) make menuconfig
2) Build Options > Libraries > static only
3) make clean
4) (See previous steps for build steps)
5) ./hello
-> No seg fault
Comment 2 Thomas Petazzoni 2016-10-22 19:59:00 UTC
Waldemar has identified that this is a regression between binutils 2.25 and binutils 2.26. I.e, with binutils 2.25, C++ programs linked dynamically work fine on Microblaze. Starting with binutils 2.26, they no longer work.
Comment 3 scotttimothye 2016-10-23 13:39:34 UTC
Changing to binutils 2.25 does not correct the problem.  I just repeated the original steps below, altering step 2) to include selection of binutils 2.25.1 during the menuconfig.  Further, I also enabled Host Utilities > host qemu > Enable system emulation.

I built everything from scratch against the latest Buildroot repo (446debc47ef42db10e96973355f441da7685929a) and launched qemu (Buildroot built v2.7.0).  Trying to run the simple ./hello program resulted in a segmentation fault.
Comment 4 scotttimothye 2016-10-24 12:11:27 UTC
(In reply to scotttimothye from comment #3)

Just to clarify comment #3, it should read "I just repeated the original steps," rather than "I just repeated the original steps below,"
Comment 5 mail 2017-02-26 20:15:10 UTC
I checked with master on x86_64 host.
With gcc 5.x and binutils 2.25.1/2.26.1/2.27.
I couldn't reproduce the segfault anymore.

So may be reopen it with exact version of buildroot, gcc, binutils and
C library used. And if it is happening on x86 or x86_64 host.