https://sourceware.org/bugzilla/show_bug.cgi?id=17068
Bug ID: 17068 Summary: --as-needed and --start-group/--end-group interact in strange ways if .so files are mentioned in --start-group/--end-group Product: binutils Version: 2.22 Status: NEW Severity: normal Priority: P2 Component: ld Assignee: unassigned at sourceware dot org Reporter: thakis at chromium dot org When doing a release components build of the target 'nacl_helper' in chromium, the link fails with c++ -Wl,-z,now -Wl,-z,relro -Wl,--fatal-warnings -pthread -Wl,-z,noexecstack -fPIC -L. -pie -Wl,-uIsHeapProfilerRunning,-uProfilerStart -Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi -Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl -Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14UnIgnoreObjectEPKv -m64 -Wl,-O1 -Wl,--as-needed -Wl,--gc-sections -Wl,-rpath=\$ORIGIN/lib/ -Wl,-rpath-link=lib/ -o nacl_helper -Wl,--start-group obj/components/nacl/loader/nacl_helper.nacl_helper_linux.o obj/components/libnacl_linux.a obj/components/libnacl.a obj/base/libbase_static.a obj/native_client/src/trusted/service_runtime/libsel.a obj/native_client/src/trusted/service_runtime/libenv_cleanser.a obj/native_client/src/trusted/service_runtime/libnacl_error_code.a obj/native_client/src/shared/gio/libgio.a obj/native_client/src/shared/platform/libplatform.a obj/native_client/src/shared/srpc/libnonnacl_srpc.a obj/native_client/src/trusted/debug_stub/libdebug_stub.a obj/native_client/src/trusted/desc/libnrd_xfer.a obj/native_client/src/trusted/desc/libdesc_wrapper.a obj/native_client/src/shared/imc/libimc.a obj/native_client/src/trusted/nacl_base/libnacl_base.a obj/native_client/src/trusted/desc_cacheability/libdesc_cacheability.a obj/native_client/src/trusted/fault_injection/libnacl_fault_inject.a obj/native_client/src/trusted/gio/libgio_wrapped_desc.a obj/native_client/src/trusted/interval_multiset/libnacl_interval.a obj/native_client/src/trusted/perf_counter/libnacl_perf_counter.a obj/native_client/src/trusted/platform_qualify/libplatform_qual_lib.a obj/native_client/src/trusted/cpu_features/libcpu_features.a obj/native_client/src/trusted/manifest_name_service_proxy/libmanifest_proxy.a obj/native_client/src/trusted/threading/libthread_interface.a obj/native_client/src/trusted/simple_service/libsimple_service.a obj/native_client/src/trusted/validator/libvalidation_cache.a obj/native_client/src/trusted/validator/libvalidators.a obj/native_client/src/trusted/service_runtime/arch/x86/libservice_runtime_x86_common.a obj/native_client/src/trusted/validator_ragel/libdfa_validate_x86_64.a obj/native_client/src/trusted/service_runtime/arch/x86_64/libservice_runtime_x86_64.a obj/native_client/src/trusted/validator_x86/libnccopy_x86_64.a obj/native_client/src/trusted/service_runtime/libnacl_signal.a obj/components/libnacl_common.a obj/components/libnacl_switches.a obj/components/libtracing.a obj/sandbox/libc_urandom_override.a obj/base/allocator/liballocator.a obj/base/third_party/dynamic_annotations/libdynamic_annotations.a lib/libseccomp_bpf.so lib/libseccomp_bpf_helpers.so lib/libcrcrypto.so lib/libsuid_sandbox_client.so lib/libppapi_shared.so lib/libsandbox_services.so lib/libipc.so lib/libbase.so lib/libppapi_proxy.so lib/libcontent.so -Wl,--end-group -lrt -ldl -lpthread -lgmodule-2.0 -lgobject-2.0 -lgthread-2.0 -lglib-2.0 /usr/bin/ld: obj/components/../ppapi/nacl_irt/nacl_linux.plugin_main.o: undefined reference to symbol 'ppapi::PPB_Audio_Shared::SetThreadFunctions(PP_ThreadFunctions const*)' /usr/bin/ld: note: 'ppapi::PPB_Audio_Shared::SetThreadFunctions(PP_ThreadFunctions const*)' is defined in DSO lib/libppapi_shared.so so try adding it to the linker command line nacl_linux.plugin_main.o is in libnacl_linux.a Note that ld tells me to add libppapi_shared.so to the link line, and it's even listed after libnacl_linux.a -- but both are in a --start-group/--end-group group, so the order shouldn't matter. The error goes away if I do any of: * Use gold to link * Remove --as-needed * Move all the lib/*.so files to appear after --end-group (this is what we went with) I tried to make a reduced repro case for a bit, but didn't succeed. Maybe it's obvious to people familiar with ld's source what's going on. I'm not even sure if this is considered a bug, but it works fine with gold. (Though I only tried with gold 2.24, which is newer than the ld I'm using.) This is with $ /usr/bin/ld --version GNU ld (GNU Binutils for Ubuntu) 2.22 Copyright 2011 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils