Bug 209413 - c++ symbolic functions broken on arm
Summary: c++ symbolic functions broken on arm
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: arm (show other bugs)
Version: CURRENT
Hardware: arm Any
: --- Affects Only Me
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-10 06:40 UTC by Sylvain Garrigues
Modified: 2017-04-23 18:21 UTC (History)
4 users (show)

See Also:


Attachments
main.cpp (260 bytes, text/plain)
2016-05-10 06:40 UTC, Sylvain Garrigues
no flags Details
shared.cpp (405 bytes, text/plain)
2016-05-10 06:41 UTC, Sylvain Garrigues
no flags Details
shared.h (175 bytes, text/plain)
2016-05-10 06:41 UTC, Sylvain Garrigues
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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