[PATCH] [ELF] Fix undefined symbol handling in DSO.

Rui Ueyama ruiu at google.com
Sun Apr 6 21:58:13 PDT 2014


Hi Bigcheese, shankarke, kledzik,

Currently LLD ignores undefined symbols found in DSOs when linking against
DSO files, if -shared flag is given. Internally, it's achieved by enabling
"useShlibUndefines" flag, which makes the file reader to ignore all undefined
symbols in DSO, so that Resolver don't see any undefined symbols when
handling DSO files.

The above behavior is not compatible with GNU LD.

GNU LD does not also warn on undefined symbols found in DSOs if -shared flag
is given. However, it actually tries to resolve such undefined symbols. As a
result, if an undefined symbol can be resolved by other objects/DSOs appears
later in the same command line, linking output will be different from LLD's
result.

This patch fixes the compatibilty issue. GNU LD seems to just not print
warning messages on undefined symbols if -shared is given. This patch
implements the same behavior.

http://reviews.llvm.org/D3304

Files:
  include/lld/ReaderWriter/ELFLinkingContext.h
  include/lld/ReaderWriter/Reader.h
  lib/Driver/GnuLdDriver.cpp
  lib/Driver/GnuLdOptions.td
  lib/ReaderWriter/ELF/DefaultTargetHandler.h
  lib/ReaderWriter/ELF/DynamicFile.h
  lib/ReaderWriter/ELF/ELFLinkingContext.cpp
  lib/ReaderWriter/ELF/ELFReader.h
  lib/ReaderWriter/ELF/Hexagon/HexagonELFReader.h
  lib/ReaderWriter/ELF/Hexagon/HexagonTargetHandler.h
  lib/ReaderWriter/ELF/PPC/PPCELFReader.h
  lib/ReaderWriter/ELF/Reader.cpp
  lib/ReaderWriter/ELF/TargetHandler.h
  test/elf/dynamic-undef.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3304.1.patch
Type: text/x-patch
Size: 15747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140406/73ad5058/attachment.bin>


More information about the llvm-commits mailing list