[PATCH] [lld] [ELF] Implement --export-dynamic/-E

Rafael Auler rafaelauler at gmail.com
Wed Oct 8 06:52:07 PDT 2014


I updated this patch according to suggestions. While this patch doesn't implement the effect of --export-dynamic when building shared libraries (currently, DynamicLibraryWriter already exports all symbols), it doesn't restrict the flag only to executables. I also moved the logic that exports symbols in the dynamic symbol table from OutputELFWriter to the ExecutableWriter class. I think it is not correct to leave this at OutputELFWriter because DynamicLibraryWriter, another subclass of OutputELFWriter, already exports all symbols, meaning we can potentially end up with duplicated symbols in the dynamic symbol table when creating shared libs.

Another aspect worth commenting is implementing --export-dynamic by making all ELF symbols to have the dynamicExportAlways propriety. I made a patch for this, but it required changing too many interfaces just to allow the "--export-dynamic" information to reach the ELFFile class, since it is loosely coupled via the Registry. The advantages would be to have exposed during the entire linking process that this symbol will be exported. After checking whether the dynamicExportAlways propriety is actually used during linking, I found out that it is not important, except when actually building the symbol table.

Therefore, I concluded that it was not worth the change and that we end up with simpler code if we just stick with checks for --export-dynamic when building the symbol table. If you think that we should change dynamicExportAlways, though, I can submit the other patch.

http://reviews.llvm.org/D5585

Files:
  include/lld/ReaderWriter/ELFLinkingContext.h
  lib/Driver/GnuLdDriver.cpp
  lib/Driver/GnuLdOptions.td
  lib/ReaderWriter/ELF/ExecutableWriter.h
  lib/ReaderWriter/ELF/OutputELFWriter.h
  test/elf/export-dynamic.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5585.14571.patch
Type: text/x-patch
Size: 8247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141008/08b218c6/attachment.bin>


More information about the llvm-commits mailing list