Bug 209413

Summary: c++ symbolic functions broken on arm
Product: Base System Reporter: Sylvain Garrigues <sylvain>
Component: armAssignee: freebsd-arm (Nobody) <freebsd-arm>
Status: New ---    
Severity: Affects Only Me CC: dim, emaste, sylvain, toolchain
Priority: ---    
Version: CURRENT   
Hardware: arm   
OS: Any   
Attachments:
Description Flags
main.cpp
none
shared.cpp
none
shared.h none

Description Sylvain Garrigues 2016-05-10 06:40:45 UTC
Created attachment 170167 [details]
main.cpp

With attached simple test case:

 # c++ -fPIC -shared -Wall -o libshared.so -Wl,-Bsymbolic shared.cpp && c++ -fPIE -Wall -o main main.cpp -L. -lshared && cp libshared.so /usr/local/lib && ./main 

false


# g++ -fPIC -shared -Wall -o libshared.so -Wl,-Bsymbolic shared.cpp && g++ -fPIE -Wall -o main main.cpp -L. -lshared && cp libshared.so /usr/local/lib && ./main 

true


I believe the bug is in ld:
https://sourceware.org/bugzilla/show_bug.cgi?id=16715

It has been fixed upstream (see commit referenced in the link above) but our ld is older.
Comment 1 Sylvain Garrigues 2016-05-10 06:41:10 UTC
Created attachment 170168 [details]
shared.cpp
Comment 2 Sylvain Garrigues 2016-05-10 06:41:38 UTC
Created attachment 170169 [details]
shared.h
Comment 3 Sylvain Garrigues 2016-05-10 07:45:00 UTC
The bug is not reproducible on x86-64 (output is always true).

The bug is not reproducible on ARM if I use the gold linker (adding -fuse-ld=gold to the 2 compiler command lines)

# /usr/local/bin/ld -v                                                                                  
GNU ld (GNU Binutils) 2.25.1

# /usr/bin/ld -v
GNU ld 2.17.50 [FreeBSD] 2007-07-03

# uname -a
FreeBSD rpi2 11.0-CURRENT FreeBSD 11.0-CURRENT #74 40afb9f(master)-dirty: Wed Apr 27 15:16:05 CEST 2016     root@cladbsd:/usr/obj/arm.armv6/usr/src/sys/RPI2  arm