Bug 22318 - ../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_2.16'
Summary: ../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_...
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: 2.30
: P2 normal
Target Milestone: 2.31
Assignee: Not yet assigned to anyone
URL: https://gcc.gnu.org/bugzilla/show_bug...
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-19 00:12 UTC by H.J. Lu
Modified: 2018-04-05 22:34 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Proposed patch (324 bytes, patch)
2017-10-19 09:33 UTC, Nick Clifton
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2017-10-19 00:12:52 UTC
When -fsanitize=address is used in CFLAGS to build binutils, I got

../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_2.16'

config/plugins.m4 has

 if test "$plugins" = "yes"; then
    AC_SEARCH_LIBS([dlopen], [dl])
  fi

plugins use dlsym, but libasan.so only intercepts dlopen, not dlsym:

[hjl@gnu-tools-1 binutils-x32-text]$ nm -D /lib64/libasan.so.4| grep " dl"
0000000000038580 W dlclose
                 U dl_iterate_phdr
000000000004dc50 W dlopen
                 U dlsym
                 U dlvsym
[hjl@gnu-tools-1 binutils-x32-text]$ 

Testing dlopen for libdl leads to false negative when -fsanitize=address
is used.
Comment 1 Nick Clifton 2017-10-19 09:33:22 UTC
Created attachment 10539 [details]
Proposed patch

Hi H.J.

  Adding a check for dlsym to config/plugins.m4 appears to work, but you
  will need to submit this bug report to the gcc project since they control
  the contents of the config/ directory.

Cheers
  Nick
Comment 2 H.J. Lu 2017-10-19 11:46:51 UTC
(In reply to Nick Clifton from comment #1)
> Created attachment 10539 [details]
> Proposed patch
> 
> Hi H.J.
> 
>   Adding a check for dlsym to config/plugins.m4 appears to work, but you
>   will need to submit this bug report to the gcc project since they control
>   the contents of the config/ directory.

Done.
Comment 3 H.J. Lu 2018-03-29 12:53:43 UTC
Give that there is no response from GCC maintainer for more than 5
months, should we check in my patch?
Comment 4 Nick Clifton 2018-04-03 12:07:43 UTC
Hi H.J.

> Give that there is no response from GCC maintainer for more than 5
> months, should we check in my patch?

Give them a prod first and see if that works.

If not, ping me and I will talk to some of the maintainers myself.

(I would *really* to avoid having binutils specific patches to the config files).

Cheers
  Nick
Comment 5 Sourceware Commits 2018-04-05 22:25:24 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=552d4da4178cc5e8d567ee150462a28d51f08fc0

commit 552d4da4178cc5e8d567ee150462a28d51f08fc0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Apr 5 15:22:13 2018 -0700

    config: Sync with GCC
    
    	Sync with GCC
    	2018-04-05  H.J. Lu  <hongjiu.lu@intel.com>
    
    	PR gas/22318
    	* plugins.m4 (AC_PLUGINS): Use dlsym to check if libdl is needed.
    
    	2018-02-14  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
    
    	PR target/84148
    	* cet.m4: Check if target support multi-byte NOPS (SSE).
Comment 6 Sourceware Commits 2018-04-05 22:33:04 UTC
The master branch has been updated by H.J. Lu <hjl@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3cba8b6c93ab8c573ba4678255df11486de61c54

commit 3cba8b6c93ab8c573ba4678255df11486de61c54
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Apr 5 15:31:41 2018 -0700

    Use dlsym to check if libdl is needed for plugin
    
    config/plugins.m4 has
    
     if test "$plugins" = "yes"; then
        AC_SEARCH_LIBS([dlopen], [dl])
      fi
    
    Plugin uses dlsym, but libasan.so only intercepts dlopen, not dlsym:
    
    [hjl@gnu-tools-1 binutils-text]$ nm -D /lib64/libasan.so.4| grep " dl"
    0000000000038580 W dlclose
                     U dl_iterate_phdr
    000000000004dc50 W dlopen
                     U dlsym
                     U dlvsym
    [hjl@gnu-tools-1 binutils-text]$
    
    Testing dlopen for libdl leads to false negative when -fsanitize=address
    is used.  It results in link failure:
    
    ../bfd/.libs/libbfd.a(plugin.o): undefined reference to symbol 'dlsym@@GLIBC_2.16'
    
    dlsym should be used to check if libdl is needed for plugin.
    
    bfd/
    
    	PR gas/22318
    	* configure: Regenerated.
    
    binutils/
    
    	PR gas/22318
    	* configure: Regenerated.
    
    gas/
    
    	PR gas/22318
    	* configure: Regenerated.
    
    gprof/
    
    	PR gas/22318
    	* configure: Regenerated.
    
    ld/
    
    	PR gas/22318
    	* configure: Regenerated.
Comment 7 H.J. Lu 2018-04-05 22:34:34 UTC
Fixed for 2.31.