[PATCH] dependency list for static libraries

Howard Chu hyc@symas.com
Wed Nov 4 14:50:13 GMT 2020


Nick Clifton wrote:
> Hi Howard,
> 
>> One big question
>> I still have is how to get this plugin to be used by default?
> 
> I do not think that there is a way to guarantee this.  After all
> plugins, by design, are intended to be optional.
> 
> Obviously if a build system is involved - one that is adding the
> --record-libdeps option when creating libraries - then it will be
> able to add the necessary linker command line option to invoke
> the plugin as well.

I suppose that means I'll still be using shell scripts to wrap these then.
Was hoping to be able to do away with them.


On a slightly related note - are linker plugins supposed to be compatible
between ld and gold? I get a SEGV using gold:

Reading symbols from ./ld-new...
(gdb) r
Starting program: /media/hyc/software/binutils.o/gold/ld-new -plugin ../ld/.libs/libdep_plugin.so -o ssljunk ../ld/ssljunk.o -L/usr/local/lib -lssl
-L/usr/lib/x86_64-linux-gnu -lpthread -lc -ldl
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
gold::Workqueue::add_to_queue (this=0x0, queue=0x8, t=0x555555bb3200, front=false)
    at ../../binutils-gdb/gold/workqueue.cc:154
154	  Hold_lock hl(this->lock_);
(gdb) bt
#0  gold::Workqueue::add_to_queue (this=0x0, queue=0x8, t=0x555555bb3200, front=false)
    at ../../binutils-gdb/gold/workqueue.cc:154
#1  0x00005555559b70ab in gold::Plugin_manager::add_input_file (this=0x555555b8c350, pathname=<optimized out>,
    is_lib=<optimized out>) at /usr/include/c++/9/bits/char_traits.h:300
#2  0x00007ffff74b2d93 in onclaim_file (claimed=<optimized out>, file=<optimized out>)
    at ../../binutils-gdb/ld/libdep_plugin.c:217
#3  onclaim_file (file=<optimized out>, claimed=<optimized out>) at ../../binutils-gdb/ld/libdep_plugin.c:145
#4  0x00005555559b6b69 in gold::Plugin::claim_file (this=<optimized out>, plugin_input_file=0x555555b8c3a8)
    at ../../binutils-gdb/gold/plugin.cc:390
#5  gold::Plugin_manager::claim_file (this=this@entry=0x555555b8c350, input_file=0x555555c2b9e0, offset=441644,
    filesize=7880, elf_object=<optimized out>, elf_object@entry=0x555555c399e0)
    at ../../binutils-gdb/gold/plugin.cc:766
#6  0x00005555558c216f in gold::Archive::get_elf_object_for_member (this=0x555555b83c80, off=441584,
    punconfigured=<optimized out>) at ../../binutils-gdb/gold/options.h:1646
#7  0x00005555558c2c3e in gold::Archive::include_member (this=0x555555b83c80, symtab=0x7fffffff4760,
    layout=0x7fffffff4a20, input_objects=0x7fffffff4520, off=441584, mapfile=<optimized out>, sym=0x555555c176f0,
    why=0x7fffffff4150 "") at ../../binutils-gdb/gold/archive.cc:1030
#8  0x00005555558c3485 in gold::Archive::add_symbols (this=0x555555b83c80, symtab=0x7fffffff4760,
    layout=0x7fffffff4a20, input_objects=0x7fffffff4520, mapfile=0x0) at /usr/include/c++/9/bits/basic_string.h:2300
#9  0x00005555558c3641 in gold::Add_archive_symbols::run (this=0x555555c357e0, workqueue=0x7fffffff4460)
    at ../../binutils-gdb/gold/archive.cc:1142
#10 0x0000555555a0ea58 in gold::Workqueue::find_and_run_task (this=0x7fffffff4460, thread_number=0)
    at ../../binutils-gdb/gold/token.h:290
#11 0x0000555555a0ecaa in gold::Workqueue::process (this=this@entry=0x7fffffff4460,
    thread_number=thread_number@entry=0) at ../../binutils-gdb/gold/workqueue.cc:495
#12 0x00005555556c6e85 in main (argc=<optimized out>, argv=<optimized out>) at ../../binutils-gdb/gold/main.cc:252
(gdb) frame 2
#2  0x00007ffff74b2d93 in onclaim_file (claimed=<optimized out>, file=<optimized out>)
    at ../../binutils-gdb/ld/libdep_plugin.c:217
217	        rv = tv_add_input_library (vec[i]+2);
(gdb)

While using ld yields:

violino:/media/hyc/software/binutils.o/ld> ./ld-new -plugin ../ld/.libs/libdep_plugin.so -o ssljunk ../ld/ssljunk.o -L/usr/local/lib -lssl
-L/usr/lib/x86_64-linux-gnu -lpthread -lc -ldl
processed deps for library /usr/local/lib/libssl.a: -lcrypto
./ld-new: warning: cannot find entry symbol _start; defaulting to 0000000000404000
./ld-new: /usr/local/lib/libcrypto.a(init.o): in function `ossl_init_register_atexit_ossl_':
init.c:(.text+0x1c0): undefined reference to `atexit'
./ld-new: /usr/local/lib/libcrypto.a(threads_pthread.o): in function `fork_once_func':
threads_pthread.c:(.text+0x1a): undefined reference to `pthread_atfork'

(Testing with __.LIBDEP in libssl.a containing just "-lcrypto")

-- 
  -- Howard Chu
  CTO, Symas Corp.           http://www.symas.com
  Director, Highland Sun     http://highlandsun.com/hyc/
  Chief Architect, OpenLDAP  http://www.openldap.org/project/


More information about the Binutils mailing list