[PATCH] D56647: [WIP] [ELF] Implement --copy-dt-needed-entries

Michał Górny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 13 03:19:36 PST 2019


mgorny created this revision.
mgorny added reviewers: ruiu, krytarowski.
Herald added subscribers: llvm-commits, jfb, arichardson, emaste.
Herald added a reviewer: espindola.

This is my proof-of-concept on making `--copy-dt-needed-entries` work. Apparently, i've been able to hack on it hard enough to make it actually emit DT_NEEDED for all symbols, recursively:

  $ clang -fuse-ld=lld  -Wl,--copy-dt-needed-entries test.c  -lgit2
  $ readelf -d a.out 
  
  Dynamic section at offset 0x3010 contains 40 entries:
    Tag        Type                         Name/Value
   0x0000000000000001 (NEEDED)             Shared library: [libgit2.so.27]
   0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
   0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
   0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
   0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]
   0x0000000000000001 (NEEDED)             Shared library: [libcurl.so.4]
   0x0000000000000001 (NEEDED)             Shared library: [libcares.so.2]
   0x0000000000000001 (NEEDED)             Shared library: [libnghttp2.so.14]
   0x0000000000000001 (NEEDED)             Shared library: [libidn2.so.4]
   0x0000000000000001 (NEEDED)             Shared library: [libunistring.so.2]
   0x0000000000000001 (NEEDED)             Shared library: [libssl.so.1.1]
   0x0000000000000001 (NEEDED)             Shared library: [libcrypto.so.1.1]
   0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
   0x0000000000000001 (NEEDED)             Shared library: [libdl.so.2]
   0x0000000000000001 (NEEDED)             Shared library: [libhttp_parser.so.2.9]
   0x0000000000000001 (NEEDED)             Shared library: [libssh2.so.1]
   0x0000000000000015 (DEBUG)              0x0
   0x0000000000000007 (RELA)               0x200620
   0x0000000000000008 (RELASZ)             48 (bytes)
   0x0000000000000009 (RELAENT)            24 (bytes)
   0x0000000000000017 (JMPREL)             0x200650
   0x0000000000000002 (PLTRELSZ)           72 (bytes)
   0x0000000000000003 (PLTGOT)             0x202010
   0x0000000000000014 (PLTREL)             RELA
   0x0000000000000006 (SYMTAB)             0x2002b0
   0x000000000000000b (SYMENT)             24 (bytes)
   0x0000000000000005 (STRTAB)             0x200488
   0x000000000000000a (STRSZ)              404 (bytes)
   0x000000006ffffef5 (GNU_HASH)           0x200400
   0x0000000000000004 (HASH)               0x200428
   0x0000000000000019 (INIT_ARRAY)         0x203008
   0x000000000000001b (INIT_ARRAYSZ)       8 (bytes)
   0x000000000000001a (FINI_ARRAY)         0x203000
   0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
   0x000000000000000c (INIT)               0x201200
   0x000000000000000d (FINI)               0x201218
   0x000000006ffffff0 (VERSYM)             0x2003b8
   0x000000006ffffffe (VERNEED)            0x2003d0
   0x000000006fffffff (VERNEEDNUM)         1
   0x0000000000000000 (NULL)               0x0

Can't say the code is nice but before I try to make it cleanly, I'd appreciate some tips on whether I'm even starting in the right direction.

FWICS, GNU ld's `--copy-dt-needed-entries` adds lot less libraries — it seems as if it implicitly forced `--as-needed`, and `--no-as-needed` doesn't seem to make a difference.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D56647

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/InputFiles.cpp
  ELF/InputFiles.h
  ELF/Options.td
  ELF/SymbolTable.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56647.181468.patch
Type: text/x-patch
Size: 5984 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190113/70310058/attachment-0001.bin>


More information about the cfe-commits mailing list